Linux Optimization Patches Significantly Speed-Up Debuggers Using /proc/kcore

Written by Michael Larabel in Programming on 10 November 2024 at 09:00 AM EST. 3 Comments
PROGRAMMING
A set of Linux kernel patches posted on Friday by Meta/Facebook provide for sizable performance optimizations for applications leveraging /proc/kcore such as for debuggers.

The /proc/kcore file is for representing the physical memory of the system in core file format. The /proc/kcore file is commonly used by debuggers like GDB and Drgn but it turns out it can be much better optimized.

Meta engineer Omar Sandoval posted the set of four patches on Friday for speeding-up interactions with /proc/kcore:
"The performance of /proc/kcore reads has been showing up as a bottleneck for drgn. drgn scripts often spend ~25% of their time in the kernel reading from /proc/kcore.

A lot of this overhead comes from silly inefficiencies. This patch series fixes the low-hanging fruit. The fixes are all fairly small and straightforward. The result is a 25% improvement in read latency in micro-benchmarks (from ~235 nanoseconds to ~175) and a 15% improvement in execution time for real-world drgn scripts.

Since I have a stake in /proc/kcore and have modified it several times, the final patch volunteers me to maintain it."

Drgn is a programmable debugger that supports scripting in Python and can be used for debugging the Linux kernel and other purposes. Drgn particularly prides itself on its scripting abilities and originated at Meta for their efforts on debugging the Linux kernel.

Drgn Python script example


For those using Drgn or other /proc/kcore users can find these new kernel optimization patches via the Linux kernel mailing list.
Related News
About The Author
Michael Larabel

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.

Popular News This Week