mirror of
https://github.com/awesome-lists/awesome-bash.git
synced 2026-07-11 13:52:35 -05:00
[PR #127] [MERGED] add forkrun #3819
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/awesome-lists/awesome-bash/pull/127
Author: @jkool702
Created: 7/26/2024
Status: ✅ Merged
Merged: 7/26/2024
Merged by: @hyperupcall
Base:
master← Head:master📝 Commits (3)
1fbfbefadd forkrunac16ca7add forkrun595676dUpdate README.md📊 Changes
1 file changed (+1 additions, -0 deletions)
View changed files
📝
README.md(+1 -0)📄 Description
New App Submission
Repo or homepage link: https://github.com/jkool702/forkrun
Description: A pure-bash tool for running code in parallel. Similar in syntax and speed to
xargs -Pbut with more features and native bash function support.Why I think it's awesome:
forkrunis the fastest "loop parallelizer" ever written in bash. In many situations is is even slightly faster than the fastest invocation ofxargs -P, and almost always a good bit faster than parallel. It also includes several nice features missing from xargs, such as "ordering output the same as if inputs were run sequentially" and "passing inputs to whatever you are parallelizing via its stdin". It also natively supports using bash functions, making it trivially easy to wrap complex multistep tasks in a bash function and parallelize it.Forkrun is so fast because it doesnt fork individual calls - rather it initially forks several persistent bash coprocs and distributes stdin to them. these coprocs each run an infinite loop (until an end condition is met) that reads data and runs it through whatever you are parallelizing. Forkrun also uses a novel and extremely efficient IPC method to distribute stdin to these coprocs without needing a separate process to actively manage it via a tmpfile on a tmpfs and a shared reading file descriptor. This tmpfile is simultaneously accesses by 3 different processes, though importantly these processes all are accessing the file at different byte offsets.
In a general sense, forkrun has been optimized considerably more than any other bash function Ive ever come across. Sometimes this comes at the cost of code readability, but it allows forkrun to directly challenge and age-old conception that "bash will always run things slowly"...it is rather hard to support that viewpoint when forkrun is parallelizing stuff faster than xargs (which is compiled C) is. (see the "hyperfine benchmarks" folder in the forkrun repo for more details and extensive benchmarking)
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.