costin opened a new pull request, #16356: URL: https://github.com/apache/lucene/pull/16356
Snowball stemming is expensive due to algorithmic suffix manipulation repeated identically for every occurrence of the same token. This PR adds an small insert-only cache (CharArrayMap) to avoid the redundant work by exploiting the fact that natural text is Zipfian (same short words account for majority of token occurrences). The cache is small (1024 entries, ~75KB) and caches only tokens up to 10 chars. It is enabled by default to avoid mapping changes for existing users and can be disabled through maxCacheSize=0. ### Benchmarks AMD EPYC 7R32 (c5a.2xlarge), JDK 25, 500 unique words, 10K tokens Zipfian corpus. 3 forks, 10 iters × 1s. cacheSize=0 is the uncached baseline. | language | cacheSize | throughput (ops/s) | vs no-cache | gc.alloc (B/op) | |----------|----------:|-------------------:|------------:|----------------:| | English | 0 | 277.9 ± 2.2 | — | 89.9 | | English | 1024 | 751.4 ± 4.0 | 2.70x | 74.2 | | English | 4096 | 743.4 ± 6.9 | 2.67x | 74.3 | | English | 8192 | 734.2 ± 7.6 | 2.64x | 74.4 | | German | 0 | 201.4 ± 1.3 | — | 99.3 | | German | 1024 | 550.2 ± 9.6 | 2.73x | 77.6 | | German | 4096 | 555.3 ± 7.2 | 2.76x | 77.5 | | German | 8192 | 551.7 ± 1.7 | 2.74x | 77.5 | The default cache size of 1024 entries was picked from the sweep above as it captures virtually all the benefits across English and German. -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
