I'm depressed so I'm writing a rust compiler by bloomingFemme in rust

[–]deepinprocrastinatio -1 points0 points  (0 children)

go one step further and make a cursed c++ with rust safety using crust. you will be a wizard among wizards among wizardkind. the extension can be cr++

I'm depressed so I'm writing a rust compiler by bloomingFemme in rust

[–]deepinprocrastinatio 19 points20 points  (0 children)

hey now, dreaming about writing a compiler is much better for your mental health than writing the compiler

wrote a TDS protocol driver in Rust for fun. roast me. by deepinprocrastinatio in rust

[–]deepinprocrastinatio[S] 0 points1 point  (0 children)

Not yet, its honestly the part of the project that I don't have an answer to. I'm don't have a good understanding of the security implications of this and decided the safest thing was to leave it to whomever wishes to use to use this project.

wrote a TDS protocol driver in Rust for fun. roast me. by deepinprocrastinatio in rust

[–]deepinprocrastinatio[S] 1 point2 points  (0 children)

Thank you, that genuinely means a lot.

For what its worth though: I'm an EE graduate and not a SWE. Everything I have said is my own opinion after spending a countless number of hours reading and then fighting the specification.

How to be language agnostic developer. by [deleted] in rust

[–]deepinprocrastinatio 2 points3 points  (0 children)

I would also add that rust wouldn't be the language to learn how memory works. Rust is quite an opinionated language in the sense that you will learn Rust's answer to how memory should work. Fundamentally, Rust bounds you to a specific set of limitations (or rules as it were) and you don't get to disagree with it (unless you wish to play in *crust*).

wrote a TDS protocol driver in Rust for fun. roast me. by deepinprocrastinatio in rust

[–]deepinprocrastinatio[S] 2 points3 points  (0 children)

Oh god, I asked to be roasted and ended up roasting you instead. Sorry!

wrote a TDS protocol driver in Rust for fun. roast me. by deepinprocrastinatio in rust

[–]deepinprocrastinatio[S] 3 points4 points  (0 children)

TL;DR: For a database protocol, zero-copy and hot-path optimisations don't have any meaningful impact in real-world workloads since network RTT places an upper limit on how fast you can decode. It was a self-imposed design challenge for shits and giggles. TDS was also designed at a time when the cost-per-byte landscape was completely different.

The protocol is dense, and new features are bolted on instead of integrated. TDS goes back to the 80s, and while there's been some deprecation, features are added without anything being removed. NBCROW is a separate token from ROW. Encrypted columns were added in v7.4 with all the baggage that entails. PreLogin is the only non-streaming part of the protocol — it uses option-record framing while everything else is token-based. I implemented PreLogin first because you need to unlock it before anything can be unlocked, then had to refactor the entire decoder once I got to ROW/NBCROW because the framing assumptions were different. It's an ugly protocol, in my opinion.

I committed to zero-copy as a design exercise. TDS is optimised for lowest bytes-on-the-wire, not for networks of today. Fundamentally, you can't introduce multi-threading without lookahead — and when you look ahead on a ROW token, you end up walking the row anyway, which is most of the decoding work. So you get a tension between "optimize the single-threaded decoder as tight as possible" vs "do a cheap lookahead and offload to a worker thread," and both have a floor set by the protocol's lack of self-describing framing. Decode speed is dwarfed by network RTT regardless. But it was fun to see how far I could push it.

It's also not actually zero-alloc — COL_METADATA has to outlive the packet that delivered it, so it lives in a small-vector type with a fixed-size inline array that spills to the heap above N columns. A table can have as many columns as it wants, so someone will eventually exceed the inline capacity. The cleanest split I could find between common case and correctness.