Skip to content

[memprof] Use std::move in toMemProfRecord #93133

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 2 commits into from
May 23, 2024

Conversation

kazutakahirata
Copy link
Contributor

@kazutakahirata kazutakahirata commented May 23, 2024

std::move and reserve here result in a measurable speed-up in
llvm-profdata modified to deserialize all MemProfRecords. The cycle
count goes down by 7.1% while the instruction count goes down by 21%.

std::move here results in a measurable speed-up in llvm-profdata
modified to deserialize all MemProfRecords.  The cycle count goes down
by 6.1% while the instruction count goes down by 20%.
Copy link
Contributor

@snehasish snehasish left a comment

Choose a reason for hiding this comment

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

This leaves the current IndexedMemProfRecord in a bad state. How can we ensure that users don't accidentally try to read after this method has been called?

I'm also skeptical how much impact this has in real usage since we don't expect to read all records for a single module. Perhaps we can try safer optimizations such as reserve() for the AllocSites vector (and the Callsites vector too)?

@kazutakahirata
Copy link
Contributor Author

This leaves the current IndexedMemProfRecord in a bad state. How can we ensure that users don't accidentally try to read after this method has been called?

I'm also skeptical how much impact this has in real usage since we don't expect to read all records for a single module. Perhaps we can try safer optimizations such as reserve() for the AllocSites vector (and the Callsites vector too)?

AI here is a local variable. This patch does not modify the current IndexedMemProfRecord in any way. In fact, toMemProfRecord is a const function.

@snehasish
Copy link
Contributor

AI here is a local variable. This patch does not modify the current IndexedMemProfRecord in any way. In fact, toMemProfRecord is a const function.

Thanks for pointing out local variable. Clearly I didn't spend much time reading the rest of the function. Can you try out the reserve calls and commit this along with it?

Copy link
Contributor

@snehasish snehasish left a comment

Choose a reason for hiding this comment

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

lgtm

@kazutakahirata kazutakahirata merged commit 300663a into llvm:main May 23, 2024
4 of 6 checks passed
@kazutakahirata kazutakahirata deleted the memprof_std_move branch May 23, 2024 19:27
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