4 ms·
stat(2) the file, and use the value from the st_blksize member of struct stat.
by tacostakohashi 10y ago
stat(2) the file, and use the value from the st_blksize member of struct stat.
- dom0 10y agoNononono, that's waaaayy to small. This will be something like 512B or 4K, meaning you'll burn the CPU on syscalls instead of doing meaningful work. Even the 32K read/write size used by many utilities (shells, XYZsum, rsync and so on) can slow things down with modern/fast IO devices. Today you'll want to use something like 32K to 2MB. Doesn't really matter around there. If you're writing synchronously (which you shouldn't), then it becomes a tad more difficult to figure out for optimal performance.
- snuxoll 10y agoSync writes have a place, if I'm copying a disk image to a flash drive I typically want to know it's done when dd finishes so I can yank the drive without worrying if the write cache has been flushed.
- mschuster91 10y agoAt least a couple years ago, it was said one should not rip out USB sticks without ejecting them before, because their controller might do invisible maintenance work and that might lead to data corruption...
- floatboth 10y agoHmm. Microsoft doesn't agree: https://i.imgur.com/JIZveQz.png https://i.imgur.com/JIZveQz.png "Disables write caching […] you can disconnect the device safely without [unmounting it]"
- dom0 10y agoBroadly speaking, flash GC/management journaling is the problem of the controller and is usually not the most broken part of it.
- deleted 10y ago[deleted]
- floatboth 10y ago$ sync; sync; sync :D