| Command | Runs (n) | A collections pauses (n) | A collections young (n) | A collections middle (n) | A collections old (n) | A per run, median gc (ms) | A per run, median cov (%) | A per run, median share (%) | A per run, median gap (ms) | A per pause P99 (ms) | A per pause max (ms) | A collected P99 (obj) | A collected max (obj) | A empty (%) | B collections pauses (n) | B collections young (n) | B collections middle (n) | B collections old (n) | B per run, median gc (ms) | B per run, median cov (%) | B per run, median share (%) | B per run, median gap (ms) | B per pause P99 (ms) | B per pause max (ms) | B collected P99 (obj) | B collected max (obj) | B empty (%) | delta on gc B/A | delta on gc margin | Loops | |----------------------------------|----------|--------------------------|-------------------------|--------------------------|-----------------------|---------------------------|---------------------------|-----------------------------|----------------------------|-----
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
| [ | |
| {"name": "process_name", "ph": "M", "pid": 6480, "args": {"name": "Parent Process"}}, | |
| {"name": "GC Pause", "cat": "gc.pause", "ph": "X", "ts": 480394753063, "dur": 0, "pid": 13448, "tid": 0, "args": {"generation": 1, "iid": 0, "collections": 9, "heap_size": 15741, "collected": 176, "uncollectable": 0, "candidates": 15421, "object_visits": 109128, "objects_transitively_reachable": 18110, "objects_not_transitively_reachable": 1170, "work_to_do": -16464}}, | |
| {"name": "GC Pause (gen=1)", "cat": "gc.pause(gen=1)", "ph": "X", "ts": 480394753063, "dur": 0, "pid": 13448, "tid": 0, "args": {"generation": 1, "iid": 0, "collections": 9, "heap_size": 15741, "collected": 176, "uncollectable": 0, "candidates": 15421, "object_visits": 109128, "objects_transitively_reachable": 18110, "objects_not_transitively_reachable": 1170, "work_to_do": -16464}}, | |
| {"name": "Heap Size", "cat": "gc.heap_size", "ph": "C", "ts": 480394753063, "pid": 13448, "tid": 0, "args": {"heap_size": 15741}}, | |
| {"name": "G1", "cat": "gc.memory(gen=1)", "ph" |
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
| import gc | |
| import json | |
| import os | |
| import sys | |
| import _gc_monitor as m | |
| import time | |
| if len(sys.argv) == 2: | |
| pid = int(sys.argv[-1]) | |
| else: |
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
| import collections.abc | |
| import gc | |
| import random | |
| import sys | |
| import statistics | |
| import time | |
| import pyperf | |
| # Adapted from https://gist.github.com/stedolan/4369a0fa27820e27d6e56bee5e412896 | |
| # See https://github.com/ocaml/ocaml/pull/10195 |
I compare different versions:
- main (29f1e778faaa31479e4ef84e2fb37a7a53984550)
- main+revert(+ https://github.com/sergey-miryanov/cpython/commit/efd2a4c0447496396445a5b5acc63a0482f1790d)
- main+gc-fix(+ https://github.com/sergey-miryanov/cpython/commits/gc-fix?author=sergey-miryanov)
I did comparison of pyperformance and gc-bench. gc-bench is pyperf-ed version of yours gc_big and gc_big_tree. Results are following:
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
| import httpx | |
| import psutil | |
| import asyncio | |
| import gc | |
| import os | |
| def get_rss(): | |
| p = psutil.Process() | |
| mem_info = p.memory_info() |
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
| #!/usr/bin/env ./python | |
| import contextlib | |
| import os | |
| import sys | |
| import shutil | |
| import subprocess | |
| import time | |
| import venv | |
| from pathlib import Path | |
| import tempfile |
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
| import gc | |
| import time | |
| import statistics | |
| # Adapted from https://gist.github.com/stedolan/4369a0fa27820e27d6e56bee5e412896 | |
| # See https://github.com/ocaml/ocaml/pull/10195 | |
| # | |
| # In Python (free threading), this uses closer to 1.9 GiB of memory isntead of 800 MiB | |
| # perf stat -e L1-dcache-loads,L1-dcache-load-misses,LLC-loads,LLC-load-misses ./python gc_big_800m.py |
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
| import sys | |
| import gc | |
| import random | |
| import time | |
| import collections.abc | |
| import statistics | |
| # perf stat -e L1-dcache-loads,L1-dcache-load-misses,LLC-loads,LLC-load-misses ./python gc_big_tree.py | |
| # perf stat -e l3_request_g1.caching_l3_cache_accesses,l3_comb_clstr_state.request_miss ./python gc_big_tree.py |
NewerOlder