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 20:51:24 UTC

[jira] Created: (HARMONY-5633) [drlvm][performance] ObjectStreamClass lookup improvement

[drlvm][performance] ObjectStreamClass lookup improvement
---------------------------------------------------------

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


For now, ObjectStreamClass (OSC) is created on-the-fly during serialization/deserialization and stored in static cache.
Performance problems arose when several threads doing the lookups, hitting on synchronized cache. Moreover, the cache is built around WeakHashMap to ensure GC of OSCs. This issue is the source of scalability problems for multi-threaded serialization benchmarks.

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


[jira] Updated: (HARMONY-5633) [drlvm][performance] ObjectStreamClass lookup improvement

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

Aleksey Shipilev updated HARMONY-5633:
--------------------------------------

    Attachment: 0001-serial-lookupClass.patch

0001-serial-lookupClass.patch
Basic POC patch for this issue:
 - stores the OSC in Class field
 - creates one OSC per Class on demand

Pitfalls:
 1. Breaks specification (public fields/methods in Class) - need to implement backing storage in o.a.h.*
 2. No weak references here. Need to wrap the OSC instance with WeakReference.

> [drlvm][performance] ObjectStreamClass lookup improvement
> ---------------------------------------------------------
>
>                 Key: HARMONY-5633
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5633
>             Project: Harmony
>          Issue Type: Improvement
>            Reporter: Aleksey Shipilev
>         Attachments: 0001-serial-lookupClass.patch
>
>
> For now, ObjectStreamClass (OSC) is created on-the-fly during serialization/deserialization and stored in static cache.
> Performance problems arose when several threads doing the lookups, hitting on synchronized cache. Moreover, the cache is built around WeakHashMap to ensure GC of OSCs. This issue is the source of scalability problems for multi-threaded serialization benchmarks.

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


[jira] Assigned: (HARMONY-5633) [classlib][luni][performance] ObjectStreamClass lookup improvement

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

Alexey Varlamov reassigned HARMONY-5633:
----------------------------------------

    Assignee: Alexey Varlamov

> [classlib][luni][performance] ObjectStreamClass lookup improvement
> ------------------------------------------------------------------
>
>                 Key: HARMONY-5633
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5633
>             Project: Harmony
>          Issue Type: Improvement
>            Reporter: Aleksey Shipilev
>            Assignee: Alexey Varlamov
>         Attachments: 0001-serial-lookupClass.patch, serial-lookupClass-RC1.patch, serial-lookupClass-RC2.patch, serial-lookupClass-RC3.patch
>
>
> For now, ObjectStreamClass (OSC) is created on-the-fly during serialization/deserialization and stored in static cache.
> Performance problems arose when several threads doing the lookups, hitting on synchronized cache. Moreover, the cache is built around WeakHashMap to ensure GC of OSCs. This issue is the source of scalability problems for multi-threaded serialization benchmarks.

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


[jira] Commented: (HARMONY-5633) [drlvm][performance] ObjectStreamClass lookup improvement

Posted by "Nathan Beyer (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-5633?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12581424#action_12581424 ] 

Nathan Beyer commented on HARMONY-5633:
---------------------------------------

Can you elaborate on the "Breaks specification" pitfall? I'm not exactly clear on what you mean by this.

I'm not familiar with the MT/SerialBench, can you provide a link or some more information about this?

> [drlvm][performance] ObjectStreamClass lookup improvement
> ---------------------------------------------------------
>
>                 Key: HARMONY-5633
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5633
>             Project: Harmony
>          Issue Type: Improvement
>            Reporter: Aleksey Shipilev
>         Attachments: 0001-serial-lookupClass.patch
>
>
> For now, ObjectStreamClass (OSC) is created on-the-fly during serialization/deserialization and stored in static cache.
> Performance problems arose when several threads doing the lookups, hitting on synchronized cache. Moreover, the cache is built around WeakHashMap to ensure GC of OSCs. This issue is the source of scalability problems for multi-threaded serialization benchmarks.

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


