postgres: bound alias memory during vulnerability updates - #2001
Draft
BradLugo wants to merge 4 commits into
Draft
postgres: bound alias memory during vulnerability updates#2001BradLugo wants to merge 4 commits into
BradLugo wants to merge 4 commits into
Conversation
Exercise UpdateVulnerabilities with enough alias-carrying vulnerabilities to cross batch-flush boundaries and verify the link tables directly. The benchmark reports peak live heap alongside the usual metrics, since allocation lifetime is invisible to B/op. Signed-off-by: Brad Lugo <blugo@redhat.com>
Insert and link aliases every 500 vulnerabilities instead of accumulating bookkeeping for the whole run, halving peak heap for large updates (82MB to 40MB at 50k vulnerabilities). The out-of-band alias inserts now happen mid-run, so a failed update can leave alias rows committed; they are unreachable until a later successful run links them. Signed-off-by: Brad Lugo <blugo@redhat.com>
The chunked link statements are INSERT..SELECTs that must see alias rows committed by concurrent updaters after the transaction began, so pin read committed instead of inheriting default_transaction_isolation. Signed-off-by: Brad Lugo <blugo@redhat.com>
Chunking runs the link statements often enough to cross the prepared-statement threshold, where the generic plan built for unnest's default row estimate gets chosen and is disastrous for the actual array sizes. Executing unprepared keeps per-execution planning. Signed-off-by: Brad Lugo <blugo@redhat.com>
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.
TL;DR: These changes improve
updateVulnerabilities()'speak-heap-BandB/opfor larger inputs, with constant cost toallocs/op, increasing cost tosec/op, and diminishing cost at the lower end toB/op. Overall, I think the tradeoffs are worthwhile for larger vulnerability feeds (read: rhel-vex).Analysis & Benchmarking
Setup:
tmpdir=$(mktemp -d)Run benchmarks for baseline:
Run benchmarks for chunking change:
Results on my system:
We start seeing some real gains at the higher end at the cost of compute.
Run benchmarks for custom plan changes:
Results:
Overall: