Stream: compiler development

Topic: typechecker perf of type erasure


view this post on Zulip Ayaz Hafiz (Jul 05 2023 at 16:20):

In a somewhat surprising result, type-erasing functions instead of using lambda sets is only ~10% faster for type checking

❯ hyperfine 'target/release/roc check examples/cli/args.roc' '../roc2/target/release/roc check examples/cli/args.roc' --warmup 20
Benchmark 1: target/release/roc check examples/cli/args.roc
  Time (mean ± σ):      38.4 ms ±   1.0 ms    [User: 59.8 ms, System: 15.3 ms]
  Range (min … max):    36.9 ms …  44.2 ms    68 runs

Benchmark 2: ../roc2/target/release/roc check examples/cli/args.roc
  Time (mean ± σ):      41.8 ms ±   0.8 ms    [User: 67.2 ms, System: 15.8 ms]
  Range (min … max):    40.0 ms …  44.7 ms    65 runs

Summary
  'target/release/roc check examples/cli/args.roc' ran
    1.09 ± 0.04 times faster than '../roc2/target/release/roc check examples/cli/args.roc'

that's fine because this is not an explicit goal of type erasure, but an interesting observation

view this post on Zulip Brendan Hansknecht (Jul 05 2023 at 16:31):

Is this a case of other steps being most of the time or are lambda sets most of the cost here?

view this post on Zulip Ayaz Hafiz (Jul 05 2023 at 16:33):

this is an example where i expected lambda sets to consume the most time, but i guess they only take 10% of the time relative to parsing, etc.

view this post on Zulip Ayaz Hafiz (Jul 05 2023 at 16:33):

in any case the boost is nice but I don't think it matters too much anyway, anything sub 100ms is excellent IMO


Last updated: Jul 06 2025 at 12:14 UTC