OpenJDK Performance Fix: How Replacing /proc Parsing with a Syscall Eliminated 400x Slowdown
By
bluestreak
Crackling crust, pillowy middle. The kind of bagel that earns a second cup of coffee.
Summary
The article analyzes a specific OpenJDK commit that dramatically improved Java performance by replacing inefficient /proc file parsing with a direct syscall. The author examines how a 40-line code change eliminated a 400x performance gap in thread CPU time measurement on Linux systems. The fix involved replacing complex file I/O operations with a single clock_gettime() system call, revealing a 20-year-old optimization opportunity in the Linux kernel's thread CPU time tracking. The article provides technical details about the commit, explains the performance implications, and discusses the broader lesson about avoiding unnecessary file operations for system information retrieval.
Key quotes
· 4 pulledThe diffstat was interesting: +96 insertions, -54 deletions. The changeset adds a 55-line JMH benchmark, which means the production code itself is actually reduced.
static jlong user_thread_cpu_time(Thread *thread) { pid_t tid = thread->osthread()->thread_id(); char *s;
The article reveals a 20-year-old optimization opportunity in the Linux kernel's thread CPU time tracking.
The fix involved replacing complex file I/O operations with a single clock_gettime() system call.
You might also wanna read

How micro-optimizations in Azure Service Bus SDK paved the way for a smarter redesign
The article discusses how micro-optimizations in the Azure Service Bus SDK led to meaningful design improvements. Rather than advocating for
How Kestra Improved Orchestrator Performance Across 14 Releases: A Year of Performance Engineering
Kestra's engineering team details their year-long performance engineering journey across releases 0.19 to 1.3, treating performance as an on
OpenFGA Implements Self-Tuning Strategy Planner with Thompson Sampling to Reduce P99 Latency by 98%
The article details how OpenFGA, an open-source authorization system modeled after Google's Zanzibar, addressed tail latency challenges in i
Performance Optimization Principles and Techniques from Google Engineers
This document by Google engineers Jeff Dean and Sanjay Ghemawat presents a comprehensive guide to performance tuning principles and techniqu
Implementing SwissTable-Style High-Performance Hash Tables in Java
This article details the author's journey implementing a SwissTable-style hash table in Java, inspired by Google's high-performance C++ hash
A critique of misusing "backpressure" in AI code-generation system design
This article critiques Lucas Costa's piece on building systems for code-generating AI robots, arguing that Costa misuses the term "backpress
