Enhance performance with caching and batch operations#4011
Open
uozalp wants to merge 9 commits into
Open
Conversation
0f772bf to
e902fa9
Compare
…nForResource and CanForInstance (derailed#4001)
…erailed#3987) FetchPodsMetrics and FetchNodesMetrics use empty ListOptions which requests the entire metrics dataset in one shot. On clusters with 10k+ pods this hits the API server's max-request-bytes limit. Switch to Limit/Continue chunked listing with pre-allocated Items slices. Same data, same cache, bounded API calls.
…erailed#3986) Extract a shared parallelRender helper that fans work across NumCPU batch workers. Both Hydrate and GenericHydrate now delegate to it, eliminating duplicated concurrency logic. At 50k pods on a 10-core machine: Before: 216ms (50k goroutines + semaphore) After: 4ms (10 goroutines, no channels) Also pre-sizes sortLabels slices and removes dead poolSize constant.
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.
Skip UI rebuild when data hasn't changed (
internal/model/table.go)TableData.Diff()existed but was never actually used in the refresh path.Every 2 seconds the full pipeline ran (clone, filter, sort, reindex, rebuild
all cells) even when nothing in the cluster had changed. Now we keep a
previous snapshot and only fire
TableDataChangedwhenDiffreturns true.On idle clusters this skips ~30 unnecessary full rebuilds per minute.
Batch delete with single reindex (
internal/model1/row_event.go,internal/model1/table_data.go)TableData.Delete()was callingRowEvents.Delete()in a loop, and eachcall did a full
reindex()of the index map. This was O(k*n) for kdeletions from n rows. Added
DeleteBatch()that collects victims, filtersin one pass, and reindexes once. Benchmarked at 21x faster (1K rows)
to 82x faster (5K rows).
Cache
resource.MustParsein capacity sort (internal/model1/helpers.go)capacityToNumber()was callingresource.MustParseon every sortcomparison, roughly 2nlog(n) times per sort. Now parsed values are cached
in a map. Only unique capacity strings need actual parsing. About 3.4x
faster per comparison.
Avoid extra clone in
initSelectedColumn(internal/ui/table.go)initSelectedColumn()calledGetFilteredData()which did anotherPeek()(full deep clone) even though the caller already had the data.Added
initSelectedColumnWith(data)that accepts already-available dataand updated
doUpdate()to use it.Load plugins/hotkeys from disk once per view (
internal/view/browser.go)refreshActions()was callingpluginActions()andhotKeyActions()onevery refresh cycle (every 2s). Both read config files from disk. This
blocked the UI goroutine and was particularly bad on slow filesystems
(NFS, network mounts). Now they load once when the browser starts and
the cached actions are reused for subsequent refreshes.
Column navigation without full table rebuild (
internal/ui/table.go)moveSelectedColumn()(Shift+Left/Right) was callingRefresh()whichrebuilt the entire table. Added
refreshHeaders()that only updates theheader row cells. Goes from O(n*cols) to O(cols).