Java outruns C++ while std::filesystem stops for syscall snacks
pages.haxiom.io·22h·
Discuss: r/programming
Flag this post

Overview

Recently, I began exploring the performance of concurrent filesystem tree walkers across various programming languages. I assumed that my C++ implementation would match or even exceed the speed of my Rust version. To my surprise, C++ lagged behind all my other implementations, including a single-threaded JavaScript version. Even with page caching, C++ was noticeably slower. This unexpected outcome prompted me to delve deeper into the underlying reasons for the performance disparity.

The Algorithm

The algorithm starts at the root of a storage device and traverses the filesystem in a depth-first manner, examining every directory and file. When a directory is encountered, a task is dispatched to a work-stealing thread pool, allowing for concurrent traversal of mu…

Similar Posts

Loading similar posts...