Is there a workaround for Java's poor performance on walking huge directories?

前端 未结 10 780
予麋鹿
予麋鹿 2020-12-02 23:30

I am trying to process files one at a time that are stored over a network. Reading the files is fast due to buffering is not the issue. The problem I have is just listing

10条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-03 00:27

    Are you sure it's due to Java, not just a general problem with having 10k entries in one directory, particularly over the network?

    Have you tried writing a proof-of-concept program to do the same thing in C using the win32 findfirst/findnext functions to see whether it's any faster?

    I don't know the ins and outs of SMB, but I strongly suspect that it needs a round trip for every file in the list - which is not going to be fast, particularly over a network with moderate latency.

    Having 10k strings in an array sounds like something which should not tax the modern Java VM too much either.

提交回复
热议问题