Skip to content

MRG: Improve memory footprint of _TimeViewer - #7480

Merged
larsoner merged 2 commits into
mne-tools:masterfrom
GuillaumeFavelier:time_viewer_memory_footprint
Mar 19, 2020
Merged

MRG: Improve memory footprint of _TimeViewer#7480
larsoner merged 2 commits into
mne-tools:masterfrom
GuillaumeFavelier:time_viewer_memory_footprint

Conversation

@GuillaumeFavelier

@GuillaumeFavelier GuillaumeFavelier commented Mar 19, 2020

Copy link
Copy Markdown
Contributor

This PR improves the memory footprint of _TimeViewer by decreasing the reference count and solving reference cycles.

This is the comparison between master (black curve) and this PR (blue curve) using the following script with mprof:

import os
import mne
import pyvista
from mne.datasets import sample
data_path = sample.data_path()
sample_dir = os.path.join(data_path, 'MEG', 'sample')
subjects_dir = os.path.join(data_path, 'subjects')
fname_stc = os.path.join(sample_dir, 'sample_audvis-meg')
stc = mne.read_source_estimate(fname_stc, subject='sample')
initial_time = 0.1
mne.viz.set_3d_backend('pyvista')
for j in range(5):
    for i in range(5):
        brain = stc.plot(subjects_dir=subjects_dir, initial_time=initial_time,
                         clim=dict(kind='value', pos_lims=[3, 6, 9]),
                         hemi='lh',
                         time_viewer=True, show_traces=True)
    pyvista.close_all()

image

There is probably room for improvement but this is a step forward.

@GuillaumeFavelier

Copy link
Copy Markdown
Contributor Author

I don't think I can go further with this method, there is the latest result:

image

@GuillaumeFavelier GuillaumeFavelier changed the title Improve memory footprint of _TimeViewer MRG: Improve memory footprint of _TimeViewer Mar 19, 2020
Comment thread mne/viz/_brain/_timeviewer.py
@larsoner

Copy link
Copy Markdown
Member

Failure is just a timeout, thanks @GuillaumeFavelier

@larsoner
larsoner merged commit bb58e03 into mne-tools:master Mar 19, 2020
@GuillaumeFavelier
GuillaumeFavelier deleted the time_viewer_memory_footprint branch June 11, 2020 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants