HNHacker News
TopNewBestAskShowJobs

nickmonad

107 karma · joined October 21, 2019

https://nickmonad.blog/
submissionscomments
nickmonad··on Static Allocation with Zig
Gotcha. Thanks for clarifying! I guess I wasn't super concerned about the 'try' failing here since this code is squarely in the initialization path, and I want the OOM to bubble up to main() and crash. Although to be fair, 1. Not a great experience to be given a stack trace, could definitely have a nice message there. And 2. If the ConnectionPool init() is (re)used elsewhere outside this overall initialization path, we could run into that leak.

The allocation failure that could occur at runtime, post-init, would be here: https://github.com/nickmonad/kv/blob/53e953da752c7f49221c9c4... - and the OOM error kicks back an immediate close on the connection to the client.

nickmonad··on Concurrent Hash Table Designs
Would love to read this, although I'm seeing some pretty horrific code formatting issues in both Firefox and Chrome.
nickmonad··on Static Allocation with Zig
Hey matklad! Thanks for hanging out here and commenting on the post. I was hoping you guys would see this and give some feedback based on your work in TigerBeetle.

You mentioned, "E.g., in OP, memory is leaked on allocation failures." - Can you clarify a bit more about what you mean there?

nickmonad··on Static Allocation with Zig
This is the fundamental question which motivated the post. :)

I think there are a few different ways to approach the answer, and it kind of depends on what you mean by "draw the line between an allocation happening or not happening." At the surface level, Zig makes this relatively easy, since you can grep for all instances of `std.mem.Allocator` and see where those allocations are occurring throughout the codebase. This only gets you so far though, because some of those Allocator instances could be backed by something like a FixedBufferAllocator, which uses already allocated memory either from the stack or the heap. So the usage of the Allocator instance at the interface level doesn't actually tell you "this is for sure allocating memory from the OS." You have to consider it in the larger context of the system.

And yes, we do still need to track vacant/occupied memory, we just do it at the application level. At that level, the OS sees it all as "occupied". For example, in kv, the connection buffer space is marked as vacant/occupied using a memory pool at runtime. But, that pool was allocated from the OS during initialization. As we use the pool we just have to do some very basic bookkeeping using a free-list. That determines if a new connection can actually be accepted or not.

Hopefully that helps. Ultimately, we do allocate, it just happens right away during initialization and that allocated space is reused throughout program execution. But, it doesn't have to be nearly as complicated as "reinventing garbage collection" as I've seen some other comments mention.

nickmonad··on Static Allocation with Zig
Nice! Will definitely take a look :)
nickmonad··on Static Allocation with Zig
Author here! Overcommit is definitely a thing to watch out for. I believe TigerBeetle calls this out in their documentation. I think you'd have to explicitly disable it on Linux.

For the second question, yes, we have to keep track of what's in use. The keys and values are allocated via a memory pool that uses a free-list to keep track of what's available. When a request to add a key/value pair comes in, we first check if we have space (i.e. available buffers) in both the key pool and value pool. Once those are marked as "reserved", the free-list kind of forgets about them until the buffer is released back into the pool. Hopefully that helps!

nickmonad··on Static Allocation with Zig
I have a few cases in this (proof of concept) codebase that require knowledge about allocation strategy, even in Zig, but that's on me and the design at this point. Something I wanted to touch on more in the post was the attempt to make the components of the system work with any kind of allocation strategy. I see a common thing in Zig projects today where something like `gpa: std.mem.Allocator` or even `arena: std.mem.Allocator` is used to signal intent, even though the allocator interface is generic.
nickmonad··on Static Allocation with Zig
Author here! That's totally fair. I did learn this is a common technique in the embedded world and I had a whole section in the original draft about how it's not a super well-known technique in the typical "backend web server" world, but I wanted to keep the length of the post down so I cut that out. I think there's a lot we can learn from embedded code, especially around performance.
nickmonad··on Ask HN: What are the best engineering blogs with real-world depth?
TigerBeetle: https://tigerbeetle.com/blog/
nickmonad··on Cloudflare outage on November 18, 2025 post mortem
Limits in systems like these are generally good. They mention the reasoning around it explicitly. It just seems like the handling of that limit is what failed and was missed in review.
nickmonad··on Multiple Digital Ocean services down
Usually because of SSL termination. It's generally "easier" to just let DO manage getting the cert installed. Of course, there are tradeoffs.
nickmonad··on Building a high-performance ticketing system with TigerBeetle
Did the company end up using it?
nickmonad··on Building a high-performance ticketing system with TigerBeetle
It seems to me that, in practice, you'd want the "LiveBatcher" to have some durability as well. Is there a scenario where a customer could lose their place because of a horribly timed server shutdown, where those transfers hadn't even been sent to TigerBeetle as pending yet? Or am I misunderstanding the architecture here?

Edit: Yes, I think I misunderstood something here. The user wouldn't even see their request as having returned a valid "pending" ticket sale since the batcher would be active as the request is active. The request won't return until its own transfer had been sent off to TigerBeetle as pending.

nickmonad··on Tangled, a Git collaboration platform built on atproto
I really like the idea of more decentralized git collaboration. What do people think are the biggest blockers to adoption in this space? Having to run a server or manage some kind of private keys? Is it purely network effect?
nickmonad··on Libghostty Is Coming
(doesn't rely on libc btw)

Just kidding of course, very cool stuff!

nickmonad··on Show HN: Zedis – A Redis clone I'm writing in Zig
Why would we want a literal BUG as a mascot?? /s
nickmonad··on Yoke: Infrastructure as code, but actually
Yeah, I've always felt like defining infrastructure in a full-on language fell nicely into that category of "just because you can doesn't mean you should."

I've only recently started to see this play out with a sufficiently large infrastructure setup and nothing is more infuriating than having to keep multiple layers of logic in your head when you're trying to figure out why some value got set on a task definition.

nickmonad··on Ask HN: What Is the Best Book for Indie SaaS Hackers
Too many to name really. One of the most influential for me though was The Mom Test. Teaches you how to validate before you build.
nickmonad··on Show HN: Free Plain-Text Bookmarking
Create one?
nickmonad··on Is htmx Just Another JavaScript Framework?
Why? If the primary client is a browser, you're giving it exactly what it needs to render.
nickmonad··on The Rise of the $10M Disc Golf Celebrity
If you aren't losing discs, you aren't playing enough.
nickmonad··on The Rise of the $10M Disc Golf Celebrity
It does make me wonder when that will flip though. "Ball" golf (as disc golfers like to say) seems to be at a point where you can make a serious living without much to do on the social media side. Companies dump so much money into the purse because there are enough eyes on the game, and I think disc golf can get to that point.

But then again, maybe disc golf is coming of age in a different era, where social media will just be ingrained moving forward, and it will continue to be just as important, if not more, than your performance on the course.

nickmonad··on The Rise of the $10M Disc Golf Celebrity
Nobody gives a shit dude. We'll keep having fun without you.
nickmonad··on Bitcoin not for me, says Bill Gates
> The billionaire said he did not choose his investments on the basis of whether they would be worth more to others.

Entertain the notion, just for one second (even if you don't think it will happen), that people are envisioning a future where the bitcoin is just, you know... used? In that context, it's worth more to _them_, not "others".

Also, didn't these people take a risk to earn their level of wealth? Starting a company can absolutely destroy people and their families, yet we encourage people to take these kinds of calculated risks everyday.

nickmonad··on Ask HN: What are the most fundamental books on computer science?
I would classify these in the realm of software engineering, not computer science.
← PreviousPage 2 of 2