Skip to content

v0.8.0 performance degradation #746

@dizcza

Description

@dizcza

Long story short, some analysis gets slower by x14 times (from 90 sec to 1279 sec) by upgrading neo from 0.7.2 to 0.8.0.

  1. The bottleneck is in utility function cut_segment_by_epoch, that till v0.8.0 has been carried on from repo to repo and now, since it's in neo release, I decided to switch it to your utils.py implementation. Previously, we used

def seg_time_slice(seg, t_start=None, t_stop=None, reset_time=False, **kwargs)

that is now replaced by segment.time_slice() (I can share the script if needed). Here is its timing profiler bottleneck, made with https://github.com/rkern/line_profiler:

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================

<0.7.2 our utils.py, seg_time_slice()  func>

  1485    165891     132936.0      0.8      0.2      for st_id in range(len(seg.spiketrains)):
  1486    165165     210739.0      1.3      0.3          if isinstance(seg.spiketrains[st_id], neo.SpikeTrain):
  1487    165165   36760743.0    222.6     56.6              st_time_slice = seg.spiketrains[st_id].time_slice(t_start, t_stop)
  1488                                                   elif (hasattr(neo.io, 'proxyobjects') and
  1489                                                         isinstance(seg.spiketrains[st_id], neo.io.proxyobjects.SpikeTrainProxy)):
  1490                                                       st_time_slice = seg.spiketrains[st_id].load(time_slice=(t_start, t_stop))

<0.8.0 neo/utils.py>

   317    165891     132030.0      0.8      0.0          for st_id in range(len(self.spiketrains)):
   318    165165     273001.0      1.7      0.0              if hasattr(self.spiketrains[st_id], '_rawio'):
   319     55055  928402216.0  16863.2     90.9                  st_time_slice = self.spiketrains[st_id].load(time_slice=(t_start, t_stop))
   320                                                       else:
   321    110110   83800203.0    761.1      8.2                  st_time_slice = self.spiketrains[st_id].time_slice(t_start, t_stop)
   322    165165     277507.0      1.7      0.0              if reset_time:
   323                                                           st_time_slice = st_time_slice.time_shift(t_shift)
   324    165165     327103.0      2.0      0.0              subseg.spiketrains.append(st_time_slice)
  1. Loading data now takes 47 sec (was 25 sec in 0.7.2) just because now the if condition is triggered while previously it was rejected and branched to else statement.
            if hasattr(neo.io, 'proxyobjects') and isinstance(st,
                                                              neo.io.proxyobjects.SpikeTrainProxy):
                st_for_calc = st.load(load_waveforms=True)
            else:
                st_for_calc = st

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions