Make lookup_variable return ValueRef#6918
Make lookup_variable return ValueRef#6918jacinta-stacks merged 20 commits intostacks-network:developfrom
Conversation
Signed-off-by: Jacinta Ferrant <236437600+jacinta-stacks@users.noreply.github.com>
7b30664 to
97c6f16
Compare
… into feat/variable-lookup-by-ref
… into feat/variable-lookup-by-ref
Signed-off-by: Jacinta Ferrant <236437600+jacinta-stacks@users.noreply.github.com>
Signed-off-by: Jacinta Ferrant <236437600+jacinta-stacks@users.noreply.github.com>
… into feat/variable-lookup-by-ref
…gument Signed-off-by: Jacinta Ferrant <236437600+jacinta-stacks@users.noreply.github.com>
aaronb-stacks
left a comment
There was a problem hiding this comment.
This looks like a great overall approach to me. I have a handful of mostly light comments on the code, but one higher-level comment on the treatment of errors.
For things like RuntimeCheckErrorKind::TypeValueError, I'm kind of wary of charging for the clone of the value. The actual contents of this error are not consensus critical, which means it would be nice to have the freedom to kind of "drop" these inner values. Now its true that these errors want ownership today, so it's fair to charge for the clone, but my current thinking is something along the lines of the following:
- We make the contents of these errors strings.
- We have a default max length of the string serialization
- We do something like
format!("{:value.MAX_LEN}")to write the contents.
That way, for the error cases, we don't have to worry about potentially cloning very large values.
Signed-off-by: Jacinta Ferrant <236437600+jacinta-stacks@users.noreply.github.com>
Signed-off-by: Jacinta Ferrant <236437600+jacinta-stacks@users.noreply.github.com>
…cost from error cases Signed-off-by: Jacinta Ferrant <236437600+jacinta-stacks@users.noreply.github.com>
Done in 64a036c. Wasn't sure what a reasonable value would be for |
Signed-off-by: Jacinta Ferrant <236437600+jacinta-stacks@users.noreply.github.com>
… rust Signed-off-by: Jacinta Ferrant <236437600+jacinta-stacks@users.noreply.github.com>
brice-stacks
left a comment
There was a problem hiding this comment.
I'm still working through this review, but posting a couple comments for today. It looks great so far btw!
… into feat/variable-lookup-by-ref
Signed-off-by: Jacinta Ferrant <236437600+jacinta-stacks@users.noreply.github.com>
|
@brice-stacks I did some benching. (64d35cb):
The >= / <= / > / < comparison operators call eval directly and pattern-match on value.as_ref() — they never call clone_with_cost at all. So for a fold where each step compares a constant, Epoch33 allocates two 128-byte copies per iteration and Epoch34 allocates zero. At 200 steps that's ~50KB of heap traffic eliminated per eval_all call. feel free to rerun with |
Signed-off-by: Jacinta Ferrant <236437600+jacinta-stacks@users.noreply.github.com>
… into feat/variable-lookup-by-ref
Signed-off-by: Jacinta Ferrant <236437600+jacinta-stacks@users.noreply.github.com>
… into feat/variable-lookup-by-ref
… into feat/variable-lookup-by-ref
Signed-off-by: Jacinta Ferrant <236437600+jacinta-stacks@users.noreply.github.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #6918 +/- ##
============================================
+ Coverage 60.61% 85.01% +24.40%
============================================
Files 412 412
Lines 219362 219782 +420
Branches 338 338
============================================
+ Hits 132974 186857 +53883
+ Misses 86388 32925 -53463
... and 267 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Closes https://github.com/stx-labs/core-epics/issues/151
Lookup_variable now returns a ref where possible. In theory we might be able to expand eval and apply to also return a value_ref...not positive. But for now this is just taking advantage in the lookup_variable instance.
The change seems bigger than it actually is. I had to seperate the Environment into the invocation context and execution context since the invocation context is immutable and what we are returning a ref to. otherwise have lifetime issues. using RC is not as clean/a bit hackier/made the cost tracking a bit trickier. So this is the result. Rip it to shreds and I will try my best to improve.