-
-
Notifications
You must be signed in to change notification settings - Fork 91
Added singleflight and deterministic ordering. #490
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
Conversation
smashing out non-deterministic issues once and for all, ordering maps and using singleflight and RWMutex.
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.
Pull request overview
This PR addresses non-deterministic behavior in reference extraction and resolution by introducing deterministic ordering through map key sorting, using singleflight for deduplication of concurrent lookups, and upgrading to RWMutex for better concurrency control.
- Implements deterministic ordering by sorting map keys before iteration across multiple index operations
- Adds singleflight pattern to deduplicate concurrent reference lookups and reduce contention
- Changes
refLockfromsync.Mutextosync.RWMutexto allow concurrent reads
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| go.mod | Adds golang.org/x/sync v0.19.0 dependency for singleflight support |
| go.sum | Updates checksums for new golang.org/x/sync dependency |
| index/index_model.go | Changes refLock from sync.Mutex to sync.RWMutex for improved concurrency |
| index/spec_index.go | Sorts polymorphic reference map keys before iteration for deterministic ordering |
| index/resolver.go | Sorts component schemas and security schemes keys before iteration for deterministic ordering |
| index/extract_refs.go | Major refactoring: introduces singleflight for deduplication, channel-based collection for reduced mutex contention, position-based sorting for deterministic ordering, and adds locateRef helper function |
| index/determinism_benchmark_test.go | Adds regression tests and benchmarks to verify consistent deterministic ordering across multiple runs |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #490 +/- ##
==========================================
+ Coverage 99.58% 99.59% +0.01%
==========================================
Files 175 175
Lines 21641 21700 +59
==========================================
+ Hits 21552 21613 +61
+ Misses 56 55 -1
+ Partials 33 32 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
added some better docs too.
Reported on discord. params were being dropped on render because the skip flag was bugging things out.
smashing out non-deterministic issues once and for all, ordering maps and using singleflight and RWMutex.