4 ms·
> 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 inexp
by 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...