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

Truffle ropes 2 #3619

Closed
wants to merge 34 commits into from
Closed

Truffle ropes 2 #3619

wants to merge 34 commits into from

Conversation

nirvdrum
Copy link
Contributor

@chrisseaton @pitr-ch @eregon This is the additional work I've done on ropes since the last pull request. I did it as a separate pull request against the branch you've already reviewed so you can see the new changes more easily.

The work here was primarily to improve performance over the original branch. The first one was basically just functionally complete. This PR has a larger emphasis on doing things more efficiently with ropes. There's still a lot more we can do, particularly in the area of regular expressions.

Notable highlights:

  • Introduced a rope table for StringLiteralNodes (NB: There's a problem with the key being removed as it's a WeakHashMap, but everything still works if the cached entry isn't available and these are all built during parse, so the effect of GC is minimized).
  • Symbols are now based ropes.
  • Rope construction methods have been converted to nodes.
  • Some primitives to help in debugging ropes were added.
  • Fixed Rope#hashCode and Rope#equals.
  • Replaced recursive byte[] building with an iterative algorithm.
  • Removed a bunch of places where we were constructing ByteLists (and subsequently materializing the rope's byte[]) unnecessarily.

if (RubyGuards.isRubyString(string)) {
return StringOperations.getByteListReadOnly(string).dup();
// TODO (nirvdrum 25-Jan-16) Should we flatten the rope to avoid caching a potentially deep rope tree?
Copy link
Member

Choose a reason for hiding this comment

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

But then you would lose Rope identity comparison, it's a trade-off.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed. Although we're still doing a full byte[] comparison if the ropes aren't identity equal. We can eliminate that, but I was just maintaining existing functionality for now. The flattening could also work in conjunction with a lookup table to ensure the same references, as well.

@eregon
Copy link
Member

eregon commented Jan 27, 2016

I read through the diff quickly, looks fine 😄

This prevents a lot of converting Ropes into ByteLists so they can be used by Symbols.
…h codes have already been calculated.

This could help avoid a length byte walk.
We probably need something more robust to various attacks, but we definitely shouldn't be creating a temporary ByteList to get a hash code.
@chrisseaton
Copy link
Contributor

Looks good to me. Can we have a final PR for all changes and a merge commit so it's clear when it went it?

@nirvdrum
Copy link
Contributor Author

Yeah. This is already rebased on truffle-ropes. I can just close both PRs and open this one against master.

@pitr-ch
Copy link
Member

pitr-ch commented Jan 27, 2016

👍

@chrisseaton chrisseaton added this to the truffle-dev milestone Jan 27, 2016
@nirvdrum nirvdrum closed this Jan 27, 2016
@nirvdrum nirvdrum mentioned this pull request Jan 27, 2016
@nirvdrum nirvdrum deleted the truffle-ropes-2 branch January 27, 2016 18:49
@enebo enebo added this to the Non-Release milestone Dec 7, 2017
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.

None yet

5 participants