Posts

Showing posts from March, 2017

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 2: sim-outorder.c

sim-outorder implements a very detailed out-of-order issue superscalar processor with a two-level memory system and speculative execution support. This simulator is a performance simulator, tracking the latency of all pipeline operations. Let's have a look at SimpleScalar simulator's code related to iTLB. (Instruction Translation Lookaside Buffer) First, there are simulator options related to iTLB: /* register simulator-specific options */ void sim_reg_options(struct opt_odb_t *odb) { /* TLB options */ opt_reg_string(odb, "-tlb:itlb", "instruction TLB config, i.e., { |none}", &itlb_opt, "itlb:16:4096:4:l", /* print */TRUE, NULL); opt_reg_int(odb, "-tlb:lat", "inst/data TLB miss latency (in cycles)", &tlb_miss_lat, /* default */30, /* print */TRUE, /* format */NULL); } /* check simulator-specific option values */ void  sim_check_options(... ) { /* sim-outorder.c  line: 1098*/   /* u...

Building and Testing Rest services with Spring

I realized that I need to learn more on Spring Boot/Spring REST and integration testing stuff. Here it goes! Let us remember: Spring Boot project aims at making it easier to build Spring applications by eliminating the need for extensive configuration. With default settings, you can feel magic tricks like implementing your interface behind the scenes etc. About REST : Have you ever worked with SOAP? How did it feel? For me, it always felt like something wrong was going on. Something simpler is needed. Then I was able to see in practice that REST services offer cleaner solutions and with the great capabilities of Java platform and Spring, you have a far better structure. HTTP is the Platform You describe the relationships using URIs. For example, you access the Bookmark's of a User with: /alice/bookmarks Clients and services agree upon a mutually understood data representation. So we send HTTP GET/POST/DELETE requests. There is usually a status code about the result of ...

Sharpening Regex Skills

Image
I needed to revisit regexes and found this sites useful: https://regexone.com https://regex101.com/ (Regex debugger is cool) Below is a useful summary: Groups: Parsing XML.. Following code creates 2 groups, then references to group 1.          boolean matchFound = false;          Pattern r = Pattern.compile("<(.+)>([^<]+)</\\1>");          Matcher m = r.matcher(line);          while (m.find()) {              System.out.println(m.group(2));              matchFound = true;          }                    if ( ! matchFound) {              System.out.println("None");          }

Java Interview Preparation

https://blog.udemy.com/java-interview-questions/ 1- What is JVM? Why is Java called the ‘Platform Independent Programming Language’? 2. What is the Difference between JDK and JRE? 3. What does the ‘static’ keyword mean? 4. What are the Data Types supported by Java? What is Autoboxing and Unboxing? 5. What is the difference between STRINGBUFFER and STRING? 6. What is Function Over-Riding and Over-Loading in Java? 7. What is Constructors, Constructor Overloading in Java and Copy-Constructor? 8. What is Java Exception Handling? What is the difference between Errors, Unchecked Exception and Checked Exception? Throwable       Error ( serious problems that a reasonable application  should not try to catch, out of memory etc. )       Exception             Checked / Unchecked 10. What is the Difference between byte stream and Character streams? A stream is a way of sequentially accessing a file. A byte str...

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