performance hit with NWB + fancy indexing
See original GitHub issueThese lines can lead to slow reads from the NWB extractor due to fancy indexing. Whenever I do something like this, I read the full channel column and then do a fast fancy index from the ndarray in memory. It is technically wasteful, but the use case for memory mapping is to pull out relatively small chunks.
I refactored this downstream as the following. Big improvement when working with a ChannelSliceRecording
if isinstance(channel_indices, slice):
traces = es.data[start_frame:end_frame, channel_indices]
else:
# channel_indices is np.ndarray
channel_indices = np.asarray(channel_indices)
if channel_indices.size > 1:
traces = es.data[start_frame:end_frame][:, channel_indices]
else:
traces = es.data[start_frame:end_frame, channel_indices[0]]
Issue Analytics
- State:
- Created a year ago
- Comments:9 (9 by maintainers)
Top Results From Across the Web
Performance of various numpy fancy indexing methods, also ...
It's simple: Integer array indexing only needs to access as many elements as there are values in the index-array. That means if there...
Read more >Fancy Indexing | Python Data Science Handbook
Fancy indexing is like the simple indexing we've already seen, but we pass arrays of indices in place of single scalars. This allows...
Read more >Why is fancy indexing slower than flattening + flat indexing?
I recently noticed that it is faster to flatten a list of index arrays and then index the flat array than to use...
Read more >Experimental Directory Structure (Exdir): An Alternative to HDF5 ...
However, issues with HDF5 have recently surfaced in the neuroscience ... Exdir supports all the operations supported by memmap, including fancy indexing:.
Read more >The problem is loss of gpu performance when matrix indexing
The problem is loss of performance when indexing. Please see the test program code... You can see that as soon as the indexing...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Excellent points. Certainly 100x memory waste is unacceptable, and probably slower. I will def keep using a subclass for the scenario with <<2x memory overhead and 4x-8x speedup. The not-very-helpful proposal that occurs to me here is a threshold policy (e.g. over/under 2x overhead) for automatically deciding between the two approaches.
closed for inactivity