Skip to content

Split String::eq into fast path + slow path for inlining#726

Merged
gfx merged 2 commits intomainfrom
claude/profile-gale-gen-8gAXY
Mar 29, 2026
Merged

Split String::eq into fast path + slow path for inlining#726
gfx merged 2 commits intomainfrom
claude/profile-gale-gen-8gAXY

Conversation

@gfx
Copy link
Copy Markdown
Member

@gfx gfx commented Mar 29, 2026

Summary

  • Split String^Eq::eq into a small fast path (length comparison only) and a separate eq_bytes slow path (byte-by-byte loop)
  • The fast path has few enough expressions to be inlined by the compiler, so callers skip the function call entirely when string lengths differ

Benchmark

gale gen SQLite.g4 (string-comparison-heavy workload):

Before After Speedup
4m13s 1m04s ~4x

Guest profiler showed String^Eq::eq at 28% inclusive time. Most calls in this workload compare strings of different lengths (e.g. array_contains_str scanning token arrays), so the length mismatch early-exit dominates.

Test plan

  • cargo test --release -p wado-compiler — all tests pass
  • CI green

https://claude.ai/code/session_01Mz8z6W978jr8Ad5x9nDoat

Separate the length check (fast path, small enough to inline) from the
byte-by-byte comparison loop (eq_bytes, separate function). This allows
the compiler to inline the length mismatch early-exit into callers,
avoiding the function call overhead when strings differ in length.

Benchmark: gale gen SQLite.g4 improved from 4m13s to 1m04s (~4x faster).

https://claude.ai/code/session_01Mz8z6W978jr8Ad5x9nDoat
@github-actions
Copy link
Copy Markdown

Working tree is dirty

