Skip to content

Commit

Permalink
Merge pull request #18093 from fengxue-IS/mac-time
Browse files Browse the repository at this point in the history
Updates Continuation profiling to use j9time_hires_clock
  • Loading branch information
babsingh committed Sep 11, 2023
2 parents 5c84d87 + aff8e87 commit 50a4e94
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
8 changes: 4 additions & 4 deletions runtime/vm/ContinuationHelpers.cpp
Expand Up @@ -43,7 +43,7 @@ createContinuation(J9VMThread *currentThread, j9object_t continuationObject)
BOOLEAN result = TRUE;
J9VMContinuation *continuation = NULL;
#if defined(J9VM_PROF_CONTINUATION_ALLOCATION)
I_64 start = j9time_nano_time();
I_64 start = j9time_hires_clock();
#endif /* defined(J9VM_PROF_CONTINUATION_ALLOCATION) */

/* First check if local cache is available. */
Expand Down Expand Up @@ -78,13 +78,13 @@ createContinuation(J9VMThread *currentThread, j9object_t continuationObject)
}
}
#if defined(J9VM_PROF_CONTINUATION_ALLOCATION)
vm->avgCacheLookupTime += j9time_nano_time() - start;
vm->avgCacheLookupTime += (I_64)j9time_hires_delta(start, j9time_hires_clock(), OMRPORT_TIME_DELTA_IN_NANOSECONDS);
#endif /* defined(J9VM_PROF_CONTINUATION_ALLOCATION) */

/* No cache found, allocate new continuation structure. */
if (NULL == continuation) {
#if defined(J9VM_PROF_CONTINUATION_ALLOCATION)
start = j9time_nano_time();
start = j9time_hires_clock();
#endif /* defined(J9VM_PROF_CONTINUATION_ALLOCATION) */
J9JavaStack *stack = NULL;
J9SFJNINativeMethodFrame *frame = NULL;
Expand Down Expand Up @@ -129,7 +129,7 @@ createContinuation(J9VMThread *currentThread, j9object_t continuationObject)
continuation->stackObject->isVirtual = TRUE;

#if defined(J9VM_PROF_CONTINUATION_ALLOCATION)
I_64 totalTime = (I_64)j9time_nano_time() - start;
I_64 totalTime = (I_64)j9time_hires_delta(start, j9time_hires_clock(), OMRPORT_TIME_DELTA_IN_NANOSECONDS);
if (totalTime > 10000) {
vm->slowAlloc += 1;
vm->slowAllocAvgTime += totalTime;
Expand Down
21 changes: 11 additions & 10 deletions runtime/vm/jvminit.c
Expand Up @@ -6367,16 +6367,17 @@ runExitStages(J9JavaVM* vm, J9VMThread* vmThread)

#if defined(J9VM_PROF_CONTINUATION_ALLOCATION)
if (0 < (vm->t1CacheHit + vm->t2CacheHit + vm->fastAlloc + vm->slowAlloc)) {
printf("\nTotal Continuation entries: %u\n", vm->t1CacheHit + vm->t2CacheHit + vm->fastAlloc + vm->slowAlloc);
printf("\nCache Hits: %u", vm->t1CacheHit + vm->t2CacheHit);
printf("\n T1 Cache Hits: %u", vm->t1CacheHit);
printf("\n T2 Cache Hits: %u", vm->t2CacheHit);
printf("\nCache Miss: %u", vm->fastAlloc + vm->slowAlloc);
printf("\n Fast Alloc (<10000ns): %u", vm->fastAlloc);
printf("\n Avg Fast Alloc Time: %ldns", (vm->fastAlloc > 0 ? (vm->fastAllocAvgTime / (I_64)vm->fastAlloc) : 0));
printf("\n Slow Alloc (>10000ns): %u", vm->slowAlloc);
printf("\n Avg Slow Alloc Time: %ldns", (vm->slowAlloc > 0 ? (vm->slowAllocAvgTime / (I_64)vm->slowAlloc) : 0));
printf("\nAvg Cache Lookup Time: %ldns\n", (vm->avgCacheLookupTime / (I_64)(vm->t1CacheHit + vm->t2CacheHit + vm->fastAlloc + vm->slowAlloc)));
PORT_ACCESS_FROM_JAVAVM(vm);
j9tty_printf(PORTLIB, "\nTotal Continuation entries: %u\n", vm->t1CacheHit + vm->t2CacheHit + vm->fastAlloc + vm->slowAlloc);
j9tty_printf(PORTLIB, "\nCache Hits: %u", vm->t1CacheHit + vm->t2CacheHit);
j9tty_printf(PORTLIB, "\n T1 Cache Hits: %u", vm->t1CacheHit);
j9tty_printf(PORTLIB, "\n T2 Cache Hits: %u", vm->t2CacheHit);
j9tty_printf(PORTLIB, "\nCache Miss: %u", vm->fastAlloc + vm->slowAlloc);
j9tty_printf(PORTLIB, "\n Fast Alloc (<10000ns): %u", vm->fastAlloc);
j9tty_printf(PORTLIB, "\n Avg Fast Alloc Time: %lldns", (vm->fastAlloc > 0 ? (vm->fastAllocAvgTime / (I_64)vm->fastAlloc) : 0));
j9tty_printf(PORTLIB, "\n Slow Alloc (>10000ns): %u", vm->slowAlloc);
j9tty_printf(PORTLIB, "\n Avg Slow Alloc Time: %lldns", (vm->slowAlloc > 0 ? (vm->slowAllocAvgTime / (I_64)vm->slowAlloc) : 0));
j9tty_printf(PORTLIB, "\nAvg Cache Lookup Time: %lldns\n", (vm->avgCacheLookupTime / (I_64)(vm->t1CacheHit + vm->t2CacheHit + vm->fastAlloc + vm->slowAlloc)));
}
#endif /* defined(J9VM_PROF_CONTINUATION_ALLOCATION) */

Expand Down

0 comments on commit 50a4e94

Please sign in to comment.