snix/tvix/eval/src/value
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
..
attrs refactor(tvix/eval): keep globals alive through VM struct 2023-01-20 22:48:13 +00:00
arbitrary.rs chore(tvix/eval): remove dead comment 2023-01-26 23:30:43 +00:00
attrs.rs chore(tvix/eval): implement From<OrdMap<..>> for NixAttrs 2023-03-04 15:18:37 +00:00
builtin.rs refactor(tvix/eval): wrap Builtin type in a Box 2023-02-03 18:47:33 +00:00
function.rs fix(tvix/eval): fix current clippy warnings 2022-12-25 18:25:06 +00:00
list.rs feat(tvix/eval): implement asynchronous list sorting algorithm 2023-03-13 20:30:59 +00:00
mod.rs feat(tvix/eval): introduce generators module 2023-03-07 22:04:59 +00:00
path.rs refactor(tvix/eval): factor out all calls to canon_path 2022-10-13 09:07:47 +00:00
string.rs feat(tvix/eval): implement builtins.toJSON 2023-01-12 10:42:44 +00:00
thunk.rs refactor(tvix/eval): remove VM argument from suspended native thunks 2023-03-04 15:53:36 +00:00