phase3: cjson cache-sim profile — float print/parse dominate

~22% of Ir in glibc float serialization (__printf_fp, cJSON print_number)
and parsing (strtod/str_to_mpn, cJSON parse_number), plus parse_value/
parse_string and malloc/free churn. Ample headroom (SPEC §6).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EcKPWQ3MQD4NdEHwar96u2
This commit is contained in:
Claude
2026-07-11 18:35:22 +00:00
parent f5f4c10b63
commit b6dab15bf2
2 changed files with 75 additions and 0 deletions
+1
View File
@@ -243,3 +243,4 @@ agent/**/__pycache__/
# cjson corpus is regenerable via gen-corpus.sh (deterministic) # cjson corpus is regenerable via gen-corpus.sh (deterministic)
corpora/cjson/input/ corpora/cjson/input/
targets/cjson/testbuild/ targets/cjson/testbuild/
results/*/callgrind-cache.out
+74
View File
@@ -0,0 +1,74 @@
--------------------------------------------------------------------------------
Profile data file 'results/cjson/callgrind-cache.out' (creator: callgrind-3.22.0)
--------------------------------------------------------------------------------
I1 cache: 32768 B, 64 B, 8-way associative
D1 cache: 32768 B, 64 B, 8-way associative
LL cache: 35651584 B, 64 B, 17-way associative
Timerange: Basic block 0 - 1005248788
Trigger: Program termination
Profiled target: /tmp/cjson-prof/cjson-bench corpora/cjson/input/big.json 3 (PID 25559, part 1)
Events recorded: Ir Dr Dw I1mr D1mr D1mw ILmr DLmr DLmw Bc Bcm Bi Bim
Events shown: Ir Dr Dw I1mr D1mr D1mw ILmr DLmr DLmw Bc Bcm Bi Bim
Event sort order: Ir Dr Dw I1mr D1mr D1mw ILmr DLmr DLmw Bc Bcm Bi Bim
Thresholds: 97 0 0 0 0 0 0 0 0 0 0 0 0
Include dirs:
User annotated:
Auto-annotation: on
--------------------------------------------------------------------------------
Ir Dr Dw I1mr D1mr D1mw ILmr DLmr DLmw Bc Bcm Bi Bim
--------------------------------------------------------------------------------
4,685,252,094 (100.0%) 1,010,069,038 (100.0%) 625,640,363 (100.0%) 5,843,765 (100.0%) 7,868,900 (100.0%) 1,241,461 (100.0%) 3,218 (100.0%) 5,919,355 (100.0%) 1,046,279 (100.0%) 754,451,991 (100.0%) 33,047,735 (100.0%) 26,673,314 (100.0%) 2,222,641 (100.0%) PROGRAM TOTALS
--------------------------------------------------------------------------------
Ir Dr Dw I1mr D1mr D1mw ILmr DLmr DLmw Bc Bcm Bi Bim file:function
--------------------------------------------------------------------------------
637,034,976 (13.60%) 158,918,280 (15.73%) 83,065,737 (13.28%) 855,746 (14.64%) 96 ( 0.00%) 90 ( 0.01%) 209 ( 6.49%) 24 ( 0.00%) 24 ( 0.00%) 113,268,981 (15.01%) 5,030,223 (15.22%) . . ./stdio-common/./stdio-common/printf_fp.c:__printf_fp_buffer_1.isra.0 [/usr/lib/x86_64-linux-gnu/libc.so.6]
384,064,650 ( 8.20%) 73,607,328 ( 7.29%) 36,730,884 ( 5.87%) 415,586 ( 7.11%) 1,414 ( 0.02%) 66 ( 0.01%) 188 ( 5.84%) 34 ( 0.00%) 20 ( 0.00%) 64,737,597 ( 8.58%) 4,818,010 (14.58%) . . ./stdlib/./stdlib/strtod_l.c:____strtod_l_internal [/usr/lib/x86_64-linux-gnu/libc.so.6]
294,602,463 ( 6.29%) 70,228,494 ( 6.95%) 63,924,435 (10.22%) 261,347 ( 4.47%) 0 3 ( 0.00%) 11 ( 0.34%) 0 3 ( 0.00%) 31,351,464 ( 4.16%) 642,309 ( 1.94%) . . ./stdlib/./stdlib/divrem.c:__mpn_divrem [/usr/lib/x86_64-linux-gnu/libc.so.6]
231,942,018 ( 4.95%) 56,776,050 ( 5.62%) 40,158,519 ( 6.42%) 1,460,784 (25.00%) 75 ( 0.00%) 0 172 ( 5.34%) 21 ( 0.00%) 0 41,220,234 ( 5.46%) 988,895 ( 2.99%) 644,706 ( 2.42%) 2 ( 0.00%) ./stdio-common/./stdio-common/vfscanf-internal.c:__vfscanf_internal [/usr/lib/x86_64-linux-gnu/libc.so.6]
208,702,098 ( 4.45%) 29,444,439 ( 2.92%) 19,802,361 ( 3.17%) 6 ( 0.00%) 7 ( 0.00%) 0 6 ( 0.19%) 3 ( 0.00%) 0 38,050,107 ( 5.04%) 263,379 ( 0.80%) . . ./stdlib/../sysdeps/x86_64/mul_1.S:__mpn_mul_1 [/usr/lib/x86_64-linux-gnu/libc.so.6]
206,409,170 ( 4.41%) 36,862,330 ( 3.65%) 25,967,440 ( 4.15%) 34 ( 0.00%) 1,578 ( 0.02%) 138,956 (11.19%) 34 ( 1.06%) 425 ( 0.01%) 70,654 ( 6.75%) 41,217,012 ( 5.46%) 3,434,391 (10.39%) 7,230,866 (27.11%) 659,683 (29.68%) targets/cjson/workspace/cJSON.c:parse_value'2 [/tmp/cjson-prof/cjson-bench]
203,365,507 ( 4.34%) 52,235,950 ( 5.17%) 20,587,887 ( 3.29%) 29 ( 0.00%) 398,923 ( 5.07%) 36 ( 0.00%) 25 ( 0.78%) 397,528 ( 6.72%) 8 ( 0.00%) 41,473,481 ( 5.50%) 272,053 ( 0.82%) . . ./malloc/./malloc/malloc.c:_int_free [/usr/lib/x86_64-linux-gnu/libc.so.6]
188,097,198 ( 4.01%) 28,995,630 ( 2.87%) 19,684,752 ( 3.15%) 23 ( 0.00%) 6,010 ( 0.08%) 4,750 ( 0.38%) 23 ( 0.71%) 485 ( 0.01%) 1,496 ( 0.14%) 36,632,961 ( 4.86%) 2,555,552 ( 7.73%) 1,109,013 ( 4.16%) 37,687 ( 1.70%) targets/cjson/workspace/cJSON.c:parse_string [/tmp/cjson-prof/cjson-bench]
186,477,852 ( 3.98%) 26,931,432 ( 2.67%) 13,769,100 ( 2.20%) 8 ( 0.00%) 24 ( 0.00%) 27 ( 0.00%) 6 ( 0.19%) 12 ( 0.00%) 8 ( 0.00%) 34,181,574 ( 4.53%) 1,910,257 ( 5.78%) . . ./stdlib/./stdlib/strtod_l.c:str_to_mpn.isra.0 [/usr/lib/x86_64-linux-gnu/libc.so.6]
151,418,740 ( 3.23%) 29,203,622 ( 2.89%) 18,286,458 ( 2.92%) 243 ( 0.00%) 1,054,542 (13.40%) 587,098 (47.29%) 174 ( 5.41%) 337,981 ( 5.71%) 587,071 (56.11%) 23,232,738 ( 3.08%) 198,846 ( 0.60%) . . ./malloc/./malloc/malloc.c:_int_malloc [/usr/lib/x86_64-linux-gnu/libc.so.6]
137,449,736 ( 2.93%) 29,781,868 ( 2.95%) 25,590,922 ( 4.09%) 262,148 ( 4.49%) 1,428,990 (18.16%) 633 ( 0.05%) 24 ( 0.75%) 1,427,269 (24.11%) 633 ( 0.06%) 19,855,242 ( 2.63%) 934,727 ( 2.83%) 4,911,881 (18.41%) 852,937 (38.37%) targets/cjson/workspace/cJSON.c:print_value'2 [/tmp/cjson-prof/cjson-bench]
136,109,002 ( 2.91%) 17,013,641 ( 1.68%) 47 ( 0.00%) 20 ( 0.00%) 265,848 ( 3.38%) 3 ( 0.00%) 20 ( 0.62%) 23,093 ( 0.39%) 0 17,013,622 ( 2.26%) 20 ( 0.00%) 16 ( 0.00%) 8 ( 0.00%) targets/cjson/harness.c:main [/tmp/cjson-prof/cjson-bench]
126,527,205 ( 2.70%) 17,319,117 ( 1.71%) 13,269,930 ( 2.12%) 38,116 ( 0.65%) 645,899 ( 8.21%) 797 ( 0.06%) 12 ( 0.37%) 643,519 (10.87%) 794 ( 0.08%) 20,976,648 ( 2.78%) 1,527,879 ( 4.62%) 1,034,259 ( 3.88%) 40,308 ( 1.81%) targets/cjson/workspace/cJSON.c:print_string_ptr [/tmp/cjson-prof/cjson-bench]
126,133,875 ( 2.69%) 33,635,655 ( 3.33%) 21,022,335 ( 3.36%) 4 ( 0.00%) 39 ( 0.00%) 9 ( 0.00%) 4 ( 0.12%) 3 ( 0.00%) 3 ( 0.00%) 21,022,380 ( 2.79%) 151,242 ( 0.46%) 45 ( 0.00%) 1 ( 0.00%) targets/cjson/workspace/cJSON.c:ensure [/tmp/cjson-prof/cjson-bench]
125,761,796 ( 2.68%) 34,362,552 ( 3.40%) 18,131,061 ( 2.90%) 20 ( 0.00%) 50 ( 0.00%) 7 ( 0.00%) 19 ( 0.59%) 39 ( 0.00%) 5 ( 0.00%) 21,958,583 ( 2.91%) 1,053,443 ( 3.19%) . . ./malloc/./malloc/malloc.c:malloc [/usr/lib/x86_64-linux-gnu/libc.so.6]
122,712,111 ( 2.62%) 27,022,743 ( 2.68%) 25,524,129 ( 4.08%) 386,191 ( 6.61%) 112 ( 0.00%) 67 ( 0.01%) 50 ( 1.55%) 34 ( 0.00%) 13 ( 0.00%) 11,107,557 ( 1.47%) 219,452 ( 0.66%) 1,766,252 ( 6.62%) 240,174 (10.81%) ./stdio-common/./stdio-common/vfprintf-internal.c:__printf_buffer [/usr/lib/x86_64-linux-gnu/libc.so.6]
93,615,657 ( 2.00%) 35,103,624 ( 3.48%) 15,675,027 ( 2.51%) 16 ( 0.00%) 0 3 ( 0.00%) 14 ( 0.44%) 0 3 ( 0.00%) 10,783,014 ( 1.43%) 487,561 ( 1.48%) . . ./stdio-common/./stdio-common/printf_fp.c:hack_digit [/usr/lib/x86_64-linux-gnu/libc.so.6]
92,724,627 ( 1.98%) 18,099,150 ( 1.79%) 0 48 ( 0.00%) 260,943 ( 3.32%) 0 48 ( 1.49%) 70,774 ( 1.20%) 0 14,991,483 ( 1.99%) 157,976 ( 0.48%) . . ./string/../sysdeps/x86_64/multiarch/strcmp-avx2.S:__strncmp_avx2 [/usr/lib/x86_64-linux-gnu/libc.so.6]
85,135,362 ( 1.82%) 15,353,376 ( 1.52%) 12,084,618 ( 1.93%) 3 ( 0.00%) 606 ( 0.01%) 237,460 (19.13%) 3 ( 0.09%) 172 ( 0.00%) 121,186 (11.58%) 19,282,410 ( 2.56%) 824,253 ( 2.49%) 779,724 ( 2.92%) 179,931 ( 8.10%) targets/cjson/workspace/cJSON.c:parse_object'2 [/tmp/cjson-prof/cjson-bench]
80,179,293 ( 1.71%) 28,635,452 ( 2.83%) 17,181,276 ( 2.75%) 16 ( 0.00%) 549,470 ( 6.98%) 8 ( 0.00%) 16 ( 0.50%) 524,102 ( 8.85%) 1 ( 0.00%) 8,590,644 ( 1.14%) 1,893 ( 0.01%) . . ./malloc/./malloc/malloc.c:free [/usr/lib/x86_64-linux-gnu/libc.so.6]
56,706,144 ( 1.21%) 16,754,088 ( 1.66%) 14,176,536 ( 2.27%) 80 ( 0.00%) 3 ( 0.00%) 55 ( 0.00%) 8 ( 0.25%) 3 ( 0.00%) 16 ( 0.00%) 6,443,880 ( 0.85%) 19 ( 0.00%) . . ./stdlib/./stdlib/mul.c:__mpn_mul [/usr/lib/x86_64-linux-gnu/libc.so.6]
55,390,023 ( 1.18%) 18,210,414 ( 1.80%) 12,140,274 ( 1.94%) 6 ( 0.00%) 0 0 6 ( 0.19%) 0 0 6,070,140 ( 0.80%) 218,420 ( 0.66%) . . ./stdio-common/./stdio-common/Xprintf_buffer_write.c:__printf_buffer_write [/usr/lib/x86_64-linux-gnu/libc.so.6]
54,208,343 ( 1.16%) 8,194,181 ( 0.81%) 0 21 ( 0.00%) 615,305 ( 7.82%) 0 16 ( 0.50%) 615,247 (10.39%) 0 7,663,768 ( 1.02%) 124,028 ( 0.38%) . . ./string/../sysdeps/x86_64/multiarch/strlen-avx2.S:__strlen_avx2 [/usr/lib/x86_64-linux-gnu/libc.so.6]
52,725,505 ( 1.13%) 13,154,156 ( 1.30%) 9,408,032 ( 1.50%) 14,092 ( 0.24%) 257,621 ( 3.27%) 270,422 (21.78%) 36 ( 1.12%) 24 ( 0.00%) 263,555 (25.19%) 13,682,759 ( 1.81%) 2,812,765 ( 8.51%) . . ./string/../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:__memcpy_avx_unaligned_erms [/usr/lib/x86_64-linux-gnu/libc.so.6]
44,294,004 ( 0.95%) 11,073,876 ( 1.10%) 7,182,816 ( 1.15%) 261,370 ( 4.47%) 15 ( 0.00%) 42 ( 0.00%) 14 ( 0.44%) 9 ( 0.00%) 15 ( 0.00%) 4,788,780 ( 0.63%) 806 ( 0.00%) . . ./stdlib/./stdlib/strtod_l.c:round_and_return [/usr/lib/x86_64-linux-gnu/libc.so.6]
43,590,700 ( 0.93%) 9,123,107 ( 0.90%) 8,089,288 ( 1.29%) 14 ( 0.00%) 1,034,506 (13.15%) 1 ( 0.00%) 14 ( 0.44%) 580,184 ( 9.80%) 1 ( 0.00%) 5,710,055 ( 0.76%) 213,263 ( 0.65%) . . ./malloc/./malloc/malloc.c:malloc_consolidate [/usr/lib/x86_64-linux-gnu/libc.so.6]
39,678,180 ( 0.85%) 4,959,777 ( 0.49%) 2,479,893 ( 0.40%) 5 ( 0.00%) 0 0 5 ( 0.16%) 0 0 7,439,661 ( 0.99%) 158,886 ( 0.48%) . . ./stdlib/../sysdeps/x86_64/lshift.S:__mpn_lshift [/usr/lib/x86_64-linux-gnu/libc.so.6]
34,172,010 ( 0.73%) 9,913,362 ( 0.98%) 4,508,925 ( 0.72%) 3 ( 0.00%) 1,161,417 (14.76%) 1 ( 0.00%) 3 ( 0.09%) 1,161,394 (19.62%) 0 8,951,199 ( 1.19%) 1,452,229 ( 4.39%) 2,286,159 ( 8.57%) 5 ( 0.00%) targets/cjson/workspace/cJSON.c:cJSON_Delete'2 [/tmp/cjson-prof/cjson-bench]
28,833,146 ( 0.62%) 3,035,068 ( 0.30%) 0 5 ( 0.00%) 10 ( 0.00%) 0 5 ( 0.16%) 4 ( 0.00%) 0 3,035,068 ( 0.40%) 325 ( 0.00%) . . ./string/../sysdeps/x86_64/multiarch/strchr-avx2.S:__strchrnul_avx2 [/usr/lib/x86_64-linux-gnu/libc.so.6]
28,713,294 ( 0.61%) 8,563,614 ( 0.85%) 7,556,130 ( 1.21%) 15 ( 0.00%) 9 ( 0.00%) 39 ( 0.00%) 15 ( 0.47%) 3 ( 0.00%) 9 ( 0.00%) 2,518,710 ( 0.33%) 6 ( 0.00%) . . ./stdio-common/./stdio-common/printf_fp.c:__printf_fp_l_buffer [/usr/lib/x86_64-linux-gnu/libc.so.6]
28,403,442 ( 0.61%) 4,260,519 ( 0.42%) 2,840,346 ( 0.45%) 49 ( 0.00%) 5 ( 0.00%) 28 ( 0.00%) 5 ( 0.16%) 3 ( 0.00%) 10 ( 0.00%) 5,680,683 ( 0.75%) 337,279 ( 1.02%) . . ./string/../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:__memcpy_chk_avx_unaligned_erms [/usr/lib/x86_64-linux-gnu/libc.so.6]
28,158,937 ( 0.60%) 6,116,843 ( 0.61%) 3,825,377 ( 0.61%) 13,883 ( 0.24%) 0 0 50 ( 1.55%) 0 0 4,363,379 ( 0.58%) 61,739 ( 0.19%) . . ./stdio-common/./stdio-common/vfprintf-process-arg.c:__printf_buffer
26,034,150 ( 0.56%) 3,793,830 ( 0.38%) 12,376,362 ( 1.98%) 10 ( 0.00%) 0 8 ( 0.00%) 10 ( 0.31%) 0 4 ( 0.00%) 1,517,532 ( 0.20%) 226,811 ( 0.69%) . . ./stdio-common/./stdio-common/sprintf.c:sprintf [/usr/lib/x86_64-linux-gnu/libc.so.6]
22,762,980 ( 0.49%) 5,311,362 ( 0.53%) 4,552,596 ( 0.73%) 10 ( 0.00%) 0 0 10 ( 0.31%) 0 0 1,517,532 ( 0.20%) 8 ( 0.00%) . . ./libio/./libio/iovsprintf.c:__vsprintf_internal [/usr/lib/x86_64-linux-gnu/libc.so.6]
22,444,905 ( 0.48%) 2,014,968 ( 0.20%) 2,780,043 ( 0.44%) 125,950 ( 2.16%) 0 14 ( 0.00%) 17 ( 0.53%) 0 3 ( 0.00%) 2,014,968 ( 0.27%) 4 ( 0.00%) . . ./stdio-common/./stdio-common/printf-parse.h:__printf_buffer
20,503,584 ( 0.44%) 5,395,680 ( 0.53%) 0 3 ( 0.00%) 189 ( 0.00%) 0 3 ( 0.09%) 44 ( 0.00%) 0 5,395,680 ( 0.72%) 282,256 ( 0.85%) . . targets/cjson/workspace/cJSON.c:buffer_skip_whitespace [/tmp/cjson-prof/cjson-bench]
19,942,017 ( 0.43%) 1,479,078 ( 0.15%) 1,224,053 ( 0.20%) 53 ( 0.00%) 13 ( 0.00%) 0 12 ( 0.37%) 4 ( 0.00%) 0 1,479,078 ( 0.20%) 273,801 ( 0.83%) . . ./stdio-common/./stdio-common/_itoa.c:_itoa_word [/usr/lib/x86_64-linux-gnu/libc.so.6]
16,314,180 ( 0.35%) 6,962,100 ( 0.69%) 2,286,064 ( 0.37%) 43 ( 0.00%) 182,820 ( 2.32%) 0 9 ( 0.28%) 135,610 ( 2.29%) 0 3,152,012 ( 0.42%) 123,817 ( 0.37%) . . ./malloc/./malloc/malloc.c:unlink_chunk.isra.0 [/usr/lib/x86_64-linux-gnu/libc.so.6]
16,148,106 ( 0.34%) 2,691,351 ( 0.27%) 1,794,234 ( 0.29%) 216,019 ( 3.70%) 0 0 9 ( 0.28%) 0 0 3,588,468 ( 0.48%) 47,108 ( 0.14%) . . ./stdlib/../sysdeps/x86_64/rshift.S:__mpn_rshift [/usr/lib/x86_64-linux-gnu/libc.so.6]
14,416,573 ( 0.31%) 3,793,835 ( 0.38%) 0 2 ( 0.00%) 0 0 2 ( 0.06%) 0 0 3,035,068 ( 0.40%) 2 ( 0.00%) . . ./stdio-common/./stdio-common/Xprintf_buffer_done.c:__printf_buffer_done [/usr/lib/x86_64-linux-gnu/libc.so.6]
14,365,632 ( 0.31%) 1,795,704 ( 0.18%) 0 261,329 ( 4.47%) 0 0 5 ( 0.16%) . . . . . . ./stdlib/../sysdeps/ieee754/dbl-64/mpn2dbl.c:__mpn_construct_double [/usr/lib/x86_64-linux-gnu/libc.so.6]
12,894,120 ( 0.28%) 1,934,118 ( 0.19%) 4,512,942 ( 0.72%) 262,717 ( 4.50%) 0 0 7 ( 0.22%) 0 0 644,706 ( 0.09%) 2 ( 0.00%) . . ./libio/./libio/strops.c:_IO_str_init_static_internal [/usr/lib/x86_64-linux-gnu/libc.so.6]
12,249,414 ( 0.26%) 2,578,824 ( 0.26%) 4,512,942 ( 0.72%) 3 ( 0.00%) 0 0 3 ( 0.09%) 0 0 644,706 ( 0.09%) 2 ( 0.00%) . . ./stdio-common/./stdio-common/isoc99_sscanf.c:__isoc99_sscanf [/usr/lib/x86_64-linux-gnu/libc.so.6]
11,082,324 ( 0.24%) 503,742 ( 0.05%) 2,014,968 ( 0.32%) 4 ( 0.00%) 0 0 4 ( 0.12%) 0 0 503,742 ( 0.07%) 2 ( 0.00%) . . ./stdlib/../sysdeps/ieee754/dbl-64/dbl2mpn.c:__mpn_extract_double [/usr/lib/x86_64-linux-gnu/libc.so.6]
10,315,296 ( 0.22%) 3,545,883 ( 0.35%) 967,059 ( 0.15%) 262,717 ( 4.50%) 12 ( 0.00%) 0 7 ( 0.22%) 3 ( 0.00%) 0 2,256,471 ( 0.30%) 16 ( 0.00%) 322,353 ( 1.21%) 1 ( 0.00%) ./libio/./libio/genops.c:__uflow [/usr/lib/x86_64-linux-gnu/libc.so.6]
9,800,838 ( 0.21%) 2,450,703 ( 0.24%) 0 322,128 ( 5.51%) 0 0 6 ( 0.19%) 0 0 1,634,460 ( 0.22%) 1,423 ( 0.00%) . . ./stdlib/./stdlib/cmp.c:__mpn_cmp [/usr/lib/x86_64-linux-gnu/libc.so.6]
9,348,329 ( 0.20%) 2,578,849 ( 0.26%) 2,578,849 ( 0.41%) 10 ( 0.00%) 1 ( 0.00%) 14 ( 0.00%) 8 ( 0.25%) 1 ( 0.00%) 5 ( 0.00%) 322,357 ( 0.04%) 4 ( 0.00%) . . ./libio/./libio/genops.c:_IO_setb [/usr/lib/x86_64-linux-gnu/libc.so.6]
--------------------------------------------------------------------------------