You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Bob Lee (JIRA)" <ji...@apache.org> on 2008/06/06 00:00:48 UTC

[jira] Updated: (HARMONY-5703) [drlvm][performance] j.l.ThreadLocal performance optimization

     [ https://issues.apache.org/jira/browse/HARMONY-5703?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bob Lee updated HARMONY-5703:
-----------------------------

    Attachment: threadlocal.diff

I couldn't get Harmony to build (hit a compile error in some native code), but I'm submitting this patch anyway since it builds and runs fine with our stuff. I created the diff from /enhanced.

This ThreadLocal implementation is a complete rewrite. It runs about as fast as the RI, but it performs fewer allocations (none in common cases due to lack of Entry objects), and it cleans up after reclaimed ThreadLocals more aggressively than the RI.

You'll need to add two fields to Thread:

    /**
     * Normal thread local values.
     */
    ThreadLocal.Values localValues;

    /**
     * Inheritable thread local values.
     */
    ThreadLocal.Values inheritableValues;

And this code to Thread's constructor:

        if (currentThread.inheritableValues != null) {
            inheritableValues
                    = new ThreadLocal.Values(currentThread.inheritableValues);
        }

I would create a package-private java.lang.AbstractThread class which can contain this sort of common logic.

I also ran this against Doug Lea's test suite successfully, but here are the results of MTHarness on a MacPro:

Sun's ThreadLocal:

**** MTHarness started
**             runner: harness.TestBench
**            threads: 16
**  warmup iterations: 1
** measure iterations: 4

Threads = 1, iteration 0:  1876.0, 
Threads = 16, iteration 1:  20458.0, 20484.0, 20254.0, 20491.0, 20377.0, 20406.0, 20226.0, 20129.0, 20508.0, 20436.0, 20220.0, 20512.0, 20390.0, 20457.0, 20463.0, 20340.0, 
Threads = 16, iteration 2:  19941.0, 20349.0, 20286.0, 20349.0, 20064.0, 20213.0, 20199.0, 20055.0, 20277.0, 20296.0, 20220.0, 19928.0, 20262.0, 20210.0, 20150.0, 20368.0, 
Threads = 16, iteration 3:  20176.0, 20300.0, 20336.0, 20431.0, 20561.0, 20585.0, 20523.0, 20097.0, 20556.0, 20549.0, 20374.0, 20568.0, 20515.0, 20510.0, 20325.0, 20172.0, 
Threads = 16, iteration 4:  20807.0, 20399.0, 20763.0, 20659.0, 20675.0, 20780.0, 20651.0, 20813.0, 20810.0, 20699.0, 20846.0, 20531.0, 20735.0, 20668.0, 20737.0, 20830.0, 

****** Global scores ********
 Score 0: 326151.0
 Score 1: 323167.0
 Score 2: 326578.0
 Score 3: 331403.0
------------------------------
 min=323,167 max=331,403
 avg=326,824.75 stdev=0.6%

crazybob's ThreadLocal:

**** MTHarness started
**             runner: harness.TestBench
**            threads: 16
**  warmup iterations: 1
** measure iterations: 4

Threads = 1, iteration 0:  1886.0, 
Threads = 16, iteration 1:  20108.0, 19491.0, 19874.0, 20167.0, 20124.0, 20143.0, 20117.0, 20058.0, 20149.0, 20178.0, 20032.0, 19933.0, 20138.0, 19918.0, 19622.0, 20143.0, 
Threads = 16, iteration 2:  19979.0, 19748.0, 19839.0, 19775.0, 20022.0, 20040.0, 20007.0, 19833.0, 20029.0, 19902.0, 19941.0, 20012.0, 19721.0, 19635.0, 19935.0, 19989.0, 
Threads = 16, iteration 3:  20228.0, 20226.0, 20133.0, 20279.0, 20120.0, 20342.0, 20272.0, 20336.0, 20240.0, 20219.0, 20327.0, 20232.0, 20303.0, 20322.0, 20283.0, 20133.0, 
Threads = 16, iteration 4:  20075.0, 20086.0, 19583.0, 20022.0, 20116.0, 20133.0, 19997.0, 19657.0, 20049.0, 20019.0, 19849.0, 20147.0, 20094.0, 19842.0, 19946.0, 20025.0, 

****** Global scores ********
 Score 0: 320195.0
 Score 1: 318407.0
 Score 2: 323995.0
 Score 3: 319640.0
------------------------------
 min=318,407 max=323,995
 avg=320,559.25 stdev=0.43%



> [drlvm][performance] j.l.ThreadLocal performance optimization
> -------------------------------------------------------------
>
>                 Key: HARMONY-5703
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5703
>             Project: Harmony
>          Issue Type: Improvement
>          Components: Classlib, DRLVM
>            Reporter: Aleksey Shipilev
>         Attachments: MTHarness.jar, threadlocal.diff
>
>
> Umbrella issue for j.l.ThreadLocal optimization.
> Uses MTHarness/ThreadLocalBench for benchmarking.

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