performance updates to jar and zip

Alan Bateman Alan.Bateman at oracle.com
Thu Oct 27 13:07:00 UTC 2011


On 27/10/2011 00:19, Xueming Shen wrote:
> :
>
> Here are the "surprising" results.
>
>  "nio" is the walkFileTree,
>  "io" is the File.list()
>  "io2" is the File.listFiles().
>
> The nio's File.walkFileTree is 15 times faster than the "traditional" 
> recursion+File.list().
> wow!
>
At least for your testing on Linux then if you run with strace then it 
should become clear. The ioIter and ioIter2 methods in the test result 
in each file being stat'ed 3 times whereas with walkFileTree it is using 
Files.readAttributes to attributes in bulk (so one stat per file).

In any case, this is all good work. One suggestion is to consider not 
introducing a -T<n> or whatever option but instead default to using a 
pipeline that has the right number of threads to work very fast in most 
cases. I'm just thinking of jar tasks in ANT or shell scripts where you 
wouldn't want to hard code a thread count.

-Alan.




More information about the core-libs-dev mailing list