mirror of
https://github.com/anoma/juvix.git
synced 2025-01-05 22:46:08 +03:00
Juvix empowers developers to write code in a high-level, functional language, compile it to gas-efficient output VM instructions, and formally verify the safety of their contracts prior to deployment and execution.
8dfe2baa93
This pr implements two additional versions of the Juvix Tree evaluator. Now we have 1. The raw implementation that does not use effects. It throws Haskell exceptions for errors. It uses `unsafePerformIO` for traces. It relies on bang patterns to force strictness and guarantee the expected order of execution (for traces). Avoiding effects allows for improved execution efficiency. 2. [`polysemy`](https://hackage.haskell.org/package/polysemy-1.9.1.3) based implementation. 3. [`effectful-core`](https://hackage.haskell.org/package/effectful-core) based implementation. One can specify which evaluator to use thus: ``` juvix dev tree eval --evaluator XXX test.jvt ``` where XXX is one of `raw`, `polysemy`, `effectful`. # Preliminary benchmarks More thorough benchmarks should be run, but here are some preliminary results: ## Test032 (Fibonacci 20) I've adapted test032 so that it main is a single call to fibonacci of 20. Command: ``` hyperfine --warmup 2 --runs 10 'juvix dev tree eval test032.jvt --evaluator polysemy' 'juvix dev tree eval test032.jvt --evaluator raw' 'juvix dev tree eval test032.jvt --evaluator e ffectful' ``` Output: ``` Benchmark 1: juvix dev tree eval test032.jvt --evaluator polysemy Time (mean ± σ): 2.133 s ± 0.040 s [User: 2.113 s, System: 0.016 s] Range (min … max): 2.088 s … 2.227 s 10 runs Benchmark 2: juvix dev tree eval test032.jvt --evaluator raw Time (mean ± σ): 308.7 ms ± 13.8 ms [User: 293.6 ms, System: 14.1 ms] Range (min … max): 286.5 ms … 330.1 ms 10 runs Benchmark 3: juvix dev tree eval test032.jvt --evaluator effectful Time (mean ± σ): 366.0 ms ± 2.8 ms [User: 345.4 ms, System: 19.4 ms] Range (min … max): 362.5 ms … 372.6 ms 10 runs Summary juvix dev tree eval test032.jvt --evaluator raw ran 1.19 ± 0.05 times faster than juvix dev tree eval test032.jvt --evaluator effectful 6.91 ± 0.34 times faster than juvix dev tree eval test032.jvt --evaluator polysemy ``` ## Test034 (Higher-order function composition) A modified version of test034 where main defined as `call[exp](3, 12)` Command: ``` hyperfine --warmup 2 --runs 10 'juvix dev tree eval test034.jvt --evaluator polysemy' 'juvix dev tree eval test034.jvt --evaluator raw' 'juvix dev tree eval test034.jvt --evaluator effectful' ``` Output: ``` Benchmark 1: juvix dev tree eval test034.jvt --evaluator polysemy Time (mean ± σ): 7.025 s ± 0.184 s [User: 6.518 s, System: 0.469 s] Range (min … max): 6.866 s … 7.327 s 10 runs Benchmark 2: juvix dev tree eval test034.jvt --evaluator raw Time (mean ± σ): 835.6 ms ± 7.4 ms [User: 757.2 ms, System: 75.9 ms] Range (min … max): 824.7 ms … 847.4 ms 10 runs Benchmark 3: juvix dev tree eval test034.jvt --evaluator effectful Time (mean ± σ): 1.578 s ± 0.010 s [User: 1.427 s, System: 0.143 s] Range (min … max): 1.563 s … 1.595 s 10 runs Summary juvix dev tree eval test034.jvt --evaluator raw ran 1.89 ± 0.02 times faster than juvix dev tree eval test034.jvt --evaluator effectful 8.41 ± 0.23 times faster than juvix dev tree eval test034.jvt --evaluator polysemy ``` ## Test036 (Streams without memoization) A modified version of test036 where main defined as `call[nth](700, call[primes]())` Command: ``` hyperfine --warmup 2 --runs 5 'juvix dev tree eval test036.jvt --evaluator polysemy' 'juvix dev tree eval test036.jvt --evaluator raw' 'juvix dev tree eval test036.jvt --evaluator effectful' ``` Output: ``` Benchmark 1: juvix dev tree eval test036.jvt --evaluator polysemy Time (mean ± σ): 1.993 s ± 0.026 s [User: 1.946 s, System: 0.043 s] Range (min … max): 1.969 s … 2.023 s 5 runs Benchmark 2: juvix dev tree eval test036.jvt --evaluator raw Time (mean ± σ): 137.5 ms ± 7.1 ms [User: 127.5 ms, System: 8.9 ms] Range (min … max): 132.8 ms … 149.8 ms 5 runs Benchmark 3: juvix dev tree eval test036.jvt --evaluator effectful Time (mean ± σ): 329.0 ms ± 7.3 ms [User: 289.3 ms, System: 37.4 ms] Range (min … max): 319.9 ms … 336.0 ms 5 runs Summary juvix dev tree eval test036.jvt --evaluator raw ran 2.39 ± 0.13 times faster than juvix dev tree eval test036.jvt --evaluator effectful 14.50 ± 0.77 times faster than juvix dev tree eval test036.jvt --evaluator polysemy ``` |
||
---|---|---|
.devcontainer | ||
.github | ||
app | ||
assets | ||
bench | ||
examples | ||
gnuplot | ||
include | ||
juvix-stdlib@183d4e9329 | ||
licenses | ||
runtime | ||
scripts | ||
src/Juvix | ||
test | ||
tests | ||
.clang-format | ||
.github_changelog_generator | ||
.gitignore | ||
.gitmodules | ||
.hlint.yaml | ||
.pre-commit-config.yaml | ||
cabal.hie.yaml | ||
cabal.project | ||
cabal.project.freeze | ||
CHANGELOG.md | ||
cntlines.sh | ||
CONTRIBUTING.md | ||
justfile | ||
LICENSE.md | ||
Makefile | ||
package.yaml | ||
README.md | ||
stack.hie.yaml | ||
stack.yaml |
Juvix
CI Status |
---|
Codebase |
This repository is specifically dedicated to the compiler of the Juvix programming language.
For any Juvix-related inquiries, we strongly advise visiting the following resources.
Our documentation offers an in-depth understanding of the Juvix programming language. It encompasses a language reference, examples, blog posts, and numerous other resources to facilitate effective use of Juvix.