Skip to content

[FIXED JENKINS-36144] Borrow the SCMTrigger's queue#126

Merged
lanwen merged 6 commits intojenkinsci:masterfrom
stephenc:jenkins-36144
Jun 24, 2016
Merged

[FIXED JENKINS-36144] Borrow the SCMTrigger's queue#126
lanwen merged 6 commits intojenkinsci:masterfrom
stephenc:jenkins-36144

Conversation

@stephenc
Copy link
Member

@stephenc stephenc commented Jun 22, 2016

https://issues.jenkins-ci.org/browse/JENKINS-36144

@reviewbybees @jenkinsci/code-reviewers


This change is Reviewable

@ghost
Copy link

ghost commented Jun 22, 2016

This pull request originates from a CloudBees employee. At CloudBees, we require that all pull requests be reviewed by other CloudBees employees before we seek to have the change accepted. If you want to learn more about our process please see this explanation.

maximumThreads = count;
try {
Field getQueue = SCMTrigger.DescriptorImpl.class.getDeclaredField("queue");
getQueue.setAccessible(true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hack?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

of course... but after a more careful analysis I decided against that and rather just mirror the pool size... which sadly means you have two pools... but this does point that perhaps we should have an explicit pool for polling that plugins can use rather than the current status where each push notifier has to roll their own... with hillarious consequences

@jtnord
Copy link
Member

jtnord commented Jun 22, 2016

🐝 @stephenc I assume you are going to file a issue for the generic issue

but after a more careful analysis I decided against that and rather just mirror the pool size... which sadly means you have two pools... but this does point that perhaps we should have an explicit pool for polling that plugins can use rather than the current status where each push notifier has to roll their own... with hillarious consequences

@rsandell
Copy link
Member

🐝 A future further improvement could perhaps also be to not schedule the polling if the same repo and branch is already in the queue.

@KostyaSha
Copy link
Member

Queue skipping polling for the same project AFAIK

@KostyaSha
Copy link
Member

A future further improvement could perhaps also be to not schedule the polling if the same repo and branch is already in the queue.

Could you describe how queue works now?

@stephenc
Copy link
Member Author

return ALLOW_HOOKURL_OVERRIDE;
}

private static ThreadFactory threadFactory() {
Copy link
Member

@lanwen lanwen Jun 22, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should be method that returns executors - threadPoolWithCapacity(int)
(it allows to reduce complexity of checkThreadPoolSize)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see the value, seems like change for change's sake. The other method is not too complex whereas we'd need to add a three way test to use this as an executor service factory method

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think the complexity reduction in such simple way is "like change for change's sake". At minimal state it should be named as namedThreadFactory as of its simple shortcut.

@jtnord
Copy link
Member

jtnord commented Jun 22, 2016

🐛 as I think the Executor service has the potential to leak threads (at least temporarily until some GC kicks in, the point of which is non-deterministic)

@ghost
Copy link

ghost commented Jun 22, 2016

I think you need to look at queue.setExecutor

Sent from my iPhone

On 22 Jun 2016, at 20:36, James Nord notifications@github.com wrote:

🐛 as I think the Executor service has the potential to leak threads (at least temporarily until some GC kicks in, the point of which is non-deterministic)


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

You received this message because you are subscribed to the Google Groups "engineering-code-reviews" group.
To unsubscribe from this group and stop receiving emails from it, send an email to engineering-code-reviews+unsubscribe@cloudbees.com.
To post to this group, send email to engineering-code-reviews@cloudbees.com.
To view this discussion on the web visit https://groups.google.com/a/cloudbees.com/d/msgid/engineering-code-reviews/jenkinsci/github-plugin/pull/126/c227853208%40github.com.

@jtnord
Copy link
Member

jtnord commented Jun 22, 2016

Yes, my bad. 🐝

if (maximumThreads != count) {
maximumThreads = count;
queue.setExecutors(
(count == 0

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAJOR Remove those useless parentheses. rule

@dummy-lanwen-bot
Copy link

SonarQube analysis reported 1 issue:

  • MAJOR 1 major

Watch the comments in this conversation to review them.

@KostyaSha
Copy link
Member

Btw, the same queue i'm using in other trigger plugins. Is it possible to make queue public and place configuration in global config?

@ghost
Copy link

ghost commented Jun 23, 2016

That is the RFE against core that I filed BTW. What I may do is add a proxy implementation into SCM-API so that people can use against earlier cores

Sent from my iPhone

On 23 Jun 2016, at 21:09, Kanstantsin Shautsou notifications@github.com wrote:

Btw, the same queue i'm using in other trigger plugins. Is it possible to make queue public and place configuration in global config?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

You received this message because you are subscribed to the Google Groups "engineering-code-reviews" group.
To unsubscribe from this group and stop receiving emails from it, send an email to engineering-code-reviews+unsubscribe@cloudbees.com.
To post to this group, send email to engineering-code-reviews@cloudbees.com.
To view this discussion on the web visit https://groups.google.com/a/cloudbees.com/d/msgid/engineering-code-reviews/jenkinsci/github-plugin/pull/126/c228168540%40github.com.

@KostyaSha
Copy link
Member

@reviewbybees @stephenc relogin!

@stephenc
Copy link
Member Author

Nahh just depends which email I reply to!

@stephenc
Copy link
Member Author

Anyway, my phone is the holder of the 2FA for that account...

* Update the {@link java.util.concurrent.ExecutorService} instance.
*/
/*package*/
synchronized void checkThreadPoolSizeAndUpdateIfNecessary() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should be a test for this logic

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have lost any energy to continue this PR any further. I want to concentrate my time on the critical root cause, i.e. https://issues.jenkins-ci.org/browse/JENKINS-36147 which once implemented will mean we can rip out this code. If you want to add tests to this code which should be removed once I implement https://issues.jenkins-ci.org/browse/JENKINS-36147, feel free. I will not be updating this PR any further at this point.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would require updating core that is not good for this plugin. Or we can backport your core improvements after.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well my plan is to make the API available via scm-api without a core bump... and then on newer cores it either will revert to the core implementation (classloader priority) or the scm-api variant will use reflection to redirect to the core implementation

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However, it will take me a while to get that API right (as I don't want to end up with the same mistakes of the main Queue API and end up having to have a "big fat lock") so for now, to save users from commit storms killing their Jenkins, this fix would be good to have released.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ookay, i'll merge this. But this is an example of permanent state "will fix that better in future releases". It can't be finished while you've start do things right everywhere

@lanwen lanwen merged commit 10e991e into jenkinsci:master Jun 24, 2016
@stephenc stephenc deleted the jenkins-36144 branch December 12, 2016 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants