cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Per Kreipke" <...@onclave.com>
Subject Speedup *DirectoryGenerator (e.g. ImageDirectoryGenerator et al)...
Date Fri, 14 Jun 2002 15:56:55 GMT
After looking at ImageDirectoryGenerator, which runs about 3x slower than
DirectoryGenerator on image files, I think the following changes will speed
it up (and similarily, MP3DirectoryGenerator).

For fun, compare DirectoryGenerator against ImageDirectoryGenerator on the
same directory (with a moderate number of images:

<map:match pattern="files/*">
	<map:generator type="DirectoryGenerator" >
		<map:parameter name="depth" value="3" />
	</map:generator>
	<map:serialize type="xml" />
</map:match>

<map:match pattern="files2/*">
	<map:generator type="ImageDirectoryGenerator" >
		<map:parameter name="depth" value="3" />
	</map:generator>
	<map:serialize type="xml" />
</map:match>

Wouldn't it be nice if the second time you requested the image info, it was
as fast as the DirectoryGenerator?



Suggestions:

- having getSize() call getFileType() and then getJpegSize() or
getGifSize(), introduces nice modularity but sacrifices speed. Each function
in that sequence calls (that's two calls total):

  new BufferedInputStream(new FileInputStream(file));

Instead, instantiate the BufferedInputStream in getSize() and pass it to the
other functions. Or move the work from getFileType() and get*Size() back in
to getSize().


- more importantly, caching the information from getSize() plus
'lastModified' in an internal hash table with the file's URL as key would
remove the need to do the expensive work each time. If the file hasn't
changed, then it's size (or MP3 info) hasn't either.


Unfortunately, I don't know Cocoon well enough to understand if Generators
are global instances (so that all requests will share the hash table) or
whether it exists per pipeline, per sitemap, etc. My point: I'm not sure how
to implement the cached info correctly.



I would love to do this work and send in the patch myself, and I'll attempt
to do so when I have the latest C2 source installed here. Unless someone
desparate does it first :-)

Per


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Mime
View raw message