All we want to know is whether we're above the `fast_limit`; if we're
above that, we don't need to know how many exactly.
By returning early instead of iterating over all entries, a lot of CPU
time can be saved. In a microbenchmark where `fio` was used to create
thousands of files, the CPU usage of `CDir::should_split_fast()` went
from 6% to less than 1% in the `perf report`.
Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
const CDentry *dn = p.second;
if (!dn->get_projected_linkage()->is_null()) {
effective_size++;
+
+ if (effective_size > fast_limit) [[unlikely]]
+ return true;
}
}
- return effective_size > fast_limit;
+ return false;
}
bool CDir::should_merge() const