Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Precompute nock hashes #3384

Merged
merged 2 commits into from
Apr 8, 2025
Merged

Precompute nock hashes #3384

merged 2 commits into from
Apr 8, 2025

Conversation

lukaszcz
Copy link
Collaborator

@lukaszcz lukaszcz commented Apr 3, 2025

Benchmarks

Both compiled with optimizations.

$ hyperfine -w 1 -p 'rm -rf .juvix-build' 'juvix-old compile anoma test001.juvix --modular' 'juvix compile anoma test001.juvix --modular'

Benchmark 1: juvix-old compile anoma test001.juvix --modular
  Time (mean ± σ):      6.178 s ±  0.041 s    [User: 12.155 s, System: 0.879 s]
  Range (min … max):    6.101 s …  6.238 s    10 runs
 
Benchmark 2: juvix compile anoma test001.juvix --modular
  Time (mean ± σ):      5.775 s ±  0.018 s    [User: 11.636 s, System: 0.900 s]
  Range (min … max):    5.750 s …  5.794 s    10 runs
 
Summary
  'juvix compile anoma test001.juvix --modular' ran
    1.07 ± 0.01 times faster than 'juvix-old compile anoma test001.juvix --modular'
$ hyperfine -w 1 'juvix-old compile anoma test001.juvix --modular' 'juvix compile anoma test001.juvix --modular'

Benchmark 1: juvix-old compile anoma test001.juvix --modular
  Time (mean ± σ):      2.160 s ±  0.049 s    [User: 3.540 s, System: 0.829 s]
  Range (min … max):    2.092 s …  2.234 s    10 runs
 
Benchmark 2: juvix compile anoma test001.juvix --modular
  Time (mean ± σ):      1.811 s ±  0.031 s    [User: 3.209 s, System: 0.847 s]
  Range (min … max):    1.769 s …  1.856 s    10 runs
 
Summary
  'juvix compile anoma test001.juvix --modular' ran
    1.19 ± 0.03 times faster than 'juvix-old compile anoma test001.juvix --modular'
$ hyperfine -w 1 'juvix-old dev nockma run builtin-evaluator test001.nockma --storage test001.modules.nockma' 'juvix dev nockma run builtin-evaluator test001.nockma --storage test001.modules.nockma'

Benchmark 1: juvix-old dev nockma run builtin-evaluator test001.nockma --storage test001.modules.nockma
  Time (mean ± σ):      6.693 s ±  0.056 s    [User: 7.388 s, System: 1.212 s]
  Range (min … max):    6.614 s …  6.811 s    10 runs
 
Benchmark 2: juvix dev nockma run builtin-evaluator test001.nockma --storage test001.modules.nockma
  Time (mean ± σ):      6.933 s ±  0.060 s    [User: 7.650 s, System: 1.321 s]
  Range (min … max):    6.783 s …  6.997 s    10 runs
 
Summary
  'juvix-old dev nockma run builtin-evaluator test001.nockma --storage test001.modules.nockma' ran
    1.04 ± 0.01 times faster than 'juvix dev nockma run builtin-evaluator test001.nockma --storage test001.modules.nockma'

Conclusion

  • Precomputing the hashes increases the performance of jamming, which dominates the final stage of compilation to Nock.
  • The additional field in the CellInfo datatype decreases evaluation performance, which is not compensated by the faster module load times. However, compilation is the main user-facing feature of the Juvix compiler.

@lukaszcz lukaszcz added this to the 0.6.11 milestone Apr 3, 2025
@lukaszcz lukaszcz self-assigned this Apr 3, 2025
@lukaszcz lukaszcz force-pushed the precompute-nock-hashes branch from 94558f8 to 514d2ff Compare April 4, 2025 13:23
@lukaszcz lukaszcz force-pushed the precompute-nock-hashes branch from 514d2ff to 7b69fd7 Compare April 4, 2025 14:45
@lukaszcz lukaszcz marked this pull request as ready for review April 4, 2025 14:47
@lukaszcz lukaszcz requested a review from janmasrovira April 4, 2025 14:47
Comment on lines 97 to 98
_cellInfo :: CellInfo a,
_cellHash :: Int
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not put _cellHash inside _cellInfo?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, we could do that. I'll change it

@lukaszcz lukaszcz requested a review from janmasrovira April 4, 2025 16:31
@janmasrovira janmasrovira merged commit e3d182d into main Apr 8, 2025
4 checks passed
@janmasrovira janmasrovira deleted the precompute-nock-hashes branch April 8, 2025 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Precompute hashes of Nock terms and store them in Cells & Atoms
2 participants