Reducing a map performance worsens as the map gets bigger #34128
Labels
Points/3
Equivalent to three days effort
Priority/High
Team/jBallerina
All the issues related to BIR, JVM backend code generation and runtime
Type/Bug
Description:
Reducing a map (i.e.
(map<int>).reduce()
) decreases in performance as the size of map increases.Steps to reproduce:
Build and run the following:
On my machine (Intel Core i7-1165G7) running this takes 20.44 seconds (as measured with
time java -jar demo.jar
)For comparison, consider the following equivalent:
This runs in 1.78 seconds (again, measured with
time java -jar demo.jar
), ~ 1 tenth of the.map
speed.The behaviour gets increasingly worse as 60000 is increased to higher values.
For example, with 100000 it takes 164.08 seconds, while the
foreach
variant requires only 2.21 seconds.Affected Versions:
Swan Lake Beta 5
OS, DB, other environment details and versions:
Linux: Fedora 34 (Linux fedora 5.15.5-100.fc34.x86_64 #1 SMP Fri Nov 26 00:52:21 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux)
openjdk 11.0.13 2021-10-19
OpenJDK Runtime Environment 18.9 (build 11.0.13+8)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.13+8, mixed mode, sharing)
Related Issues (optional):
N/A
Suggested Labels (optional):
N/A
Suggested Assignees (optional):
N/A
The text was updated successfully, but these errors were encountered: