Skip to content

Tachyon --gecko collector memory growing ad infinitum #150662

@maurycy

Description

@maurycy

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:

https://github.com/mozilla/gecko-dev/blob/5836a062726f715fda621338a17b51aff30d0a8c/mozglue/baseprofiler/public/ProfileBufferChunkManagerWithLocalLimit.h#L33-L44

https://github.com/mozilla/gecko-dev/blob/5836a062726f715fda621338a17b51aff30d0a8c/mozglue/baseprofiler/public/ProfileBufferChunkManagerWithLocalLimit.h#L292-L316

samply is just more efficient (that'd be array in our case?):

https://github.com/mstange/samply/blob/d31a3e9ed59f06d309d6984455c824a03a15f081/fxprof-processed-profile/src/sample_table.rs#L19-L29

https://github.com/mstange/samply/blob/d31a3e9ed59f06d309d6984455c824a03a15f081/fxprof-processed-profile/src/profile.rs#L178-L199

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions