-
Notifications
You must be signed in to change notification settings - Fork 277
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
Do not use synchronised checks during event processing #363
base: master
Are you sure you want to change the base?
Do not use synchronised checks during event processing #363
Conversation
Using synchronised checks during event processing leads to contention on GerritWorker threads. Especially if lock is done on ToGerritRunListener. So, to speed up the processing we need to get rid of `isProjectTriggeredAndIncomplete`. `isProjectTriggeredAndIncomplete` can be replaced by `isTriggered` and `isBuilding`. That transforms the previos version of check to `(isTriggered && isBuilding) || isTriggered`. So, it's absolutely safe to keep `isTriggered` only. After that plugin itself does not use `isProjectTriggeredAndIncomplete`.
Parallel triggering of multiple jobs for the same event should not produce any issues as there is synchronization in onStarted method as well. But in same time onTriggered also is part of initial event processing. That's why it's important to not have a lock here.
e922ff2
to
37b2b42
Compare
//TODO stop builds for earlier patch-sets on same change. | ||
memory.triggered(event, project); | ||
if (event instanceof GerritEventLifecycle) { | ||
((GerritEventLifecycle)event).fireProjectTriggered(project); | ||
} | ||
//Logging | ||
String name = null; |
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.
Why did you remove this?
@@ -328,18 +332,13 @@ protected void cleanUpGerritCauses(GerritCause firstFound, Run build) { | |||
* @param project the project that will be built. | |||
* @param event the event that caused the build to be scheduled. | |||
*/ | |||
public synchronized void onTriggered(Job project, GerritTriggeredEvent event) { | |||
public void onTriggered(Job project, GerritTriggeredEvent event) { | |||
//TODO stop builds for earlier patch-sets on same change. | |||
memory.triggered(event, project); | |||
if (event instanceof GerritEventLifecycle) { |
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.
This is a change that might have outside repercussions. The lifecycle listeners might have assumptions about owning the monitor when called (which is normal behavior in most listener cases that I've seen)
But I think I can live with that risk if this change is really needed.
Using synchronised checks during event processing leads to contention on
GerritWorker threads. Especially if lock is done on ToGerritRunListener.
So, to speed up the processing we need to get rid of
isProjectTriggeredAndIncomplete
.isProjectTriggeredAndIncomplete
can be replaced byisTriggered
andisBuilding
.That transforms the previos version of check to
(isTriggered && isBuilding) || isTriggered
.So, it's absolutely safe to keep
isTriggered
only.After that plugin itself does not use
isProjectTriggeredAndIncomplete
.Screenshot that shows that we were waiting for 2 minutes to parse 4 events.
![screen shot 2018-05-16 at 14 39 40](https://user-images.githubusercontent.com/4785672/40118857-5d7d94dc-591b-11e8-925a-360dfc37d903.png)