11#!/usr/bin/env python3
2- """Génère les SVG des benchmarks pour le README (aucune dépendance )."""
2+ """Generates benchmark SVG charts for the README (no dependencies )."""
33import csv , os
44
55OUT = os .path .join (os .path .dirname (__file__ ), ".." , "docs" , "img" )
@@ -60,6 +60,7 @@ def bar_chart(path, title, subtitle, bars, unit="MB"):
6060 s .append (f'<rect width="{ W } " height="{ H } " fill="#0d1117"/>' )
6161 s .append (f'<text x="{ W / 2 } " y="22" fill="#e6edf3" font-size="15" text-anchor="middle" font-family="sans-serif" font-weight="600">{ title } </text>' )
6262 s .append (f'<text x="{ W / 2 } " y="38" fill="#8b949e" font-size="11" text-anchor="middle" font-family="sans-serif">{ subtitle } </text>' )
63+ s .append (f'<text x="{ ML - 10 } " y="{ MT - 6 } " fill="#8b949e" font-size="10" text-anchor="end" font-family="sans-serif">{ unit } </text>' )
6364 for i , (label , before , after ) in enumerate (bars ):
6465 cy = MT + (i * 2 + 1 ) * bh
6566 wb = before / vmax * PW
@@ -69,10 +70,10 @@ def bar_chart(path, title, subtitle, bars, unit="MB"):
6970 s .append (f'<rect x="{ ML } " y="{ cy + bh * 0.9 :.0f} " width="{ wa :.0f} " height="{ bh * 0.8 } " rx="2" fill="#3fb950"/>' )
7071 s .append (f'<text x="{ ML + wb + 6 :.0f} " y="{ cy + bh * 0.75 :.0f} " fill="#c9d1d9" font-size="10" font-family="sans-serif">{ before :g} </text>' )
7172 s .append (f'<text x="{ ML + wa + 6 :.0f} " y="{ cy + bh * 1.7 :.0f} " fill="#3fb950" font-size="10" font-weight="600" font-family="sans-serif">{ after :g} </text>' )
72- s .append (f'<rect x="{ ML } " y="{ H - 6 } " width="14" height="4" fill="#8957e5"/>' )
73- s .append (f'<text x="{ ML + 18 } " y="{ H - 2 } " fill="#8b949e" font-size="10" font-family="sans-serif">avant memflux </text>' )
74- s .append (f'<rect x="{ ML + 110 } " y="{ H - 6 } " width="14" height="4" fill="#3fb950"/>' )
75- s .append (f'<text x="{ ML + 128 } " y="{ H - 2 } " fill="#8b949e" font-size="10" font-family="sans-serif">après memflux </text>' )
73+ s .append (f'<rect x="{ ML } " y="{ H - 8 } " width="14" height="4" fill="#8957e5"/>' )
74+ s .append (f'<text x="{ ML + 18 } " y="{ H - 4 } " fill="#8b949e" font-size="10" font-family="sans-serif">before </text>' )
75+ s .append (f'<rect x="{ ML + 90 } " y="{ H - 8 } " width="14" height="4" fill="#3fb950"/>' )
76+ s .append (f'<text x="{ ML + 108 } " y="{ H - 4 } " fill="#8b949e" font-size="10" font-family="sans-serif">after </text>' )
7677 s .append ("</svg>" )
7778 with open (path , "w" ) as f :
7879 f .write ("\n " .join (s ))
@@ -83,39 +84,39 @@ def bar_chart(path, title, subtitle, bars, unit="MB"):
8384swap_pts = [(float (r ["t_sec" ]), float (r ["swap_mb" ])) for r in rows ]
8485line_chart (
8586 os .path .join (OUT , "pageout_timeline.svg" ),
86- "Pageout d'un processus de 2 Go dormant " ,
87- "memfluxd — process_madvise(MADV_PAGEOUT), 2 cycles de working-set" ,
88- [("RSS (Mo )" , "#f85149" , rss_pts ), ("Swap zram (Mo )" , "#3fb950" , swap_pts )],
89- "secondes " , "Mo " )
87+ "Pageout of a dormant 2 GiB process " ,
88+ "memfluxd — process_madvise(MADV_PAGEOUT), 2 working-set windows " ,
89+ [("RSS (MB )" , "#f85149" , rss_pts ), ("zram swap (MB )" , "#3fb950" , swap_pts )],
90+ "seconds " , "MB " )
9091
91- # ---------------------------------------------------------------- 2. allocateur
92+ # ---------------------------------------------------------------- 2. allocator
9293bar_chart (
9394 os .path .join (OUT , "allocator_rss.svg" ),
94- "Allocateur interposé : RSS après libération " ,
95- "300 000 blocs de 4 Ko libérés — glibc 1 180 Mo vs memflux-preload 10 Mo " ,
95+ "Interposed allocator : RSS after free " ,
96+ "300, 000 × 4 KiB blocks freed — glibc keeps 1, 180 MB vs 10 MB " ,
9697 [("glibc (malloc)" , 1180 , 1180 ), ("memflux-preload" , 1186 , 10 )],
97- "Mo " )
98+ "MB " )
9899
99- # ---------------------------------------------------------------- 3. récap avant/après
100+ # ---------------------------------------------------------------- 3. before/after
100101bar_chart (
101102 os .path .join (OUT , "before_after.svg" ),
102- "Résumé des gains mesurés " ,
103- "machine de test : 32 Go RAM, zram, kernel 7.1 — 2 sep 2026" ,
103+ "Measured gains summary " ,
104+ "test machine : 32 GB RAM, zram, kernel 7.1 — Sep 2, 2026" ,
104105 [
105- ("Process 2 GB dormeur " , 2046 , 2 ),
106- ("App 300K objets libérés " , 1180 , 10 ),
107- ("Burst 1.5 GB libéré " , 1538 , 2 ),
106+ ("Dormant 2 GB process " , 2046 , 2 ),
107+ ("App freeing 300K objects " , 1180 , 10 ),
108+ ("Released 1.5 GB burst " , 1538 , 2 ),
108109 ],
109- "Mo RSS" )
110+ "MB RSS" )
110111
111112# ---------------------------------------------------------------- 4. damon_reclaim
112113line_chart (
113114 os .path .join (OUT , "damon_reclaim.svg" ),
114- "damon_reclaim (kdamond noyau ) — 1.5 Go dormant" ,
115- "min_age=10 s, quota 10 ms/s, wmarks 950/900/100 — piloté par memfluxd" ,
116- [("Swap zram (Mo )" , "#3fb950" , [(0 , 0 ), (12 , 34 ), (24 , 58 ), (36 , 58 ), (48 , 74 )])],
117- "secondes " , "Mo " , ymax = 120 )
115+ "damon_reclaim (kernel kdamond ) — 1.5 GiB dormant" ,
116+ "min_age=10 s, quota 10 ms/s, wmarks 950/900/100 — driven by memfluxd" ,
117+ [("zram swap (MB )" , "#3fb950" , [(0 , 0 ), (12 , 34 ), (24 , 58 ), (36 , 58 ), (48 , 74 )])],
118+ "seconds " , "MB " , ymax = 120 )
118119
119- print ("SVG générés dans " , os .path .abspath (OUT ))
120+ print ("SVGs written to " , os .path .abspath (OUT ))
120121for f in sorted (os .listdir (OUT )):
121122 print (" " , f )
0 commit comments