8316927: JFR: Move shouldCommit check earlier for socket events

Reviewed-by: alanb, dfuchs, mgronlun
This commit is contained in:
Erik Gahlin 2023-10-17 13:11:52 +00:00
parent 5ca1beb30e
commit 6aa837eee6
5 changed files with 49 additions and 29 deletions

View file

@ -137,7 +137,10 @@ public class SocketEventOverhead {
try {
nbytes = write0();
} finally {
SocketWriteEvent.offer(start, nbytes, getRemoteAddress());
long duration = start - SocketWriteEvent.timestamp();
if (SocketWriteEvent.shouldCommit(duration)) {
SocketWriteEvent.emit(start, duration, nbytes, getRemoteAddress());
}
}
return nbytes;
}
@ -155,7 +158,10 @@ public class SocketEventOverhead {
try {
nbytes = read0();
} finally {
SocketReadEvent.offer(start, nbytes, getRemoteAddress(), 0);
long duration = start - SocketReadEvent.timestamp();
if (SocketReadEvent.shouldCommit(duration)) {
SocketReadEvent.emit(start, duration, nbytes, getRemoteAddress(), 0);
}
}
return nbytes;
}