Avoid re-parsing sql expressions. #3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When queries in Pinot run at high QPS rate, it would be desirable to keep a LRU cache of certain sizes for the parsed query objects. There's a lot of new objects being allocated and expensive ANTLR grammar parsing that goes into converting the query expression strings into parsed Pinot Queries.
This PR introduces two separate capped LRU caches for the purpose of removing the unnecessary overhead of ANTRL parsing. The caches are very similar to how the Metric Names are cached in AsbtractMetrics and this PR requires that change, because it relies on the same library for fast concurrent LRU caching.
Todo:
Performance measurement results:
Machine configuration:
4 core (8 threads) Intel(R) Xeon(R) W-2123 CPU @ 3.60GHz
32GB of RAM
Linux x86-64, kernel: 5.0.0-37-generic
Benchmark configuration:
TPC-H (optimal index)
20 clients
180s runtime
Results (QPS higher is better, response time lower is better)
Base with (metrics-improvements):
Time Passed: 180.014s, Query Executed: 528540, QPS: 2936.104969613474, Avg Response Time: 6.800626253452908ms
Improved (this branch):
Time Passed: 180.018s, Query Executed: 554955, QPS: 3082.7750558277507, Avg Response Time: 6.476053013307386ms
Co-authored-by: @grcevski @charliegracie @macarte @adityamandaleeka