Live data from Hacker News

Parallel – A command-line CPU load balancer written in Rust

github.com

1–10 of 65 posts

Re: Parallel – A command-line CPU load balancer written in Rust

#3
post #2

This looks like a perfect real world complete useful application that a beginner in rust could look at.

A rust beginner could also look at Jonathan Turner's lessons from solving first 12 Project Euler problems.

[0] https://www.jonathanturner.org/2015/10/lessons-from-first-12...

Re: Parallel – A command-line CPU load balancer written in Rust

#6
post #4

Why this can be faster than GNU parallel?

One possible reason is that GNU parallel is a perl script.

a version in C that I think was first released before GNU parallel is in "moreutils" https://joeyh.name/code/moreutils/

A few years ago, debian made GNU parallel provide the "/usr/bin/parallel" executable, instead of moreutils. The maintainer of moreutils had some interesting things to say about that: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=597050#75

Re: Parallel – A command-line CPU load balancer written in Rust

#7
post #4

Why this can be faster than GNU parallel?

One possible reason is that GNU parallel is a perl script.

I'm sure that's the cause. Their test script is just a straight `echo` of the input, so each test process will exit essentially immediately - it's unlikely the parallel aspect actually kicks in to any decent degree. The majority of the test is spent in the Rust/Perl code vs actually running commands. That said, while the test isn't hugely useful, the fact that this Rust implementation has much less overhead is still a notable improvement.

To add to this, parallel mentions as much in its man pages (that there is a certain startup cost, and a certain job-startup cost), and offers tips for speeding up the processing of jobs which exit fairly fast. But there's no reason you couldn't also do those things in the Rust version, so it's going to win every time. When dealing with commands which take a while to complete though, the extra overhead of the perl script would probably be negligible.

Re: Parallel – A command-line CPU load balancer written in Rust

#8
post #4

Why this can be faster than GNU parallel?

One possible reason is that GNU parallel is a perl script.

Err, no. It execs other processes. the runtime overhead of running the interpreter is irrelevant as it provides no overhead over the general runtime of the sub-process.

Re: Parallel – A command-line CPU load balancer written in Rust

#9
post #6

Earlier quoted context omitted.

One possible reason is that GNU parallel is a perl script.

a version in C that I think was first released before GNU parallel is in "moreutils" https://joeyh.name/code/moreutils/ A few years ago, debian made GNU parallel provide the "/usr/bin/parallel" executable, instead of moreutils. The maintainer of moreutils had some interesting things to say about that: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=597050#75

> It is 5143 lines of code, and the anthethesis of a simple, clean, well-designed unix command.

Only 5k? :D

But, yes, the criticisms are valid. I recommend moreutils.

Re: Parallel – A command-line CPU load balancer written in Rust

#10

Earlier quoted context omitted.

One possible reason is that GNU parallel is a perl script.

Err, no. It execs other processes. the runtime overhead of running the interpreter is irrelevant as it provides no overhead over the general runtime of the sub-process.

GNU Parallel takes a surprising amount of CPU time. It does have various tasks (track it's children, feed them input, gather all their output and output it to the screen in the correct order), but I'm still surprised how much CPU it takes.
Post reply on HN