Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Creating a sparse analyzer with multiprocessing crashes if sorting has a lot of units

Open
#4,566 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
38/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Quiet
Tech stack
python

Research direction

Start at the create_sorting_analyzer entry point and reproduce the failure with the provided recording, sorting, sparse=True, and varying n_jobs and unit counts. Compare in-memory, binary-folder, and zarr analyzers, then inspect estimate_sparsity and multiprocessing resource handling. Done means large sparse analyzers complete without a leaked shared-memory warning or a stuck kernel.

Written by the indexing model from the issue text.

Description

When creating a new analyzer from a sorting object with a few hundred units, it can crash if n_jobs is set to use more than one core.

From a recording with ~1500 units :

import spikeinterface.full as si
from pathlib import Path

path = r'/path/to/folder/sc2_output'
recording = si.load(Path(path).joinpath('spikeinterface_recording.json'))
sorting = si.load(Path(path).joinpath('sorter_output/sorting'))
analyzer = si.create_sorting_analyzer(recording=recording,
                                        sorting=sorting,
                                        sparse=True,
                                        format='memory',
                                        n_jobs=0.25,
                                      )

Results in the following :

/home/user/.conda/envs/spike/lib/python3.12/multiprocessing/resource_tracker.py:254: UserWarning: resource_tracker: There appear to be 1 leaked shared_memory objects to clean up at shutdown
  warnings.warn('resource_tracker: There appear to be %d '

Or a stuck kernel in a notebook.

This seems to be dependant on both the number of cores and the number of units. By selecting n units with :

sorting = sorting.select_units(sorting.unit_ids[0:n])

I can see the limit is about 800 units with n_jobs=0.25, which on my machine is 10 cores.
If I lower n_jobs to 0.15, which is 6 cores, I can go up to 1000 units, and 4 cores can handle the full sorting.

This is the case when creating both in-memory and on-disk analyzers (binary folder and zarr). I've monitored ressources during the process and it does not look like an OOM error.

This can get pretty constraining specifically because of estimate_sparsity, which can take a while on long recordings with no parallel processing. Afterwards, computing extensions on the full recording with 10 cores doesn't cause any problem.

Dominant language
Python
Stars
855
Forks
280
Avg merge
3d 2h
Merged PRs (30d)
38

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from SpikeInterface/spikeinterface

All issues in SpikeInterface/spikeinterface

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.