Skip to content

Comment on Ask HN: why is it faster to delete files from a disc than to write them?

Comments

Writing a file means that all the data has to pass trhough the file system, the io driver, the disk controller interface onto the disk with a certain maximum write speed. If the file is large then it will take a long time. The 'bookkeeping' to administer where the file goes is a very small portion compared to the data of the file in such cases.

When you delete the data you only update the bookkeeping, so that's much quicker.

If you were to erase the file then it would take just as long as writing it in the first place.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.