Find query_source_location using lazy Enumerator #35985
Merged
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.
In development,
extract_query_source_location
is called on every SQL query. In my test app, a SQL query from the controller results in a stack trace 200 deep, with the first "clean" frame 60 in.By filtering on
caller.lazy
, a lazy enumerator, instead of the full array, we only need to filter the backtrace up to the first non-noise stack frame.This also updates noise to be able to deal with being passed a lazy enum. We don't need this anywhere, but it seemed better for this to be consistent.
Benchmark:
There are a few more improvements I'd like to make to this later, running X regex against Y strings for Z queries ends up pretty expensive even for development. It would be really great if we had an interface to filter on
caller_locations
(Thread::Backtrace::Location) instead ofcaller
.