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=...

More on Virtual Memory and TLB


Below is a series of videos on virtual memory:

https://www.youtube.com/watch?v=KNUJhZCQZ9c
  • Virtual memory is a layer of indirection. Without virtual memory the program address would be equal to the RAM address. 
  • Discs are 1000x slower than RAM.
  • What happens if a page is not on RAM? 
    • Page table tells that the page is on disc.
    • Hardware (CPU) generates a page fault exception.
    • This exception will be picked up by the operating system. (page fault handler)
    • Operating system kicks out (evicts) another page from RAM and writes it to disc
    • If the page is dirty, it needs to be written back to disc first.
    • Then OS reads the page from disk and puts it in RAM
    • Then OS updates the page table to map the new page
    • Finally OS jumps back to the instruction that caused the page fault
    • A page fault is the slowest possible thing that can happen to a computer. (except for human interaction)
  • Some operating sytems do not use paging:
    • iOS kills the program if it uses too much memory.
  • TLB should be fast, we have to use it for every memory access. Do there are seperate TLBs for instructions and data (iTLB/dTLB) 

  • For iTLB, if the CPU reads the instuctions from the same page, we can put the iTLB to low leakage mode, which decreases the energy usage.
    • But how will we know when the current page will be left? (So that we switch the iTLB to the normal energy mode)
    • First step: run SPEC benchmarks on normal SuperScalar configuration. 
    • Second step: How to implement low energy mode for iTLB.
      • Put it on low energy mode all the time, and see the benchmark results.
    • Third Step: How to guess the time when the current page is left. Implement.

Lecture on simulators:

https://www.youtube.com/watch?v=yfKk4GcBMi8&t=206s

An article on SimpleScalar:

http://www.dre.vanderbilt.edu/~sutambe/documents/pubs/wcre2004.pdf

Modified Version of SimpleScalar:

https://github.com/aivus/SimpleScalar

Visual C++ notes:

http://stackoverflow.com/questions/16883037/remove-secure-warnings-crt-secure-no-warnings-from-projects-by-default-in-vis

Library Directories:
C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10150.0\ucrt\x86

C/C++ Additional Include Libraries:
C:\Program Files (x86)\Windows Kits\10\Include\10.0.10150.0\ucrt


http://stackoverflow.com/questions/31736361/visual-studio-2015-gives-me-errors-upon-creating-a-simple-test-console-program

Building simplescalar on linux is easy as described in readme file.





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