News for hackers. Stuff that matters.
Re:How to write slow Rust code by likeabbas on Monday August 02, 2021 @10:02AM (#28036639)
There’s a distinct difference between Java and Rust/C++ which is that Java has a stop-the-world-GC and rust/c++ don’t. And in large scale systems, Java’s GC is usually the limiting factor.
Re:How to write slow Rust code by nobleach on Monday August 02, 2021 @10:20AM (#28036852)
Newer versions of Java have more interesting GC implementations that reduce that "stop the world, swab the decks" performance. The fine engineers working on the JVM keep finding ways to incrementally garbage collect. It's getting to a point where it's imperceptible in some applications. Granted, if you're writing high-speed/high-frequency trading apps for Wall Street, Java still isn't there. Rust could be the logical next step in that arena. (Although, most C++ devs I know in that space don't hate C++)
Re:How to write slow Rust code by maccard on Monday August 02, 2021 @11:05AM (#28037460)
> if you're writing high-speed/high-frequency trading apps for Wall Street, Java still isn't there.

Stop-the-world GC doesn't stop you from using Java for high-speed apps, unpredictable stalls do. It doesn't matter if your GC takes 2 seconds to run fully as long as it doesn't kick off during your hot loop, and the opposite is true; there will never be a low enough overhead "magic" GC that can be run in the background that may cause a microsecond stutter on your finely tuned trading algotirhm, it has to be explicit.

Re:How to write slow Rust code by lordnacho on Monday August 02, 2021 @10:24AM (#28036899)
> if you're writing high-speed/high-frequency trading apps for Wall Street, Java still isn't there

A fair few trading system job ads seem to be for Java. I also wrote code that faced a Java server at various banks. Seems to be fast enough for certain market related applications.

Re:How to write slow Rust code by magila on Monday August 02, 2021 @11:45AM (#28038171)
The use of Java in trading systems is widely misunderstood. Java is typically used to implement the high level business logic where microsecond latency is not required. The output of the Java service is feed to another system which handles the actual trade execution. That part is typically done with C++, or FPGAs driven by C++.
Re:How to write slow Rust code by nobleach on Monday August 02, 2021 @03:58PM (#28041838)
This was the method used by my former employer. Are entire backend was Kotlin/Java/Scala... and a couple of NodeJS apps. Right up until the very edge where C++ handled the interface with the exchanges. We also did the typical thing of having our servers as physically close as possible (in New Jersey).
Re:How to write slow Rust code by tuxman on Monday August 02, 2021 @11:43AM (#28038142)
From my understanding of previous talks on this, a fair amount of HFT's and trading firms use Java. The trick is that the trading day is a well-defined window with clear starts and stops. So if you load up your server with huge amounts of memory, you can get away with never calling GC during the trading day. The GC can be paused until after hours or just kill the program and start it up before market open the next day.
Re:How to write slow Rust code by nobleach on Monday August 02, 2021 @03:56PM (#28041812)
One solution I had been dying to implement is the Erlang style of letting a Kubernetes POD OOM, and just respawning it. If the app performs well right up until it runs out of memory, I see no reason to have a GC turned on at all. (obviously there ARE reasons, I just wanted to try this approach)
Re:How to write slow Rust code by pjmlp on Monday August 02, 2021 @10:17AM (#28036820)
Yeah, like 1ms when handling heaps of 3TB sizes, when most people are still complaining about 16 GB on laptops, I can live with that.
Re:How to write slow Rust code by Diggsey on Monday August 02, 2021 @10:32AM (#28037005)
Firstly, 1ms for a 3TB heap size is very unrealistic even for modern JVMs.

Secondly, the figures that are often quoted for how long the program must be stopped are for the "happy path" where enough memory can be freed that the program can continue without issue.

In practice, what often happens with large heap sizes is that the GC starts lagging behind because there's not enough memory head-room. In these cases, the GC stops the world for much longer, because the program hangs on a memory allocation that cannot be satisfied until the GC completes.

This primarily affects programs that have high rates of allocation. You can avoid this in Java with effort, but you end up with very non-idiomatic code.

Re:How to write slow Rust code by pjmlp on Monday August 02, 2021 @10:36AM (#28037049)
Enjoy, https://malloc.se/blog/zgc-jdk16

I guess Oracle, IBM, Azul, PTC, Microsoft can provide the necessary data about their pauseless GC implementantions to any relevant customer.

Re:How to write slow Rust code by native_samples on Monday August 02, 2021 @05:12PM (#28042704)
Modern JVMs have a GC that has O(1) pause times, often of less than 1msec regardless of heap size. In ZGC and Shenandoah, GC is fully concurrent and pauses are basically imperceptible. Even walking the stacks to locate pointers into the heap is done whilst the application is still running.
Re:How to write slow Rust code by nlitened on Monday August 02, 2021 @10:17AM (#28036819)
If I understand correctly, modern Java has multiple GC engines available (that can be chosen with a command-line switch), some of which are either fully concurrent or with sub-millisecond stop times.