-
Notifications
You must be signed in to change notification settings - Fork 8
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
Dialogs parsing performance #28
Comments
Hm, that would mean that you should have observed slower load times everywhere, especially when loading the VOb tree. There might be optimisations that can be done in |
I've made a few experiment locally:
// messages messages::parse(buffer& buf)
...
std::sort(msgs.blocks.begin(), msgs.blocks.end(), [](const message_block& l, const message_block& r){
return l.name<r.name;
});
return msgs;
}
const message_block* messages::block_by_name(std::string_view name) const {
auto it = std::lower_bound(blocks.begin(), blocks.end(), name, [](const message_block& l, std::string_view name) {
return l.name < name;
});
if (it!=blocks.end())
return &*it;
return nullptr;
} |
It certainly makes sense that not allocating potentially thousands of small |
Yes, I've tested this solution locally. |
The allocation of many thousands of small strings as keys of the `std::unordered_map` used for looking up blocks by their name is not very fast. Using binary search instead improves parsing performance and decreases memory usage while still keeping block lookup performance within an acceptable range.
Implemented :) |
GameScript::loadDialogOU()
become noticeably slower with phenix backend.I haven't done proper profiling, but issue seem to be rooted in large amount of small allocations, while population hash-map.
Lazy profiling(debug break a few times) shows, that this place can be an issue:
The text was updated successfully, but these errors were encountered: