@@ -545,6 +545,41 @@ def get_optimizer_stats(self) -> dict[str, tuple[int, int | None]]:
545545 ): (incorrect_keys , attempts ),
546546 }
547547
548+ def get_jit_memory_stats (self ) -> dict [Doc , tuple [int , int | None ]]:
549+ jit_total_memory_size = self ._data ["JIT total memory size" ]
550+ jit_code_size = self ._data ["JIT code size" ]
551+ jit_trampoline_size = self ._data ["JIT trampoline size" ]
552+ jit_data_size = self ._data ["JIT data size" ]
553+ jit_padding_size = self ._data ["JIT padding size" ]
554+ jit_freed_memory_size = self ._data ["JIT freed memory size" ]
555+
556+ return {
557+ Doc (
558+ "Total memory size" ,
559+ "The total size of the memory allocated for the JIT traces" ,
560+ ): (jit_total_memory_size , None ),
561+ Doc (
562+ "Code size" ,
563+ "The size of the memory allocated for the code of the JIT traces" ,
564+ ): (jit_code_size , jit_total_memory_size ),
565+ Doc (
566+ "Trampoline size" ,
567+ "The size of the memory allocated for the trampolines of the JIT traces" ,
568+ ): (jit_trampoline_size , jit_total_memory_size ),
569+ Doc (
570+ "Data size" ,
571+ "The size of the memory allocated for the data of the JIT traces" ,
572+ ): (jit_data_size , jit_total_memory_size ),
573+ Doc (
574+ "Padding size" ,
575+ "The size of the memory allocated for the padding of the JIT traces" ,
576+ ): (jit_padding_size , jit_total_memory_size ),
577+ Doc (
578+ "Freed memory size" ,
579+ "The size of the memory freed from the JIT traces" ,
580+ ): (jit_freed_memory_size , jit_total_memory_size ),
581+ }
582+
548583 def get_histogram (self , prefix : str ) -> list [tuple [int , int ]]:
549584 rows = []
550585 for k , v in self ._data .items ():
@@ -1161,6 +1196,18 @@ def calc_optimizer_table(stats: Stats) -> Rows:
11611196 for label , (value , den ) in optimizer_stats .items ()
11621197 ]
11631198
1199+ def calc_jit_memory_table (stats : Stats ) -> Rows :
1200+ jit_memory_stats = stats .get_jit_memory_stats ()
1201+
1202+ return [
1203+ (
1204+ label ,
1205+ Count (value ),
1206+ Ratio (value , den , percentage = label != "Total memory size" ),
1207+ )
1208+ for label , (value , den ) in jit_memory_stats .items ()
1209+ ]
1210+
11641211 def calc_histogram_table (key : str , den : str ) -> RowCalculator :
11651212 def calc (stats : Stats ) -> Rows :
11661213 histogram = stats .get_histogram (key )
@@ -1214,6 +1261,17 @@ def iter_optimization_tables(base_stats: Stats, head_stats: Stats | None = None)
12141261
12151262 yield Table (("" , "Count:" , "Ratio:" ), calc_optimization_table , JoinMode .CHANGE )
12161263 yield Table (("" , "Count:" , "Ratio:" ), calc_optimizer_table , JoinMode .CHANGE )
1264+ yield Section (
1265+ "JIT memory stats" ,
1266+ "" ,
1267+ [
1268+ Table (
1269+ ("" , "Size (bytes):" , "Ratio:" ),
1270+ calc_jit_memory_table ,
1271+ JoinMode .CHANGE
1272+ )
1273+ ],
1274+ )
12171275 for name , den in [
12181276 ("Trace length" , "Optimization traces created" ),
12191277 ("Optimized trace length" , "Optimization traces created" ),
0 commit comments