Repository navigation
Halve the memory a tracking run kept in memory needs - #13
Merged
Merged
Conversation
antonio-dimeglio
force-pushed
the
tracker-memory
branch
from
October 29, 2026 21:30
e33d0df to
93cb0a3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A tracking run with no output file kept each batch's streamlines as a tractogram of its own and joined them at the end, so for a moment it held every streamline twice, plus the per-batch copies. On a large run that pushes a 16 GB machine into swap, which slows the end of the run and whatever comes next, such as the viewer's Dissect workspace.
The kept points now go straight from each batch's buffer into one buffer that grows by a quarter when full, in place where the allocator allows it, and is trimmed at the end. Runs written to a file are unchanged. The result is the same tractogram, point for point, with the same end statuses.
Measurements
One million streamlines on the ISMRM example data (det, whole brain mask, seed 1), 431.6 million points (5.18 GB), on an Apple M-series laptop with 16 GB. Peak memory footprint from
/usr/bin/time -l, which counts swapped and compressed memory; the same SHA-256 of the points and offsets in both runs.The memory beyond the tractogram itself falls from 5.8 GB to 1.3 GB. A growth of 1.5 instead of 1.25 gave 7.4 GB at the same speed.
Tests
The existing test that compares a run kept in memory with the same run written to TCK and TRK, with batches of seven seeds, covers the buffer growing several times; the tracking, viewer and CLI tests pass.