You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "Holger Hoffstätte (JIRA)" <ji...@apache.org> on 2006/10/16 20:02:35 UTC

[jira] Created: (IO-97) Trivial performance improvements to ByteArrayOutputStream

Trivial performance improvements to ByteArrayOutputStream
---------------------------------------------------------

                 Key: IO-97
                 URL: http://issues.apache.org/jira/browse/IO-97
             Project: Commons IO
          Issue Type: Improvement
          Components: Streams/Writers
    Affects Versions: 1.2
            Reporter: Holger Hoffstätte


Found a few trivial ways to improve performance in ByteArrayOutputStream by fast paths:

- write(int) does not have to be synchronized

- write(byte[]..) does not have to be synchronized as a whole either; it's enough to synchonize the code that follows the first paramter-checking if-then statement (so parameter checks can pop out quickly)

- toByteArray() could just check if count == 0 and quickly return an empty static final byte[] instead of returning a new zero-sized one, doing useless System.arraycopy() etc.

A somewhat more involved optimization would be to implement write(int) without the new byte[1] since just poking the byte into the right page is going to be much faster than what happens in write(byte[]..); I'll see if I can do a patch for that.


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


[jira] Updated: (IO-97) Trivial performance improvements to ByteArrayOutputStream

Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/IO-97?page=all ]

Henri Yandell updated IO-97:
----------------------------

    Fix Version/s: 1.4

The diff is relatively involved, and as 1.3 looks pretty close I figure this will be looked at for the subsequent 1.4 release.

> Trivial performance improvements to ByteArrayOutputStream
> ---------------------------------------------------------
>
>                 Key: IO-97
>                 URL: http://issues.apache.org/jira/browse/IO-97
>             Project: Commons IO
>          Issue Type: Improvement
>          Components: Streams/Writers
>    Affects Versions: 1.2
>            Reporter: Holger Hoffstätte
>             Fix For: 1.4
>
>         Attachments: BAOS.patch
>
>
> Found a few trivial ways to improve performance in ByteArrayOutputStream by fast paths:
> - write(int) does not have to be synchronized
> - write(byte[]..) does not have to be synchronized as a whole either; it's enough to synchonize the code that follows the first paramter-checking if-then statement (so parameter checks can pop out quickly)
> - toByteArray() could just check if count == 0 and quickly return an empty static final byte[] instead of returning a new zero-sized one, doing useless System.arraycopy() etc.
> A somewhat more involved optimization would be to implement write(int) without the new byte[1] since just poking the byte into the right page is going to be much faster than what happens in write(byte[]..); I'll see if I can do a patch for that.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


[jira] Updated: (IO-97) Trivial performance improvements to ByteArrayOutputStream

Posted by "Holger Hoffstätte (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/IO-97?page=all ]

Holger Hoffstätte updated IO-97:
--------------------------------

    Attachment: BAOS.patch

Attached patch for BAOS & BAOSTestCase that implements the previous suggestions. Also in strict accordance to the JMM getSize() must be synchronized; this is included.
All tests pass.


> Trivial performance improvements to ByteArrayOutputStream
> ---------------------------------------------------------
>
>                 Key: IO-97
>                 URL: http://issues.apache.org/jira/browse/IO-97
>             Project: Commons IO
>          Issue Type: Improvement
>          Components: Streams/Writers
>    Affects Versions: 1.2
>            Reporter: Holger Hoffstätte
>         Attachments: BAOS.patch
>
>
> Found a few trivial ways to improve performance in ByteArrayOutputStream by fast paths:
> - write(int) does not have to be synchronized
> - write(byte[]..) does not have to be synchronized as a whole either; it's enough to synchonize the code that follows the first paramter-checking if-then statement (so parameter checks can pop out quickly)
> - toByteArray() could just check if count == 0 and quickly return an empty static final byte[] instead of returning a new zero-sized one, doing useless System.arraycopy() etc.
> A somewhat more involved optimization would be to implement write(int) without the new byte[1] since just poking the byte into the right page is going to be much faster than what happens in write(byte[]..); I'll see if I can do a patch for that.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


[jira] Resolved: (IO-97) Trivial performance improvements to ByteArrayOutputStream

Posted by "Stephen Colebourne (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/IO-97?page=all ]

Stephen Colebourne resolved IO-97.
----------------------------------

    Fix Version/s: 1.3
                       (was: 1.4)
       Resolution: Fixed
         Assignee: Stephen Colebourne

> Trivial performance improvements to ByteArrayOutputStream
> ---------------------------------------------------------
>
>                 Key: IO-97
>                 URL: http://issues.apache.org/jira/browse/IO-97
>             Project: Commons IO
>          Issue Type: Improvement
>          Components: Streams/Writers
>    Affects Versions: 1.2
>            Reporter: Holger Hoffstätte
>         Assigned To: Stephen Colebourne
>             Fix For: 1.3
>
>         Attachments: BAOS.patch
>
>
> Found a few trivial ways to improve performance in ByteArrayOutputStream by fast paths:
> - write(int) does not have to be synchronized
> - write(byte[]..) does not have to be synchronized as a whole either; it's enough to synchonize the code that follows the first paramter-checking if-then statement (so parameter checks can pop out quickly)
> - toByteArray() could just check if count == 0 and quickly return an empty static final byte[] instead of returning a new zero-sized one, doing useless System.arraycopy() etc.
> A somewhat more involved optimization would be to implement write(int) without the new byte[1] since just poking the byte into the right page is going to be much faster than what happens in write(byte[]..); I'll see if I can do a patch for that.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org