frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

Static Allocation for Compilers

https://matklad.github.io/2025/12/23/static-allocation-compilers.html
20•enz•6d ago

Comments

delifue•5d ago
How does static allocation avoid wasting memory?

Static memory allocation requires hardcoding an upper limit of size of everything. For example, if you limit each string to be at most 256 bytes, then a string with only 10 bytes will waste 246 bytes of memory.

If you limit string length to 32 bytes it will waste fewer memory but when a string longer than 32 bytes comes it cannot handle.

Joker_vD•5d ago
> if you limit each string to be at most 256 bytes, then a string with only 10 bytes will waste 246 bytes of memory.

No? Unless you limit each string to be exactly 256 bytes but that's silly.

> If you limit string length to 32 bytes it will waste fewer memory but when a string longer than 32 bytes comes it cannot handle.

Not necessarily. The early compilers/linkers routinely did "only the first 6/8 letters of an identifier are meaningful" schtick: the rest was simply discarded.

AlotOfReading•1h ago
Your C++ compiler already implements a solution to that called short string optimization. Strings start out as small byte buffers that can be easily be passed around. When they grow beyond that, the fixed buffer is swapped out for pointer to another allocation on the heap. There's no (immediate) reason that allocation has to come from a direct call to the system allocator though, and it usually doesn't. It can just as easily come from an allocation pool that was initialized at startup.

Even if you needed to hardcode upper size limits, which your compiler already does to some extent (the C/C++ standards anticipate this by setting minimum limits for certain things like string length), you wouldn't actually pay the full price on most systems because of overcommit. There are other downsides to this depending on implementation details like how you reclaim memory and spawn compiler processes, so I'm not suggesting it as a good idea. It's just possible.

Joker_vD•5d ago
Yes, you can dump your IR straight to the disk and then stream it to process further. That's how quite a number of compilers (and assemblers) were written back in the 70s and it was quite painful.

IIRC, Unix's original as works that way: during assembly, the text and data sections are written into separate temporary files, and then they are merged together into the a.out. And yes, it's slow.

