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. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
