Skip to content

Stats now prints cache hits#414

Merged
arthurpaulino merged 2 commits into
mainfrom
cache-hits
May 19, 2026
Merged

Stats now prints cache hits#414
arthurpaulino merged 2 commits into
mainfrom
cache-hits

Conversation

@gabriel-barrett
Copy link
Copy Markdown
Member

@gabriel-barrett gabriel-barrett commented May 19, 2026

Example:

=== Circuit Statistics ===
Circuits: 626
Total width: 48210
Total FFT cost: 348748181
Total cache hits: 336151
Total saved cost: 32.65%
------------------------------------------------------------------------------------------------------------------
Name                                                                   Width Height  Hits FFT cost       %     %++
------------------------------------------------------------------------------------------------------------------
u32_add                                                                   60  87952   332 86673682  24.85%  24.85%
blake3_g_function                                                        210  14714    14 42779916  12.27%  37.12%
u32_xor                                                                   38  60914    46 36791476  10.55%  47.67%
blake3_compress_chunks                                                    75  14692     0 15253319   4.37%  52.04%
k_infer                                                                  188   6031  1207 14238818   4.08%  56.13%
expr_inst1                                                                60  16108  7161 13507031   3.87%  60.00%
whnf_with_spine                                                          179   5437   180 12076330   3.46%  63.46%
expr_inst1_walk                                                           73  11520     0 11346109   3.25%  66.71%
memory[3]                                                                 14  35123 82952  7425065   2.13%  68.84%
list_lookup_u64.Ptr.Univ                                                  49  10530    69  6894504   1.98%  70.82%
...

Note that the saved cost is a bit misleading. In general, the real saved cost is much more, because it is not considering recursive calls. For instance, if you call a function factorial 4 twice, the cache hit will not only save the need to prove factorial 4 again, but also factorial 3, factorial 2, etc

@gabriel-barrett gabriel-barrett force-pushed the cache-hits branch 3 times, most recently from 517b532 to d6cee4c Compare May 19, 2026 00:10
Comment thread Ix/Aiur/Semantics/BytecodeFfi.lean Outdated
execute now returns Array QueryCount with named uniqueRows/totalHits
fields instead of opaque (Nat × Nat) pairs. computeStats consumes the
struct directly.
@arthurpaulino arthurpaulino enabled auto-merge (squash) May 19, 2026 11:40
@arthurpaulino arthurpaulino merged commit 51d31c2 into main May 19, 2026
14 checks passed
@arthurpaulino arthurpaulino deleted the cache-hits branch May 19, 2026 11:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants