-
Notifications
You must be signed in to change notification settings - Fork 10
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
Replace map with unordered map #1323
Conversation
|
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.
I simply run e2e tests and no regression is spotted. If there are specific parts I need to pay attend to, please let me know. Thanks.
@kswang1029 to do performance test via e2e tests. check test elapsed time! |
@acdo2002 please execute ICD test manually in a sequence (not in parallel) and compare elapsed time of each test to see if there is significant performance boost or degradation. I will do a similar one but from e2e perspective. @confluence these test results would provide a hint about performance impact hopefully. |
@markccchiang @confluence Not sure if I am seeing a thing here. It appears to me that dev (with map) performs better than unordered_map branch. Basically all tests with unordered_map branch require more time to execute. |
Hmm. In that case, I suggest that we move this to draft until I can dig further into the code and look at how we're using the maps in different components. It's possible that only some of the maps should be changed, none of them should be changed, or that some of our unordered maps should be ordered maps! Clearly it's not as simple as changing them across the board. |
Any naive explanations why? |
My short answer is: the way we're accessing the maps is (on average!) triggering cases where
But these are just guesses, and this requires further investigation. It's possible that only one of these maps is the source of the slowdown, and all the other maps do in fact benefit from being converted (but the one slow map is disproportionately affecting the outcome because it's accessed a lot more frequently).
|
I've also noticed that some of the region code repeatedly creates and destroys local variables which are small maps, and this might be more expensive for unordered maps. But I also don't know if this is happening frequently enough to be an issue. Rather than continuing to guess, I will try to use a profiler. :) |
indeed, region e2e tests do have the performance degradation problem more significantly. All the e2e tests have a set of common step: load file list, load file info, and then load image or images. |
Yes. Considering the current performance test results, we may switch between map and unordered_map one by one, and see which is better. This is trivial but time-consuming work -- so far there is no clear guide on which kind of map is better for us to use. |
I did a quick test, here is the result. the unordered map branch: NOTE: there is a regression failure happened on SET_REGION_ANNOTATION_EXPORT_IMPORT_CASA_PIXEL.test.ts |
Description
What is implemented or fixed? Mention the linked issue(s), if any.
Closes Replace map with unordered_map #1295. Being a pure lookup table,
unordered_map
is supposed to perform better thanmap
. According to the discussions from the stake overflow. However, usingunordered_map
would need more memory space than that formap
. The new testerTestMapPerf
simply tests the performances ofmap
andunordered_map
.unordered_map
is a little bit faster thanmap
when inserting a new data element or finding & copying a specific data element. But it is significantly slower thanmap
when erasing map elements or manipulating the map structure. Ref: map vs. unordered_map in C++.How does this PR solve the issue? Give a brief summary.
Replace all
map
withunordered_map
, except for the ordered array fromHttpServer
.Are there any companion PRs (frontend, protobuf)?
No.
Is there anything else that testers should know (e.g. exactly how to reproduce the issue)?
It will not affect the original tests. @acdo2002 could you please check if there are any performance differences compared to the dev branch?
Checklist
/ no changelog update neededcorresponding fix added/new e2e test createdprotobuf updated to the latest dev commit /no protobuf update neededprotobuf version bumped /protobuf version not bumped