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

Remove allocation for builder cache hits #40

Closed
wants to merge 3 commits into from
Closed

Remove allocation for builder cache hits #40

wants to merge 3 commits into from

Conversation

CAD97
Copy link
Owner

@CAD97 CAD97 commented May 25, 2020

Credit to @simonvandel over at the main rowan repository for pointing out how this is possible.

Draft proof of concept includes many problematic corners that make this not mergeable:

  • Nightly-only for vec::Drain::as_slice (Tracking issue for slice::IterMut::as_slice and vec::Drain::as_slice rust-lang/rust#58957)
  • Includes a bunch of ptr-union wrangling in green/builder.rs that shouldn't need to be there
    • Should probably use a fn Union2::as_untagged_ptr rather than unpacking the union
  • trait AsSlice is a hack to accept the as_slice-having by-value iterators
    • AsRef<[T]> is probably the correct bound here
  • APIs should go back to taking IntoIterator rather than Iterator directly
    • The Into bound is nice but unnecessary
  • Should maintain having an API that doesn't require as_slice/RandomAccessIterator and performs the old behavior of collecting into a provisional node
  • Need to go over deserialization paths to see if any are impacted (or improved) by this technique
  • Code is ugly and commits sins on match (though not as nice as match match match)

@codecov
Copy link

codecov bot commented May 25, 2020

Codecov Report

Merging #40 into master will decrease coverage by 0.73%.
The diff coverage is 77.38%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #40      +/-   ##
==========================================
- Coverage   79.00%   78.26%   -0.74%     
==========================================
  Files           8        9       +1     
  Lines         543      612      +69     
==========================================
+ Hits          429      479      +50     
- Misses        114      133      +19     
Impacted Files Coverage Δ
src/green/builder.rs 66.22% <76.25%> (+3.43%) ⬆️
src/lib.rs 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

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

@CAD97
Copy link
Owner Author

CAD97 commented May 25, 2020

Clippy failure is expected due to the beta stabilization making a polyfill unused, tracked in #17.

@CAD97
Copy link
Owner Author

CAD97 commented May 25, 2020

rust-lang/rust#72583 and rust-lang/rust#72584 propose stabilizing/adding the API into the stdlib to make this work nicely. #41 implements just the subset of this that works and makes sense even on today's stable.

@CAD97
Copy link
Owner Author

CAD97 commented Jun 17, 2020

superseded by #45

@CAD97 CAD97 closed this Jun 17, 2020
bors bot added a commit that referenced this pull request Jun 23, 2020
45: Remove allocation for builder cache hits r=CAD97 a=CAD97

Credit to @simonvandel [over at the main rowan repository](rust-analyzer/rowan#59) for pointing out how this is possible. Previously: #40 

Now that the necessary APIs for this are riding the trains to stable, here's an actual decent implementation of alloc-free cache hits!

Also adds a bit more explicit typing on pointers, as that led to a bug in the construction of this patch.

Co-authored-by: CAD97 <cad97@cad97.com>
@CAD97 CAD97 deleted the less-alloc branch June 27, 2020 02:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant