-
Notifications
You must be signed in to change notification settings - Fork 613
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bad performance of fs2.io.file.Files[IO].walk() #3329
Comments
Thanks for the report. Are you using |
Thanks for your reply. I am using I hope this helps. |
This doesn't entirely surprise me. |
Minor update: this is so slow that I had to trim down the depth used in benchmarking in order to make it tractable on my laptop. Here's what I'm using to test: @State(Scope.Thread)
class FilesBenchmark {
private[this] var target: Path = _
@Setup
def setup() = {
val file = File.createTempFile("fs2-benchmarks-", "-walk")
file.delete()
file.mkdir()
target = Path(file.toString) // ewwwww
val MaxDepth = 4
val Names = 'A'.to('E').toList.map(_.toString)
def loop(cwd: File, depth: Int): Unit = {
if (depth < MaxDepth) {
Names foreach { name =>
val sub = new File(cwd, name)
sub.mkdir()
loop(sub, depth + 1)
}
} else if (depth == MaxDepth) {
Names foreach { name =>
val sub = new File(cwd, name)
sub.createNewFile()
loop(sub, depth + 1)
}
}
}
loop(file, 0)
}
@Benchmark
def countFiles(): Int = {
Files[IO]
.walk(target)
.chunks
.map(_.size)
.fold(0)(_ + _)
.compile
.lastOrError
.unsafeRunSync()
}
} |
I am migrating a tool to use fs2 (v3.9.2).
The first step is just to collect about 26000 files in a directory tree for further processing.
Here are the timings of this first step for several solutions:
java.nio.file.Files#walkFileTree
: 0.5sDeprecatedFilesApi.walk
: 0.7sfs2.io.file.Files#walk
: 4sThe text was updated successfully, but these errors were encountered: