frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

Show HN: Timep – A next-gen profiler and flamegraph-generator for bash code

https://github.com/jkool702/timep
2•jkool702•2h ago
Note: this is an update to [this](https://news.ycombinator.com/item?id=44568529) "Show HN" post.

timep is a state-of-the-art [debug-]trap-based bash profiler that is efficient and extremely accurate. Unlike other profilers, timep records:

1. per-command wall-clock time

2. per-command CPU time, and

3. the hierarchy of parent function calls /subshells for each command

the wall-clock + CPU time combination allows you to determine if a particular command is CPU-bound or IO-bound, and the hierarchical logging gives you a map of how the code actually executed.

The standout feature of timep is that it will take these records and automatically generate a bash-native flamegraph (that shows bash commands, not syscalls).

------------------------------------------------

USAGE

timep is extremely easy to use - just source the `timep.bash` file from the repo and add "timep" in front of whatever you want to profile. for example:

    . /path/to/timep.bash
    timep ./some_script
    echo "stdin" | timep some_function
ZERO changes need to be made to the code being profiled!

------------------------------------------------

EXAMPLES

[test code that will be profiled](https://github.com/jkool702/timep/blob/main/TESTS/timep.test...)

[output profile for that test code](https://github.com/jkool702/timep/blob/main/TESTS/OUTPUT/out...)

[flamegraph for that test code](https://github.com/jkool702/timep/blob/main/TESTS/OUTPUT/fla...)

[flamegraph from a "real world" test of "forkrun", a parallelization engine written in bash](https://github.com/jkool702/timep/blob/main/TESTS/FORKRUN/fl...)

In the "forkrun test", 13 different checksums were computed for ~670k small files on a ramdisk using 28 parallel workers. this was repeated twice. In total, this test ran around 67,000 individual bash commands. [This is its `perf stat` (without timep)](https://github.com/jkool702/timep/blob/main/TESTS/FORKRUN/pe...).

------------------------------------------------

EFFICIENCY AND ACCURACY

The forkrun test (see "examples" section above) was basically as demanding of a workload as one can have in bash. it fully utilized 24.5 cores on a 14c/28t i9-7940x CPU, racking up >840 seconds of CPU time in ~34.5 seconds of wall-clock time. When profiling this group of 67,000 commands with timep:

1. the time it took for the code to run with the debug-trap instrumentation was ~38 seconds, an increase of just slightly over 10%. CPU time had a similiar increase.

2. the time profile was ready at +2 minutes (1 minute + 15 seconds after the profiling run finished)

3. the flamegraphs were ready at +5 minutes (4 minute + 15 seconds after the profiling run finished)

Note that timep records both "start" and "stop" timestamps for every command, and the debug trap instrumentation runs between one commands "stop" timestamp and the next commands "start" timestamp, meaning the error in the profiles timings is far less than the 10% overhead. Comparing the total (sys+user) CPU time that perf stat gave (without using timep) and the CPU time timep gives (from summing together the CPU time of all 67,000-ish commands), the difference is virtually always less than 0.5%, and often less than 0.2%. Ive seen as low as 0.04%, which is 1/3 of a second on a run that took ~850 seconds of CPU time.

------------------------------------------------

MAJOR CHANGES SINCE THE LAST "SHOW HN" POST

1. CPU time is now recorded too (instead of just wall-clock time). This is done via a loadable builtin that calls `getrusage` and (if available) `clock_gettime` to efficiently and accurate determine the CPU time of the process and all its descendants.

2. the .so file required to use the loadable builtin mentioned in #1 is built directly into the script has an embedded compressed base64 sequence. I also developed the bash-native compression scheme that it uses. The .so files for x86_64, aarch64, ppc64le and i686 are all included. Im hoping to add arm7 soon as well. the flamegraph generator perl script is also embedded, making the script 100% fully self-contained. NOTE: these embedded base64 strings include both sha256 and md5 checksums of the resulting .so file that are verified on extraction.

3. the flamegraph generation has been completely overhauled. The flamegraphs now a) are colored based on runtime (hot colors = longer runtime), b) desaturate colors for commands where cpu time << wall-clock time (e.g., blocking reads, sleep, wait, ...), and c) use a runtime-weighted CDF color mapping that ensures, regardless of the distribution of the underlying data, that the resulting flamegraph has a roughly equal amount of each color in the colorspace (where "equal" means "the same number of pixels are showing each color"). timep also combines multiple flamegraphs (that show wallclock time vs cpu time and that us the full vs folded set of traces) by vertically stacking them into a single SVG image, giving "dual stack" and "quad stack" flamegraphs.

4. the post-processing workflow has been basically completely re-written, making it more robust, easier to understand/maintain, and much faster. The "forkrun" test linked above (that ran 67,000 commands) previously took ~20 minutes. With the new version, you can get a profile in 2 minutes or a profile + flamegraph in 5 minutes - a 4x to 10x speedup!

About Containers and VMs

https://linuxcontainers.org/incus/docs/main/explanation/containers_and_vms/
2•Bogdanp•5m ago•0 comments

No place is safe: families flee Gaza City Israel vows to press on with offensive

https://www.theguardian.com/world/2025/aug/24/families-flee-gaza-city-as-israel-vows-to-press-on-...
1•NomDePlum•8m ago•0 comments

The Cost of Poor Documentation for Developers

https://andiku.com/blog/the-real-cost-of-poor-documentation-for-developers
1•TheAnkurTyagi•9m ago•0 comments

China is quietly upstaging America with its open models

https://www.economist.com/business/2025/08/21/china-is-quietly-upstaging-america-with-its-open-mo...
3•thunderbong•15m ago•0 comments

Neovim now natively supports inline competitions from LLMs

https://github.com/neovim/neovim/pull/33972
1•f311a•17m ago•0 comments

ResumeAI – Job Search App

https://resume-ai.org
1•jam_cha123•23m ago•1 comments

DocumentDB Joins the Linux Foundation

https://opensource.microsoft.com/blog/2025/08/25/documentdb-joins-the-linux-foundation/
4•aleksi•37m ago•0 comments

Once Upon a Pipe in the West: A Working Adapter from HDMI to Gardena – Jhauser

https://jhauser.de/once-upon-a-pipe-in-the-west-hdmi-gardena
2•todsacerdoti•41m ago•0 comments

Mysterious X-37B spaceplane flies again carrying a quantum GPS alternative

https://www.theregister.com/2025/08/25/x37b_quantum_navigation_payload/
2•beardyw•44m ago•0 comments

On the Screen, Libyans Learned About Everything but Themselves (2021)

https://newlinesmag.com/argument/on-the-screen-libyans-learned-about-everything-but-themselves/
3•thomassmith65•52m ago•0 comments

Phishing Emails Are Now Aimed at Users and AI

https://malwr-analysis.com/2025/08/24/phishing-emails-are-now-aimed-at-users-and-ai-defenses/
1•f311a•52m ago•0 comments

China mandates domestic firms source 50% of chips from Chinese producers

https://www.tomshardware.com/tech-industry/semiconductors/china-mandates-domestic-firms-source-50...
2•ivape•53m ago•0 comments

Exploring LLM Confidence in Code Completion

https://arxiv.org/abs/2508.16131
1•Hard_Space•59m ago•0 comments

We Put Agentic AI Browsers to the Test – They Clicked, They Paid, They Failed

https://guard.io/labs/scamlexity-we-put-agentic-ai-browsers-to-the-test-they-clicked-they-paid-th...
3•mindracer•1h ago•0 comments

Which is better for vibe coding – Pycharm or Cursor

1•mthorbal•1h ago•0 comments

Are AI sermons ethical? Clergy consider where to draw the line

https://www.ncronline.org/culture/are-ai-sermons-ethical-clergy-consider-where-draw-line
2•Michelangelo11•1h ago•0 comments

Spoon-Bending, a logical framework for analyzing GPT-5 alignment behavior

https://github.com/pablo-chacon/Spoon-Bending
2•pablo-chacon•1h ago•1 comments

Show HN: Lekh – write-only, encrypted micro-journal at your own URL

https://www.lekh.space/
3•doodyman•1h ago•0 comments

Agency Is Eating the World

https://giansegato.com/essays/agency-is-eating-the-world
1•vinhnx•1h ago•0 comments

Owner of 'US 8964' licence plate faced police scrutiny and a year of harassment

https://hongkongfp.com/2025/08/24/driven-out-why-the-owner-of-us-8964-licence-plate-faced-police-...
4•baylearn•1h ago•2 comments

VLF Plotter

https://www.skyandsolar.com/plotter
1•austinallegro•1h ago•0 comments

I built a Task manager to prevent developer Burnout

2•BlogCat•1h ago•1 comments

Ask HN: How can I recover and run my old mobile game from the 2010s?

2•diasks2•1h ago•1 comments

Zero Ethics AI [video]

https://www.youtube.com/watch?v=kboTCBHyYd0
1•frag•1h ago•0 comments

The battle of Gaza City is beginning. Get ready for a barrage of Hamas lies

https://www.telegraph.co.uk/news/2025/08/24/gaza-city-idf-hamas-propaganda-israel-battle/
2•socialcreditlow•1h ago•1 comments

Google: Was 1995 30 years ago?

https://imgur.com/a/2bQot5i
5•scarface_74•1h ago•0 comments

Founders of This New Development Say You Must Be White to Live There

https://www.nytimes.com/2025/08/19/realestate/arkansas-white-housing-return-to-land.html
3•belter•1h ago•0 comments

What are OKLCH colors?

https://jakub.kr/components/oklch-colors
111•tontonius•1h ago•35 comments

Show HN: Discover, share, and collaborate on effective coding prompts

https://www.aitmpl.com/
1•alexander2002•1h ago•0 comments

A comprehensive list of 2025 tech layoffs

https://techcrunch.com/2025/08/15/tech-layoffs-2025-list/
3•bbzjk7•1h ago•0 comments