OS in Go? Why Not
blog.jetbrains.com
blog.jetbrains.com
It's absolutely possible to roll your own data structures, even if the language provides its own implementations. Some use their own hash map instead of std::unordered_map/set in C++, and some use hash maps specialised for primitive types in Java (as the generic HashMap boxes).
(On the contrary: do people roll good implementations of data structures usually?)
> As explained in this Reddit thread, mouse lag is likely because the interrupt handler allocates memory that triggers garbage collection.
The Biscuit paper states "the longest single GC-related pause suffered by NGINX was 115 microseconds"; I'm not sure how well that generalises to other workloads, but (infrequent already) pauses would be hard to notice if that does generalise.
In high-level languages, my general observation is that hand-rolled data structures can be divided into two kinds: the kind written by somebody who has no clue what they're doing, and the kind written by a data structures wizard that leaves you in awe about the details.
The most notable example of I've seen of the latter kind was in some read-optimised database where they wrote a cache that linearly scales with the number of readers almost infinitely -- some black magic with maintaining two copies of a map, and having each reader go through completely wait-free paths and switching maps on writes so they never interfere, whilst sharing the underlying storage to not make writes completely inefficient. Stuff like this just makes admire the crazy things that are possible.
Then you have the crappy linked list implementation #82432 that segfaults it you look at it funny.
> The Biscuit paper states "the longest single GC-related pause suffered by NGINX was 115 microseconds"; I'm not sure how well that generalises to other workloads, but (infrequent already) pauses would be hard to notice if that does generalise
> The collector suspends ordinary execution on all cores (a “stop-the-world” pause) twice during a collection: at the beginning to enable the write barrier on all cores and at the end to check that all objects have been marked. These stop-the-world pauses typically last dozens of microseconds
Yeah that certainly seems to be the case, for interactive use, I find it hard to believe that anything less than a few ms will cause issues, and that's 3 orders of magnitude more than what biscuit found.
Although I do wonder if there are GC concerns elsewhere -- these are just vague memories, but I believe that the Go GC is pretty conservative and will not reap anything that looks like a pointer, so there might be concerns around leaks especially with all the special pcie registers, dma buffers, etc that might be lying around in memory.
Feels like it's written by somebody who's never even looked at kernel code before tbh.
Don’t want to insult the author, but passages like these really trigger my ChatGPT detectors :) Am I alone?
Maybe I exaggerate about the writing quality, but that's certainly the impression I get. The blog post right before this one is another guest post, and while I don't think this is happening on Jetbrains' blog, it really reminds me of the shady "reputation boost" agencies that charge money to put out press releases and articles with the author's name on it so they get to boast about being "in the media" and such.
- Google's gVisor[1] (a re-implementation of a significant subset of the Linux syscall ABI for isolation, also mentioned in the article).
- USBArmory's Tamago[2] (a single-threaded bare-metal Go runtime for SOCs).
Both of these are security-focused with a clear trade off: sacrifice some performance for memory safety and excellent readability (and auditability). I feel like that's the sweet spot for low-level Go - projects that need memory safety but would rather trade some performance for simplicity.
gVisor is a very fun project - they're really pushing the boundaries of what's possible in Go. Typical overhead is <10% thanks to a number of new features (systrap[3], directfs, in-process overlay...), all while maintaining a well-documented and super clean code base.
[1]: https://github.com/google/gvisor
This would make a good case for a valuable title change.
And the title says “OS”, not “an OS”, leading me to think that OS was a proper noun. Is that so crazy?
Anyway, the title is a bit vague, writing “an operating system” would just be better for everybody.