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

Add cold annotations #286

Merged
merged 1 commit into from
Nov 22, 2024
Merged

Add cold annotations #286

merged 1 commit into from
Nov 22, 2024

Conversation

x-hgg-x
Copy link
Contributor

@x-hgg-x x-hgg-x commented Nov 21, 2024

This PR add #[cold] annotations to specific functions to hint the compiler that they should not be inlined, so that other more critical functions like iterators has better chance to be inlined.

@Eh2406
Copy link
Member

Eh2406 commented Nov 22, 2024

Why do we think these functions are cold? Is there perf data showing this helping?

@x-hgg-x
Copy link
Contributor Author

x-hgg-x commented Nov 22, 2024

Is there perf data showing this helping?

Yes, this will avoid future unrelated drops in performance when moving code (the addition of #[inline] in #283 was not enough). In #274 this improved performance by 5-10%, because iterators were not inlined before.

Why do we think these functions are cold?

The problem this solves is that LLVM tries to inline a maximum of code if possible, but if a function is too big it will stop inlining in the middle of the function because the analysis cost is too big.
By giving LLVM specific cold functions which doesn't cause performance drops when not inlined, the inline cost is reduced and the function content is more likely to be inlined.
I chose these specific functions because they were already not inlined, so this PR prevents their inlining.

Copy link

codspeed-hq bot commented Nov 22, 2024

CodSpeed Performance Report

Merging #286 will not alter performance

Comparing x-hgg-x:cold-annotations (6bbe19f) with dev (4ac6c42)

Summary

✅ 6 untouched benchmarks

Copy link
Member

@Eh2406 Eh2406 left a comment

Choose a reason for hiding this comment

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

Seams ok.

@Eh2406 Eh2406 added this pull request to the merge queue Nov 22, 2024
Merged via the queue into pubgrub-rs:dev with commit 4c6cdde Nov 22, 2024
6 checks passed
@x-hgg-x x-hgg-x deleted the cold-annotations branch November 22, 2024 18:38
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