3 ms·
> - Writing to a fresh file is slower than writing to an existing file > mold can link a 4 GiB LLVM/clang executable in ~1.8 seconds on my machine if the linke
by dietr1ch 2y ago
> - Writing to a fresh file is slower than writing to an existing file
> mold can link a 4 GiB LLVM/clang executable in ~1.8 seconds on my
machine if the linker reuses an existing file and overwrites it.
However, the speed decreases to ~2.8 seconds if the output file does
not exist and mold needs to create a fresh file. I tried using
fallocate(2) to preallocate disk blocks, but it didn't help. While 4
GiB is not small, should creating a file really take almost a second?
1s difference here is insane these days. There must be something weird going on, even if the physical disk is one of those ancient spinning things.
- Sesse__ 2y agoHe doesn't specify what file system he's using, but offhand, you would assume that what actually takes time isn't to creating the file, but rather allocating all the blocks. A good first step would be to reproduce the issue and take a profile of both cases?
- the8472 2y agoxfs, ext4 and btrfs all have delayed allocation. so they should only synchronously allocate the blocks if there is memory pressure or if they're triggering those well-meant (but in this case counterproductive) auto_da_alloc heuristics.