forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sql: lazily copy prepStmtNamespace to avoid repeat allocations
Fixes cockroachdb#32427. This change reworks the handling of `prepStmtsNamespace` and `prepStmtsNamespaceAtTxnRewindPos` to avoid cloning the former indiscriminately after every statement. This clone was very expensive because it resulted in a series of map allocations and memory copies. The new approach avoids the cloning in almost all cases by performing the copy only when it is needed. In the past, this would translate to cases where `prepStmtsNamespace` and `prepStmtsNamespaceAtTxnRewindPos` actually differed. It does so by introducing a new `checkpointedPrepStmtNamespace` type which abstracts away the details of taking snapshots of the namespace and rewinding when necessary. The change also adds a fast-path that I've wanted for a while which allows us to avoid map accesses entirely for the unnamed prepared statement/portal. A large number of drivers only use the unnamed portal by default, so this should provide a nice speedup. Release note: None
- Loading branch information
1 parent
61d058c
commit aabda88
Showing
3 changed files
with
303 additions
and
131 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Oops, something went wrong.