Bug 199140 - unlinking symlinks oddly slow on UFS
Summary: unlinking symlinks oddly slow on UFS
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 9.3-RELEASE
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-fs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-04-03 07:54 UTC by sigsys
Modified: 2015-04-15 17:28 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description sigsys 2015-04-03 07:54:27 UTC
On a UFS2 filesystem with soft updates, deleting a directory of thousands of symlinks is hundreds of times slower than deleting regular files.

It looks like the writes are synchronous.

  $ mkdir test1 && for f in `seq 5000`; do touch "test1/$f"; done
  $ mkdir test2 && for f in `seq 5000`; do echo test > "test2/$f"; done
  $ mkdir test3 && for f in `seq 5000`; do ln -s test "test3/$f"; done
  $ sync
  $ time rm -r test1
          0.20 real         0.01 user         0.17 sys
  $ time rm -r test2
          0.30 real         0.00 user         0.25 sys
  $ time rm -r test3
         94.73 real         0.02 user         0.72 sys

But if the symlinks are made large enough that their targets cannot be stored in the inode directly, then unlinking them is fast!

  $ test="$(perl -e 'print "x"x1023')"
  $ mkdir test4 && for f in `seq 5000`; do ln -s "$test" "test4/$f"; done
  $ time rm -r test4
          0.17 real         0.00 user         0.17 sys