Denis Makogon Profile picture
Aug 2 13 tweets 4 min read
#JavaTuesdayThread

Today I’d like to speak a bit regarding #Java Flight Recorder (JFR) and how far you can get with it. #OpenJDK #JFR #JMC
So, as you may know, a few releases ago, Java developers were able to create, publish, and react to particular JDK events, also known as JFR.
The first and most important JFR feature is that the whole JDK is pierced with tons of JFR events. You can enable them to get most of the information about what’s going on with the JVM.
Another valuable feature is the ability to create custom events of different nature. The JDK JFR framework does not enforce developers regarding the type and the nature of events, so, most events are free-form classes that extend "jdk.jfr.Event" class.
Recently, I decided to explore how complicated it is to implement a resource state-tracking event. Meaning, that a certain entity will emit events based on some state of an object through its lifecycle.
In my case the idea was to track how many actively running threads are in the thread pool provided in the form of an executor to the HTTP server whose purpose is to run long-running math operations like FIPS-140-3 tests against certain bite-sequences:
The biggest challenge is that ExecutorService doesn’t provide API methods to know how many threads are up and running at a particular moment. So, to bypass the problem, we’d have to wrap an executor accompanied by an atomic counter:
In order to make the most negligible impact against executor service and the code running in threads, the easiest trick is to enhance the executor with a service thread that will process the value of an atomic counter and build stats out of it:
By enabling this event in the recording stream, we can observe how often the amount of actively running threads is changing through the lifecycle of an executor service:
And later on, those events can be observed in Java Mission Control:
Another massive topic with the JFR is: is it really a good idea to turn a subscriber-based operation model (you can only react to the particular event) into a poll-based model...
... i.e., build an interface between JFR and server metrics that can be consumed more straightforwardly than JMX socket-based interface just on purpose for JFR event streaming.
If it’s possible and really makes a lot of sense then it will significantly simplify application metrics emitting and consuming within 3rd-party metering services over HTTP in a cloud (VMs, K8s, etc).

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Denis Makogon

Denis Makogon Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @denis_makogon

Jul 19
It's time for #JavaTuesdayThread!

You know that JDK 19 will be released in 2 months on Sept. 20th. It will bring some major changes to the JDK. Project #Loom is one of those HUGE changes I want to talk about a little bit more. #Java #OpenJDK
JEP 425 introduces Virtual Threads. The most interesting thing is that the JDK was reworked to make it possible to block both platform and virtual threads in different ways.
While thread blocking methods will put on pause the whole platform thread, the virtual thread blocking wouldn't block its underlying carrier thread so it can pick up the segment of another virtual thread to execute.
Read 15 tweets
Mar 9
This is the first war in a modern world where we have more than just one physical frontier. As Ukrainian IT community we started another one - virtual. I’ll explain you how it works here in #Ukraine and abroad
[thread]:
#Ukraine has more than 160K IT specialists: hardware engineers, cloud engineers, software engineers, devops, architects, QA, etc.
We do have IT security folks known as Ukrainian Cyber Alliance (@UCA_ruhate_). They were the first ones who attacked #Russia’s IT infrastructure.
Read 11 tweets
Mar 8
Yesterday I explained you how a war in Ukraine will affect Europe in terms of food.

Today I will explain you how it will affect your comfort [thread]:
I’d you didn’t know - Ukraine average per hour rate is pretty low comparing to European. That’s why we do lots of outsourcing businesses. We have thousands of smart engineers who do work for US/EU businesses.
VM, Mercedes-Daimler, BMW uses Ukraine as an R&D centers.
Read 8 tweets
Aug 25, 2021
The reason why I love and hate #Kubernetes is it actually good platform to host scalable apps. But the road from developing the app to making it scalable is so painful. Here are few-reasons-why-thread:
#Kubernetes in its bare configuration can only host containers and let you talk to them. Include config maps, volumes, RBAC, etc.
If you ever wanted to scale your app on #Kubernetes you probably heard of MetricsServer - it can collect standard metrics like CPU and RAM of every pod/container.

It’s not a part of #k8s distribution - you need to install it separately.
Read 11 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(