tvix-eval: thunk suspension forces span calculation
I noticed that when suspending a thunk (at cl/7551, this is not canon
code), we collect the span for the thunk which is a very expensive operation:
let thunk = if matches!(op, OpCode::OpThunkClosure(_)) { debug_assert!( upvalue_count > 0, "OpThunkClosure should not be called for plain lambdas" ); Thunk::new_closure(blueprint) } else { Thunk::new_suspended(blueprint, self.current_span()) };
This needs to be changed, similar to b/228, to avoid doing this expensive calculation over and over again.
I think what should be happening is that the thunk should only return
ErrorKind
with its inner span on failure, and the outer part that is forcing the thunk needs to wrap this. I'm trying to reason my way through why this is going from the outside in, there's probably something I'm missing.tazjin at 2022-12-10T10·53+00
Actually this is at
canon
, it was introduced in cl/6932.We might be able to get around this by instead doing something like persisting the tuple of the chunk pointer and offset, and resolving the span only in an error case.
tazjin at 2022-12-10T11·09+00
This is significantly faster with cl/7558
tazjin at 2022-12-11T12·19+00
The above CL basically fixes this.
tazjin at 2022-12-16T10·43+00
- tazjin closed this issue at 2022-12-16T10·43+00