News for hackers. Stuff that matters.
Re:Why Discord is switching from Go to Rust by chrisseaton on Tuesday February 04, 2020 @05:12PM (#22241595)
> context switches between JVM and native code are typically fairly expensive

Aren't these Unsafe memory read and write methods intrinsified by any serious compiler? I don't believe they're using JNI or doing any kind of managed/native transition, except in the interpreter. They turn into the same memory read and write operations in the compiler's intermediate representation as Java field read and writes do.

Re:Why Discord is switching from Go to Rust by jfim on Tuesday February 04, 2020 @10:58PM (#22243887)
They are optimized, yes, but from what I recall from reading the JVM code a few years ago, some optimizations don't get applied to those reads/writes. For example, summing two arrays together will be vectorized to use SSE instructions while doing so through Unsafe won't [0].

[0] https://cr.openjdk.java.net/~vlivanov/talks/2017_Vectorizati...