Project

Profile

Help

Bug #4865

closed

map:merge() optimiization opportunities

Added by Michael Kay over 3 years ago. Updated almost 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Performance
Sprint/Milestone:
-
Start date:
2020-12-24
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
10, trunk
Fix Committed on Branch:
10, trunk
Fixed in Maintenance Release:
Platforms:

Description

map:merge() is very inefficient if given two maps where the first is a singleton.

See https://github.com/eXist-db/exist/issues/3682 example 6.

Using map:put() here cuts the execution time from 9m to 90ms.

Reversing the order of the maps would probably be equally effective; it would be worth starting with the largest map as the baseline.

So we could do a static optimization (rewrite as map:put) for the case where we can see that one of the maps is a singleton, or we could do a dynamic optimization by re-ordering the maps.

Please register to edit this issue

Also available in: Atom PDF