4 ms·
> Walter doing that is why compiling my work project uses 70 gigs of ram and is slow - because nothing stays in the cache This sounds like guesswork. Do you kn
by MaxBarraclough 2y ago
> Walter doing that is why compiling my work project uses 70 gigs of ram and is slow - because nothing stays in the cache
This sounds like guesswork. Do you know the details of DMD's internals? Have you done profiling to confirm poor cache behaviour?
Again, per the article I linked, when Walter made the change there was a drastic improvement in performance.
> everything gets copied so much (because copies are cheap right?)
I'm not sure what copying you're referring to here. Declining to call free has nothing to do with needless copy operations.
> like should end up near like whereas if you have everything going through a single bumping allocator then you can have a pattern of ABABAB where a proper allocator would do AAABBB which the cache can actually use.
A general purpose allocator like malloc can't segment the allocations for different types/purposes, it only has the allocation size to go on. That's true whether or not you ever call free. If you want to manage memory using purpose-specific pools, you'd need to do that yourself.
As for whether this really would improve cache performance, I imagine it's possible, which is why we have discussions about structure-of-arrays vs array-of-structures, and the entity component system pattern used in gamedev. I'd be surprised if compiler code could be significantly accelerated with that kind of reworking, though.
- mhh__ 2y agoI know the internals of DMD extremely well.
- mhh__ 2y ago> I'm not sure what copying you're referring to here. Declining to call free has nothing to do with needless copy operations Think. You make malloc feel inexpensive both by using a crappy but fast allocator and disabling free. People (reflexively) know this, and then they don't get punished when they get extremely careless with their allocations because test suites never allocate enough memory to OOM the machine. This isn't some hypothetical, I have measured the amount of memory dmd ever actually writes to (i.e. after allocation) to be absurdly low. Like single digits. Pretty much every bit of semantic analysis that hasn't been optimized post-facto involves copying hundreds to thousands of bytes. > A general purpose allocator like malloc can't segment the allocations for different types/purposes, it only has the allocation size to go on. That's true whether or not you ever call free. The size is what I'm getting at, but a D allocator can do this because it gets given type information. (dmd allocates mainly with `new` which is then forwarded to the bump the pointer allocator if the GC is not un-disabled) Also evidence that the exact scheme dmd uses is suboptimal wrt allocator impl: https://forum.dlang.org/thread/zmknwhsidfigzsiqcibs@forum.dlang.org https://forum.dlang.org/thread/zmknwhsidfigzsiqcibs@forum.dl...