Observability of the Java Virtual Machine

Image
The JVM is one of the most observable runtimes. It provides us lots of tools for troubleshooting a JVM application in production. 1. Thread observability Threads are how the JVM actually does work. When something is wrong in production, the symptom is almost always a thread: stopped, blocked, leaking etc. Thread dumps work on any JVM with no  instrumentation, no agents, no restarts. <Example project link with /threaddump endpoint>         // (1) Deadlock — two threads grab the same pair of locks in opposite order.         new Thread(() -> grab(LOCK_A, LOCK_B), "deadlock-A-then-B").start();         new Thread(() -> grab(LOCK_B, LOCK_A), "deadlock-B-then-A").start(); http://localhost:8080/actuator/threaddump To list the JVMS, we can use the command below. PS C:\observe-jvm> jps -lv 25296 jdk.jcmd/sun.tools.jps.Jps -Dapplication.home=C:\Program Files\Microsoft\jdk-21.0.3.9-hotspot -Xms8m -Djdk.module.main=...

SimpleScalar Simulator - Part 3

Problem: Can you detect when current page is left for the instruction stream?

Inside cache.c we know if the hit is fast (same block) or slow.

/*cache.c  line 533*/
printf("Cache tagset: %d  Last tagset: %d\n", CACHE_TAGSET(cp, addr), cp->last_tagset);

  /* check for a fast hit: access to same block */
  if (CACHE_TAGSET(cp, addr) == cp->last_tagset)
    {

      printf("Same block hit!\n");

      /* hit in the same block */
      blk = cp->last_blk;
      goto cache_fast_hit;
    }

printf("Slow hit or miss!\n");

Before cache access, we control the nature of the access and set the iTLB power mode:

          if (itlb)
  {

   if (CACHE_TAGSET(itlb, IACOMPRESS(fetch_regs_PC)) == itlb->last_tagset) {
       low_power = 1;
       ++low_power_count;
   } else {
                low_power = 0;
                ++normal_power_count;
   }

   printf("Low count = %d, normal count = %d\n", low_power_count, normal_power_count);

            printf("Low power ratio: %f\n", (double)low_power_count / (low_power_count + normal_power_count));

     /* access the I-TLB*/
     tlb_lat = cache_access(itlb, Read, IACOMPRESS(fetch_regs_PC), NULL, ISCOMPRESS(sizeof(md_inst_t)), sim_cycle, NULL, NULL);
  
printf("Address is: %d  Size is: %d  Cycle is: %d\n", IACOMPRESS(fetch_regs_PC), ISCOMPRESS(sizeof(md_inst_t)), sim_cycle);

After running my hello.c program, the result is:

Low count = 9010, normal count = 159
Low power ratio: 0.982659



Comments

Popular posts from this blog

The WeakReference class, monitoring memory leak and garbage collection in a Java application

Simplescalar Simulator - Part 2: sim-outorder.c

Notes on Java Performance