Skip to content

Use map from key to count instead of multiset#3885

Merged
aleks-f merged 2 commits intopocoproject:develfrom
davenger:fix_enumerate
Jan 24, 2023
Merged

Use map from key to count instead of multiset#3885
aleks-f merged 2 commits intopocoproject:develfrom
davenger:fix_enumerate

Conversation

@davenger
Copy link
Copy Markdown
Contributor

We noticed slow performance of XMLConfiguration::enumerate when a node had lots of children with the same name. In this case std::multiset is not needed for assigning consequent indexes to children, std::map is better in terms of number allocations and memory consumption.

@davenger
Copy link
Copy Markdown
Contributor Author

I added test XMLConfigurationTest::testManyKeys that reproduces the problem by enumerating 100K elements with the same name.
Without the fix it takes around 2 minutes on my machine in release and with the fix it take 0.1 seconds.

@aleks-f aleks-f added this to the Release 1.13.0 milestone Jan 24, 2023
@aleks-f aleks-f merged commit 0fd1749 into pocoproject:devel Jan 24, 2023
aleks-f pushed a commit that referenced this pull request Nov 27, 2023
* Test that enumerates lots of elements with the same name

* Use map from key to count instead of multiset

Co-authored-by: Alexander Gololobov <{ID}+{username}@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants