A 40-Line Fix Eliminated a 400x Performance Gap

I have a habit of skimming the OpenJDK commit log every few weeks. Many commits are too complex for me to grasp in the limited time I have reserved for this … special hobby. But occasionally something catches my eye. Last week, this commit stopped me mid-scroll: 858d2e434dd 8372584: [Linux]: Replace reading proc to get thread CPUtime with clock_gettime The diffstat was interesting: +96 insertions, -54 deletions. The changeset adds a 55-line JMH benchmark, which means the production code itself is actually reduced. The Deleted Code Here’s what got removed from os_linux.cpp: static jlong user_thread_cpu_time(Thread *thread) { pid_t tid = thread->osthread()->thread_id(); char *s; char stat[2048]; size_t statlen; char proc_name[64]; int count; long sys_time, user_time; char cdummy;…

Read more on Hacker News