chore(matching): introduce task list registry#7720
chore(matching): introduce task list registry#7720dkrotx merged 1 commit intocadence-workflow:masterfrom
Conversation
c6f55c9 to
fb1239a
Compare
Abstracting the way task-lists are managed simplifies matcher: it doesn't need to care about how task-lists managers are stored, retrieved and deleted and don't need to care about locks anymore. In addition, this brings ability to introduce optimized views (like per-domain or per-shard-name) transparently (preserving the same interface). This will avoid quadratic complexity in shard-processor' functions which previously had to iterate over the entire list of task list managers for every single shard. Which could greatly impact performance in production where we have thousands of task-lists in a single matching instance. Signed-off-by: Jan Kisel <dkrot@uber.com>
fb1239a to
0cbb813
Compare
Code Review ✅ Approved 3 resolved / 3 findingsClean refactoring that properly encapsulates task list management into a well-designed ManagerRegistry. All three previously identified issues (redundant name check, off-by-one in String(), nil mockRegistry in test helper) have been resolved in the current code. ✅ 3 resolved✅ Bug: Test helper uses nil mockRegistry instead of local variable
✅ Quality: Redundant name check after ManagersByTaskListName filter
✅ Edge Case: Off-by-one: String() now prints 1001 items instead of 1000
OptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change:
Was this helpful? React with 👍 / 👎 | Gitar |
| e.taskListsLock.Lock() | ||
| if result, ok := e.taskLists[*taskList]; ok { | ||
| e.taskListsLock.Unlock() | ||
| e.taskListCreationLock.Lock() |
There was a problem hiding this comment.
Can we move the task list creation logic into the registry so that the synchronization happens in that component? We can remove this lock then.
There was a problem hiding this comment.
I thought about this originally, but task creation / initialisation is quite big by itself and has a lot of dependencies on engine.
I think this lock is OK since we need to guard task-creation anyway. I can do a small refactoring afterwards to have this lock in defer, though, so it's only mentioned once with a very clear scope. But currently I kept this exactly as the lock (for taskLists) we had previously.
What changed?
First step (refactoring) for #7712.
Abstracting the way task-lists are managed by introducing a manager registry.
Why?
Abstracting the way task-lists are managed simplifies matcher: it
doesn't need to care how task-lists managers are stored, retrieved
and deleted and don't need to care about the locks anymore.
In addition, this brings ability to introduce optimized views (like per-domain or
per-shard-name) transparently (preserving the same interface). This will
avoid quadratic complexity in shard-processor' functions which
previously had to iterate over the entire list of task list managers for every single shard.
This should greatly impact performance in production where we have
thousands of task-lists in a single matching instance.
Potential risks
None, this should be a transparent optimisation
Release notes
Documentation Changes
Reviewer Validation
PR Description Quality (check these before reviewing code):
go testinvocation)