-
Notifications
You must be signed in to change notification settings - Fork 187
Singularity performance improvements #1702
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
…ests to be synchronous
Additional improvements:
Test updates:
|
@@ -421,13 +421,14 @@ private void deleteScheduledTasks(final Collection<SingularityPendingTask> sched | |||
} | |||
|
|||
private List<SingularityTaskId> getMatchingTaskIds(SingularityRequest request, SingularityDeployKey deployKey) { | |||
List<SingularityTaskId> activeTaskIdsFroRequest = leaderCache.getActiveTaskIdsForRequest(deployKey.getRequestId()); |
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.
Minor typo
} | ||
|
||
final long start = schedulerLock.lock(maybeTaskId.get().getRequestId(), "statusUpdate"); | ||
try { |
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.
Does it make sense to use callWithRequestLock()
here as well, and then make SingularitySchedulerLock#(lock|unlock)
private?
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.
yes, I think I had a different exception in here at one point and didn't refactor back to callWithRequestLock, thanks for finding that
} | ||
|
||
public long lock(String name) { | ||
public long lock(String requestId, String name) { |
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.
Could it be a good idea to accept the calling class here instead of a name, and then log out the class name in the trace logs below? Just to ensure that the names we pass when locking aren't arbitrary and are useful for tracing the flow of the scheduler.
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.
maybe even going as far as class#methodName could be useful for that logging
return System.currentTimeMillis(); | ||
} | ||
|
||
public void unlock(String name, long start) { | ||
LOG.info("{} - Unlocking ({})", name, JavaUtils.duration(start)); | ||
public void unlock(String requestId, String name, long start) { |
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.
Should be safe to make lock()
and unlock()
private now, and only allow the rest of the scheduler to interact via runWithRequestLock()
.
🚢 |
This is a first pass at updates to the scheduler internals to improve the speed of offer processing, status updates, and other processes that contend for the scheduler lock. The main theme here is parallelizing things that were previously sequential.
The biggest change in this PR that still needs additional testing is the removal of the global scheduler lock in favor of many smaller locks. There are now three classes of locks. One lock for the scheduler state, one for accessing/processing offers, and one ConcurrentHashMap of request locks such that only one process can be updating the state or tasks for a request at a time. This change lets offers, status updates, deploy checks, pending request processes, and more run in parallel.
Other changes include:
The request level locking along with our proxy to leader code opens us up to some better UI experiences in the future as well. Instead of waiting for pollers, we can more easily execute many actions like bounces or task kills at request time and immediately return results to the UI.
Further TODOs include finishing off fixing tests, running additional benchmarks of the new code, and cleaning up some rough edges (like hard coded values that should instead be configurable)
@darcatron @baconmania @pschoenfelder