-
Notifications
You must be signed in to change notification settings - Fork 860
Column seeking rework #5476
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Column seeking rework #5476
Conversation
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
84732c9
to
a771a87
Compare
a771a87
to
c624fdf
Compare
This was referenced Dec 7, 2023
2483bfd
to
65f92ec
Compare
65f92ec
to
3a88048
Compare
3a88048
to
73de110
Compare
Instead of two separate implementations for buffered and sequential
845f822
to
067e640
Compare
a1020df
to
ddf2369
Compare
ddf2369
to
8a89705
Compare
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.
Column Seeking Rework
This PR reworks the split implementation we have for column seeking in NpgsqlDataReader.
Where previously we had two methods split by behavior; one for non buffered mode (sync only) and one for sequential mode (async/sync).
We now just have a sync and an async implementation, with the sync method having a tiny bit of additional validation for sequential behavior.
Fast paths should essentially be unaffected and we might even see a small speedup in TE non sequential scenarios due to streamlining column seeking but also PgReader.{Init,Commit} even more.
For the async implementation we're exploiting the fact that any rereading or rewinding necessarily means we already have the data. So we're able to fully delegate all that work to the sync implementation.
Similarly we're now always using the sync implementation if we know the row is buffered entirely.
Async Seeking Caveat
One optimization that I introduced in 8.0 that didn't make it over is when doing an *async sequential* seek (so mostly via IsDBNullAsync or GetFieldValueAsync). We used to try and seek up to the column that was buffered before switching to the async method, saving a small bit of time setting up the state machine and entering it.
In my opinion that complexity isn't worth carrying over. It was initially introduced because sequential seeking had no sync only method at all, impacting the super common sync methods like GetFieldValue. While the async column reading methods are rarely used. Even then the new implementation will still use the sync path when the entire row is buffered.
On the other hand *sync sequential* seeking now uses the same heavily optimized implementation as buffered mode does.