Skip to content

Avoid unnecessary binary search in rewrite_call #1599

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

Merged
merged 1 commit into from
May 28, 2017

Conversation

topecongiro
Copy link
Contributor

@topecongiro topecongiro commented May 27, 2017

rewrite_call uses binary search to decide the appropriate width for callee.
However, this is unnecessary when we are passing string as callee to rewrite_call,
since the width of string does not change after calling rewrite against it.
This PR avoids using binary search when callee is string.

We get roughly 0~20% speed up against a large code base with this PR.

@topecongiro
Copy link
Contributor Author

master (sec) PR (sec) LoC
rustfmt 0.22 0.20 28,000
librustc 1.50 1.25 79,000
libstd 0.72 0.72 82,000

@nrc
Copy link
Member

nrc commented May 28, 2017

Nice! Good savings.

I've always wondered if it is worth using the binary search at all - if there is some heuristic we could use instead and save some time.

@nrc nrc merged commit bfb89aa into rust-lang:master May 28, 2017
@topecongiro topecongiro deleted the performance/binary-search branch July 11, 2017 21:23
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.

2 participants