[jira] Updated: (HARMONY-5633) [classlib][luni][performance] ObjectStreamClass lookup improvement

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

Aleksey Shipilev updated HARMONY-5633:
--------------------------------------

    Attachment: serial-lookupClass-RC3.patch

serial-lookupClass-RC3.patch
RC2 + preserving incapsulation with private cache

Alexei?

> [classlib][luni][performance] ObjectStreamClass lookup improvement
> ------------------------------------------------------------------
>
>                 Key: HARMONY-5633
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5633
>             Project: Harmony
>          Issue Type: Improvement
>            Reporter: Aleksey Shipilev
>         Attachments: 0001-serial-lookupClass.patch, serial-lookupClass-RC1.patch, serial-lookupClass-RC2.patch, serial-lookupClass-RC3.patch
>
>
> For now, ObjectStreamClass (OSC) is created on-the-fly during serialization/deserialization and stored in static cache.
> Performance problems arose when several threads doing the lookups, hitting on synchronized cache. Moreover, the cache is built around WeakHashMap to ensure GC of OSCs. This issue is the source of scalability problems for multi-threaded serialization benchmarks.

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


[jira] Commented: (HARMONY-5633) [drlvm][performance] ObjectStreamClass lookup improvement

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

Aleksey Shipilev commented on HARMONY-5633:
-------------------------------------------

Nathan, 
1) Patch breaks specification while declaring non Java-spec public method in Class.
2) MT/SerialBench is custom multithreaded harness, inspired by JBoss serialization benchmark. You may see it in the parent issue HARMONY-5632.

I have more clear idea how to implement this patch - ClassLocalStorage (like the ThreadLocalStorage) - will follow up soon.

> [drlvm][performance] ObjectStreamClass lookup improvement
> ---------------------------------------------------------
>
>                 Key: HARMONY-5633
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5633
>             Project: Harmony
>          Issue Type: Improvement
>            Reporter: Aleksey Shipilev
>         Attachments: 0001-serial-lookupClass.patch
>
>
> For now, ObjectStreamClass (OSC) is created on-the-fly during serialization/deserialization and stored in static cache.
> Performance problems arose when several threads doing the lookups, hitting on synchronized cache. Moreover, the cache is built around WeakHashMap to ensure GC of OSCs. This issue is the source of scalability problems for multi-threaded serialization benchmarks.

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


[jira] Commented: (HARMONY-5633) [classlib][luni][performance] ObjectStreamClass lookup improvement

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

Aleksey Shipilev commented on HARMONY-5633:
-------------------------------------------

Sorry, I had confused weak keys and weak values. Then I have to resort to variant (d). Let me think more about it.

> [classlib][luni][performance] ObjectStreamClass lookup improvement
> ------------------------------------------------------------------
>
>                 Key: HARMONY-5633
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5633
>             Project: Harmony
>          Issue Type: Improvement
>            Reporter: Aleksey Shipilev
>         Attachments: 0001-serial-lookupClass.patch, serial-lookupClass-RC1.patch
>
>
> For now, ObjectStreamClass (OSC) is created on-the-fly during serialization/deserialization and stored in static cache.
> Performance problems arose when several threads doing the lookups, hitting on synchronized cache. Moreover, the cache is built around WeakHashMap to ensure GC of OSCs. This issue is the source of scalability problems for multi-threaded serialization benchmarks.

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


[jira] Resolved: (HARMONY-5633) [classlib][luni][performance] ObjectStreamClass lookup improvement

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

Alexey Varlamov resolved HARMONY-5633.
--------------------------------------

       Resolution: Fixed
    Fix Version/s: 5.0M6

Integrated at revision: 646645, thanks!

