Skip to content

port(wasm): Avoid cloning symbol tables during module layout - #2293

Merged
lapla-cogito merged 1 commit into
wild-linker:mainfrom
lapla-cogito:wasm_symclone
Jul 30, 2026
Merged

lapla-cogito merged 1 commit into
wild-linker:mainfrom
lapla-cogito:wasm_symclone

Conversation

@lapla-cogito

Copy link
Copy Markdown
Member

Borrow linking symbols and init funcs from each input File as slices instead of cloning them into WasmObjectLayoutInput and again into WasmLayout. This contributes to a slight reduction in RSS.

Benchmark 1 (116 runs): /home/lapla/wild-rg/save/0/run-with /tmp/wild-symclone/wild-before --no-fork
  measurement          mean ± σ            min … max           outliers         delta
  wall_time          43.2ms ± 2.33ms    37.5ms … 47.1ms          0 ( 0%)        0%
  peak_rss           85.6MB ±  453KB    84.3MB … 86.7MB          4 ( 3%)        0%
  cpu_cycles         38.8M  ± 21.8M     14.3M  … 83.9M           0 ( 0%)        0%
  instructions       75.7M  ± 40.7M     27.3M  …  166M           0 ( 0%)        0%
  cache_references    803K  ±  552K      262K  … 1.78M           0 ( 0%)        0%
  cache_misses        448K  ±  299K      157K  …  930K           0 ( 0%)        0%
  branch_misses       258K  ±  134K      114K  …  558K           0 ( 0%)        0%
Benchmark 2 (118 runs): /home/lapla/wild-rg/save/0/run-with /tmp/wild-symclone/wild-after --no-fork
  measurement          mean ± σ            min … max           outliers         delta
  wall_time          42.6ms ± 2.41ms    37.2ms … 49.1ms          0 ( 0%)          -  1.4% ±  1.4%
  peak_rss           83.2MB ±  421KB    81.7MB … 84.3MB          3 ( 3%)        ⚡-  2.7% ±  0.1%
  cpu_cycles         37.5M  ± 20.6M     10.6M  … 77.5M           0 ( 0%)          -  3.4% ± 14.0%
  instructions       74.6M  ± 39.2M     20.9M  …  150M           0 ( 0%)          -  1.6% ± 13.5%
  cache_references    759K  ±  527K      182K  … 1.70M           0 ( 0%)          -  5.5% ± 17.2%
  cache_misses        415K  ±  276K      125K  …  872K           0 ( 0%)          -  7.4% ± 16.4%
  branch_misses       254K  ±  129K     83.7K  …  494K           0 ( 0%)          -  1.6% ± 13.1%

Part of #1431

@davidlattimore

Copy link
Copy Markdown
Member

BTW, I just tried benchmarking this and with sufficient runs and a quiet system, I saw a speedup too:

Benchmark 1 (1294 runs): /home/david/save/ripgrep-wasm/run-with /home/d/wild-builds/2026-07-30.cg1 --strip-debug --no-fork
  measurement          mean ± σ            min … max           outliers         delta
  wall_time          46.3ms ± 1.60ms    43.1ms … 81.3ms          6 ( 0%)        0%
  peak_rss           81.8MB ±  838KB    78.0MB … 85.2MB         23 ( 2%)        0%
  cpu_cycles          239M  ± 8.81M      184M  …  258M          22 ( 2%)        0%
  instructions        304M  ± 3.99M      290M  …  316M          15 ( 1%)        0%
  cache_references   10.0M  ±  163K     9.51M  … 10.6M          13 ( 1%)        0%
  cache_misses       1.39M  ± 32.1K     1.22M  … 1.48M          19 ( 1%)        0%
  branch_misses      1.07M  ± 17.4K     1.01M  … 1.13M          19 ( 1%)        0%
Benchmark 2 (1332 runs): /home/david/save/ripgrep-wasm/run-with target/cg1/wild --strip-debug --no-fork
  measurement          mean ± σ            min … max           outliers         delta
  wall_time          45.0ms ± 1.24ms    42.3ms … 51.7ms          4 ( 0%)        ⚡-  2.8% ±  0.2%
  peak_rss           79.2MB ±  870KB    76.0MB … 82.7MB         27 ( 2%)        ⚡-  3.1% ±  0.1%
  cpu_cycles          237M  ± 8.71M      203M  …  261M          23 ( 2%)          -  1.0% ±  0.3%
  instructions        303M  ± 4.04M      291M  …  315M           6 ( 0%)          -  0.3% ±  0.1%
  cache_references   9.85M  ±  160K     9.34M  … 10.4M           8 ( 1%)        ⚡-  1.9% ±  0.1%
  cache_misses       1.35M  ± 31.3K     1.24M  … 1.44M          13 ( 1%)        ⚡-  2.3% ±  0.2%
  branch_misses      1.07M  ± 17.0K     1.02M  … 1.14M          10 ( 1%)          -  0.3% ±  0.1%

@lapla-cogito
lapla-cogito merged commit 8d6cb8f into wild-linker:main Jul 30, 2026
24 checks passed
@lapla-cogito
lapla-cogito deleted the wasm_symclone branch July 30, 2026 00:55
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