Skip to content
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

[Wisp] Port WispCounterMXBean and PerfCounterMonitor to JDK17. #98

Merged
merged 1 commit into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,7 @@ protected void closeEngineSelector() {
@Override
public void shutdown() {
hasBeenShutdown = true;
deRegisterPerfCounter();
if (WispEngine.current().current == threadTask) {
doShutdown();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ public void shutdown() {
return;
}
hasBeenShutdown = true;
deRegisterPerfCounter();
group.scheduler.executeWithCarrierThread(new StealAwareRunnable() {
@Override
public void run() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ public void run() {
engine.group = group;
engine.carrier = this;
group.carrierEngines.add(engine);
engine.registerPerfCounter();
runCarrier(engine);
} finally {
WispEngine.carrierThreads.remove(thread);
Expand Down Expand Up @@ -461,6 +462,8 @@ public void run() {
last = cs[i];
}
carriers = cs;
Wisp2Engine engine = (Wisp2Engine) JLA.getWispEngine(thread);
engine.deRegisterPerfCounter();
}
}

Expand Down
118 changes: 86 additions & 32 deletions src/java.base/share/classes/com/alibaba/wisp/engine/WispCounter.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package com.alibaba.wisp.engine;

final class WispCounter {
final public class WispCounter {

private long switchCount = 0;

private long waitTimeTotal = 0;

private long runningTimeTotal = 0;

private long completeTaskCount = 0;
private long completedTaskCount = 0;

private long createTaskCount = 0;

Expand All @@ -26,18 +26,26 @@ final class WispCounter {

private long totalEnqueueTime = 0;

private long maxEnqueueTime = 0;

private long enqueueCount = 0;

private long totalExecutionTime = 0;

private long maxExecutionTime = 0;

private long executionCount = 0;

private long totalWaitSocketIOTime = 0;

private long maxWaitSocketIOTime = 0;

private long waitSocketIOCount = 0;

private long totalBlockingTime = 0;

private long maxBlockingTime = 0;

private long unparkFromJvmCount = 0;

WispEngine engine;
Expand All @@ -46,55 +54,56 @@ private WispCounter(WispEngine engine) {
this.engine = engine;
}

boolean getRunningState() {
return engine.isRunning();
public boolean getRunningState() {
WispEngine e = engine;
return e != null ? e.isRunning() : false;
}

void incrementSwitchCount() {
switchCount++;
}

long getSwitchCount() {
public long getSwitchCount() {
return switchCount;
}

void incrementCompleteTaskCount() {
completeTaskCount++;
completedTaskCount++;
}

void incrementRunningTimeTotal(long value) {
runningTimeTotal += value;
}

long getRunningTimeTotal() {
public long getRunningTimeTotal() {
return runningTimeTotal;
}

void incrementWaitTime(long value) {
waitTimeTotal += value;
}

long getWaitTimeTotal() {
public long getWaitTimeTotal() {
return waitTimeTotal;
}

long getCompleteTaskCount() {
return completeTaskCount;
public long getCompletedTaskCount() {
return completedTaskCount;
}

void incrementCreateTaskCount() {
createTaskCount++;
}

long getCreateTaskCount() {
public long getCreateTaskCount() {
return createTaskCount;
}

void incrementParkCount() {
parkCount++;
}

long getParkCount() {
public long getParkCount() {
return parkCount;
}

Expand All @@ -103,120 +112,165 @@ void incrementUnparkInterruptSelectorCount() {
unparkInterruptSelectorCount++;
}

long getUnparkInterruptSelectorCount() {
public long getUnparkInterruptSelectorCount() {
return unparkInterruptSelectorCount;
}

void incrementSelectableIOCount() {
selectableIOCount++;
}

long getSelectableIOCount() {
public long getSelectableIOCount() {
return selectableIOCount;
}

void incrementTimeOutCount() {
timeOutCount++;
}

long getTimeOutCount() {
public long getTimeOutCount() {
return timeOutCount;
}

void incrementEventLoopCount() {
eventLoopCount++;
}

long getEventLoopCount() {
public long getEventLoopCount() {
return eventLoopCount;
}

void incrementTotalEnqueueTime(long value) {
totalEnqueueTime += value;
enqueueCount++;
if (value > maxEnqueueTime) {
maxEnqueueTime = value;
}
}

long getTotalEnqueueTime() {
public long getTotalEnqueueTime() {
return totalEnqueueTime;
}

long getEnqueueCount() {
public long getEnqueueCount() {
return enqueueCount;
}

void incrementTotalExecutionTime(long value) {
totalExecutionTime += value;
executionCount++;
if (value > maxExecutionTime) {
maxExecutionTime = value;
}
}

long getTotalExecutionTime() {
public long getTotalExecutionTime() {
return totalExecutionTime;
}

long getExecutionCount() {
public long getExecutionCount() {
return executionCount;
}

void incrementTotalWaitSocketIOTime(long value) {
totalWaitSocketIOTime += value;
waitSocketIOCount++;
if (value > maxWaitSocketIOTime) {
maxWaitSocketIOTime = value;
}
}

long getTotalWaitSocketIOTime() {
public long getTotalWaitSocketIOTime() {
return totalWaitSocketIOTime;
}

long getWaitSocketIOCount() {
public long getWaitSocketIOCount() {
return waitSocketIOCount;
}

void incrementTotalBlockingTime(long value) {
totalBlockingTime += value;
unparkCount++;
if (value > maxBlockingTime) {
maxBlockingTime = value;
}
}

long getTotalBlockingTime() {
public long getTotalBlockingTime() {
return totalBlockingTime;
}

long getUnparkCount() {
public long getUnparkCount() {
return unparkCount;
}

public long getQueueLength() {
return engine.getTaskQueueLength();
public long getTaskQueueLength() {
WispEngine e = engine;
return e != null ? e.getTaskQueueLength() : 0;
}

long getNumberOfRunningTasks() {
return engine.getRunningTaskCount();
public long getRunningTaskCount() {
WispEngine e = engine;
return e != null ? e.getRunningTaskCount() : 0;
}

void incrementUnparkFromJvmCount() {
unparkFromJvmCount++;
}

long getUnparkFromJvmCount() {
public long getUnparkFromJvmCount() {
return unparkFromJvmCount;
}

public long getMaxEnqueueTime() {
return maxEnqueueTime;
}

public long getMaxExecutionTime() {
return maxExecutionTime;
}

public long getMaxWaitSocketIOTime() {
return maxWaitSocketIOTime;
}

public long getMaxBlockingTime() {
return maxBlockingTime;
}

WispCounter() {}

void assign(WispCounter counter) {
createTaskCount = counter.createTaskCount;
completeTaskCount = counter.completeTaskCount;
createTaskCount = counter.createTaskCount;
completedTaskCount = counter.completedTaskCount;
totalEnqueueTime = counter.totalEnqueueTime;
enqueueCount = counter.enqueueCount;
maxEnqueueTime = counter.maxEnqueueTime;
totalExecutionTime = counter.totalExecutionTime;
executionCount = counter.executionCount;
maxExecutionTime = counter.maxExecutionTime;
totalBlockingTime = counter.totalBlockingTime;
unparkCount = counter.unparkCount;
maxBlockingTime = counter.maxBlockingTime;
totalWaitSocketIOTime = counter.totalWaitSocketIOTime;
waitSocketIOCount = counter.waitSocketIOCount;
maxWaitSocketIOTime = counter.maxWaitSocketIOTime;
switchCount = counter.switchCount;
unparkFromJvmCount = counter.unparkFromJvmCount;
}

public static WispCounter create(WispEngine engine) {
void resetMaxValue() {
maxEnqueueTime = 0;
maxExecutionTime = 0;
maxWaitSocketIOTime = 0;
maxBlockingTime = 0;
}

void cleanup() {
engine = null;
}

static WispCounter create(WispEngine engine) {
return new WispCounter(engine);
}
}
Loading
Loading