tvl-depot/tvix/eval/src
Vincent Ambo d00229753d feat(tvix/eval): implement asynchronous list sorting algorithm
In order to implement an asynchronous builtins.sort (required for
moving builtins to generators), we need an `async` sorting algorithm
as our comparators involve invoking a Nix function.

This commit implements a fairly simple, optimised bubble sort as the
sorting algorithm used in our `async fn sort_by`.

There don't seem to be any crates providing async versions of things
like this, and they might actually be pretty hard to implement
generically due to some constraints about how `async` works.

Note that this algorithm is less efficient than the hybrid
"timsort/mergesort/insert sort" used in the Rust standard library. I
tried to write a merge sort implementation, but ran into isuses with
the sort becoming unstable because our comparators can not yield
equality. This is the simplest implementation which I know to be
correct.

Note that as of this commit this is *not* covered by the Tvix test
suite, but it will be as soon as the rest of the generator code lands.

Change-Id: Ia9a604f7dd941d6acc9212c902e0e637ed75bebc
Reviewed-on: https://cl.tvl.fyi/c/depot/+/8239
Reviewed-by: Adam Joseph <adam@westernsemico.com>
Tested-by: BuildkiteCI
2023-03-13 20:30:59 +00:00
..
builtins refactor(tvix/eval): remove VM argument from suspended native thunks 2023-03-04 15:53:36 +00:00
compiler feat(tvix/eval): don't warn twice about dead code 2023-03-11 14:26:49 +00:00
tests fix(tvix/eval): skip runtime completely on compiler errors 2023-02-13 16:21:47 +00:00
value feat(tvix/eval): implement asynchronous list sorting algorithm 2023-03-13 20:30:59 +00:00
vm feat(tvix/eval): introduce generators module 2023-03-07 22:04:59 +00:00
chunk.rs refactor(tvix/eval): enhance debug output for bytecode dumps 2023-03-03 10:52:48 +00:00
errors.rs fix(tvix/eval): make fields of eval's Error type public 2023-02-13 16:21:46 +00:00
io.rs chore(tvix/eval): only use Rc with impure feature 2023-02-03 18:58:17 +00:00
lib.rs refactor(tvix/eval): insert storeDir "builtin" in eval startup 2023-03-04 15:53:36 +00:00
nix_search_path.rs fix(tvix/eval): fix current clippy warnings 2022-12-25 18:25:06 +00:00
observer.rs fix(tvix/eval): correctly print lambda address in observer 2023-02-14 08:02:40 +00:00
opcode.rs refactor(tvix/eval): merge OpCall & OpTailCall 2023-03-07 22:04:59 +00:00
pretty_ast.rs fix(tvix/eval): fix current clippy warnings 2022-12-25 18:25:06 +00:00
properties.rs refactor(tvix/eval): Don't (ab)use PartialEq for Nix equality 2022-09-18 22:03:41 +00:00
source.rs chore(tvix/eval): implement std::error::Error for tvix_eval::Error 2023-01-02 22:24:43 +00:00
spans.rs refactor(tvix/eval): implement From<Span> for LightSpan 2023-03-04 15:18:37 +00:00
systems.rs fix(tvix/eval): fix current clippy warnings 2022-12-25 18:25:06 +00:00
test_utils.rs test(tvix/eval): Add proof-of-concept test for Chunk 2022-09-18 17:55:06 +00:00
upvalues.rs fix(tvix/eval): remove impl PartialEq for Value 2022-11-04 00:30:13 +00:00
vm.rs feat(tvix/eval): introduce generators module 2023-03-07 22:04:59 +00:00
warnings.rs chore(tvix/eval): delete "useless parenthesis" warning/optimisation 2023-01-23 17:59:06 +00:00