News for hackers. Stuff that matters.
Re:Why Rust helps even if you have to use a lot of `unsafe` by RhodesianHunter on Wednesday August 02, 2023 @11:01AM (#36971833)
> hey both come with baggage (JVM).

I'm always surprised to hear people say this, when my perspective on the JVM is that it's a modern technical marvel several decades in the making with advantages like several unparalleled GCs and an ecosystem with extensive off-the-shelf & highly performant code available for any domain.

Re:Why Rust helps even if you have to use a lot of `unsafe` by fnfjfk on Wednesday August 02, 2023 @11:12AM (#36971977)
I don’t work on server code, and I think a lot of discussions are really focused on server-side work. I have done desktop, mobile, and developer tools (CLIs and “scripts”).

If I was working on a server thing Kotlin would seem really good. In my work it is obviously applicable to Android, but not so much elsewhere.

I think Rust is nearly perfect for developer CLIs, you don’t really need to deal with the thorny memory and lifetime stuff because most things are allocated on the stack and the entire program is synchronous. clap is very good. Performance, especially startup performance, is incredible.

Re:Why Rust helps even if you have to use a lot of `unsafe` by square_usual on Wednesday August 02, 2023 @01:13PM (#36973765)
You can use GraalVM Native Image and Kotlin/Native to compile Kotlin to a binary executable, which is fairly fast to start up but does not have all of the high-performance JVM features.
Re:Why Rust helps even if you have to use a lot of `unsafe` by throwaway894345 on Wednesday August 02, 2023 @11:30AM (#36972265)
JVM is a marvel at making OOP code merely 10% or 50% slower than C, but I find procedural/data-oriented programming to be quite a lot clearer, faster, and more predictable (with respect to performance) and I don't need nor a huge runtime nor an expert to tune it nor a complicated toolchain to bundle it in with my application (or otherwise ensure that the properly tuned runtime is installed on my target).
Re:Why Rust helps even if you have to use a lot of `unsafe` by hedora on Wednesday August 02, 2023 @11:42AM (#36972437)
To get it to that level of performance, you need to have expert java programmers, and the result will be hard to maintain.

For instance, you can’t use String on hot paths. Also, NPEs can happen almost anywhere, and the compiler doesn’t enforce thread safely (by which I mean “statically checked to be data race free”)

Also, the 10-50% slower rule of thumb only applies to throughput. Tail latency is generally much worse than that.

Re:Why Rust helps even if you have to use a lot of `unsafe` by RhodesianHunter on Wednesday August 02, 2023 @01:29PM (#36974006)
It depends on what you're doing. In C you're going to be hampered by, again, the ecosystem.

There is nothing comparable in C as performant as all of the streaming tooling built up around Kafka for example.

So your can benchmark percentages all you want, but there are a lot of things you just can't do in C that you can on the JVM (without 100 developers and three years)

Re:Why Rust helps even if you have to use a lot of `unsafe` by morelisp on Wednesday August 02, 2023 @01:33PM (#36974069)
> There is nothing comparable in C as performant as all of the streaming tooling built up around Kafka for example.

This is an ill-chosen example.

librdkafka is as or more performant than the Java stuff.

As a server, Redpanda blows Kafka out of the water (but this is rarely any bottleneck with brokers).

Re:Why Rust helps even if you have to use a lot of `unsafe` by RhodesianHunter on Wednesday August 02, 2023 @03:25PM (#36975855)
Yes, if you take the time to hand roll a replacement like Redpanda did it will be faster (though to your point that seems fairly pointless given the constraints imposed by IO)

I was referring more to the general ecosystem of Flink/Spark/KStreams/KTable etc.

Re:Why Rust helps even if you have to use a lot of `unsafe` by agallego on Wednesday August 02, 2023 @03:48PM (#36976241)
this seems truthy but isn't in practice. a lot of work, my perf optimization team @ redpanda does (yes we have a full team chasing tail latencies) is spent on CPU optimization, debouncing, amortizing costs, metadata lookups, hash tables, profilers, etc. so there is a lot of additional work after the IO layer which a decent async eventing thing can get you to get good perf.
Re:Why Rust helps even if you have to use a lot of `unsafe` by RhodesianHunter on Wednesday August 02, 2023 @04:50PM (#36977202)
What I mean to say is that in my experience the time spent round-tripping to Kafka is more than the time it takes Kafka to do whatever I'm asking it to do. So at least for my use-cases a faster Kafka would be of no benefit.

Now if it means I can run fewer smaller brokers that's awesome.

Re:Why Rust helps even if you have to use a lot of `unsafe` by agallego on Monday August 07, 2023 @07:01PM (#37042122)
def. that should be the case, we have iot companies pushing us on a single pthread a a few megs of ram.
Re:Why Rust helps even if you have to use a lot of `unsafe` by morelisp on Wednesday August 02, 2023 @04:58PM (#36977319)
> Flink/Spark/KStreams/KTable etc.

Then it's still a bit of an untruth since all of those use RocksDB for their high-performance storage layer, which isn't in Java. You could maybe (maybe!) argue for some ergonomics (though especially hard to argue for Spark!) but performance still goes plainly to C (/ C++).

Re:Why Rust helps even if you have to use a lot of `unsafe` by RhodesianHunter on Friday August 04, 2023 @04:04PM (#37005122)
We're not talking about the systems you build on top of here. We're talking about the code. You write yourself. The fact that rocks is written in c is irrelevant to the fact that in order to use the ecosystem I'm describing you need to be on the JVM or your experience will be at best subpar.
Re:Why Rust helps even if you have to use a lot of `unsafe` by morelisp on Saturday August 05, 2023 @07:09PM (#37017128)
Sure, if you ignore offloading all the hard work to a C library, we can pretend any language is as fast as any other. It's a boring conversation then though - might as well use Python...

Not to mention you still pay a real performance penalty for being unable to make direct use of RocksDB features, because Kafka is shoving a million "abstraction" and cache layers in there and you just want your your damned merge operator to apply.

I don't agree Kafka off the JVM is subpar. Kafka Streams has a lot of sharp edges from "abstractions" that aren't, Spark is a godawful developer experience and tuning it for performance is black magic for 99% of data engineers, and Flink keeps dithering about how consistent/stable baseline features like queries will be. You can stand up very good apps for a huge set of common cases just as quickly in Go or C++, and not have to deal with Kafka Streams's funny opinions about threads/tasks/consumers.

Re:Why Rust helps even if you have to use a lot of `unsafe` by c_crank on Wednesday August 02, 2023 @01:57PM (#36974453)
You can write procedural/data-oriented code in Java.
Re:Why Rust helps even if you have to use a lot of `unsafe` by throwaway894345 on Wednesday August 02, 2023 @02:41PM (#36975099)
Sort of (Java still doesn't have value types), and even then you still have most of the cons of a big runtime.
Re:Why Rust helps even if you have to use a lot of `unsafe` by morelisp on Wednesday August 02, 2023 @02:17PM (#36974725)
As long as you hire C/C++/Rust programmers to write it.
Re:Why Rust helps even if you have to use a lot of `unsafe` by za3faran on Wednesday August 02, 2023 @06:08PM (#36978412)
Always funny to see OOP being thrown around like it's some sort of bogeyman. C++ is OOP, so is Rust (minus inheritance), yet both are as fast or faster than C.
Re:Why Rust helps even if you have to use a lot of `unsafe` by soulbadguy on Wednesday August 02, 2023 @11:44AM (#36972456)
As compared to what... JVM is neither particularly advance nor particularly performant.

Can't quite comment on the GCs though

Re:Why Rust helps even if you have to use a lot of `unsafe` by jacquesm on Wednesday August 02, 2023 @12:27PM (#36973122)
> JVM is neither particularly advance nor particularly performant

I'm not exactly a fan of Java, to put it mildly, but it is pretty efficient these days. To the point that it sometimes amazes me.

Re:Why Rust helps even if you have to use a lot of `unsafe` by soulbadguy on Wednesday August 02, 2023 @08:54PM (#36979953)
I don't want to sound like i am downplaying you understanding of the JVM. But i still have to ask : efficient as compare to what ?

From having played around the JVM, and spent quite a bite of time optimizer large spark workload , from the limited Monomorphization, to memory and cache inefficient object model, to the limited inlining depth, absence of code compaction ( for i-cache performance), the poor registor allocator etc... the JVM is really not up there.

I think it only shines when compare to things like go/python/javascript that the JVM can appear to be great.

Re:Why Rust helps even if you have to use a lot of `unsafe` by pjmlp on Thursday August 03, 2023 @02:10AM (#36982028)
Compared to doing distributed systems in DCOM/CORBA using C and C++ for example, that is one of the reasons it took off.

Many that like to bash Java EE, have no clue how bad it was before it came to be, it wasn't only Sun's marketing pushing it.

It isn't by accident that RMI had interoperability with CORBA.

Re:Why Rust helps even if you have to use a lot of `unsafe` by soulbadguy on Thursday August 03, 2023 @01:52PM (#36989288)
I am not sure how this is an answer the my argument. However saying that distributed system in JAVA EE are more performant that in C++ ( i am no familliar with DCOM/CORBA but i do know other libraries and system ) is news to me.

And again, the success of JAVA in the 90 and 00 can also be explained by better tooling, safer language,better x-platform stories,better libraries etc... etc...

Saying that java/jvm are not particularly performant is not bashing ... java/jvm have other great things going on... performance just isnt one of them

Re:Why Rust helps even if you have to use a lot of `unsafe` by pjmlp on Thursday August 03, 2023 @02:25PM (#36989698)
I guess if what one is measuring FPS for AAA, then surely not.

Naturally not having a clue about how to write proper Java code (for loops instead of System.arraycopy()), use profilers, use JIT caches with PGO feedback, not understanding how to allocate off heap, not using JNI to avoid writing everything in C or C++ with their own set of issues, doing background stuff on main threads,...also helps some Java applications not being performant.

Re:Why Rust helps even if you have to use a lot of `unsafe` by RhodesianHunter on Wednesday August 02, 2023 @01:31PM (#36974053)
Have you used it since Java 8?

There's a reason the entire streaming ecosystem (Kafka/Flink/Spark/Etc.) has built up around the JVM.

Re:Why Rust helps even if you have to use a lot of `unsafe` by imtringued on Wednesday August 02, 2023 @12:00PM (#36972693)
JVM memory consumption is prohibitive for small applications and overall the JVM is very memory inefficient. If you can, avoid Java for anything that isn't a long running server process
Re:Why Rust helps even if you have to use a lot of `unsafe` by RhodesianHunter on Wednesday August 02, 2023 @01:30PM (#36974037)
Have your worked with the JVM since Java 8?

Is memory util on servers still really a consideration in 2023 for most workloads if performance is otherwise good?

> If you can, avoid Java for anything that isn't a long running server process

Isn't that the JVM's niche?

Re:Why Rust helps even if you have to use a lot of `unsafe` by chriskrycho on Wednesday August 02, 2023 @01:59PM (#36974480)
Memory utilization on servers is absolutely a consideration in 2023. At work, we're looking seriously at migrating some key parts of our infrastructure from Java to Rust precisely because of factor (as well as startup time, throughput).
Re:Why Rust helps even if you have to use a lot of `unsafe` by RhodesianHunter on Wednesday August 02, 2023 @03:20PM (#36975758)
As someone working on systems that handle trillions of message per day in Java, I find this hard to relate to. Is it bad code? Some critical infrastructure flaw? Misunderstanding of memory options settings or how they work in containers?

Startup time is definitely a concern. Good luck on the throughput front though. Java libs (like Netty) still outpace what's available in Rust. You may end up with your own code being more performant, but the things you rely on externally being slower. This was our experience when trialing re-writes in Rust.

Re:Why Rust helps even if you have to use a lot of `unsafe` by za3faran on Wednesday August 02, 2023 @06:09PM (#36978436)
It's probably RDD (resume driven development). It's always fun to rewrite in the latest new hype, and I don't have anything against Rust - I think it's great in the domains it is targeting.
Re:Why Rust helps even if you have to use a lot of `unsafe` by insanitybit on Wednesday August 02, 2023 @03:06PM (#36975539)
> Is memory util on servers still really a consideration in 2023 for most workloads if performance is otherwise good?

The way that cloud scaling works is that as you increase RAM you also increase CPU, which costs a fortune. You can go for 'memory optimized' instances but even still, there are costs associated with memory that aren't just the RAM modules, unfortunately.

Plus with container orchestration it's increasingly important to pack your services into a single instance, and memory can veryyyy quickly become the constraint - in fact, it might be the one I've seen most often.

Re:Why Rust helps even if you have to use a lot of `unsafe` by RhodesianHunter on Wednesday August 02, 2023 @03:23PM (#36975810)
I don't find this, but maybe it's something K8's helps us get away from?

For our workloads we seem to need more CPU when we need more ram anyways.

Re:Why Rust helps even if you have to use a lot of `unsafe` by insanitybit on Wednesday August 02, 2023 @06:00PM (#36978282)
No, you'd run into it with k8s more, if anything. But it is workload dependent.
Re:Why Rust helps even if you have to use a lot of `unsafe` by morelisp on Wednesday August 02, 2023 @01:29PM (#36974008)
I don't want several GCs, though.
Re:Why Rust helps even if you have to use a lot of `unsafe` by RhodesianHunter on Wednesday August 02, 2023 @01:34PM (#36974083)
Yeah, I've always derided the having of options as well. I find it best when you cannot toggle between various options to find the best set of tradeoffs for your use case.
Re:Why Rust helps even if you have to use a lot of `unsafe` by morelisp on Wednesday August 02, 2023 @01:36PM (#36974120)
Yes, for example, it's much better when the language completely takes away your ability to specify memory layouts or allocation patterns because it will never pick stupid ones.
Re:Why Rust helps even if you have to use a lot of `unsafe` by za3faran on Wednesday August 02, 2023 @06:10PM (#36978444)
Value types are in the works for the JVM.
Re:Why Rust helps even if you have to use a lot of `unsafe` by morelisp on Thursday August 03, 2023 @02:28AM (#36982130)
I'm pretty sure I had this exact conversation five years ago, and believe I will be having it five years from now.