You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Aleksey Shipilev (JIRA)" <ji...@apache.org> on 2008/03/23 21:21:24 UTC

[jira] Created: (HARMONY-5635) [classlib][luni][performance] ObjectInputStream should empty the underlying stream in right way

[classlib][luni][performance] ObjectInputStream should empty the underlying stream in right way
-----------------------------------------------------------------------------------------------

                 Key: HARMONY-5635
                 URL: https://issues.apache.org/jira/browse/HARMONY-5635
             Project: Harmony
          Issue Type: Improvement
            Reporter: Aleksey Shipilev


For now, ObjectInputStream empties the underlying stream by assigning it to static emptyStream instance.

This is very buggy way to do things, for two reasons:
 1. Consider you've done
         ByteArrayInputStream temp1 = emptyStream;
     then you might do temp1.write(...) and spoil the emptyStream with garbage. Luckily there are no such opportunities in current OIS.

 2. Consider you've "emptied" several streams in different threads and then ask for OIS.available() then you would have the BAIS.available() [synchronized by spec] - and the _contention_, up to fat monitors invocation.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HARMONY-5635) [classlib][luni][performance] ObjectInputStream should empty the underlying stream in right way

Posted by "Aleksey Shipilev (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-5635?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Aleksey Shipilev updated HARMONY-5635:
--------------------------------------

    Attachment: 0003-serial-emptystream.patch

0003-serial-emptystream.patch
Patch which solves the problem by making emptyStream non-static instance.

It solves the problem (2), giving +20% on SerialBench running at 8-core Clovertown.
However, it does not solve the problem (1), more elegant solution must clear the stream out.

> [classlib][luni][performance] ObjectInputStream should empty the underlying stream in right way
> -----------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-5635
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5635
>             Project: Harmony
>          Issue Type: Improvement
>            Reporter: Aleksey Shipilev
>         Attachments: 0003-serial-emptystream.patch
>
>
> For now, ObjectInputStream empties the underlying stream by assigning it to static emptyStream instance.
> This is very buggy way to do things, for two reasons:
>  1. Consider you've done
>          ByteArrayInputStream temp1 = emptyStream;
>      then you might do temp1.write(...) and spoil the emptyStream with garbage. Luckily there are no such opportunities in current OIS.
>  2. Consider you've "emptied" several streams in different threads and then ask for OIS.available() then you would have the BAIS.available() [synchronized by spec] - and the _contention_, up to fat monitors invocation.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-5635) [classlib][luni][performance] ObjectInputStream should empty the underlying stream in right way

Posted by "Aleksey Shipilev (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-5635?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12582675#action_12582675 ] 

Aleksey Shipilev commented on HARMONY-5635:
-------------------------------------------

Thanks, Tim!
Sorry for (1), it was my oversight. You're right.

> [classlib][luni][performance] ObjectInputStream should empty the underlying stream in right way
> -----------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-5635
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5635
>             Project: Harmony
>          Issue Type: Improvement
>            Reporter: Aleksey Shipilev
>            Assignee: Tim Ellison
>         Attachments: 0003-serial-emptystream.patch
>
>
> For now, ObjectInputStream empties the underlying stream by assigning it to static emptyStream instance.
> This is very buggy way to do things, for two reasons:
>  1. Consider you've done
>          ByteArrayInputStream temp1 = emptyStream;
>      then you might do temp1.write(...) and spoil the emptyStream with garbage. Luckily there are no such opportunities in current OIS.
>  2. Consider you've "emptied" several streams in different threads and then ask for OIS.available() then you would have the BAIS.available() [synchronized by spec] - and the _contention_, up to fat monitors invocation.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HARMONY-5635) [classlib][luni][performance] ObjectInputStream should empty the underlying stream in right way

Posted by "Aleksey Shipilev (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-5635?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Aleksey Shipilev updated HARMONY-5635:
--------------------------------------

    Issue Type: Sub-task  (was: Improvement)
        Parent: HARMONY-5632

