Skip to content

Avoid materializing entire time vector from zarr for time_to_sample_index#4620

Open
grahamfindlay wants to merge 1 commit into
SpikeInterface:mainfrom
grahamfindlay:perf/lazy_time_to_sample_index
Open

Avoid materializing entire time vector from zarr for time_to_sample_index#4620
grahamfindlay wants to merge 1 commit into
SpikeInterface:mainfrom
grahamfindlay:perf/lazy_time_to_sample_index

Conversation

@grahamfindlay

Copy link
Copy Markdown
Contributor

np.searchsorted is fine for mem-maps, but for out-of-core arrays (zarr) it reads the whole time vector (even if a zarr.Array) into memory. Bisecting instead reads O(log N) elements, which saves an order of magnitude of RAM for long recordings.

…ndex

`np.searchsorted` is fine for mem-maps, but for out-of-core arrays (zarr) it reads
the whole time vector (even if a `zarr.Array`) into memory. Bisecting instead reads
O(log N) elements, which saves an order of magnitude of RAM for long recordings.
"""
grahamfindlay added a commit to grahamfindlay/spikeinterface that referenced this pull request Jun 16, 2026
@alejoe91

Copy link
Copy Markdown
Member

Stumbled upon the same issue yesterday!!

Elegant solution :)

@alejoe91 alejoe91 added core Changes to core module performance Performance issues/improvements labels Jun 25, 2026
@grahamfindlay

Copy link
Copy Markdown
Contributor Author

@alejoe91
I am pretty sure that this failing test has nothing to do with the PR. I think it is because test_pipeline_equiv_to_step calls multiple preprocessors (e.g. detect_and_remove_artifacts, detect_and_interpolate_bad_channels) that are nondeterministic without seeding them. Pick any unseeded nondeterministic preprocessor, call it twice and test the results for equivalence, and if you do it enough times, you'll get a failure.

Pretty sure this is hitting #4601 too. Both safe to merge. I can work on a PR to fix the test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Changes to core module performance Performance issues/improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants