compact compiler ids and spans to reduce memory usage
This commit is contained in:
@@ -29,3 +29,9 @@ The measured run reduced token size by 14.3% and peak tracked memory by 9.8%.
|
||||
After the iterative compiler-hardening work on 2026-06-12, the same benchmark
|
||||
reported 13,222,443 peak bytes and 40,117 allocations. The reusable traversal
|
||||
stacks keep allocation count effectively unchanged from the interning baseline.
|
||||
|
||||
After migrating persistent compiler references and spans to compact IDs on
|
||||
2026-06-12, the benchmark reported 8,651,659 peak bytes and 40,117 allocations.
|
||||
`Span` is 12 bytes and `Token` is 24 bytes; AST expressions, HIR expressions,
|
||||
and IR instructions are 64, 88, and 88 bytes respectively. These sizes are
|
||||
also printed by the benchmark to catch layout regressions.
|
||||
|
||||
@@ -3,6 +3,7 @@ package main
|
||||
import "../../compiler/ast"
|
||||
import "../../compiler/checker"
|
||||
import "../../compiler/hir"
|
||||
import "../../compiler/ir"
|
||||
import "../../compiler/lexer"
|
||||
import "../../compiler/parser"
|
||||
import "../../compiler/source"
|
||||
@@ -72,6 +73,10 @@ main :: proc() {
|
||||
fmt.printf("allocation_count: %d\n", tracker.total_allocation_count)
|
||||
fmt.printf("token_count: %d\n", metrics.token_count)
|
||||
fmt.printf("token_size_bytes: %d\n", size_of(token.Token))
|
||||
fmt.printf("span_size_bytes: %d\n", size_of(source.Span))
|
||||
fmt.printf("ast_expr_size_bytes: %d\n", size_of(ast.Expr))
|
||||
fmt.printf("hir_expr_size_bytes: %d\n", size_of(hir.Expr))
|
||||
fmt.printf("ir_instruction_size_bytes: %d\n", size_of(ir.Instruction))
|
||||
fmt.printf("unique_symbol_count: %d\n", metrics.unique_symbol_count)
|
||||
fmt.printf("stored_symbol_bytes: %d\n", metrics.stored_symbol_bytes)
|
||||
fmt.printf("diagnostic_count: %d\n", metrics.diagnostic_count)
|
||||
|
||||
Reference in New Issue
Block a user