I created a bugzilla for this:
    http://issues.apache.org/bugzilla/show_bug.cgi?id=42259

> -----Original Message-----
> From: Brus, Tom [mailto:[EMAIL PROTECTED]
> Sent: Thursday, April 26, 2007 09:55
> To: Ant Developers List
> Subject: RE: class loading speed can be improved in
AntClassLoader.java
> 
> Sounds sensible and more traceable ;)
> I will do that later today.
> 
> -Tom
> 
> > -----Original Message-----
> > From: Jeffrey E Care [mailto:[EMAIL PROTECTED]
> > Sent: Thursday, April 26, 2007 00:44
> > To: Ant Developers List
> > Subject: RE: class loading speed can be improved in
> AntClassLoader.java
> >
> > It may be better to open a feature request in bugzilla and attach
the
> > patch there.
> >
> >
>
________________________________________________________________________
> __
> > __________________
> >
> > Jeffrey E. (Jeff) Care
> > [EMAIL PROTECTED]
> > IBM WebSphere Application Server
> > Systems Management Tools Architecture & Development
> >
> >
> >
> >
> >
> >
> >
> > "Brus, Tom" <[EMAIL PROTECTED]>
> > 04/25/2007 01:29 PM
> > Please respond to
> > "Ant Developers List" <dev@ant.apache.org>
> >
> >
> > To
> > "Ant Developers List" <dev@ant.apache.org>
> > cc
> >
> > Subject
> > RE: class loading speed can be improved in AntClassLoader.java
> >
> >
> >
> >
> >
> >
> > > From: Peter Reilly [mailto:[EMAIL PROTECTED]
> > > Sent: Wednesday, April 25, 2007 15:24
> > >
> > > This sounds useful,
> > > can you provide a patch please?
> >
> > With pleasure (also attached in case there are line wrapping
> problems):
> >
> > ========= snip snip ===========
> > diff -Naur old/org/apache/tools/ant/AntClassLoader.java
> > new/org/apache/tools/ant/AntClassLoader.java
> > --- old/org/apache/tools/ant/AntClassLoader.java        2006-12-13
> > 06:16:00.000000000 +0100
> > +++ new/org/apache/tools/ant/AntClassLoader.java        2007-04-25
> > 19:17:46.546875000 +0200
> > @@ -799,19 +799,16 @@
> >       */
> >      private InputStream getResourceStream(File file, String
> > resourceName) {
> >          try {
> > -            if (!file.exists()) {
> > -                return null;
> > -            }
> > -
> > -            if (file.isDirectory()) {
> > +            // is it a file in the zipfile cache
> > +            ZipFile zipFile = (ZipFile) zipFiles.get(file);
> > +            if (zipFile==null && file.isDirectory()) {
> > +                // not in the cache, but it is a dir
> >                  File resource = new File(file, resourceName);
> > -
> >                  if (resource.exists()) {
> >                      return new FileInputStream(resource);
> >                  }
> > -            } else {
> > -                // is the zip file in the cache
> > -                ZipFile zipFile = (ZipFile) zipFiles.get(file);
> > +            } else if (zipFile!=null || file.exists()) {
> > +                // found in the cache or not yet in the cache but
> > existing
> >                  if (zipFile == null) {
> >                      zipFile = new ZipFile(file);
> >                      zipFiles.put(file, zipFile);
> > @@ -994,13 +991,11 @@
> >       */
> >      protected URL getResourceURL(File file, String resourceName) {
> >          try {
> > -            if (!file.exists()) {
> > -                return null;
> > -            }
> > -
> > -            if (file.isDirectory()) {
> > +            // is it a file in the zipfile cache
> > +            ZipFile zipFile = (ZipFile) zipFiles.get(file);
> > +            if (zipFile==null && file.isDirectory()) {
> > +                // not in the cache, but it is a dir
> >                  File resource = new File(file, resourceName);
> > -
> >                  if (resource.exists()) {
> >                      try {
> >                          return FILE_UTILS.getFileURL(resource);
> > @@ -1008,13 +1003,12 @@
> >                          return null;
> >                      }
> >                  }
> > -            } else {
> > -                ZipFile zipFile = (ZipFile) zipFiles.get(file);
> > +            } else if (zipFile!=null || file.exists()) {
> > +                // found in the cache or not yet in the cache but
> > existing
> >                  if (zipFile == null) {
> >                      zipFile = new ZipFile(file);
> >                      zipFiles.put(file, zipFile);
> >                  }
> > -
> >                  ZipEntry entry = zipFile.getEntry(resourceName);
> >                  if (entry != null) {
> >                      try {
> > ========= snip snip ===========
> > > Hi,
> > >
> > > We have a lot of classes that are loaded by the AntClassLoader.
From
> > > performance measurements I noticed that a lot of time was spend in
> > > File.exists() during class loading. I checked the code and noticed
> > that
> > > in:
> > >
> > >      InputStream getResourceStream  (File file, String
> resourceName);
> > >
> > > and in
> > >
> > >      URL         getResourceURL     (File file, String
> resourceName);
> > >
> > > The following check is done first:
> > >
> > >      if (!file.exists()) {
> > >          return null;
> > >      }
> > >
> > > This seems smart, because if the file does not exist the answer is
> > > clear. Unless of course 'exists()' is slow; which it turns out to
be
> > (on
> > > Windows at least). A considerable improvement can be accomplished
by
> > > first checking the 'zipFiles' Hashtable: if "zipFiles.get(file)"
> > returns
> > > non-null we can be sure that the file exists and that it is not a
> > > directory. Remember that most calls will be for a jar file that
has
> > > already been opened. So those expensive (compared to
> Hashtable.get())
> > > tests on File can be skipped most of the time.
> > >
> > > One of our test runs was reduced by 1/3 in runtime by a quick
patch
> I
> > > made (it loads thousands of classes...).
> > >
> > > Has this issue ever been noticed/discussed?
> > >
> > > Regards,
> > > Tom Brus
> > >
> > > The contents of this e-mail are intended for the named addressee
> only.
> > It contains information that may be confidential. Unless you are the
> > named addressee or an authorized designee, you may not copy or use
it,
> > or disclose it to anyone else. If you received it in error please
> notify
> > us immediately and then destroy it.
> > >
> > > Compuware Europe B.V. (Registration number: 33245192) is a company
> > registered in The Netherlands whose registered office is at
> > Hoogoorddreef 5, 1101 BA  Amsterdam, The Netherlands. Compuware B.V.
> > (Registration number: 33227492) is a company registered in the
> > Netherlands whose registered office is at Hoogoorddreef 5, 1101 BA
> > Amsterdam, The Netherlands
> > >
> > >
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > >
> > >
> >
> >
---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> > The contents of this e-mail are intended for the named addressee
only.
> It
> > contains information that may be confidential. Unless you are the
> named
> > addressee or an authorized designee, you may not copy or use it, or
> > disclose it to anyone else. If you received it in error please
notify
> us
> > immediately and then destroy it.
> >
> > Compuware Europe B.V. (Registration number: 33245192) is a company
> > registered in The Netherlands whose registered office is at
> Hoogoorddreef
> > 5, 1101 BA  Amsterdam, The Netherlands. Compuware B.V. (Registration
> > number: 33227492) is a company registered in the Netherlands whose
> > registered office is at Hoogoorddreef 5, 1101 BA  Amsterdam, The
> > Netherlands
> >
---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> 
> The contents of this e-mail are intended for the named addressee only.
It
> contains information that may be confidential. Unless you are the
named
> addressee or an authorized designee, you may not copy or use it, or
> disclose it to anyone else. If you received it in error please notify
us
> immediately and then destroy it.
> 
> Compuware Europe B.V. (Registration number: 33245192) is a company
> registered in The Netherlands whose registered office is at
Hoogoorddreef
> 5, 1101 BA  Amsterdam, The Netherlands. Compuware B.V. (Registration
> number: 33227492) is a company registered in the Netherlands whose
> registered office is at Hoogoorddreef 5, 1101 BA  Amsterdam, The
> Netherlands
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]


The contents of this e-mail are intended for the named addressee only. It 
contains information that may be confidential. Unless you are the named 
addressee or an authorized designee, you may not copy or use it, or disclose it 
to anyone else. If you received it in error please notify us immediately and 
then destroy it.

Compuware Europe B.V. (Registration number: 33245192) is a company registered 
in The Netherlands whose registered office is at  Hoogoorddreef 5, 1101 BA  
Amsterdam, The Netherlands. Compuware B.V. (Registration number: 33227492) is a 
company registered in the Netherlands whose registered office is at 
Hoogoorddreef 5, 1101 BA  Amsterdam, The Netherlands

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to