Bug report
Bug description:
Tachyon --gecko collector keeps growing memory.
I believe that's why it happens:
| for t in times: | |
| samples_stack.append(stack_index) | |
| samples_time.append(t) | |
| samples_delay.append(None) |
Fix
Not sure. Perhaps it could be made more efficient with something like:
samples = {"stack": array('q'), "time": array('d')}
It doesn't solve the underlying issue, though, that is Gecko format is not really suitable for longer runs.
If I understand correctly, Firefox solves this with a ring buffer and mMaxTotalBytes:
samply is just more efficient (that'd be array in our case?):
Reproduction
See the RSS growing.
2026-05-31T11:54:39.306496000+0200 maurycy@gimel /Users/maurycy/src/github.com/maurycy/cpython (main 2c20f9c) % ./python.exe -c " def work(): return sum(i*i for i in range(2000)) while True: work() " & TARGET=$! sudo ./python.exe -m profiling.sampling attach --gecko -r 10000 -d 900 -o /tmp/gecko.json $TARGET & sleep 2; PROF=$(pgrep -fn "profiling.sampling attach") for i in $(seq 15); do printf "t=%2dmin RSS=%d MB\n" $i $(($(ps -o rss= -p $PROF|tr -d ' ')/1024)); sleep 60; done [3] 47206 [4] 47207 t= 1min RSS=28 MB t= 2min RSS=62 MB t= 3min RSS=89 MB t= 4min RSS=116 MB t= 5min RSS=127 MB t= 6min RSS=139 MB t= 7min RSS=155 MB t= 8min RSS=163 MB t= 9min RSS=182 MB t=10min RSS=194 MB t=11min RSS=221 MB t=12min RSS=248 MB t=13min RSS=275 MB t=14min RSS=302 MB t=15min RSS=329 MB [130] 2026-05-31T12:09:34.268838000+0200 maurycy@gimel /Users/maurycy/src/github.com/maurycy/cpython (main 2c20f9c) % Captured 9,000,005 samples in 900.00 seconds Sample rate: 10,000.01 samples/sec Error rate: 16.58 Gecko profile written to /tmp/gecko.json Open in Firefox Profiler: https://profiler.firefox.com/ [4] + done sudo ./python.exe -m profiling.sampling attach --gecko -r 10000 -d 900 -o [130] 2026-05-31T12:09:58.283070000+0200 maurycy@gimel /Users/maurycy/src/github.com/maurycy/cpython (main 2c20f9c) %
CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS