Skip to content

Instantly share code, notes, and snippets.

View sergey-miryanov's full-sized avatar
💭
Father of the little toddler, may be spontaneously unavailable

Sergey Miryanov sergey-miryanov

💭
Father of the little toddler, may be spontaneously unavailable
View GitHub Profile
@sergey-miryanov
sergey-miryanov / gc_trace_cyclops.json
Created April 24, 2026 19:50
gc_trace_cyclops.json
[
{"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"
@sergey-miryanov
sergey-miryanov / monitor.py
Last active March 18, 2026 15:00
monitor.py
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:
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
import httpx
import psutil
import asyncio
import gc
import os
def get_rss():
p = psutil.Process()
mem_info = p.memory_info()
@sergey-miryanov
sergey-miryanov / run_sphinx_bench.py
Created December 4, 2025 20:50 — forked from nascheme/run_sphinx_bench.py
Benchmark of sphinx processing typing.rst file
#!/usr/bin/env ./python
import contextlib
import os
import sys
import shutil
import subprocess
import time
import venv
from pathlib import Path
import tempfile
@sergey-miryanov
sergey-miryanov / gc_big.py
Created December 4, 2025 20:49 — forked from nascheme/gc_big.py
Python GC benchmark based on OCaml pre-fetch PR
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
@sergey-miryanov
sergey-miryanov / gc_big_tree.py
Created December 4, 2025 20:49 — forked from nascheme/gc_big_tree.py
BTree benchmark for testing cyclic GC performance
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

asyncio

async generator's finalization is broken

import asyncio
work_done = False

async def cursor():
 try:
+--------------------------+----------+------------------------+
| Benchmark | win-main | main |
+==========================+==========+========================+
| 2to3 | 342 ms | 171 ms: 2.01x faster |
+--------------------------+----------+------------------------+
| async_generators | 436 ms | 269 ms: 1.62x faster |
+--------------------------+----------+------------------------+
| asyncio_tcp | 659 ms | 301 ms: 2.19x faster |
+--------------------------+----------+------------------------+
| asyncio_tcp_ssl | 1.82 sec | 801 ms: 2.27x faster |