1
1
mirror of https://github.com/anoma/juvix.git synced 2024-08-16 19:50:26 +03:00
Commit Graph

1427 Commits

Author SHA1 Message Date
Jan Mas Rovira
270a287f88 get a bigger lens 2024-07-04 01:17:23 +02:00
Jan Mas Rovira
20318f6742 immediateSubExpressions 2024-07-04 01:17:23 +02:00
Jan Mas Rovira
9bfc1cfb5e remove qualified GHC.Type 2024-07-04 01:17:07 +02:00
Jan Mas Rovira
d08bf942b6
Add front-end support for case expressions boolean side conditions (#2852)
- Syntax for #2804.
- ⚠️ Depends on #2869.

This pr introduces:
1. front-end support (parsing, printing, typechecking) for boolean side
conditions for branches of case expressions.
2. Now `if` is a reserved keyword.
3. Multiway `if` is allowed to have only the `else` branch. I've also
refactored the parser to be simpler.

Example:
```
 multiCaseBr : Nat :=
    case 1 of
      | zero
        | if 0 < 0 := 3
        | else := 4
      | suc (suc n)
        | if 0 < 0 := 3
        | else := n
      | suc n if 0 < 0 := 3;
```
The side if branches must satisfy the following.
1. There must be at least one `if` branch.
4. The `else` branch is optional. If present, it must be the last.

Future work:
1. Translate side if conditions to Core and extend the exhaustiveness
algorithm.
5. Add side if conditions to function clauses.
2024-07-04 01:16:30 +02:00
Łukasz Czajka
7c8016dbca
Pragmas for record fields (#2875)
* Closes #2872
2024-07-03 19:15:35 +02:00
Paul Cadman
379e76b708
Release 0.6.3 (#2870)
This PR updates:

- [x] Package version
- [x] Smoke test
- [x] Changelog
2024-07-02 12:37:45 +01:00
Paul Cadman
e3c35077b0
Update juvix-stdlib to main ref (#2871)
This PR updates the juvix-stdlib submodule ref to point to the current
main ref of the juvix-stdlib repository.

Previously it was pointing to the ref of a branch.
2024-07-02 11:23:41 +01:00
Jan Mas Rovira
82e6b5f5d2
Merge if -> ite renaming from stdlib (#2869) 2024-07-02 10:03:06 +02:00
Paul Cadman
93b76ce7f0
Adapt Anoma builtins to new Anoma Node API (#2861) 2024-07-01 18:44:02 +01:00
Jan Mas Rovira
6fcc9f21d2
Improve performance of formatting a project (#2863)
Currently formatting a project is equivalent to running `juvix format`
on each individual file. Hence, the performance is quadratic wrt the
number of modules in the project. This pr fixes that and we now we only
process each module once.

# Benchmark (1236% faster 🚀)
Checking the standard library
```
hyperfine --warmup 1 'juvix format --check' 'juvix-main format --check'
Benchmark 1: juvix format --check
  Time (mean ± σ):     450.6 ms ±  33.7 ms    [User: 707.2 ms, System: 178.7 ms]
  Range (min … max):   396.0 ms … 497.0 ms    10 runs

Benchmark 2: juvix-main format --check
  Time (mean ± σ):      6.019 s ±  0.267 s    [User: 9.333 s, System: 1.512 s]
  Range (min … max):    5.598 s …  6.524 s    10 runs

Summary
  juvix format --check ran
   13.36 ± 1.16 times faster than juvix-main format --check
```

# Other changes:
1. The `EntryPoint` field `entryPointModulePath` is now optional.
2. I've introduced a new type `TopModulePathKey` which is analogous to
`TopModulePath` but wihout location information. It is used in hashmap
keys where the location in the key is never used. This is useful as we
can now get a `TopModulePathKey` from a `Path Rel File`.
3. I've refactored the `_formatInput` field in `FormatOptions` so that
it doesn't need to be a special case anymore.
4. I've introduced a new effect `Forcing` that allows to individually
force fields of a record type with a convenient syntax.
5. I've refactored some of the constraints in scoping so that they only
require `Reader Package` instead of `Reader EntryPoint`.
6. I've introduced a new type family so that local modules are no longer
required to have `ModuleId` from their type. Before, they were assigned
one, but it was never used.


# Future work:
1. For project-wise formatting, the compilation is done in parallel, but
the formatting is still done sequentially. That should be improved.
2024-07-01 18:05:24 +02:00
Łukasz Czajka
fef37a86ee
Optimize letFunctionDefs in Juvix.Compiler.Internal.Data.InfoTable (#2867)
* Closes #2394 
* Removes the use of Uniplate in `letFunctionDefs` altogether, in favour
of handwritten traversal accumulating let definitions (implemented via
the new `HasLetDefs` typeclass).

Benchmark results
------------------

Using Uniplate:
```
heliax@imac bench % hyperfine --prepare 'juvix clean --global' -w 1 'juvix typecheck bench.juvix -N 1'
Benchmark 1: juvix typecheck bench.juvix -N 1
  Time (mean ± σ):      1.399 s ±  0.023 s    [User: 1.346 s, System: 0.041 s]
  Range (min … max):    1.374 s …  1.452 s    10 runs
```

Using `HasLetDefs`:
```
heliax@imac bench % hyperfine --prepare 'juvix clean --global' -w 1 'juvix typecheck bench.juvix -N 1'
Benchmark 1: juvix typecheck bench.juvix -N 1
  Time (mean ± σ):      1.098 s ±  0.015 s    [User: 1.047 s, System: 0.040 s]
  Range (min … max):    1.074 s …  1.120 s    10 runs
```

So it's roughly 1.1s vs. 1.4s, faster by 0.2s. About 14% improvement.

The benchmark file just imports the standard library:
```
module bench;

import Stdlib.Prelude open;

main : Nat := 0;
```

Both `juvix` binaries were compiled with optimizations, using `just
install`.
2024-06-28 18:23:27 +02:00
Łukasz Czajka
69a12d0c2f
Refactor pipeline functions for tests (#2864)
* Closes #2859
2024-06-28 12:15:51 +02:00
Łukasz Czajka
802d82f22e
Peephole optimization of Cairo assembly (#2858)
* Closes #2703 
* Adds [peephole
optimization](https://en.wikipedia.org/wiki/Peephole_optimization) of
Cairo assembly.
* Adds a transformation framework for the CASM IR.
* Adds `--transforms`, `--run` and `--no-print` options to the `dev casm
read` command.
2024-06-27 12:41:27 +02:00
Łukasz Czajka
4dcbb002fe
Add an if instruction to JuvixReg (#2855)
* Closes #2829
* Adds a transformation which converts `br` to `if` when the variable
branched on was assigned in the previous instruction. The transformation
itself doesn't check liveness and doesn't remove the assignment. Dead
code elimination should be run afterwards to remove the assignment.
* For Cairo, it only makes sense to convert `br` to `if` for equality
comparisons against zero. The assignment before `br` will always become
dead after converting `br` to `if`, because we convert to SSA before.
2024-06-26 19:08:33 +02:00
Paul Cadman
7cfddcf915
Make Maybe a builtin inductive type (#2860)
This is required as the return type of the builtin
`anomaVerifyWithMessage` axiom.

Part of:
* https://github.com/anoma/juvix/issues/2850
2024-06-26 17:12:29 +01:00
Paul Cadman
5538aee7fe
Support Anoma representation of Maybe (#2856) 2024-06-26 12:39:36 +01:00
Paul Cadman
b8cd84170b
Update juvix-stdlib to remove non-ASCII indentifiers (#2857)
This PR updates the juvix-stdlib to the current main commit which
includes:

* https://github.com/anoma/juvix-stdlib/issues/59
* https://github.com/anoma/juvix-stdlib/issues/101

All the Juvix test suite files and examples in this repo have been
updated to be compatible with the new stdlib.
2024-06-26 10:23:35 +02:00
Paul Cadman
6d24d7186d
Add support for anoma specific functions to the Core evaluator (#2851)
This PR adds support for the `anoma{encode, decode, sign, verify,
signDetached, verifyDetached}` functions to the Core evaluator.

## Encoding / Decoding

The serialization of values to `ByteString` for `anomaEncode` reuses the
Stored Core serialization. The Stored Core `Node` is extended to include
closures.

Anoma expects encoding of bytes as little-endian integers. In general
`ByteString -> Integer` is ambiguous because two `ByteString`s that
differ only by zero padding will map to the same integer. So we must
encode the length of the ByteString in the encoded integer alongside the
ByteString data so when it is decoded we can pad appropriately. We use
the same length encoding scheme that is used by Nockma jam.

## Verify

The Core evaluator implementation of `anomaVerify` crashes if the
verification fails. This matches the behaviour of Anoma node.

### `jvc` Support

You can now use `anoma-*` functions within `.jvc` core files.

* Closes https://github.com/anoma/juvix/issues/2808
2024-06-25 20:02:44 +02:00
Jan Mas Rovira
694d46fb4f
Add error message for ill-scoped variables (#2566)
- This PR adds a temporary compiler error for when the bug #2247
happens. We do not have plans to fix this bug until we move the
typechecker to Core, so it makes sense to add a better error message.
2024-06-25 16:56:36 +02:00
Łukasz Czajka
c963df7f5f
Cairo: untagged record representation (#2853)
* Closes #2722 
* Omits the header (tag) field from in-memory record representation in
Cairo
* Requires updating
[juvix-cairo-vm](https://github.com/anoma/juvix-cairo-vm): depends on
https://github.com/anoma/juvix-cairo-vm/pull/8
2024-06-25 10:29:39 +02:00
Łukasz Czajka
7bb663c308
Dead code elimination in JuvixReg (#2835)
* Closes #2827 
* Adds an optimization phase to the JuvixReg -> Casm pipeline, which
consists of repeated copy & constant propagation and dead code
elimination.
2024-06-24 13:56:50 +02:00
Jan Mas Rovira
e43797f0a0
Generalize import syntax (#2819)
- Closes #2429 

This pr introduces two enchancements to import statements:
1. They can have `using/hiding` list of symbols, with a behaviour
analogous to the open statement.
2. They can be public. When an import is marked as public, a local
module (or a series of nested local modules) is generated like this:
   ```
    import A public;
    -- equivalent to
    import A;
    module A;
      open A public;
    end;
   ```
    It is easier to understand when there is an alias.
    ```
    import A as X.Y public;
    -- equivalent to
    import A;
    module X;
      module Y;
        open A public;
      end;
    end;
   ```
Public imports are allowed to be combined with `using/hiding` modifier
and open statements with the expected behaviour.
2024-06-21 15:02:30 +02:00
Łukasz Czajka
1410b6354a
Constant propagation in JuvixReg (#2833)
* Closes #2702 
* For this to give any improvement, we need to run dead code elimination
afterwards (#2827).

Depends on:
* #2828
2024-06-21 12:35:12 +02:00
Łukasz Czajka
af758cc8ad
Inline immediate values (#2842)
* Closes #2745 
* Adds inlining of immediate values, i.e., values that don't require
computation or memory allocation.
* Non-immediate zero-argument functions / values should not be inlined,
because when not inlined they can be computed only once.
2024-06-20 21:23:08 +02:00
Paul Cadman
a5cd3c9aa9
Add lcomposition fixity to support (>>) in the stdlib (#2847)
The stdlib composition function `∘` has fixity `composition` which means
it is right associative.

We will rename `∘` to `<<` in the stdlib and add a new function:

```
>> {a b c} : (a -> b) -> (b -> c) -> a -> c
```

for consistency with `<<` this should be left associative.

This is not a breaking change to package-base so we don't need to
increment the version number.
2024-06-20 12:34:24 +01:00
Łukasz Czajka
285b23742f
Remove copy propagation from the native/WASM and Rust pipelines (#2846)
* Closes #2845 
* Copy propagation is not correct without subsequent adjusting of live
variables. See the comments in #2845.
* Enables JuvixReg transformations in the test suite, which exposes the
bug.
* Adds a test in JuvixAsm crafted specifically to expose this bug.
2024-06-20 12:44:15 +02:00
Jan Mas Rovira
9e6e8d8a35
just format uses ghc flags in juvix.cabal (#2844) 2024-06-20 11:30:04 +02:00
Łukasz Czajka
33d565037d
Fix names in Core (#2843)
* Closes #2733
2024-06-19 18:05:57 +02:00
Łukasz Czajka
235d88f303
Copy propagation in JuvixReg (#2828)
* Closes #1614 
* Implements the copy propagation transformation in JuvixReg and adds
tests for it.
* For this optimization to give any improvement, we need to run dead
code elimination afterwards (#2827).
2024-06-18 21:38:02 +02:00
Jan Mas Rovira
7a7c8cedef
Give proper colors to builtins (#2834)
- Closes #2800 

I've added a field `_nameKindPretty :: NameKind` that is used to store
the nameKind which should be used when highlighting and printing.
There is no need for pragmas as we can set a color for each builtin
axiom statically in the haskell code.

I've also removed the fields `_infoHighlightDoc :: DocTable` and
`_infoHighlightNames :: [S.AName]` from the
`Store/Scoped/Data/InfoTable` as they were never being read.
2024-06-18 18:12:15 +02:00
Łukasz Czajka
e2a6344f29
Fix Rust toolchain caching (#2825)
Fixes the error in the Rust toolchain caching by setting
`cache-on-failure` to false for the `setup-rust-toolchain` action.
2024-06-13 13:23:35 +02:00
Łukasz Czajka
84101536bf
Cairo: Support complex data types in program input (#2822)
* Types of arguments to `main` can now be field elements, numbers,
booleans and (nested) records and lists.
* Type of `main` result can now be a record of field elements, numbers
and booleans. Lists or nested records are not allowed for the result.
* Adds checks for the type of `main` in the Cairo pipeline.
* Requires updating
[juvix-cairo-vm](https://github.com/anoma/juvix-cairo-vm). The input can
be provided in a Json file via the `--program_input` option of
`juvix-cairo-vm`.
2024-06-13 12:37:01 +02:00
Paul Cadman
4095cf3c36
Update CHANGELOG for 0.6.2 (#2824)
I didn't release 0.6.2 last week, but we can do it now. I've updated the
CHANGELOG with the work we did last week.

Other release changes for 0.6.2 were done in
https://github.com/anoma/juvix/pull/2795
2024-06-12 16:26:02 +01:00
Jan Mas Rovira
6622d88c3b
Upgrade to ghc-9.8.2 (#2794)
haskell lsp 2.8.0.0 (available in ghc-up) is compatible with ghc-9.8.2.
I had to do some renaming in order to avoid shadowing.
2024-06-08 14:43:33 +02:00
Jan Mas Rovira
2c683a1179
Report proper location for normalized types in the WrongType error (#2814)
There is currently no automated way to test this. One can manually check
that when trying to typecheck `tests/negative/issue2771/Main.juvix/` the
error location is wrong:

![image](https://github.com/anoma/juvix/assets/5511599/1be986d8-a045-424e-bfdb-2ea4a695b31a)

That is now fixed:

![image](https://github.com/anoma/juvix/assets/5511599/2ee62034-6485-4c03-934b-a20f90878db3)
2024-06-08 12:09:00 +02:00
Łukasz Czajka
346a48d55b
Disable macOS CI (#2821)
It's failing because of rate limits exceeded when installing RISC0 VM.
We should disable the macOS CI until we figure out how to reliably get
around this problem.
2024-06-08 10:52:29 +02:00
Jan Mas Rovira
c825f23c58
Add pedantic option to justfile (#2816) 2024-06-08 09:44:43 +02:00
Jan Mas Rovira
bae025be7c
Add LeafExpression to make leafExpressions type more explicit (#2817) 2024-06-08 08:56:04 +02:00
Jan Mas Rovira
7acad0a13b
Add GHC Identity to Juvix/Prelude (#2815) 2024-06-07 18:40:42 +02:00
Jan Mas Rovira
cb03014dc4
Fixes crash when trying to normalize case expression (#2811)
- Closes #2771
2024-06-07 15:43:50 +02:00
Jan Mas Rovira
a2c1a4aea3
Improve parallel template (#2809)
- Closes #2806 

Now we properly wait for the log and worker threads to finish instead of
keeping them alive until the main thread dies.

Also, because we are now using
[`replicateConcurrently_`](https://hackage.haskell.org/package/effectful-2.3.0.0/docs/Effectful-Concurrent-Async.html#v:replicateConcurrently)
from `async`, any exception in a worker thread should be properly
propagated.
2024-06-07 11:24:40 +02:00
Łukasz Czajka
a4f551547b
RISC0 Rust backend (#2792)
* Adds a RISC0 backend which generates Rust code that can be compiled
with the official RISC0 toolchain.
* The RISC0 backend is a wrapper around the Rust backend.
* Adds the `risc0-rust` to the `compile` CLI command, which creates a
directory containing host and guest Rust sources for the RISC0 zkVM. The
generated code can be compiled/run using `cargo` from inside the created
directory (requires having RISC0 installed:
https://dev.risczero.com/api/zkvm/install).
2024-06-07 07:57:27 +02:00
Łukasz Czajka
ce938efdcf
Juvix to Isabelle/HOL translation (#2752)
* Closes #2689 
* Adds the command `juvix isabelle program.juvix` which translates a
given file to an Isabelle/HOL theory.
* Currently, only a single module is translated.
* By default translates types and function signatures. Translating
function signatures can be disabled with the `--only-types` option.

Blocked by:
- https://github.com/anoma/juvix/issues/2763

---------

Co-authored-by: Jonathan Cubides <jonathan.cubides@uib.no>
2024-06-05 12:23:24 +02:00
Jan Mas Rovira
44cdd8404b
Fix generation of wildcards in RecordPattern (#2802)
- Closes #2801
2024-06-04 18:28:25 +02:00
Paul Cadman
371f8f2258
Support Anoma stdlib sign-detached API (#2798)
This PR adds support for the Anoma stdlib `sign-detached` API.

```
builtin anoma-sign-detached
axiom anomaSignDetached : {A : Type}
  -- message to sign
  -> A
  -- private key
  -> Nat
 -- signature
  -> Nat;
```

This corresponds to the
[sign_detached](https://hexdocs.pm/enacl/enacl.html#sign_detached-2)
libsodium API.

This is requried to support to new Anoma nullifier format:


d6a61451ae

Previously resource nullifiers were defined using `anomaSign`:

```
nullifier (r : Resource) (secretKey : Nat) : Nat :=
  anomaSign (anomaEncode (nullifierHeader, r)) secretKey;
```

They are now defined using `anomaSignDetached`:

```
nullifier (r : Resource) (secretKey : Nat) : Nat :=
  let encodedResource : Nat := anomaEncode (nullifierHeader, r) in
  anomaEncode (encodedResource , anomaSignDetached encodedResource secretKey);
```

This is so that a logic function can access the nullified resources
directly from the `nullifier` field.

## Evaluator Note

When decoding a public key, private key or signature from an integer
atom to a bytestring it's important to pad the bytestring to the
appropriate number of bytes. For example a private key must be 64 bytes
but the corresponding encoded integer may fit into 63 bytes or fewer
bytes (depending on leading zeros). This PR also fixes this issue by
adding a
[`atomToByteStringLen`](c68c7187b1/src/Juvix/Compiler/Nockma/Encoding/ByteString.hs (L14))
function with also accepts the expected size of the resulting
bytestring.
2024-06-03 19:07:56 +02:00
Paul Cadman
823b37c216
Release 0.6.2 (#2795)
This PR updates:

- [x] Package version
- [x] Smoke test
- [x] Changelog
2024-06-01 11:33:36 +02:00
Paul Cadman
88b4cb88f0
Use little endian encoding of ByteStrings in Anoma (#2793)
Anoma decodes integer atoms as bytes assuming a little endian layout.


ea25f88cea/lib/noun.ex (L182)

This commit adds functions `byteStringToIntegerLE` and
`integerToByteStringLE` that makes it clear that little endian encoding
is being used.
2024-05-31 18:20:48 +02:00
Jan Mas Rovira
e9afdad82a
Parallel pipeline (#2779)
This pr introduces parallelism in the pipeline to gain performance. I've
included benchmarks at the end.

- Closes #2750.

# Flags:
There are two new global flags:
1. `-N / --threads`. It is used to set the number of capabilities.
According to [GHC
documentation](https://hackage.haskell.org/package/base-4.20.0.0/docs/GHC-Conc.html#v:setNumCapabilities):
_Set the number of Haskell threads that can run truly simultaneously (on
separate physical processors) at any given time_. When compiling in
parallel, we create this many worker threads. The default value is `-N
auto`, which sets `-N` to half the number of logical cores, capped at 8.
2. `--dev-show-thread-ids`. When given, the thread id is printed in the
compilation progress log. E.g.

![image](https://github.com/anoma/juvix/assets/5511599/9359fae2-0be1-43e5-8d74-faa82cba4034)

# Parallel compilation
1. I've added `src/Parallel/ParallelTemplate.hs` which contains all the
concurrency related code. I think it is good to keep this code separated
from the actual compiler code.
2. I've added a progress log (only for the parallel driver) that outputs
a log of the compilation progress, similar to what stack/cabal do.

# Code changes:
1. I've removed the `setup` stage where we were registering
dependencies. Instead, the dependencies are registered when the
`pathResolver` is run for the first time. This way it is safer.
1. Now the `ImportTree` is needed to run the pipeline. Cycles are
detected during the construction of this tree, so I've removed `Reader
ImportParents` from the pipeline.
3. For the package pathresolver, we do not support parallelism yet (we
could add support for it in the future, but the gains will be small).
4. When `-N1`, the pipeline remains unchanged, so performance should be
the same as in the main branch (except there is a small performance
degradation due to adding the `-threaded` flag).
5. I've introduced `PipelineOptions`, which are options that are used to
pass options to the effects in the pipeline.
6. `PathResolver` constraint has been removed from the `upTo*` functions
in the pipeline due to being redundant.
7. I've added a lot of `NFData` instances. They are needed to force the
full evaluation of `Stored.ModuleInfo` in each of the threads.
2. The `Cache` effect uses
[`SharedState`](https://hackage.haskell.org/package/effectful-core-2.3.0.1/docs/Effectful-State-Static-Shared.html)
as opposed to
[`LocalState`](https://hackage.haskell.org/package/effectful-core-2.3.0.1/docs/Effectful-Writer-Static-Local.html).
Perhaps we should provide different versions.
3. I've added a `Cache` handler that accepts a setup function. The setup
is triggered when a miss is detected. It is used to lazily compile the
modules in parallel.

# Tests
1. I've adapted the smoke test suite to ignore the progress log in the
stderr.
5. I've had to adapt `tests/positive/Internal/Lambda.juvix`. Due to
laziness, a crash happening in this file was not being caught. The
problem is that in this file we have a lambda function with different
number of patterns in their clauses, which we currently do not support
(https://github.com/anoma/juvix/issues/1706).
6. I've had to comment out the definition
   ```
   x : Box ((A : Type) → A → A) := box λ {A a := a};
   ```
From the test as it was causing a crash
(https://github.com/anoma/juvix/issues/2247).
# Future Work
1. It should be investigated how much performance we lose by fully
evaluating the `Stored.ModuleInfo`, since some information in it will be
discarded. It may be possible to be more fine-grained when forcing
evaluation.
8. The scanning of imports to build the import tree is sequential. Now,
we build the import tree from the entry point module and only the
modules that are imported from it are in the tree. However, we have
discussed that at some point we should make a distinction between
`juvix` _the compiler_ and `juvix` _the build tool_. When using `juvix`
as a build tool it makes sense to typecheck/compile (to stored core) all
modules in the project. When/if we do this, scanning imports in all
modules in parallel becomes trivial.
9. The implementation of the `ParallelTemplate` uses low level
primitives such as
[forkIO](https://hackage.haskell.org/package/base-4.20.0.0/docs/Control-Concurrent.html#v:forkIO).
At some point it should be refactored to use safer functions from the
[`Effectful.Concurrent.Async`](https://hackage.haskell.org/package/effectful-2.3.0.0/docs/Effectful-Concurrent-Async.html)
module.
10. The number of cores and worker threads that we spawn is determined
by the command line. Ideally, we could use to import tree to compute an
upper bound to the ideal number of cores to use.
11. We could add an animation that displays which modules are being
compiled in parallel and which have finished being compiled.

# Benchmarks

On some benchmarks, I include the GHC runtime option
[`-A`](https://downloads.haskell.org/ghc/latest/docs/users_guide/runtime_control.html#rts-flag--A%20%E2%9F%A8size%E2%9F%A9),
which sometimes makes a good impact on performance. Thanks to
@paulcadman for pointing this out. I've figured a good combination of
`-N` and `-A` through trial and error (but this oviously depends on the
cpu and juvix projects).

## Typecheck the standard library
   
### Clean run (88% faster than main):
```
 hyperfine --warmup 1 --prepare 'juvix clean' 'juvix -N 4 typecheck Stdlib/Prelude.juvix +RTS -A33554432'  'juvix -N 4 typecheck Stdlib/Prelude.juvix' 'juvix-main typecheck Stdlib/Prelude.juvix'
Benchmark 1: juvix -N 4 typecheck Stdlib/Prelude.juvix +RTS -A33554432
  Time (mean ± σ):     444.1 ms ±   6.5 ms    [User: 1018.0 ms, System: 77.7 ms]
  Range (min … max):   432.6 ms … 455.9 ms    10 runs

Benchmark 2: juvix -N 4 typecheck Stdlib/Prelude.juvix
  Time (mean ± σ):     628.3 ms ±  23.9 ms    [User: 1227.6 ms, System: 69.5 ms]
  Range (min … max):   584.7 ms … 670.6 ms    10 runs

Benchmark 3: juvix-main typecheck Stdlib/Prelude.juvix
  Time (mean ± σ):     835.9 ms ±  12.3 ms    [User: 788.5 ms, System: 31.9 ms]
  Range (min … max):   816.0 ms … 853.6 ms    10 runs

Summary
  juvix -N 4 typecheck Stdlib/Prelude.juvix +RTS -A33554432 ran
    1.41 ± 0.06 times faster than juvix -N 4 typecheck Stdlib/Prelude.juvix
    1.88 ± 0.04 times faster than juvix-main typecheck Stdlib/Prelude.juvix
```
   
### Cached run (43% faster than main):
```
hyperfine --warmup 1 'juvix -N 4 typecheck Stdlib/Prelude.juvix +RTS -A33554432'  'juvix -N 4 typecheck Stdlib/Prelude.juvix' 'juvix-main typecheck Stdlib/Prelude.juvix'
Benchmark 1: juvix -N 4 typecheck Stdlib/Prelude.juvix +RTS -A33554432
  Time (mean ± σ):     241.3 ms ±   7.3 ms    [User: 538.6 ms, System: 101.3 ms]
  Range (min … max):   231.5 ms … 251.3 ms    11 runs

Benchmark 2: juvix -N 4 typecheck Stdlib/Prelude.juvix
  Time (mean ± σ):     235.1 ms ±  12.0 ms    [User: 405.3 ms, System: 87.7 ms]
  Range (min … max):   216.1 ms … 253.1 ms    12 runs

Benchmark 3: juvix-main typecheck Stdlib/Prelude.juvix
  Time (mean ± σ):     336.7 ms ±  13.3 ms    [User: 269.5 ms, System: 67.1 ms]
  Range (min … max):   316.9 ms … 351.8 ms    10 runs

Summary
  juvix -N 4 typecheck Stdlib/Prelude.juvix ran
    1.03 ± 0.06 times faster than juvix -N 4 typecheck Stdlib/Prelude.juvix +RTS -A33554432
    1.43 ± 0.09 times faster than juvix-main typecheck Stdlib/Prelude.juvix
```
## Typecheck the test suite of the containers library
At the moment this is the biggest juvix project that we have.

### Clean run (105% faster than main)
```
hyperfine --warmup 1 --prepare 'juvix clean' 'juvix -N 6 typecheck Main.juvix +RTS -A67108864' 'juvix -N 4 typecheck Main.juvix' 'juvix-main typecheck Main.juvix'
Benchmark 1: juvix -N 6 typecheck Main.juvix +RTS -A67108864
  Time (mean ± σ):      1.006 s ±  0.011 s    [User: 2.171 s, System: 0.162 s]
  Range (min … max):    0.991 s …  1.023 s    10 runs

Benchmark 2: juvix -N 4 typecheck Main.juvix
  Time (mean ± σ):      1.584 s ±  0.046 s    [User: 2.934 s, System: 0.149 s]
  Range (min … max):    1.535 s …  1.660 s    10 runs

Benchmark 3: juvix-main typecheck Main.juvix
  Time (mean ± σ):      2.066 s ±  0.010 s    [User: 1.939 s, System: 0.089 s]
  Range (min … max):    2.048 s …  2.077 s    10 runs

Summary
  juvix -N 6 typecheck Main.juvix +RTS -A67108864 ran
    1.57 ± 0.05 times faster than juvix -N 4 typecheck Main.juvix
    2.05 ± 0.03 times faster than juvix-main typecheck Main.juvix
```

### Cached run (54% faster than main)
```
hyperfine --warmup 1 'juvix -N 6 typecheck Main.juvix +RTS -A33554432'  'juvix -N 4 typecheck Main.juvix' 'juvix-main typecheck Main.juvix'
Benchmark 1: juvix -N 6 typecheck Main.juvix +RTS -A33554432
  Time (mean ± σ):     551.8 ms ±  13.2 ms    [User: 1419.8 ms, System: 199.4 ms]
  Range (min … max):   535.2 ms … 570.6 ms    10 runs

Benchmark 2: juvix -N 4 typecheck Main.juvix
  Time (mean ± σ):     636.7 ms ±  17.3 ms    [User: 1006.3 ms, System: 196.3 ms]
  Range (min … max):   601.6 ms … 655.3 ms    10 runs

Benchmark 3: juvix-main typecheck Main.juvix
  Time (mean ± σ):     847.2 ms ±  58.9 ms    [User: 710.1 ms, System: 126.5 ms]
  Range (min … max):   731.1 ms … 890.0 ms    10 runs

Summary
  juvix -N 6 typecheck Main.juvix +RTS -A33554432 ran
    1.15 ± 0.04 times faster than juvix -N 4 typecheck Main.juvix
    1.54 ± 0.11 times faster than juvix-main typecheck Main.juvix
```
2024-05-31 12:41:30 +01:00
Łukasz Czajka
cfaa176af9
Update stdlib to the main branch (#2791)
* Update Juvix Standard Library to its main branch
* This include the Pedersen hash commit
2024-05-29 14:44:07 +02:00
Łukasz Czajka
55598e0f95
Rust backend (#2787)
* Implements code generation through Rust.
* CLI: adds two `dev` compilation targets: 
  1. `rust` for generating Rust code
  2. `native-rust` for generating a native executable via Rust
* Adds end-to-end tests for compilation from Juvix to native executable
via Rust.
* A target for RISC0 needs to be added in a separate PR building on this
one.
2024-05-29 13:34:04 +02:00