harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Ellison <t.p.elli...@gmail.com>
Subject Re: [classlib] add cache for file's canonical path
Date Fri, 08 May 2009 13:40:15 GMT
Regis wrote:
> Recently I'm trying to optimize implementation of java.File,


> and find File.getCanonicalPath is very time cost and is heavily used
> by checking file permission. But in the most of cases, the canonical
> path is never change, so I think it's better to cache them to avoid
> calculate every time. And I found RI also has cache:
> File.getCanonicalPath doesn't reflect change in file system
> real-time.

Hmm, sounds risky to me -- at least liable to create unpredictable behavior.

> I have created a JIRA HARMONY-6200 for this, and attach a simple cache
> implementation for file's canonical path, someone interested in this may
> can help to review it.
> The cache has fixed size, when it's full oldest element would be remove,
> and elements would be expired in 10 minutes, that mean if the element
> stay in cache more than 10 minutes, it's not validate and will be removed.

Ten minutes seems like a very long time.  I would have thought that
having a cache that expires in a relatively short time (since that file
path was last accessed) would be sufficient.

> It's a initial implementation, I believe there are still many places can
> be improved, any comments and suggestions are welcome.

My initial thought is that it would be preferable to have the OS tell
you when a file path changes so you can invalidate the cache, but there
may not be enough info to be able to do that...


View raw message