The Directory Walk Cost

The Directory Walk, Stat Calls and Their Measured Cost

The manual warns that each directory costs a file-system access "even if none of those files are present". To measure it, a 1 KB file nine directories deep was fetched with wrk 40,414 -t4 -c32 -d8s, three runs per setup, from 48 preforked children on 36 cores; CPU per request is the service cgroup's usage_usec divided by requests served. Medians:

Cost of the directory walk for one static file nine levels deep (Apache 2.4.66 129 , prefork)
AllowOverride Lookups Requests/s CPU per request (us)
None 0 75,761 147
None, no FollowSymLinks 9 lstat 71,165 190
All, no files 10 70,304 209
All, 14-line file 10 69,390 296
Same + 4 deeper files 10 66,837 357
14 lines in Directory 0 75,325 157

Missing files cost about 6 microseconds a lookup, 42% more CPU before any rule runs. A present file is read, parsed and its regular expressions compiled on every request: with the 14 lines of Override Classes, a request cost 296 microseconds from .htaccess and 157 from the main configuration. Without FollowSymLinks, Apache lstat()s each path component, so Ubuntu 225 's default is also the fast one. These lookups hit the dentry cache; on a network file system a miss can cost a round trip.