Defer Memory Allocation of AHI Hash Tables Until AHI Is Enabled - #729
Open
SongLibing wants to merge 2 commits into
Open
Defer Memory Allocation of AHI Hash Tables Until AHI Is Enabled#729SongLibing wants to merge 2 commits into
SongLibing wants to merge 2 commits into
Conversation
Run untrusted pull request builds with restricted permissions against validated revisions, and publish statuses and labels only from trusted workflows that revalidate the repository, workflow run, PR head, and ordering. Replace the custom review client with the pinned OpenAI Codex Action, bound its input to a validated PR diff, pin third-party actions, and add dependency maintenance for GitHub Actions. Retry a failed or empty Codex review once after a delay with a configurable fallback model while preserving the same read-only isolation boundary and structured output contract. Publish structured Codex findings as one commit-bound GitHub review. Validate each file and right-side line range against the current diff, keep unanchored findings in the summary, prevent duplicate reviews, and revalidate both reviewed revisions before posting. Warm trusted Boost and ccache entries, align the MTR compiler cache with the GCC build, shard MTR suites across runners, run tests in parallel with bounded retries, and retain diagnostics. Safely reset head-scoped CI state, standardize labels, and remove the obsolete OCA checkbox. Require both the OCA Verified label and a current trusted approval before adding Integrate. Revalidate both conditions around label publication and remove Integrate if either condition no longer holds. Temporarily disable parallel-run failures tracked by Bug#39882117 and restore the required restart and expected output for the buffer-pool-load MTR. Change-Id: I7393e75cab3afa172a99237337c26e3974f955fa
Problem ======= The AHI hash tables are initialized at startup even when AHI is disabled. They are initialized with buf_pool_get_curr_size()/sizeof(void *)/64 cells. Each slot takes 8 bytes. So the total memory they occupy is approximately equal to 1/64 of the buffer pool size. The memory is wasted if AHI is disabled. On large servers, initializing large hash tables slows startup. Solution ======== This commit initializes the AHI hash tables with one cell per AHI partition if AHI is disabled. The hash tables are restored to their normal size before AHI is enabled. With one slot existing, the AHI system is fully initialized. This preserves the invariant that the per-partition hash table objects always exist. During a buffer pool resizing, AHI is temporarily disabled. If AHI was enabled when the resize started, its full-sized hash tables are retained and resized only when necessary, avoiding an unnecessary shrink-and-restore cycle.
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.
Problem
The AHI hash tables are initialized at startup even when AHI is disabled. They are initialized with
buf_pool_get_curr_size()/sizeof(void *)/64 cells. Each cell takes 8 bytes. So the total memory they occupy is approximately equal to 1/64 of the buffer pool size. The memory is wasted if AHI is disabled. On large servers, initializing large hash tables slows startup.
Solution
This commit initializes the AHI hash tables with one cell per AHI partition if AHI is disabled. The hash tables are restored to their normal size before AHI is enabled.
With one slot existing, the AHI system is fully initialized. This preserves the invariant that the per-partition hash table objects always exist.
During a buffer pool resizing, AHI is temporarily disabled. If AHI was enabled when the resize started, its full-sized hash tables are retained and resized only when necessary, avoiding an unnecessary shrink-and-restore cycle.
What does this change do?
https://bugs.mysql.com/bug.php?id=112223
Why is it needed?
This patch reduces memory usage and startup time when AHI is disabled. AHI has been disabled by default since 8.4 and AHI is not recommended for production use. Therefore, without this commit, most of the server would wastes an amount of memory approximately equal to 1/64 of buffer pool size.
How was it tested?
mysql-test/scripts/ci/mtr.shpasses locallyContributor checklist
scripts/ci/format.sh)AI assistance
If AI assistance was used, describe the tool(s) and extent of use: Port the patch, added more testcases.
Areas touched
InnoDB