ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jim Wright <>
Subject [PATCH] Proposed StreamPumper Hacks
Date Sun, 08 Sep 2002 23:42:05 GMT

I've been integrating Ant into my own tools and
noticed from the code that StreamPumper
sleeps for 5 ms after every 128 bytes
limiting throughput to approx 25kb/s.
I made some tentative changes aimed at removing
what I saw as distractions in the code but have
since realised that this 5ms delay can make quite
a difference.

For example I list the contents of large backup tar
archives to file by effectively running:

<exec output="archive.lis" executable="tar">

etc., but I actually do it in Java. Without the patch
for a 3MB list of filenames it takes a couple of
minutes longer than it should -  apparently
10-20 seconds with the patch.

I don't feel it is necessary for a StreamPumper thread
to yield explicitly in any way because it is likely to
frequently block on reading from the input stream and
otherwise on writing to the output stream, assuming
the related processing is not both trivial and performed
selfishly. But I have actually changed the sleep
to a harmless Thread.yield() to be on the safe side.

While there I remove a couple of TODO comments.

One was replaced with explanatory comment and
I have included a proposed implementation of the

Instead of a status flag I have added a method
exceptionCheck() that throws any IOException that
occurred. The idea is to achieve an effect consistent
with what would happen if there was no thread in the
implementation. With hindsight this might have been
combined with waitFor().

If you accept this proposal then a call to
exceptionCheck() should probably be added to (easy) and is more difficult.

The fact that I've done this TODO does not
affect calling code. It just provides the option of
additional error handling. In the case of logging
there is not much point in attempting to *report*
failure ;-) But for cases like the example above it
would appear that PumpStreamHandler should be

I have not got as far as working out if this class should be
deprecated in favour of LogStreamHandler (or
vice-versa). Nor have I searched the mailing list for
history of StreamPumper development discussion etc.
(Actually I couldn't find an online search of ant-dev.)
So use your informed judgement.



View raw message