From 72ece2e5184df7cb2099e54ace01154a4043d289 Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Sat, 25 Nov 2023 01:38:00 -0800 Subject: feat(tvix/eval): nonrecursive nix_eq() This commit rewrites Value::nix_eq() into an equivalent. Except for calls to Thunk::force(), the new form no longer uses generators, and is async only because of the fact that it calls Thunk::force(). I believed that the nonrecursive form would be faster. It is, in fact, slightly slower. I believe this is due to the vec![] allocation; I am investigating. Prev-Nixpkgs-Benchmark: {"attrpath":"pkgsCross.aarch64-multiplatform.hello.outPath","peak-kbytes":"459068","system-seconds":"0.71","user-seconds":"5.39"} This-Nixpkgs-Benchmark: {"attrpath":"pkgsCross.aarch64-multiplatform.hello.outPath","peak-kbytes":"460048","system-seconds":"0.68","user-seconds":"5.73"} Change-Id: I10f4868891e4b7475df13f0cbc41ec78dd985dd8 Reviewed-on: https://cl.tvl.fyi/c/depot/+/10118 Reviewed-by: tazjin Tested-by: BuildkiteCI Autosubmit: Adam Joseph --- tvix/eval/src/value/thunk.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'tvix/eval/src/value/thunk.rs') diff --git a/tvix/eval/src/value/thunk.rs b/tvix/eval/src/value/thunk.rs index 3ff3bde65934..345903237b76 100644 --- a/tvix/eval/src/value/thunk.rs +++ b/tvix/eval/src/value/thunk.rs @@ -205,7 +205,14 @@ impl Thunk { } } - pub async fn force(mut myself: Thunk, co: GenCo, span: LightSpan) -> Result { + pub async fn force(myself: Thunk, co: GenCo, span: LightSpan) -> Result { + Self::force_(myself, &co, span).await + } + pub async fn force_( + mut myself: Thunk, + co: &GenCo, + span: LightSpan, + ) -> Result { // This vector of "thunks which point to the thunk-being-forced", to // be updated along with it, is necessary in order to write this // function in iterative (and later, mutual-tail-call) form. @@ -261,7 +268,7 @@ impl Thunk { // be turned into a tailcall to vm::execute_bytecode() by // passing `also_update` to it. let value = - generators::request_enter_lambda(&co, lambda, upvalues, light_span).await; + generators::request_enter_lambda(co, lambda, upvalues, light_span).await; myself.0.replace(ThunkRepr::Evaluated(value)); continue; } -- cgit 1.4.1