perf: skip stream pipeline for single-row reads and trim hot-path overhead#283
Merged
Conversation
…rhead - getSingleResult/getOptionalResult read at most two rows directly and close synchronously, skipping the stream pipeline, leak-detection proxy, and deferred close; exception types and messages are unchanged - RecordMapper reuses the flat args array when every step is a one-column pass-through, avoiding a per-row allocation and copy - SqlParser detects the SQL operation with regionMatches instead of evaluating a stream of regexes per statement - SqlInterceptorManager skips the read lock when no global operators are registered - TemplateMetrics stripes counters with LongAdder/LongAccumulator to avoid CAS contention - whereId/whereRef pin the root primary-key metamodel so binding does not re-derive the target column from the value's runtime type - OrderableHelper skips the topological sort for 0/1-element lists
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
A set of hot-path optimizations in storm-core. No behavior changes: exception types and messages on the single-row paths are identical to the previous stream-based defaults.
getSingleResult()/getOptionalResult()now execute the statement, read at most two rows (the second only to enforce uniqueness), and close synchronously (QueryImpl.readSingleRow). This skips the stream pipeline construction, the leak-detection proxy, and the deferred close, none of which earn anything for a single-row read.QueryBuilderexposes overridablesingleResultInternal/optionalResultInternalhooks;SelectBuilderImplroutes non-ref results through the new path and keeps ref results on the stream path.regionMatchesinstead of evaluating a stream ofDOTALLregexes on every parsed statement.intercept()skip acquiring the read lock entirely when no global operators are registered, the common production state.AtomicLongcounters replaced withLongAdder/LongAccumulatorso concurrent template renders do not contend on a single CAS.