ast: avoid extra work parsing objects vs obj comprehensions (#3726)
Now we're only caching what we need in a linked-list form. Anything we don't need anymore is dropped, and we are thus more space-efficient than previous approaches. The idea is that when an object or array is pushed to the cache, its elements, which had been parsed and cached before, will be dropped. This is to support the case we're interested in improving: * object, or set or object/set comprehension * array or array comprehension ``` name old time/op new time/op delta ParseModuleRulesBase/1-16 4.32µs ± 4% 4.80µs ±19% +11.13% (p=0.008 n=5+5) ParseModuleRulesBase/10-16 30.5µs ± 4% 35.6µs ± 4% +16.67% (p=0.008 n=5+5) ParseModuleRulesBase/100-16 302µs ± 2% 340µs ± 2% +12.56% (p=0.008 n=5+5) ParseModuleRulesBase/1000-16 3.38ms ± 6% 3.45ms ± 2% ~ (p=0.548 n=5+5) ParseStatementBasicCall-16 2.70µs ± 8% 3.07µs ± 6% +13.74% (p=0.008 n=5+5) ParseStatementMixedJSON-16 78.6µs ± 1% 101.0µs ± 4% +28.43% (p=0.008 n=5+5) ParseStatementSimpleArray/1-16 2.20µs ± 5% 2.43µs ± 8% +10.52% (p=0.008 n=5+5) ParseStatementSimpleArray/10-16 7.61µs ± 1% 8.74µs ± 1% +14.78% (p=0.016 n=4+5) ParseStatementSimpleArray/100-16 58.1µs ± 1% 73.0µs ± 3% +25.65% (p=0.008 n=5+5) ParseStatementSimpleArray/1000-16 555µs ± 4% 759µs ± 1% +36.76% (p=0.008 n=5+5) ParseStatementNestedObjects/1x1-16 2.93µs ± 3% 3.52µs ± 3% +20.09% (p=0.008 n=5+5) ParseStatementNestedObjects/5x1-16 8.10µs ± 2% 10.24µs ± 4% +26.46% (p=0.008 n=5+5) ParseStatementNestedObjects/10x1-16 14.0µs ± 2% 18.2µs ± 3% +29.72% (p=0.008 n=5+5) ParseStatementNestedObjects/1x5-16 7.87µs ± 2% 10.67µs ± 5% +35.57% (p=0.008 n=5+5) ParseStatementNestedObjects/1x10-16 13.6µs ± 3% 19.4µs ±10% +41.96% (p=0.008 n=5+5) ParseStatementNestedObjects/5x5-16 4.99ms ± 5% 6.94ms ± 2% +39.08% (p=0.008 n=5+5) ParseBasicABACModule-16 46.4µs ± 2% 54.7µs ± 2% +17.80% (p=0.008 n=5+5) name old alloc/op new alloc/op delta ParseModuleRulesBase/1-16 3.97kB ± 0% 4.88kB ± 0% +23.00% (p=0.008 n=5+5) ParseModuleRulesBase/10-16 26.0kB ± 0% 32.4kB ± 0% +24.54% (p=0.029 n=4+4) ParseModuleRulesBase/100-16 252kB ± 0% 314kB ± 0% +24.22% (p=0.008 n=5+5) ParseModuleRulesBase/1000-16 2.56MB ± 0% 3.17MB ± 0% +23.77% (p=0.008 n=5+5) ParseStatementBasicCall-16 3.02kB ± 0% 3.63kB ± 0% +20.13% (p=0.008 n=5+5) ParseStatementMixedJSON-16 51.9kB ± 0% 86.3kB ± 0% +66.15% (p=0.008 n=5+5) ParseStatementSimpleArray/1-16 2.86kB ± 0% 3.46kB ± 0% +21.29% (p=0.008 n=5+5) ParseStatementSimpleArray/10-16 5.86kB ± 0% 9.20kB ± 0% +57.10% (p=0.008 n=5+5) ParseStatementSimpleArray/100-16 38.4kB ± 0% 69.1kB ± 0% +80.06% (p=0.008 n=5+5) ParseStatementSimpleArray/1000-16 390kB ± 0% 694kB ± 0% +78.07% (p=0.008 n=5+5) ParseStatementNestedObjects/1x1-16 3.66kB ± 0% 4.57kB ± 0% +24.95% (p=0.008 n=5+5) ParseStatementNestedObjects/5x1-16 6.44kB ± 0% 9.78kB ± 0% +51.93% (p=0.008 n=5+5) ParseStatementNestedObjects/10x1-16 10.0kB ± 0% 16.4kB ± 0% +63.77% (p=0.008 n=5+5) ParseStatementNestedObjects/1x5-16 8.51kB ± 0% 11.86kB ± 0% +39.29% (p=0.008 n=5+5) ParseStatementNestedObjects/1x10-16 14.6kB ± 0% 20.9kB ± 0% +43.85% (p=0.008 n=5+5) ParseStatementNestedObjects/5x5-16 3.42MB ± 0% 5.79MB ± 0% +69.53% (p=0.008 n=5+5) ParseBasicABACModule-16 35.1kB ± 0% 44.2kB ± 0% +25.99% (p=0.016 n=5+4) name old allocs/op new allocs/op delta ParseModuleRulesBase/1-16 80.0 ± 0% 89.0 ± 0% +11.25% (p=0.008 n=5+5) ParseModuleRulesBase/10-16 600 ± 0% 663 ± 0% +10.50% (p=0.008 n=5+5) ParseModuleRulesBase/100-16 5.83k ± 0% 6.43k ± 0% +10.34% (p=0.008 n=5+5) ParseModuleRulesBase/1000-16 58.0k ± 0% 64.1k ± 0% +10.34% (p=0.008 n=5+5) ParseStatementBasicCall-16 47.0 ± 0% 53.0 ± 0% +12.77% (p=0.008 n=5+5) ParseStatementMixedJSON-16 1.02k ± 0% 1.36k ± 0% +33.33% (p=0.008 n=5+5) ParseStatementSimpleArray/1-16 36.0 ± 0% 42.0 ± 0% +16.67% (p=0.008 n=5+5) ParseStatementSimpleArray/10-16 112 ± 0% 145 ± 0% +29.46% (p=0.008 n=5+5) ParseStatementSimpleArray/100-16 837 ± 0% 1140 ± 0% +36.20% (p=0.008 n=5+5) ParseStatementSimpleArray/1000-16 8.05k ± 0% 11.05k ± 0% +37.31% (p=0.008 n=5+5) ParseStatementNestedObjects/1x1-16 49.0 ± 0% 58.0 ± 0% +18.37% (p=0.008 n=5+5) ParseStatementNestedObjects/5x1-16 121 ± 0% 154 ± 0% +27.27% (p=0.008 n=5+5) ParseStatementNestedObjects/10x1-16 207 ± 0% 270 ± 0% +30.43% (p=0.008 n=5+5) ParseStatementNestedObjects/1x5-16 125 ± 0% 158 ± 0% +26.40% (p=0.008 n=5+5) ParseStatementNestedObjects/1x10-16 220 ± 0% 283 ± 0% +28.64% (p=0.008 n=5+5) ParseStatementNestedObjects/5x5-16 71.1k ± 0% 94.5k ± 0% +32.95% (p=0.008 n=5+5) ParseBasicABACModule-16 841 ± 0% 931 ± 0% +10.70% (p=0.008 n=5+5) ``` Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
S
Stephan Renatus committed
bed4156ff2d2a972400d6568f1cf4b2f899b77fc
Parent: 2979b25
Committed by GitHub <noreply@github.com>
on 9/21/2021, 5:10:22 PM