Merged
Conversation
…-server into max/sync-status-updates
zachmu
approved these changes
Aug 1, 2024
Member
zachmu
left a comment
There was a problem hiding this comment.
Kind of crazy how much perf this unlocks, good find
sql/core.go
Outdated
| @@ -713,7 +713,7 @@ type StatusVariableRegistry interface { | |||
| // SetGlobal sets the global value of the status variable with the given name, returns an error if the variable is SessionOnly scope | |||
| SetGlobal(name string, val interface{}) error | |||
| // IncrementGlobal increments the value of the status variable by the given integer value | |||
Member
There was a problem hiding this comment.
Should document failure behavior, kind of important
Contributor
Author
There was a problem hiding this comment.
added note about session-only nooping
| v, ok := g.varVals[name] | ||
| if !ok || v.Variable().GetScope() == sql.StatusVariableScope_Session { | ||
| return sql.ErrUnknownSystemVariable.New(name) | ||
| return |
Member
There was a problem hiding this comment.
Appropriate to panic here? Basically always means a bug right?
Contributor
Author
There was a problem hiding this comment.
The globals list excludes sessionOnly*, so it's only ~297/678 of the total list. So we want to ideally not call this on session only, but noop if we do.
Contributor
Author
There was a problem hiding this comment.
The query type counters have both scopes unfortunately, so I had to leave those for now
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.
System variables can be session, global, or both.
sql.IncrementStatusVariableis a helper method that primarily helps the "both" category increment the global and session counters for certain variables.Threads_runningis a global only variable that is incremented/decremented every begin/end query, and gets a lot of traffic. The old code usedsql.IncrementStatusVariableto incrementThreads_running, which was a particularly expensive way to increment a global var because (1) we'd make a new error for every call to the session updater, and (2) the extra map lookup is unnecessary. We don't do the extra map lookup now, and we weren't using the error return so I removed the return variable.Note: this also refactors status variables to be explicitly initializated in the engine
bump/perf here: dolthub/dolt#8189