code wiki / _hdl_build / nx_eqsat_race_bench.nx

nx_eqsat_race_bench.nx

buildroot/runtime/_hdl_build/nx_eqsat_race_bench.nx

7443 B151 linesdepth 7pulls 9 transitivereach 0 importersview sourcekind benchtopic eqsat
docsdependenciesstructsconstsfunctions

about

nx_eqsat_race_bench.nx -- RACE TIMING HARNESS vs egg 0.11.0 on the SAME task. THE RACE: egg's /tmp/race_egg/examples/nx_race.rs timed E2 "(* x 8)" : parse-string -> RecExpr -> Runner -> saturate -> Extractor::find_best -> to_string == (<< x 3) 100000 iterations = 783465 us total = 7.835 us/op (LatCost model). OUR analogue, ONE timed iteration (the same end-to-end pipeline, no proxy): nx_eqsat_init (fresh e-graph -- egg's RecExpr alloc) add_var x, add_const 8, add_binary(MUL, x, 8) (BUILD the (* x 8) input -- egg's parse) nx_eqsat_saturate(g, 16) (egg's Runner::run to saturation) nx_eqsat_recompute_best(g) (egg's Extractor bottom-up cost pass) nx_eqsat_extract_best_node(mul) (egg's find_best for the mul e-class) read the root op of that node (egg's to_string root-symbol read) CONFIRM the extracted op == NX_EQ_OP_SHL (11) and shift const == 3. Everything that egg counted (parse->saturate->extract->stringify-root) is inside OUR timed loop too, so the us/op is comparable 1:1. We do NOT include the membership PROOF/provenance machinery (egg has none) -- only the same optimize-and-read-the-answer work egg performed. FAIL LOUD: if the extracted representative is not (shl x 3) the harness sys_exit(nonzero) BEFORE printing timing -- a fast wrong answer is not a win. Output (one line): RESULT_OP=11 SHIFT=3 ITERS=100000 TOTAL_US=<t> US_PER_OP=<u>

dependencies 1 imports · 0 importers

nx_eqsat.nx nx_eqsat_race_bench.nx

imports: nx_eqsat.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main _one_iter nx_eqsat_init nx_eqsat_add_var nx_eqsat_add nx_eqsat_op_is_valid nx_eqsat_arity_for nx_cf_intern_const nx_eqsat_add_const nx_eqsat_add ↻ nx_eqsat_mix nx_cf_make_const_node nx_eqsat_new_class nx_eqsat_find nx_eqsat_find ↻ nx_eqsat_fold_value nx_eqsat_op_to_gate_kind nx_gsim_kind_supported nx_eqsat_arity_for ↻ nx_eqsat_find ↻ nx_gsim_eval_cell nx_eqsat_op_cost nx_eqsat_new_class ↻ nx_eqsat_union_cited nx_eqsat_find ↻ nx_eqsat_log_rule nx_eqsat_push_dirty nx_eqsat_fingerprint nx_eqsat_mix ↻ nx_hmap_has nx_hmap_probe_find nx_hmap_hash nx_hmap_entry_at nx_hmap_get nx_hmap_probe_find ↻ nx_hmap_entry_at ↻ nx_eqsat_node_matches nx_eqsat_arity_for ↻ nx_eqsat_find ↻ nx_hmap_put

structs

none

consts

29const K_MAGIC_100000: i64 = 100000

functions

32func _emit_num(v: i64) -> i64
called by 1: main
47func _emit_str(s: *u8, len: i64) -> i64
called by 1: main
52func _nl() -> i64
called by 1: main
68func _one_iter(eg: *NxEGraph,
96func main() -> i64