Skip to content

Commit

Permalink
Merge PR #297: Swap tracing buffers for blocked threads
Browse files Browse the repository at this point in the history
  • Loading branch information
smarr committed Jun 3, 2019
2 parents f5e965f + 6b170c6 commit d92e50e
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 12 deletions.
14 changes: 13 additions & 1 deletion src/tools/concurrency/TracingBackend.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.LockSupport;

import javax.management.Notification;
import javax.management.NotificationEmitter;
Expand Down Expand Up @@ -274,6 +275,10 @@ public static final void forceSwapBuffers() {
} else if (t.swapTracingBufferIfThreadSuspendedInDebugger()) {
runningThreads -= 1;
result[i] = null;
} else if (isBlockedInJava(t)) {
runningThreads -= 1;
result[i] = null;
t.getBuffer().swapStorage();
}
}
}
Expand All @@ -290,6 +295,11 @@ public static final void forceSwapBuffers() {
}
}

private static boolean isBlockedInJava(final Thread t) {
Object blocker = LockSupport.getBlocker(t);
return blocker != null;
}

public static final long[] getStatistics() {
if (currentWorkerThread == null) {
return new long[] {0, 0};
Expand Down Expand Up @@ -394,7 +404,9 @@ protected TraceWorkerThread(final byte snapshotVersion) {
this.snapshotVersion = snapshotVersion;
}

protected TraceWorkerThread() {}
protected TraceWorkerThread() {
super("TraceWorkerThread");
}

private BufferAndLimit tryToObtainBuffer() {
BufferAndLimit buffer;
Expand Down
41 changes: 30 additions & 11 deletions tools/kompos/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -1,29 +1,48 @@
{
"version": "0.1.0",
"command": "npm",
"isShellCommand": true,
"showOutput": "always",
"version": "2.0.0",
"echoCommand": true,
"suppressTaskName": true,
"options": {
"cwd": "${workspaceRoot}"
},
"tasks": [
{
"taskName": "continuous compilation",
"type": "process",
"group": "build",
"label": "continuous compilation",
"command": "npm",
"isBackground": true,
"args": ["run", "watch"],
"problemMatcher": "$tsc-watch"
"problemMatcher": "$tsc-watch",
"presentation": {
"reveal": "silent",
"panel": "shared"
}
},
{
"taskName": "test",
"type": "process",
"label": "test",
"group": "test",
"command": "npm",
"isBackground": false,
"args": []
"args": ["test"],
"presentation": {
"echo": true,
"reveal": "always",
"focus": true,
"clear": true
}
},
{
"taskName": "format",
"type": "process",
"command": "npm",
"label": "format",
"group": "build",
"isBackground": false,
"args": ["run", "format"]
"args": ["run", "format"],
"presentation": {
"reveal": "silent",
"panel": "shared"
}
}
]
}

0 comments on commit d92e50e

Please sign in to comment.