-
Notifications
You must be signed in to change notification settings - Fork 0
Unified Storage Performance Optimizations #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: performance-optimization-baseline
Are you sure you want to change the base?
Unified Storage Performance Optimizations #1
Conversation
…#97529) * dont lazy init unified storage * Inits index when creating new resource server. Fixes trace propagation by passing span ctx. Update some logging. * Use finer grained cache locking when building indexes to speed things up. Locking the whole function was slowing things down. * formatting * linter fix * go mod * make update-workspace * fix workspaces check error * update dependency owner in mod file * wait 1 second before querying metrics * try with big timeout, see if fixes CI. Wont fail locally. * skips postgres integration test. Only fails in drone. Will fix later. * put delay back to 500 ms
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
Greptile OverviewConfidence Score: 2/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant Constructor as NewResourceServer
participant Server as server.Init()
participant Search as searchSupport.init()
participant Bleve as bleveBackend
participant Storage as SQL Backend
participant Watcher as Event Watcher
Note over Constructor: Initialization moved to constructor
Constructor->>Server: Call Init(ctx)
Server->>Search: search.init(ctx)
Note over Search: Parallel index building
Search->>Storage: GetResourceStats(ctx)
Storage-->>Search: Return stats
par For each resource type
Search->>Search: build(ctx, nsr, size, rv)
Search->>Bleve: BuildIndex(ctx, key, ...)
Note over Bleve: Lock moved after build
Bleve->>Bleve: Create index & build documents
Bleve->>Bleve: Lock cache & add index
Bleve-->>Search: Return index
end
Note over Search: RACE: TotalDocs called here
Search->>Bleve: TotalDocs()
Note over Bleve: Iterates cache WITHOUT lock
Bleve-->>Search: Return count
Search->>Storage: WatchWriteEvents(ctx)
Storage-->>Search: Event channel
Search->>Watcher: Start goroutine
Server->>Server: initWatcher()
Server-->>Constructor: Return initialized server
Note over Server: Operations no longer call Init()
Server->>Server: Create/Update/Delete/Read/List/Watch
Note over Server: Removed redundant Init() checks
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additional Comments (1)
-
pkg/storage/unified/search/bleve.go, line 144-154 (link)logic: Race condition:
TotalDocs()iterates overb.cachewithout holding a lock, whileBuildIndexmodifies the cache on line 137-139. This can cause concurrent map read/write panics when called during initialization.
5 files reviewed, 1 comment
Test 10
Replicated from ai-code-review-evaluation/grafana-greptile#10