Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: Remove Boxing of SymbolicExpressions #4530

Merged

Conversation

ASuciuX
Copy link
Contributor

@ASuciuX ASuciuX commented Mar 13, 2024

Description

SymbolicExpressions and PreSymbolicExpressions are unnecessarily Boxed in a few places in the clarity crate when used in Vecs. As Vecs are already on the heap, a Box is not necessary.

Closes #4445

@ASuciuX ASuciuX requested a review from cylewitruk March 13, 2024 12:37
@ASuciuX ASuciuX self-assigned this Mar 13, 2024
Copy link

codecov bot commented Mar 13, 2024

Codecov Report

Attention: Patch coverage is 93.40659% with 6 lines in your changes are missing coverage. Please review.

Project coverage is 83.07%. Comparing base (5150acf) to head (462356c).
Report is 41 commits behind head on next.

Additional details and impacted files
@@            Coverage Diff             @@
##             next    #4530      +/-   ##
==========================================
- Coverage   83.29%   83.07%   -0.22%     
==========================================
  Files         452      452              
  Lines      326071   326068       -3     
  Branches      323      323              
==========================================
- Hits       271589   270876     -713     
- Misses      54474    55184     +710     
  Partials        8        8              
Files Coverage Δ
clarity/src/vm/ast/parser/v1.rs 90.93% <100.00%> (-0.02%) ⬇️
clarity/src/vm/ast/sugar_expander/mod.rs 94.20% <100.00%> (ø)
clarity/src/vm/costs/mod.rs 81.22% <100.00%> (-0.54%) ⬇️
clarity/src/vm/mod.rs 88.86% <100.00%> (-0.26%) ⬇️
clarity/src/vm/representations.rs 82.28% <100.00%> (ø)
clarity/src/vm/ast/parser/v2/mod.rs 56.32% <33.33%> (+0.14%) ⬆️

... and 33 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5150acf...462356c. Read the comment docs.

Copy link
Member

@cylewitruk cylewitruk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm :) This suggestion stemmed from playing with different binary serialization formats, which aren't as forgiving as JSON.

@jcnelson
Copy link
Member

@kantai Is there a reason we were Box-ing these before?

@kantai
Copy link
Member

kantai commented Mar 14, 2024

Classic case of early optimization, I think. These structs never need to be resized, so boxed slices were maybe a closer match to their usage than vecs. No real reason that they need to be boxed slices instead of vecs, though, and I doubt that there's a performance benefit to keeping them as boxed slices (I wouldn't be surprised if it was the opposite).

@jcnelson jcnelson self-requested a review March 18, 2024 15:11
Copy link
Member

@jcnelson jcnelson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's fine with @kantai it's fine with me 👍

@jbencin
Copy link
Contributor

jbencin commented Mar 18, 2024

I doubt that there's a performance benefit to keeping them as boxed slices (I wouldn't be surprised if it was the opposite).

They compile to pretty much the same thing. A Boxed slice is represented on the stack with 2 elements: ptr and len. Vec has an additional element: capacity. So the cost of using a Vec is just an extra usize, which is trivial

@cylewitruk
Copy link
Member

Boxed slices also had issues with several binary encodings I tried for these types, where Vecs were handled otob -- that's essentially the birth place of the issue, preparing for that kind of change.

@ASuciuX ASuciuX added this pull request to the merge queue Mar 19, 2024
Merged via the queue into stacks-network:next with commit 80adc27 Mar 19, 2024
2 checks passed
ASuciuX added a commit to ASuciuX/archived-stacks-core that referenced this pull request Apr 2, 2024
@blockstack-devops
Copy link
Contributor

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.

@stacks-network stacks-network locked as resolved and limited conversation to collaborators Nov 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants