-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[MC][NFC] Reduce Address2ProbesMap size #102904
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
aaupov
merged 10 commits into
main
from
users/aaupov/spr/mcnfc-reduce-address2probesmap-size
Aug 26, 2024
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
de98725
[𝘀𝗽𝗿] initial version
aaupov 112c8f5
[𝘀𝗽𝗿] changes to main this commit is based on
aaupov 3ffb03f
stable_sort
aaupov dd08b76
[𝘀𝗽𝗿] changes introduced through rebase
aaupov b31fe61
Use std::sort for vector of tuples (address, original index) - achiev…
aaupov 55f4ba3
[𝘀𝗽𝗿] changes introduced through rebase
aaupov e16ecf9
Speed up find in case of missing Addr
aaupov 445b646
Check find addr
aaupov 12f6d30
[𝘀𝗽𝗿] changes introduced through rebase
aaupov ab99e16
rebase, address nit
aaupov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1183,11 +1183,9 @@ void ProfileGeneratorBase::extractProbesFromRange( | |
do { | ||
const AddressProbesMap &Address2ProbesMap = | ||
Binary->getAddress2ProbesMap(); | ||
auto It = Address2ProbesMap.find(IP.Address); | ||
if (It != Address2ProbesMap.end()) { | ||
for (const MCDecodedPseudoProbe &Probe : It->second) { | ||
ProbeCounter[&Probe] += Count; | ||
} | ||
for (const MCDecodedPseudoProbe &Probe : | ||
Address2ProbesMap.find(IP.Address)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a hot path, but now we change the O(1) |
||
ProbeCounter[&Probe] += Count; | ||
} | ||
} while (IP.advance() && IP.Address <= RangeEnd); | ||
} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this guarantee it's equivalent to
std::map<uint64_t, ....>
? specifically, if the address doesn't exist in the map,std::map
returnsend()
but usinglower_bound
, it will points to the next element.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. Initially I used equal_range in find(Addr) case, and lower_bound in find(From, To) case. Need to revert to equal_range.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I remember now why I went with lower_bound in both cases:
find(Addr) does the same as find(Addr, Addr+1), which in the case of missing Addr would return an empty range.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, thanks for the clarification. but
getIt(From), getIt(To))
introduces two vector search, can we just check if the return value's address is equal to the given address, if not, then returnend()
? this would save one search.