[
https://issues.apache.org/jira/browse/GROOVY-12327?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18110502#comment-18110502
]
ASF GitHub Bot commented on GROOVY-12327:
-----------------------------------------
paulk-asert opened a new pull request, #2854:
URL: https://github.com/apache/groovy/pull/2854
LazyMap holds entries in parallel key/value arrays until something asks for
a key, so the small objects that dominate JSON documents never build a backing
map. Duplicate-key detection scanned those arrays linearly on every put, which
costs O(n^2) comparisons for an object of n keys — on the default JsonSlurper
path, and with the per-comparison cost tunable from the document by giving the
keys a long common prefix. Past 32 entries put now builds the backing map and
delegates, keeping insertion amortized constant-time while leaving narrow
objects on the compact representation. Parsing 64k keys drops from 3048ms to
18ms, and scales linearly rather than quadratically.
Hydration sized its LinkedHashMap with a 0.01 load factor to blunt hash
collisions, forcing a bucket table ~100x the entry count. Every runtime this
builds for treeifies a heavily-collided String-keyed bucket by itself, so the
table now uses the default load factor with capacity to match. This matters
more once put hydrates during the parse rather than on first access: without
it, a 0.7MB document of 3000 40-key objects retains 104MB read or not, against
10MB now.
> Improve performance of JSON LazyMap
> -----------------------------------
>
> Key: GROOVY-12327
> URL: https://issues.apache.org/jira/browse/GROOVY-12327
> Project: Groovy
> Issue Type: Improvement
> Reporter: Paul King
> Assignee: Paul King
> Priority: Major
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)