> [classlib][luni][performance] ObjectStreamClass lookup improvement
> ------------------------------------------------------------------
>
>                 Key: HARMONY-5633
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5633
>             Project: Harmony
>          Issue Type: Improvement
>            Reporter: Aleksey Shipilev
>            Assignee: Alexey Varlamov
>             Fix For: 5.0M6
>
>         Attachments: 0001-serial-lookupClass.patch, serial-lookupClass-RC1.patch, serial-lookupClass-RC2.patch, serial-lookupClass-RC3.patch
>
>
> For now, ObjectStreamClass (OSC) is created on-the-fly during serialization/deserialization and stored in static cache.
> Performance problems arose when several threads doing the lookups, hitting on synchronized cache. Moreover, the cache is built around WeakHashMap to ensure GC of OSCs. This issue is the source of scalability problems for multi-threaded serialization benchmarks.

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


[jira] Updated: (HARMONY-5633) [classlib][luni][performance] ObjectStreamClass lookup improvement

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

Aleksey Shipilev updated HARMONY-5633:
--------------------------------------

    Attachment: serial-lookupClass-RC2.patch

serial-lookupClass-RC2.patch
 - Moves caches to ThreadLocalCache.
 - Leaves WeakHashMap as storage.

I think this patch solves the problem Alexei described. Alexei?

This patch still gives +80% boost for MT/SerialBench at 8-core Clovertown.

> [classlib][luni][performance] ObjectStreamClass lookup improvement
> ------------------------------------------------------------------
>
>                 Key: HARMONY-5633
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5633
>             Project: Harmony
>          Issue Type: Improvement
>            Reporter: Aleksey Shipilev
>         Attachments: 0001-serial-lookupClass.patch, serial-lookupClass-RC1.patch, serial-lookupClass-RC2.patch
>
>
> For now, ObjectStreamClass (OSC) is created on-the-fly during serialization/deserialization and stored in static cache.
> Performance problems arose when several threads doing the lookups, hitting on synchronized cache. Moreover, the cache is built around WeakHashMap to ensure GC of OSCs. This issue is the source of scalability problems for multi-threaded serialization benchmarks.

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


[jira] Updated: (HARMONY-5633) [classlib][luni][performance] ObjectStreamClass lookup improvement

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

Aleksey Shipilev updated HARMONY-5633:
--------------------------------------

    Attachment: serial-resolveClass-RC3.patch

serial-resolveClass-RC3.patch
RC2 + preserving incapsulation with private cache.

Alexei?

> [classlib][luni][performance] ObjectStreamClass lookup improvement
> ------------------------------------------------------------------
>
>                 Key: HARMONY-5633
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5633
>             Project: Harmony
>          Issue Type: Improvement
>            Reporter: Aleksey Shipilev
>         Attachments: 0001-serial-lookupClass.patch, serial-lookupClass-RC1.patch, serial-lookupClass-RC2.patch, serial-resolveClass-RC3.patch
>
>
> For now, ObjectStreamClass (OSC) is created on-the-fly during serialization/deserialization and stored in static cache.
> Performance problems arose when several threads doing the lookups, hitting on synchronized cache. Moreover, the cache is built around WeakHashMap to ensure GC of OSCs. This issue is the source of scalability problems for multi-threaded serialization benchmarks.

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


[jira] Updated: (HARMONY-5633) [classlib][luni][performance] ObjectStreamClass lookup improvement

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

Aleksey Shipilev updated HARMONY-5633:
--------------------------------------

    Attachment:     (was: serial-resolveClass-RC3.patch)

> [classlib][luni][performance] ObjectStreamClass lookup improvement
> ------------------------------------------------------------------
>
>                 Key: HARMONY-5633
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5633
>             Project: Harmony
>          Issue Type: Improvement
>            Reporter: Aleksey Shipilev
>         Attachments: 0001-serial-lookupClass.patch, serial-lookupClass-RC1.patch, serial-lookupClass-RC2.patch, serial-lookupClass-RC3.patch
>
>
> For now, ObjectStreamClass (OSC) is created on-the-fly during serialization/deserialization and stored in static cache.
> Performance problems arose when several threads doing the lookups, hitting on synchronized cache. Moreover, the cache is built around WeakHashMap to ensure GC of OSCs. This issue is the source of scalability problems for multi-threaded serialization benchmarks.

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


[jira] Updated: (HARMONY-5633) [classlib][luni][performance] ObjectStreamClass lookup improvement

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

Aleksey Shipilev updated HARMONY-5633:
--------------------------------------

    Patch Info: [Patch Available]
       Summary: [classlib][luni][performance] ObjectStreamClass lookup improvement  (was: [drlvm][performance] ObjectStreamClass lookup improvement)

Changing to Classlib/LUNI as proposed patch belong there.

> [classlib][luni][performance] ObjectStreamClass lookup improvement
> ------------------------------------------------------------------
>
>                 Key: HARMONY-5633
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5633
>             Project: Harmony
>          Issue Type: Improvement
>            Reporter: Aleksey Shipilev
>         Attachments: 0001-serial-lookupClass.patch
>
>
> For now, ObjectStreamClass (OSC) is created on-the-fly during serialization/deserialization and stored in static cache.
> Performance problems arose when several threads doing the lookups, hitting on synchronized cache. Moreover, the cache is built around WeakHashMap to ensure GC of OSCs. This issue is the source of scalability problems for multi-threaded serialization benchmarks.

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


[jira] Closed: (HARMONY-5633) [classlib][luni][performance] ObjectStreamClass lookup improvement

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

Aleksey Shipilev closed HARMONY-5633.
-------------------------------------


Verified.

> [classlib][luni][performance] ObjectStreamClass lookup improvement
> ------------------------------------------------------------------
>
>                 Key: HARMONY-5633
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5633
>             Project: Harmony
>          Issue Type: Improvement
>            Reporter: Aleksey Shipilev
>            Assignee: Alexey Varlamov
>             Fix For: 5.0M6
>
>         Attachments: 0001-serial-lookupClass.patch, serial-lookupClass-RC1.patch, serial-lookupClass-RC2.patch, serial-lookupClass-RC3.patch
>
>
> For now, ObjectStreamClass (OSC) is created on-the-fly during serialization/deserialization and stored in static cache.
> Performance problems arose when several threads doing the lookups, hitting on synchronized cache. Moreover, the cache is built around WeakHashMap to ensure GC of OSCs. This issue is the source of scalability problems for multi-threaded serialization benchmarks.

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


[jira] Updated: (HARMONY-5633) [classlib][luni][performance] ObjectStreamClass lookup improvement

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

Aleksey Shipilev updated HARMONY-5633:
--------------------------------------

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

> [classlib][luni][performance] ObjectStreamClass lookup improvement
> ------------------------------------------------------------------
>
>                 Key: HARMONY-5633
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5633
>             Project: Harmony
>          Issue Type: Sub-task
>            Reporter: Aleksey Shipilev
>            Assignee: Alexey Varlamov
>             Fix For: 5.0M6
>
>         Attachments: 0001-serial-lookupClass.patch, serial-lookupClass-RC1.patch, serial-lookupClass-RC2.patch, serial-lookupClass-RC3.patch
>
>
> For now, ObjectStreamClass (OSC) is created on-the-fly during serialization/deserialization and stored in static cache.
> Performance problems arose when several threads doing the lookups, hitting on synchronized cache. Moreover, the cache is built around WeakHashMap to ensure GC of OSCs. This issue is the source of scalability problems for multi-threaded serialization benchmarks.

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


[jira] Commented: (HARMONY-5633) [drlvm][performance] ObjectStreamClass lookup improvement

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

Aleksey Shipilev commented on HARMONY-5633:
-------------------------------------------

This POC patch gives up to +80% boost on MT/SerialBench running at 8-core Clovertown.

> [drlvm][performance] ObjectStreamClass lookup improvement
> ---------------------------------------------------------
>
>                 Key: HARMONY-5633
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5633
>             Project: Harmony
>          Issue Type: Improvement
>            Reporter: Aleksey Shipilev
>         Attachments: 0001-serial-lookupClass.patch
>
>
> For now, ObjectStreamClass (OSC) is created on-the-fly during serialization/deserialization and stored in static cache.
> Performance problems arose when several threads doing the lookups, hitting on synchronized cache. Moreover, the cache is built around WeakHashMap to ensure GC of OSCs. This issue is the source of scalability problems for multi-threaded serialization benchmarks.

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


[jira] Updated: (HARMONY-5633) [classlib][luni][performance] ObjectStreamClass lookup improvement

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

Aleksey Shipilev updated HARMONY-5633:
--------------------------------------

    Attachment: serial-lookupClass-RC1.patch

serial-lookupClass-RC1.patch
Proposed patch, clean, does not break specification.
JUnit tests for LUNI passed.

1. Replaces problematic WeakHashMap<Class,ObjectStreamClass> with HashMap<Class,SoftReference<ObjectStreamClass>>.
2. Performs unsynchronized get on fastpath.

Gives +80% boost for MT/SerialBench (see parent issue) on 8-core Clovertown.

> [classlib][luni][performance] ObjectStreamClass lookup improvement
> ------------------------------------------------------------------
>
>                 Key: HARMONY-5633
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5633
>             Project: Harmony
>          Issue Type: Improvement
>            Reporter: Aleksey Shipilev
>         Attachments: 0001-serial-lookupClass.patch, serial-lookupClass-RC1.patch
>
>
> For now, ObjectStreamClass (OSC) is created on-the-fly during serialization/deserialization and stored in static cache.
> Performance problems arose when several threads doing the lookups, hitting on synchronized cache. Moreover, the cache is built around WeakHashMap to ensure GC of OSCs. This issue is the source of scalability problems for multi-threaded serialization benchmarks.

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


[jira] Commented: (HARMONY-5633) [classlib][luni][performance] ObjectStreamClass lookup improvement

Posted by "Alexey Varlamov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-5633?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12586665#action_12586665 ] 

Alexey Varlamov commented on HARMONY-5633:
------------------------------------------

Aleksey, I'm afraid you misunderstand the contract and purpose of WeakHashMap: the mission is to allow GC to clean up globally mapped keys, while you try to replace it with a sort of smart cache - yet keys are never collected and class unloading is stuck.
BTW, looking closely, original ObjectStreamClass may still prevent CU due to strong links to methods of a wrapped class:
private transient Method methodWriteReplace;
private transient Method methodReadResolve;
private transient Method methodWriteObject;
private transient Method methodReadObject;
private transient Method methodReadObjectNoData;
I believe they also must be weakly referenced, will file another JIRA.

Another issue, such fast-paths are not truly thread-safe. The spec for HashMap reads:
"Note that this implementation is not synchronized. If multiple threads access this map concurrently, and at least one of the threads modifies the map structurally, it must be synchronized externally. (A structural modification is any operation that adds or deletes one or more mappings; merely changing the value associated with a key that an instance already contains is not a structural modification.) "

OTOH the "classesAndDescriptors" mapping itself seems to be mere performance optimization (just cache indeed), so does not need to be global here... Making cache TreadLocal most probably is not effective, so I see the only thread-safe way to reduce contention is a multi-bucket cache - e.g. a small array of self-synchronized WeakHashMaps + even distribution of buckets per threads. Say threads can access buckets by thread ID (take ID%aray.length as index) or via randomly selected index, etc. 
Looks scary though, needs trial :)


> [classlib][luni][performance] ObjectStreamClass lookup improvement
> ------------------------------------------------------------------
>
>                 Key: HARMONY-5633
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5633
>             Project: Harmony
>          Issue Type: Improvement
>            Reporter: Aleksey Shipilev
>         Attachments: 0001-serial-lookupClass.patch, serial-lookupClass-RC1.patch
>
>
> For now, ObjectStreamClass (OSC) is created on-the-fly during serialization/deserialization and stored in static cache.
> Performance problems arose when several threads doing the lookups, hitting on synchronized cache. Moreover, the cache is built around WeakHashMap to ensure GC of OSCs. This issue is the source of scalability problems for multi-threaded serialization benchmarks.

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


[jira] Commented: (HARMONY-5633) [classlib][luni][performance] ObjectStreamClass lookup improvement

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

Aleksey Shipilev commented on HARMONY-5633:
-------------------------------------------

Alexey, thanks for the comment! 

1. I didn't expect the issue with CU, can you please point me to spec or doc where such contract is defined? While I haven't one I'll try to understand in the scope of common sense. I assume that CU initiates unloading when Class is not strongly referenced anymore. Then referencing the class with SoftReference instead of WeakReference does not change the behavior significantly, because SoftReference will eventually free the referent when memory is exhausted thus allowing CU to reduce the footprint by unloading certain classes. And so the question is: whether we have the requirement when CU should happen?

2. Yep, you're right, thanks. The get() operation is not thread-safe here. We might tolerate this in two ways: using ConcurrentHashMap or using ThreadLocal. 

Keeping this two points in mind, how about this ways? I could check the performance of each of them and report back.

a. Use ConcurrentHashMap<Class,SoftReference<ObjectStreamClass>>
b. Use ConcurrentHashMap<Class,WeakReference<ObjectStreamClass>>
c. Use ThreadLocal with HashMap<Class,SoftReference<ObjectStreamClass>>
d. Use ThreadLocal with WeakHashMap<Class,ObjectStreamClass>

> [classlib][luni][performance] ObjectStreamClass lookup improvement
> ------------------------------------------------------------------
>
>                 Key: HARMONY-5633
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5633
>             Project: Harmony
>          Issue Type: Improvement
>            Reporter: Aleksey Shipilev
>         Attachments: 0001-serial-lookupClass.patch, serial-lookupClass-RC1.patch
>
>
> For now, ObjectStreamClass (OSC) is created on-the-fly during serialization/deserialization and stored in static cache.
> Performance problems arose when several threads doing the lookups, hitting on synchronized cache. Moreover, the cache is built around WeakHashMap to ensure GC of OSCs. This issue is the source of scalability problems for multi-threaded serialization benchmarks.

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


[jira] Commented: (HARMONY-5633) [classlib][luni][performance] ObjectStreamClass lookup improvement

Posted by "Alexey Varlamov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-5633?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12587150#action_12587150 ] 

Alexey Varlamov commented on HARMONY-5633:
------------------------------------------

RC2 is a good one! 
Minor note, I personally dislike that style of incorporating actual caches to ThreadLocalCache impl, clearly it breaks incapsulation. Why not keep the cache private to ObjectStreamClass?

> [classlib][luni][performance] ObjectStreamClass lookup improvement
> ------------------------------------------------------------------
>
>                 Key: HARMONY-5633
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5633
>             Project: Harmony
>          Issue Type: Improvement
>            Reporter: Aleksey Shipilev
>         Attachments: 0001-serial-lookupClass.patch, serial-lookupClass-RC1.patch, serial-lookupClass-RC2.patch
>
>
> For now, ObjectStreamClass (OSC) is created on-the-fly during serialization/deserialization and stored in static cache.
> Performance problems arose when several threads doing the lookups, hitting on synchronized cache. Moreover, the cache is built around WeakHashMap to ensure GC of OSCs. This issue is the source of scalability problems for multi-threaded serialization benchmarks.

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


[jira] Updated: (HARMONY-5633) [classlib][luni][performance] ObjectStreamClass lookup improvement

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

Aleksey Shipilev updated HARMONY-5633:
--------------------------------------

    Comment: was deleted

> [classlib][luni][performance] ObjectStreamClass lookup improvement
> ------------------------------------------------------------------
>
>                 Key: HARMONY-5633
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5633
>             Project: Harmony
>          Issue Type: Improvement
>            Reporter: Aleksey Shipilev
>         Attachments: 0001-serial-lookupClass.patch, serial-lookupClass-RC1.patch, serial-lookupClass-RC2.patch, serial-lookupClass-RC3.patch
>
>
> For now, ObjectStreamClass (OSC) is created on-the-fly during serialization/deserialization and stored in static cache.
> Performance problems arose when several threads doing the lookups, hitting on synchronized cache. Moreover, the cache is built around WeakHashMap to ensure GC of OSCs. This issue is the source of scalability problems for multi-threaded serialization benchmarks.

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