Integrity checks produced the following changes:

 docs/cheatsheet-stdlib-core.md                       |  1 +
 docs/stdlib-core.md                                  |  2 ++
 .../fixtures.golden/array_append_collapse.wir.wado   | 20 ++++++++++----------
 .../fixtures.golden/assert_inspect_string.wir.wado   | 20 ++++++++++----------
 .../fixtures.golden/auto_deref_template.wir.wado     | 20 ++++++++++----------
 .../tests/fixtures.golden/base64_encode.wir.wado     | 20 ++++++++++----------
 .../tests/fixtures.golden/closure_1.wir.wado         | 20 ++++++++++----------
 .../tests/fixtures.golden/closure_2.wir.wado         | 20 ++++++++++----------
 .../cross_module_treemap_variant.wir.wado            | 20 ++++++++++----------
 .../tests/fixtures.golden/default_trait.wir.wado     | 20 ++++++++++----------
 .../tests/fixtures.golden/dict_mini.wir.wado         | 20 ++++++++++----------
 .../tests/fixtures.golden/display_1.wir.wado         | 20 ++++++++++----------
 .../tests/fixtures.golden/display_2.wir.wado         | 20 ++++++++++----------
 .../tests/fixtures.golden/from-literal-cast.wir.wado | 20 ++++++++++----------
 .../fixtures.golden/from-literal-custom.wir.wado     | 20 ++++++++++----------
 .../fixtures.golden/from-literal-return.wir.wado     | 20 ++++++++++----------
 .../fixtures.golden/from_char_to_string.wir.wado     | 20 ++++++++++----------
 .../fixtures.golden/generic_function_merged.wir.wado | 20 ++++++++++----------
 .../fixtures.golden/generic_method_merged.wir.wado   | 20 ++++++++++----------
 .../tests/fixtures.golden/generic_struct_1.wir.wado  | 20 ++++++++++----------
 .../tests/fixtures.golden/http-request-path.wir.wado | 20 ++++++++++----------
 .../fixtures.golden/http-routing-created.wir.wado    | 20 ++++++++++----------
 .../tests/fixtures.golden/http-routing.wir.wado      | 20 ++++++++++----------
 .../tests/fixtures.golden/ident_merged.wir.wado      | 20 ++++++++++----------
 .../tests/fixtures.golden/include_str_basic.wir.wado | 20 ++++++++++----------
 .../tests/fixtures.golden/inspect_1.wir.wado         | 20 ++++++++++----------
 .../tests/fixtures.golden/inspect_2.wir.wado         | 20 ++++++++++----------
 .../tests/fixtures.golden/inspect_3.wir.wado         | 20 ++++++++++----------
 .../tests/fixtures.golden/iterator_merged.wir.wado   | 20 ++++++++++----------
 .../fixtures.golden/iterator_trait_map.wir.wado      | 20 ++++++++++----------
 .../key-value-literal-both-traits.wir.wado           | 20 ++++++++++----------
 .../key-value-literal-conditional.wir.wado           | 20 ++++++++++----------
 .../key-value-literal-immutable.wir.wado             | 20 ++++++++++----------
 .../tests/fixtures.golden/local_merged.wir.wado      | 20 ++++++++++----------
 wado-compiler/tests/fixtures.golden/match_1.wir.wado | 20 ++++++++++----------
 .../tests/fixtures.golden/match_ergonomics.wir.wado  | 20 ++++++++++----------
 .../fixtures.golden/match_or_pattern_1.wir.wado      | 20 ++++++++++----------
 .../fixtures.golden/match_or_pattern_3.wir.wado      | 20 ++++++++++----------
 .../fixtures.golden/match_or_pattern_6.wir.wado      | 20 ++++++++++----------
 .../fixtures.golden/match_return_from_arm.wir.wado   | 20 ++++++++++----------
 .../tests/fixtures.golden/mut_param.wir.wado         | 20 ++++++++++----------
 .../tests/fixtures.golden/mut_param_merged.wir.wado  | 20 ++++++++++----------
 .../opt_copy_prop_multi_field.wir.wado               | 20 ++++++++++----------
 .../fixtures.golden/opt_copy_prop_while_let.wir.wado | 20 ++++++++++----------
 .../fixtures.golden/opt_crossmod_array.wir.wado      | 20 ++++++++++----------
 .../fixtures.golden/opt_sroa_box_parameter.wir.wado  | 20 ++++++++++----------
 .../fixtures.golden/opt_sroa_single_field.wir.wado   | 20 ++++++++++----------
 .../opt_sroa_variant_per_case.wir.wado               | 20 ++++++++++----------
 .../tests/fixtures.golden/ordering-basic.wir.wado    | 20 ++++++++++----------
 .../fixtures.golden/pattern_mut_binding.wir.wado     | 20 ++++++++++----------
 .../pub_struct_field_same_module.wir.wado            | 20 ++++++++++----------
 .../ref_equality_struct_with_ref.wir.wado            | 20 ++++++++++----------
 .../tests/fixtures.golden/return_merged.wir.wado     | 20 ++++++++++----------
 .../fixtures.golden/serde_default_init.wir.wado      | 20 ++++++++++----------
 .../fixtures.golden/serde_json_array_string.wir.wado | 20 ++++++++++----------
 .../fixtures.golden/serde_json_default.wir.wado      | 20 ++++++++++----------
 .../fixtures.golden/serde_json_deser_error.wir.wado  | 20 ++++++++++----------
 .../serde_json_deser_error_edge.wir.wado             | 20 ++++++++++----------
 .../fixtures.golden/serde_json_int_types.wir.wado    | 20 ++++++++++----------
 .../fixtures.golden/serde_json_large_int.wir.wado    | 20 ++++++++++----------
 .../serde_json_nested_struct.wir.wado                | 20 ++++++++++----------
 .../serde_json_option_array_fields.wir.wado          | 20 ++++++++++----------
 .../fixtures.golden/serde_json_primitives.wir.wado   | 20 ++++++++++----------
 .../tests/fixtures.golden/serde_json_rename.wir.wado | 20 ++++++++++----------
 .../fixtures.golden/serde_json_rename_all.wir.wado   | 20 ++++++++++----------
 .../tests/fixtures.golden/serde_json_result.wir.wado | 20 ++++++++++----------
 .../serde_json_roundtrip_complex.wir.wado            | 20 ++++++++++----------
 .../fixtures.golden/serde_json_ser_error.wir.wado    | 20 ++++++++++----------
 .../serde_json_string_escape.wir.wado                | 20 ++++++++++----------
 .../fixtures.golden/serde_json_synth_enum.wir.wado   | 20 ++++++++++----------
 .../serde_json_synth_variant.wir.wado                | 20 ++++++++++----------
 .../fixtures.golden/serde_json_treemap.wir.wado      | 20 ++++++++++----------
 .../tests/fixtures.golden/serde_json_tuple.wir.wado  | 20 ++++++++++----------
 .../tests/fixtures.golden/serde_synth.wir.wado       | 20 ++++++++++----------
 .../tests/fixtures.golden/static_2.wir.wado          | 20 ++++++++++----------
 .../fixtures.golden/string-truncate-panic.wir.wado   |  4 ++--
 .../string_from_utf8_lossy_newtype.wir.wado          | 20 ++++++++++----------
 .../tests/fixtures.golden/struct_2.wir.wado          | 20 ++++++++++----------
 .../fixtures.golden/struct_eq_auto_generic.wir.wado  | 20 ++++++++++----------
 .../struct_eq_auto_variant_field.wir.wado            | 20 ++++++++++----------
 .../fixtures.golden/template-string-generic.wir.wado | 20 ++++++++++----------
 .../template_string_option_loop.wir.wado             | 20 ++++++++++----------
 .../test_world_variant_group.wir.wado                | 20 ++++++++++----------
 .../tmpl_hoist_escape_unsafe.wir.wado                | 20 ++++++++++----------
 .../tests/fixtures.golden/trait_bound_7.wir.wado     | 20 ++++++++++----------
 .../fixtures.golden/treemap-literal-basic.wir.wado   | 20 ++++++++++----------
 .../fixtures.golden/treemap-literal-cast.wir.wado    | 20 ++++++++++----------
 .../fixtures.golden/treemap-literal-fn-arg.wir.wado  | 20 ++++++++++----------
 .../fixtures.golden/treemap-literal-mutable.wir.wado | 20 ++++++++++----------
 .../treemap-literal-string-values.wir.wado           | 20 ++++++++++----------
 .../tests/fixtures.golden/treemap_btree.wir.wado     | 20 ++++++++++----------
 .../tests/fixtures.golden/treemap_btree2.wir.wado    | 20 ++++++++++----------
 .../tests/fixtures.golden/try_merged.wir.wado        | 20 ++++++++++----------
 wado-compiler/tests/fixtures.golden/tuple_1.wir.wado | 20 ++++++++++----------
 wado-compiler/tests/fixtures.golden/tuple_2.wir.wado | 20 ++++++++++----------
 .../tests/fixtures.golden/tuple_for_of.wir.wado      | 20 ++++++++++----------
 .../tests/fixtures.golden/variadic_1.wir.wado        | 20 ++++++++++----------
 .../tests/fixtures.golden/variadic_2.wir.wado        | 20 ++++++++++----------
 .../tests/fixtures.golden/variadic_3.wir.wado        | 20 ++++++++++----------
 .../fixtures.golden/variadic_deserialize.wir.wado    | 20 ++++++++++----------
 .../variant_deref_cross_module.wir.wado              | 20 ++++++++++----------
 .../tests/fixtures.golden/variant_infer.wir.wado     | 20 ++++++++++----------
 .../wir_issue8_cross_module_variant.wir.wado         | 20 ++++++++++----------
 .../wir_optimize_unwrap_fresh_elision_edge.wir.wado  | 20 ++++++++++----------
 .../tests/format.fixtures.golden/all.lower.wado      | 17 +++++++++--------
 .../tests/format.fixtures.golden/mess.lower.wado     | 17 +++++++++--------
 .../tests/format.fixtures.golden/ops.all.lower.wado  | 17 +++++++++--------
 .../tests/format.fixtures.golden/ops.mess.lower.wado | 17 +++++++++--------
 108 files changed, 1051 insertions(+), 1044 deletions(-)

Please run mise run on-task-done locally and commit the changes.

@gfx gfx enabled auto-merge March 29, 2026 09:09
@gfx gfx merged commit b8a3810 into main Mar 29, 2026
10 checks passed
@gfx gfx deleted the claude/profile-gale-gen-8gAXY branch March 29, 2026 09:39
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.

2 participants