> [classlib][luni][performance] ObjectInputStream should empty the underlying stream in right way
> -----------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-5635
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5635
>             Project: Harmony
>          Issue Type: Sub-task
>            Reporter: Aleksey Shipilev
>            Assignee: Tim Ellison
>         Attachments: 0003-serial-emptystream.patch
>
>
> For now, ObjectInputStream empties the underlying stream by assigning it to static emptyStream instance.
> This is very buggy way to do things, for two reasons:
>  1. Consider you've done
>          ByteArrayInputStream temp1 = emptyStream;
>      then you might do temp1.write(...) and spoil the emptyStream with garbage. Luckily there are no such opportunities in current OIS.
>  2. Consider you've "emptied" several streams in different threads and then ask for OIS.available() then you would have the BAIS.available() [synchronized by spec] - and the _contention_, up to fat monitors invocation.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-5635) [classlib][luni][performance] ObjectInputStream should empty the underlying stream in right way

Posted by "Tim Ellison (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-5635?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12582667#action_12582667 ] 

Tim Ellison commented on HARMONY-5635:
--------------------------------------

Aleksey,

Removed the static modifier at repo revision r641839.

re: (1) How could the code succeed in writing to an InputStream anyway?


> [classlib][luni][performance] ObjectInputStream should empty the underlying stream in right way
> -----------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-5635
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5635
>             Project: Harmony
>          Issue Type: Improvement
>            Reporter: Aleksey Shipilev
>            Assignee: Tim Ellison
>         Attachments: 0003-serial-emptystream.patch
>
>
> For now, ObjectInputStream empties the underlying stream by assigning it to static emptyStream instance.
> This is very buggy way to do things, for two reasons:
>  1. Consider you've done
>          ByteArrayInputStream temp1 = emptyStream;
>      then you might do temp1.write(...) and spoil the emptyStream with garbage. Luckily there are no such opportunities in current OIS.
>  2. Consider you've "emptied" several streams in different threads and then ask for OIS.available() then you would have the BAIS.available() [synchronized by spec] - and the _contention_, up to fat monitors invocation.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (HARMONY-5635) [classlib][luni][performance] ObjectInputStream should empty the underlying stream in right way

Posted by "Tim Ellison (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-5635?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Tim Ellison reassigned HARMONY-5635:
------------------------------------

    Assignee: Tim Ellison

> [classlib][luni][performance] ObjectInputStream should empty the underlying stream in right way
> -----------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-5635
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5635
>             Project: Harmony
>          Issue Type: Improvement
>            Reporter: Aleksey Shipilev
>            Assignee: Tim Ellison
>         Attachments: 0003-serial-emptystream.patch
>
>
> For now, ObjectInputStream empties the underlying stream by assigning it to static emptyStream instance.
> This is very buggy way to do things, for two reasons:
>  1. Consider you've done
>          ByteArrayInputStream temp1 = emptyStream;
>      then you might do temp1.write(...) and spoil the emptyStream with garbage. Luckily there are no such opportunities in current OIS.
>  2. Consider you've "emptied" several streams in different threads and then ask for OIS.available() then you would have the BAIS.available() [synchronized by spec] - and the _contention_, up to fat monitors invocation.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (HARMONY-5635) [classlib][luni][performance] ObjectInputStream should empty the underlying stream in right way

Posted by "Tim Ellison (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-5635?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Tim Ellison closed HARMONY-5635.
--------------------------------

    Resolution: Fixed

Verified by Aleksey.


> [classlib][luni][performance] ObjectInputStream should empty the underlying stream in right way
> -----------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-5635
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5635
>             Project: Harmony
>          Issue Type: Improvement
>            Reporter: Aleksey Shipilev
>            Assignee: Tim Ellison
>         Attachments: 0003-serial-emptystream.patch
>
>
> For now, ObjectInputStream empties the underlying stream by assigning it to static emptyStream instance.
> This is very buggy way to do things, for two reasons:
>  1. Consider you've done
>          ByteArrayInputStream temp1 = emptyStream;
>      then you might do temp1.write(...) and spoil the emptyStream with garbage. Luckily there are no such opportunities in current OIS.
>  2. Consider you've "emptied" several streams in different threads and then ask for OIS.available() then you would have the BAIS.available() [synchronized by spec] - and the _contention_, up to fat monitors invocation.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.