-
-
Notifications
You must be signed in to change notification settings - Fork 272
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
[JENKINS-38692] Add extra logging to help diagnosing Thread spike. #116
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -292,6 +292,10 @@ public final void removeInterestConnect(SelectionKey key) { | |
* @param key the key. | ||
*/ | ||
public final void addInterestRead(SelectionKey key) { | ||
if (LOGGER.isLoggable(Level.FINEST)) { | ||
// TODO probably want some more info about the key here... | ||
LOGGER.log(Level.FINEST, "Scheduling adding OP_READ to {0}", key); | ||
} | ||
interestOps.add(new InterestOps(key, SelectionKey.OP_READ, 0)); | ||
selector.wakeup(); | ||
} | ||
|
@@ -302,6 +306,10 @@ public final void addInterestRead(SelectionKey key) { | |
* @param key the key. | ||
*/ | ||
public final void removeInterestRead(SelectionKey key) { | ||
if (LOGGER.isLoggable(Level.FINEST)) { | ||
// TODO probably want some more info about the key here... | ||
LOGGER.log(Level.FINEST, "Scheduling removing OP_READ to {0}", key); | ||
} | ||
interestOps.add(new InterestOps(key, 0, SelectionKey.OP_READ)); | ||
selector.wakeup(); | ||
} | ||
|
@@ -312,6 +320,10 @@ public final void removeInterestRead(SelectionKey key) { | |
* @param key the key. | ||
*/ | ||
public final void addInterestWrite(SelectionKey key) { | ||
if (LOGGER.isLoggable(Level.FINEST)) { | ||
// TODO probably want some more info about the key here... | ||
LOGGER.log(Level.FINEST, "Scheduling adding OP_WRITE to {0}", key); | ||
} | ||
interestOps.add(new InterestOps(key, SelectionKey.OP_WRITE, 0)); | ||
selector.wakeup(); | ||
} | ||
|
@@ -322,6 +334,10 @@ public final void addInterestWrite(SelectionKey key) { | |
* @param key the key. | ||
*/ | ||
public final void removeInterestWrite(SelectionKey key) { | ||
if (LOGGER.isLoggable(Level.FINEST)) { | ||
// TODO probably want some more info about the key here... | ||
LOGGER.log(Level.FINEST, "Scheduling removing OP_WRITE to {0}", key); | ||
} | ||
interestOps.add(new InterestOps(key, 0, SelectionKey.OP_WRITE)); | ||
selector.wakeup(); | ||
} | ||
|
@@ -480,7 +496,11 @@ public final void run() { | |
* Process the scheduled tasks list. | ||
*/ | ||
private void processScheduledTasks() { | ||
if (scheduledTasks.size() > 4) { | ||
final int tasksWaiting = scheduledTasks.size(); | ||
if (LOGGER.isLoggable(Level.FINEST)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. test saves auto-boxing and GC churn |
||
LOGGER.log(Level.FINEST, "{0} scheduled tasks to process", tasksWaiting); | ||
} | ||
if (tasksWaiting > 4) { | ||
// DelayQueue.drainTo is more efficient than repeated polling | ||
// but we don't want to create the ArrayList every time the selector loops | ||
List<DelayedRunnable> scheduledWork = new ArrayList<DelayedRunnable>(); | ||
|
@@ -690,6 +710,14 @@ public void run() { | |
final String oldName = workerThread.getName(); | ||
try { | ||
workerThread.setName("IOHub#" + _id + ": Worker[channel:" + key.channel() + "] / " + oldName); | ||
if (LOGGER.isLoggable(Level.FINEST)) { | ||
// TODO probably want some more info about the key here... | ||
LOGGER.log(Level.FINEST, "Calling listener.ready({0}, {1}, {2}, {3}) for channel {4}", | ||
new Object[] { (ops & SelectionKey.OP_ACCEPT) == SelectionKey.OP_ACCEPT, | ||
(ops & SelectionKey.OP_CONNECT) == SelectionKey.OP_CONNECT, | ||
(ops & SelectionKey.OP_READ) == SelectionKey.OP_READ, | ||
(ops & SelectionKey.OP_WRITE) == SelectionKey.OP_WRITE, key.channel() }); | ||
} | ||
listener.ready((ops & SelectionKey.OP_ACCEPT) == SelectionKey.OP_ACCEPT, | ||
(ops & SelectionKey.OP_CONNECT) == SelectionKey.OP_CONNECT, | ||
(ops & SelectionKey.OP_READ) == SelectionKey.OP_READ, | ||
|
@@ -742,11 +770,17 @@ private InterestOps(SelectionKey key, int add, int remove) { | |
} | ||
|
||
/** | ||
* Returns the desired {@link SelectionKey#interestOps()}. | ||
* Returns {@code true} if the desired {@link SelectionKey#interestOps()} was potentially updated. | ||
* This method will generally return {@code false} only if the {@link SelectionKey} is no longer valid when the request runs. | ||
* | ||
* @return the desired {@link SelectionKey#interestOps()}. | ||
* @return {@code true} if the desired {@link SelectionKey#interestOps()} was potentially modified. | ||
*/ | ||
private boolean interestOps() { | ||
if (LOGGER.isLoggable(Level.FINEST)) { | ||
// TODO probably want some more info about the key here... | ||
LOGGER.log(Level.FINEST, "updating interest ops &={0} |={1} on {2} with existing ops {3} on key {4}", | ||
new Object[] { opsAnd, opsOr, key.channel(), key.interestOps(), key }); | ||
} | ||
if (key.isValid()) { | ||
key.interestOps((key.interestOps() & opsAnd) | opsOr); | ||
return true; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I thought you were going to pull this out to a class level constant initialized on classloading so that hotspot can reduce to no-op
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.
I wouldn't have added the if here. It's adding verbosity for no reason in that case. I suppose you added that because of the TODO below...
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.
@stephenc so the performance without inlining didn't seem to bad - and if we leave it as is then you can use the standard Jenkins UI (or JMX for agents) to change the logging level
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 - easier to do it now and know the performance hit - also prevents someone forgetting to do it later.