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

Avoid multiple lookups during body-copying while inlining. #15493

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

ekpyron
Copy link
Member

@ekpyron ekpyron commented Oct 8, 2024

No description provided.

@ekpyron ekpyron force-pushed the bodyCopierMicroOptimization branch from e491a64 to a7233c0 Compare October 8, 2024 16:21
Comment on lines 364 to 367
YulName BodyCopier::translateIdentifier(YulName _name)
{
if (m_variableReplacements.count(_name))
return m_variableReplacements.at(_name);
else
return _name;
return util::valueOrDefault(m_variableReplacements, _name, _name);
}
Copy link
Member

@cameel cameel Oct 8, 2024

Choose a reason for hiding this comment

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

It does seem to have some effect, though minimal.

Here's the time taken by BodyCopier when compiling Uniswap on 5 runs I tried:

  1. 2.000305 s (before)
  2. 1.972689 s (before)
  3. 1.905709 s (after)
  4. 1.910145 s (after)
  5. 1.962662 s (after)

So it's consistently lower, but the variance of the results is on the same order as the difference between them so it could very well turn out that will more runs the difference disappears.

For context, the inliner as a whole takes ~3.5 s and the whole compilation process somewhere around 110-120 s.

Copy link
Member

Choose a reason for hiding this comment

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

Measuring BodyCopier::translateIdentifier() itself, performance concerns seem to be negligible. 2250827 calls take takes 0.008033 s in total, compared to ~120 s running time of full compilation.

@cameel
Copy link
Member

cameel commented Oct 16, 2024

Anything more to be done here? It's still a draft.

@cameel cameel added the 🟡 PR review label label Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants