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

[Skylark] Speed up string.partition function. #5736

Closed
wants to merge 3 commits into from

Conversation

ttsugriy
Copy link
Contributor

@ttsugriy ttsugriy commented Aug 2, 2018

According to JMH using ImmutableList.of or Arrays.asList is ~2X faster
than using existing approach of creating an empty ArrayList with expected
size and populating it using add method. This is most likely due to extra
range and capacity checks.

Returning ImmutableList instead of ArrayList avoids the need to copy it
again in order to create a SkylarkTuple.

These changes speed up the function by ~3X.

According to JMH and JIT assembly generated for iterators and index
accesses, iterator methods like `hasNext` and `next` are not optimized
away and result in 3-4X slower execution.
Copy link
Contributor

@laurentlb laurentlb left a comment

Choose a reason for hiding this comment

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

lgtm

@bazel-io bazel-io closed this in 13ebd67 Aug 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants