[hotfix][Optimizer] Cache group thread counts for quota sorting - #4323
Draft
czy006 wants to merge 2 commits into
Draft
[hotfix][Optimizer] Cache group thread counts for quota sorting#4323czy006 wants to merge 2 commits into
czy006 wants to merge 2 commits into
Conversation
…s TTL) getThreadCount() ran SELECT * FROM optimizer (including the mediumtext properties column) on every calculateQuotaOccupy call. QuotaOccupySorter invokes it for each pending table on every poll-driven sort, and all tables of a queue share one group: N identical full-table scans per sort, multiplied by optimizer poll frequency - the largest steady-state DB load in the scheduler hot path. Add a per-group cache with a 5s TTL (CAS-guarded expiry; races only cause a rare extra query). Staleness is harmless for the heuristic quota weighting since group thread counts only change on optimizer register/unregister. No signature changes. Regression test TestDefaultTableRuntimeThreadCountCache (red without cache: second read immediately reflected the new optimizer). Also documents the targetQuota=0 -> Infinity division surfaced while testing (to be fixed at config parsing). Fix record: docs/fix-records/2026-08-15-fix-10-quota-sorter-thread-count-cache.md
czy006
force-pushed
the
codex/hotfix-optimizer-thread-count-cache
branch
from
August 18, 2026 02:16
e7a92c5 to
4b0a451
Compare
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.
Brief change log
Cache each optimizer group thread-count query for five seconds while calculating quota ordering. This avoids repeated external lookups without changing the refresh behavior after the cache interval.
How was this patch tested?
TestDefaultTableRuntimeThreadCountCachelocally with JDK 11 before creating this pull request.Documentation