News for hackers. Stuff that matters.
Re:Case Study: Npm uses Rust for its CPU-bound bottlenecks [... by Quenty on Sunday March 03, 2019 @12:26PM (#19295578)
The paper makes it clear they were evaluating languages based upon efficiency.

The rust implementation was more efficient than the JS one. A CPU bound service of course is bottlenecked at the CPU, and this benefits from efficiency.

At scale, it makes sense to replace this with Rust. Javascript did the job, but did not provide the same efficiency as Rust.

Re:Case Study: Npm uses Rust for its CPU-bound bottlenecks [... by tyingq on Sunday March 03, 2019 @12:41PM (#19295654)
I'm not clear on why this is particularly CPU heavy, though: "the authorization service that determines whether a user is allowed to, say, publish a particular package"
Re:Case Study: Npm uses Rust for its CPU-bound bottlenecks [... by Filligree on Sunday March 03, 2019 @01:26PM (#19295916)
Lots of users. Anything will be CPU-heavy if you give it enough work.

Except the things that end up being memory-bound instead, but the NPM database isn't large enough for that.

Re:Case Study: Npm uses Rust for its CPU-bound bottlenecks [... by Dylan16807 on Sunday March 03, 2019 @02:29PM (#19296300)
> Anything will be CPU-heavy if you give it enough work.

Not in a relative sense. If authorization is 5% of the work, scaling it leaves it at 5% of the work, and it's never a bottleneck. Authorization was being a significant bottleneck, not a tiny percent, and that is somewhat surprising.

Re:Case Study: Npm uses Rust for its CPU-bound bottlenecks [... by andy_ppp on Sunday March 03, 2019 @03:10PM (#19296524)
Obviously authorisation will be a huge overhead compared to sendfile + nginx right? Am I misunderstanding what npm does?
Re:Case Study: Npm uses Rust for its CPU-bound bottlenecks [... by Dylan16807 on Sunday March 03, 2019 @05:34PM (#19297378)
I mean, to use sendfile you need to open the file, and that does a permission check too...
Re:Case Study: Npm uses Rust for its CPU-bound bottlenecks [... by andy_ppp on Sunday March 03, 2019 @09:54PM (#19298444)
No I'm talking about private NPM right. The perms on the file system are not equal to (or as costly as) the auth I need to have to access my private NPM repo.
Re:Case Study: Npm uses Rust for its CPU-bound bottlenecks [... by yawaramin on Sunday March 03, 2019 @03:39PM (#19296701)
Couldn't you implement the authorization logic in, say, Redis? Then the npm service is I/O-bound again, and everyone is doing the job they're optimized for.
Re:Case Study: Npm uses Rust for its CPU-bound bottlenecks [... by Filligree on Monday March 04, 2019 @09:10AM (#19301319)
Authorization checks aren't that expensive. The overhead of using an external service might well make it take up more hardware overall.
Re:Case Study: Npm uses Rust for its CPU-bound bottlenecks [... by Thaxll on Sunday March 03, 2019 @01:59PM (#19296112)
It's not clear either, it makes sens to use Rust for CPU heavy task, but a CRUD service that do authentication would be fine in Nodejs since every low level crypto are using C. So I'm not sure exatly what they mean, tbh the paper is very light on details.
Re:Case Study: Npm uses Rust for its CPU-bound bottlenecks [... by nwlieb on Sunday March 03, 2019 @02:50PM (#19296407)
Some CPU heavy operations like crypto are not put in a threadpool. While it may be running C code, it will block the main thread while executing. See https://github.com/nodejs/node/issues/678

Perhaps the new worker threads may alleviate this, but I'm not sure (it's still an experimental API).

Re:Case Study: Npm uses Rust for its CPU-bound bottlenecks [... by throwaway66666 on Sunday March 03, 2019 @05:18PM (#19297296)
My gut feeling is that the user keys are not random generated, but actually encrypted strings that contain the permission values. Decrypting them with modern encryption algorithms (like ChaCha) is pretty CPU intensive.
Re:Case Study: Npm uses Rust for its CPU-bound bottlenecks [... by 0815test on Sunday March 03, 2019 @12:43PM (#19295666)
"Javascript did the job", but not very well apparently. They specifically say that they "were able to forget about the Rust service because it caused so few operational issues". Add to that the increased CPU- and RAM-efficiency that generally comes with a rust implementation, and that rust rewrite looks like a no-brainer.