News for hackers. Stuff that matters.
Re:Building a Cloud Database from Scratch: Why We Moved from... by verdagon on Friday May 27, 2022 @08:53PM (#31536599)
I think it makes sense for some segments of the programming world and not others.

On Google Earth, garbage collection pauses weren't really acceptable, but we also wanted to add new functionality without being slowed down. Rust is great for a lot of reasons, but as many know, it can be slower on the feature velocity front.

In some AAA games, they need much more flexibility than the borrow checker thinks is appropriate. At some point, one has so many unsafe blocks that undermine the guarantees of surrounding code, that it makes more sense to use a different paradigm.

I know it's taboo to say this, but in many real world use cases, memory safety bugs aren't that bad and have the severity of any other logic error. Having a few more bugs per release might be worth it, if it means not dealing with the borrow checker's restrictions around abstraction, encapsulation, and polymorphism. You just fix them and push a new release.

Also, the problem is nicely mitigated by tools like Address Sanitizer, and will get even better with upcoming advances such as memory tagging and generational references, all which detect memory problems with surprising efficacy and accuracy.

In short, manual memory management is the right choice when Rust's drawbacks are a bit too much, and benefits aren't enough, for a particular situation.

Just my two cents!

Re:Building a Cloud Database from Scratch: Why We Moved from... by Kranar on Friday May 27, 2022 @09:46PM (#31536875)
>I know it's taboo to say this, but in many real world use cases, memory safety bugs aren't that bad and have the severity of any other logic error.

I don't think it's true of many real world use cases and if anything is only true of perhaps trivial use cases, where an application is run on a computer that has no other sensitive information and is not connected to the Internet.

I think what's true is that many programs don't ever reach a point where they're popular enough that someone can reliably exploit it. The threat of memory related errors has not much to do with use case and more to do with whether someone cares enough to identify that error, can reliably reproduce it, and whether the application that exhibits that error is on enough computers that exploiting it is profitable. If those three conditions are satisfied then it matters not whether the program is a video game, a word processor, an image viewer or whatever.

Re:Building a Cloud Database from Scratch: Why We Moved from... by verdagon on Friday May 27, 2022 @11:16PM (#31537295)
A lot of apps don't need internet access, or only communicate with a single (trusted) website, with no data exchanged with other users. I might even say most apps.
Re:Building a Cloud Database from Scratch: Why We Moved from... by woodruffw on Saturday May 28, 2022 @01:05AM (#31537754)
Regardless of whether this is true (I don't think it is), it's probably not the right metric: even if Microsoft Word was completely offline and had no way to make Internet connections (it does), memory unsafety in it is exploitable by getting a user to open a file.

(And the funny thing about "trusted" communications: they're trusted until an attacker figures out how to store and forward untrusted data, at which point a logic error in the server itself is now nicely composable with code that "didn't need" to be particularly memory safe.)

Re:Building a Cloud Database from Scratch: Why We Moved from... by tempodox on Saturday May 28, 2022 @04:00AM (#31538483)
Isn't the whole point of an exploit to go beyond what the software was originally built to do?
Re:Building a Cloud Database from Scratch: Why We Moved from... by throwawaymaths on Saturday May 28, 2022 @11:18AM (#31540958)
> I don't think it's true of many real world use cases and if anything is only true of perhaps trivial use cases,

If you're running a single threaded cloud lambda, you could allocate into an arena and never free, so you don't get UAF or DF.

Re:Building a Cloud Database from Scratch: Why We Moved from... by nine_k on Friday May 27, 2022 @10:08PM (#31536995)
A memory safety error usually leads to some kind of exploit, with a bit of bad luck, to an RCE.

This may not be a big deal for a toy game like Tetris. In a multiplayer AAA game it could lead to a bunch of bitter consequences though, from malware pwning customers' computers to ruined multiplayer experience because the bug would affect the server.

I'd say that a memory safety bug is not like a blemish on the surface of a building, unsightly but tolerable. It's more like a crack in the foundation, which may look tiny on the surface, but who knows how deep it goes.

Re:Building a Cloud Database from Scratch: Why We Moved from... by verdagon on Friday May 27, 2022 @11:19PM (#31537316)
Sure, I don't contest that memory unsafety has some large drawbacks of its own. I'm glad that languages are innovating in memory safety.

My comment was about the tradeoffs we make for our memory safety guarantees, and whether they're always worth it.

Re:Building a Cloud Database from Scratch: Why We Moved from... by dralley on Saturday May 28, 2022 @12:42AM (#31537670)
>On Google Earth, garbage collection pauses weren't really acceptable, but we also wanted to add new functionality without being slowed down. Rust is great for a lot of reasons, but as many know, it can be slower on the feature velocity front.

I have some doubt that Rust feature velocity is meaningfully worse than C++ or C. I would bet good money the other way to be honest.

Re:Building a Cloud Database from Scratch: Why We Moved from... by verdagon on Saturday May 28, 2022 @01:02AM (#31537748)
I've found it depends on what paradigm one is using. The borrow checker is great in some architectures that agree with it, but pretty incompatible with a lot of basic abstractions and can therefore impose more artificial complexity and refactoring in many situations.

It also depends on one's familiarity with the languages, I've used both pretty extensively and can't comment on the velocity when just learning.

Just my experience, YMMV.

Re:Building a Cloud Database from Scratch: Why We Moved from... by kouteiheika on Saturday May 28, 2022 @03:32AM (#31538342)
> It also depends on one's familiarity with the languages, I've used both pretty extensively and can't comment on the velocity when just learning.

When you're just learning it Rust can definitely be a lot less productive and a lot more frustrating. But once you get to an expert level I think there's just no contest, and you can churn out code high quality code significantly faster than you can in C++. (At least that's how it is for me, and I've been programming C++ for over 10 years and I'm don't intend to ever go back.)

Re:Building a Cloud Database from Scratch: Why We Moved from... by dureuill on Saturday May 28, 2022 @05:04AM (#31538795)
> Just my experience, YMMV.

Indeed. IME (around 10y C++, mostly c++14 and c++17, and 6y Rust), I measure x2-x3 velocity in Rust, a lot of which comes from the tooling, a part of which from ub-freedom and much easier and safer parallelism, and the rest from the expressive type system and functional polish.

This is for initial development. Factoring in the maintenance over the years I suspect it tends to an order of magnitude of difference.

Re:Building a Cloud Database from Scratch: Why We Moved from... by lumost on Friday May 27, 2022 @11:39PM (#31537403)
Modern low latency GC like Shenandoah/golang and to a lesser extent g1 mitigate the pause issue pretty substantially.

It’s impossible to verify, but some of the workarounds in very large c apps seem like they have about as much overhead as A modern GC.

Re:Building a Cloud Database from Scratch: Why We Moved from... by jandrewrogers on Saturday May 28, 2022 @12:43AM (#31537671)
At a prior job (writing database kernels in C++), code commits were automatically rejected if any core operation had an observed tail latency of 1 millisecond under stress tests. Also a way to become unfortunately familiar with storage firmware behavior. A GC with a worst-case latency in low milliseconds is a big improvement over the bad old days I remember, but that is still too high for data infrastructure performance-engineering.

The effectiveness of some key optimizations were sensitive to how tight we could make tail latencies for important operations, so a GC always had an unacceptable cost to the extent it occasionally introduced a stall at an inopportune moment. If GC stalls were more like 10 microseconds, consistently, that would be much more viable. I have no idea if that is realistically achievable.

Re:Building a Cloud Database from Scratch: Why We Moved from... by kaba0 on Saturday May 28, 2022 @04:19AM (#31538580)
JVM’s ZGC promises sub-millisecond pauses regardless of heap size, so I’m fairly sure it is no longer applicable to say that GC’s are incompatible with this type of workload. Though of course where these things really matter one should also look at the underlying OS and at least pin the process to fixed cores, as the OS scheduler may cause bigger latencies than the GC.

Though for completeness’s sake I will add that in case of the JVM, variable tail latency still can be experienced due to the JIT compiler.

Re:Building a Cloud Database from Scratch: Why We Moved from... by pjmlp on Saturday May 28, 2022 @04:12AM (#31538534)
As usual, it depends.

GC's don't exist in abstract, and there are plenty of GC enabled languages that also have value types and manual memory management capabilities.

There is no need to throw everything away when the right GC enabled language is chosen in first place.

Re:Building a Cloud Database from Scratch: Why We Moved from... by lumost on Saturday May 28, 2022 @01:58AM (#31537971)
I don't see why a GC couldn't be told avoid stalling in critical code paths. From a practical standpoint, non-generational GCs have no hard requirement to ever stall.
Re:Building a Cloud Database from Scratch: Why We Moved from... by jcelerier on Saturday May 28, 2022 @02:27AM (#31538070)
But can them in practice, and ten years ago when $PROJECT was started and a tech stack had to be chosen ?
Re:Building a Cloud Database from Scratch: Why We Moved from... by pjmlp on Saturday May 28, 2022 @04:13AM (#31538544)
Given how long GC enabled languages with manual memory management capabilities do exist, 10 years ago there were already options available, D would have been an option.
Re:Building a Cloud Database from Scratch: Why We Moved from... by verdagon on Friday May 27, 2022 @11:43PM (#31537419)
That's probably acceptable for most use cases.

On Google Earth, even sub-millisecond pauses would have been too much, we had to fight pretty hard for every sliver of performance we could get.

Re:Building a Cloud Database from Scratch: Why We Moved from... by jcelerier on Saturday May 28, 2022 @02:30AM (#31538079)
That's not acceptable in any GUI or multimedia case, which is, by far, what most people do with their computers. Current screens have a 240hz refresh rate, deadline for a frame is 4ms (and more realistically 2-3ms because your program isn't the only one hogging the cpu) ; 1ms GC stall is up to half of your time budget.
Re:Building a Cloud Database from Scratch: Why We Moved from... by eklavya on Saturday May 28, 2022 @12:27AM (#31537603)
You missed ZGC, that’s great.
Re:Building a Cloud Database from Scratch: Why We Moved from... by dralley on Saturday May 28, 2022 @12:46AM (#31537686)
Shenandoah and ZGC are roughly at par with each other (although ZGC has greater reach because Oracle), but yes that is true with ZGC as well.
Re:Building a Cloud Database from Scratch: Why We Moved from... by adamnemecek on Friday May 27, 2022 @09:59PM (#31536957)
> Also, the problem is nicely mitigated by tools like Address Sanitizer, and will get even better with upcoming advances such as memory tagging and generational references, all which detect memory problems with surprising efficacy and accuracy.

It would be nice if languages had Address Sanitizer built into the language. Maybe some sort of system of checking who owns and borrows memory at any point in time.

Re:Building a Cloud Database from Scratch: Why We Moved from... by kaba0 on Saturday May 28, 2022 @04:39AM (#31538673)
Isn’t Zig’s debug mode something similar?
Re:Building a Cloud Database from Scratch: Why We Moved from... by kaba0 on Saturday May 28, 2022 @04:09AM (#31538524)
I recently wrote a toy JVM implementation in Rust where basically the whole Java-semantic memory management has to happen without the borrow-checker’s guarantees.

But contrary to expectations, I didn’t have many unsafe usages — they were all hidden under some abstraction (like allocate_object function of an ObjectPool), there is perhaps 7-8 in the whole (semi-partial) implementation? (Though it doesn’t yet have a GC, so there is that).

So all in all, in my anecdotal experience one can reasonably well hide the unsafe usages and then use the good expressivity of the language to combine these APIs in strictly safe ways. I also ran the program regularly through MIRI (a rust AST interpreter, which is similar to Valgrind in goals for my use-case) and whenever I found a memory bug I could pin-point it to a few lines of code at most, greatly speeding up debugging.

Re:Building a Cloud Database from Scratch: Why We Moved from... by evnix on Sunday May 29, 2022 @04:56AM (#31547590)
do you have it somewhere on github? I would definitely want to check it out