cloudhead•2h ago
How does this work? Files need to reference other files eg. for calling functions from other modules, which means semantic analysis needs both files in memory to check the types. This is especially complicated with mutual recursion across modules (separate compilation doesn't apply here). If you're building a language like C where everything requires forward declarations, then maybe, but anything more modern seems difficult.
pwdisswordfishy•1h ago
> I feel that a strict separation between O(N) compiler output and O(1) intermediate processing artifacts [...]

I don't follow. He has just said that although the size of the arena is finite, the input and output are unbounded, and the compiler does its work by processing "a sequence of chunks" (i.e. those things that will fit into the finitely sized arena). That's not "O(1) intermediate processing artifacts". It's still O(n).

> [...] can clarify compiler’s architecture, and I won’t be too surprised if O(1) processing in compilers would lead to simpler code

This doesn't seem like an intuitive conclusion at all. There's more recordkeeping needed now, and more machinery in need of being implemented, and one should expect that this scheme would make for things that are neither simple nor easy.

We haven't even gotten around to addressing how "statically allocating" a fixed size arena that your program necessarily subdivides into pieces (before moving onto the next chunk and doing the same) is just "dynamic allocation with extra steps". (If you want or just think that it would be neat to write/control your own allocator, then fine, but... say that.)

pwdisswordfishy•58m ago
Having said that, if this is really all just a roundabout way to get the Rust people to actually give a damn about memory use and sell the idea that "you really shouldn't require more than 4GB of memory just to bootstrap the compiler and/or build other medium-to-very-large programs," then hey that's great.
deivid•22m ago
It's an interesting idea. I'm butchering TCC (tiny c compiler) for a side project/experiment, and using arenas sped it up 2x. This of course requires the memory limit to be specified in advance, but for my situation that's fine.

Google is dead. Where do we go now?

https://www.circusscientist.com/2025/12/29/google-is-dead-where-do-we-go-now/
368•tomjuggler•3h ago•345 comments

AI Employees Don't Pay Taxes

https://alec.is/posts/ai-employees-dont-pay-taxes/
65•arm32•1h ago•53 comments

Show HN: Stop Claude Code from forgetting everything

https://github.com/mutable-state-inc/ensue-skill
28•austinbaggio•1h ago•19 comments

Parsing Advances

https://matklad.github.io/2025/12/28/parsing-advances.html
6•birdculture•23m ago•0 comments

Flame Graphs vs Tree Maps vs Sunburst (2017)

https://www.brendangregg.com/blog/2017-02-06/flamegraphs-vs-treemaps-vs-sunburst.html
86•gudzpoz•2d ago•21 comments

Static Allocation with Zig

https://nickmonad.blog/2025/static-allocation-with-zig-kv/
146•todsacerdoti•7h ago•77 comments

ManusAI Joins Meta

https://manus.im/blog/manus-joins-meta-for-next-era-of-innovation
80•gniting•1h ago•43 comments

When someone says they hate your product

https://www.getflack.com/p/responding-to-negative-feedback
64•jger15•4h ago•60 comments

List of domains censored by German ISPs

https://cuiiliste.de/domains
259•elcapitan•5h ago•101 comments

AI is forcing us to write good code

https://bits.logic.inc/p/ai-is-forcing-us-to-write-good-code
70•sgk284•4h ago•49 comments

A production bug that made me care about undefined behavior

https://gaultier.github.io/blog/the_production_bug_that_made_me_care_about_undefined_behavior.html
90•birdculture•5h ago•55 comments

Lead-Free Organic–Inorganic Halobismuthate for Large Piezoelectric Effect

https://pubs.acs.org/doi/10.1021/jacs.5c15484
4•PaulHoule•49m ago•0 comments

All Delisted Steam Games

https://delistedgames.com/all-delisted-steam-games/
155•Bondi_Blue•4h ago•64 comments

Left Behind: Futurist Fetishists, Prepping and the Abandonment of Earth (2019)

https://www.boundary2.org/2019/08/sarah-t-roberts-and-mel-hogan-left-behind-futurist-fetishists-p...
30•naves•4h ago•19 comments

Obelisk 0.32: Cancellation, WebAPI, Postgres

https://obeli.sk/blog/announcing-obelisk-0-32/
16•tomasol•3h ago•3 comments

Show HN: Aroma: Every TCP Proxy Is Detectable with RTT Fingerprinting

https://github.com/Sakura-sx/Aroma
53•Sakura-sx•4d ago•28 comments

Which Humans? (2023)

https://osf.io/preprints/psyarxiv/5b26t_v1
27•surprisetalk•3h ago•14 comments

GOG is getting acquired by its original co-founder

https://www.gog.com/blog/gog-is-getting-acquired-by-its-original-co-founder-what-it-means-for-you/
491•haunter•7h ago•275 comments

Libgodc: Write Go Programs for Sega Dreamcast

https://github.com/drpaneas/libgodc
196•drpaneas•10h ago•46 comments

Intelligence – A Mystery Investigation Game

https://intelligencegame.tech/
5•throw_a_grenade•4d ago•0 comments

Show HN: Superset – Terminal to run 10 parallel coding agents

https://superset.sh/
54•avipeltz•6d ago•52 comments

Linux DAW: Help Linux musicians to quickly and easily find the tools they need

https://linuxdaw.org/
173•prmoustache•11h ago•86 comments

Kidnapped by Deutsche Bahn

https://www.theocharis.dev/blog/kidnapped-by-deutsche-bahn/
892•JeremyTheo•11h ago•816 comments

You can't design software you don't work on

https://www.seangoedecke.com/you-cant-design-software-you-dont-work-on/
226•saikatsg•15h ago•82 comments

Static Allocation for Compilers

https://matklad.github.io/2025/12/23/static-allocation-compilers.html
20•enz•6d ago•8 comments

Karpathy on Programming: "I've never felt this much behind"

https://twitter.com/karpathy/status/2004607146781278521
259•rishabhaiover•3d ago•251 comments

High-performance C++ hash table using grouped SIMD metadata scanning

https://github.com/Cranot/grouped-simd-hashtable
41•rurban•5d ago•15 comments

Nvidia takes $5B stake in Intel under September agreement

https://www.reuters.com/legal/transactional/nvidia-takes-5-billion-stake-intel-under-september-ag...
182•taubek•6h ago•70 comments

Binance's Trust Wallet extension hacked; users lose $7M

https://www.web3isgoinggreat.com/?id=trust-wallet-hack
84•ilamont•3h ago•15 comments

Show HN: Evidex – AI Clinical Search (RAG over PubMed/OpenAlex and SOAP Notes)

https://www.getevidex.com
30•amber_raza•6h ago•15 comments