Skywalking: To improve DataCarrier

Created on 12 Jul 2019  路  16Comments  路  Source: apache/skywalking

Please answer these questions before submitting your issue.

  • Why do you submit this issue?
  • [ ] Question or discussion
  • [ ] Bug
  • [ ] Requirement
  • [x] Feature or performance improvement

Requirement or improvement

  • Please describe about your requirements or improvement suggestions.

This issue traces whether to use ArrayList instead of LinkedList. We have worked something on #3021 before this. Now we need to discuss how to make sure which is the better.

core feature feature

All 16 comments

Hi, I am back from travell, so we could work on this now.

For your prev tests
image

  1. You set consume size to 4k, from my prev calculation, it should at least 40k, is it your mistake or mine?
  2. You didn't clear the link after each consume cycle, I assume it is a bug? If you don't add, the link size keeps increasing.

How about improving this as the first step?

  1. It is my mistake.
  2. It is recreated every time. That is why make the test more seem like reality. (I know it out of benchmark)

It is recreated every time. That is why make the test more seem like reality. (I know it out of benchmark)

You are testing different list size, why is it more real?

  1. The max capacity is 40k with default initial capacity. It showed that the ArrayList seem like better in ops. And the reused ListedList is better at GC.
    @Benchmark
    public void testReusedArray() {
        List<SampleData> consumerList = new ArrayList<SampleData>();
        for (int times=0; times<1000; times++) {
            for (int pos = 0; pos < 40000; pos++) {
                consumerList.add(new SampleData());
            }
            consumerList.clear();
        }
    }

    @Benchmark
    public void testLinked() {
        for (int times=0; times<1000; times++) {
            List<SampleData> consumerList = new LinkedList<SampleData>();

            for (int pos = 0; pos < 40000; pos++) {
                consumerList.add(new SampleData());
            }
        }
    }

    @Benchmark
    public void testReusedLinked() {
        List<SampleData> consumerList = new LinkedList<SampleData>();
        for (int times=0; times<1000; times++) {

            for (int pos = 0; pos < 40000; pos++) {
                consumerList.add(new SampleData());
            }
            consumerList.clear();
        }
    }

Result:

Benchmark                                                                   Mode  Cnt           Score          Error   Units
LinkedArrayBenchmark.testReusedArray                                       thrpt    5           4.099 卤        0.254   ops/s
LinkedArrayBenchmark.testReusedArray:路gc.alloc.rate                        thrpt    5        3577.493 卤      218.971  MB/sec
LinkedArrayBenchmark.testReusedArray:路gc.alloc.rate.norm                   thrpt    5   960569530.436 卤        0.529    B/op
LinkedArrayBenchmark.testReusedArray:路gc.churn.PS_Eden_Space               thrpt    5        3579.288 卤      227.314  MB/sec
LinkedArrayBenchmark.testReusedArray:路gc.churn.PS_Eden_Space.norm          thrpt    5   961045357.161 卤  7069943.693    B/op
LinkedArrayBenchmark.testReusedArray:路gc.churn.PS_Survivor_Space           thrpt    5           2.369 卤        0.343  MB/sec
LinkedArrayBenchmark.testReusedArray:路gc.churn.PS_Survivor_Space.norm      thrpt    5      636105.700 卤    95920.377    B/op
LinkedArrayBenchmark.testReusedArray:路gc.count                             thrpt    5        1133.000                 counts
LinkedArrayBenchmark.testReusedArray:路gc.time                              thrpt    5        3254.000                     ms

LinkedArrayBenchmark.testReusedLinked                                      thrpt    5           1.578 卤        0.068   ops/s
LinkedArrayBenchmark.testReusedLinked:路gc.alloc.rate                       thrpt    5        2753.590 卤      112.877  MB/sec
LinkedArrayBenchmark.testReusedLinked:路gc.alloc.rate.norm                  thrpt    5  1920000059.000 卤        0.001    B/op
LinkedArrayBenchmark.testReusedLinked:路gc.churn.PS_Eden_Space              thrpt    5        2752.897 卤      113.153  MB/sec
LinkedArrayBenchmark.testReusedLinked:路gc.churn.PS_Eden_Space.norm         thrpt    5  1919516672.000 卤   713769.991    B/op
LinkedArrayBenchmark.testReusedLinked:路gc.churn.PS_Survivor_Space          thrpt    5           6.904 卤        0.680  MB/sec
LinkedArrayBenchmark.testReusedLinked:路gc.churn.PS_Survivor_Space.norm     thrpt    5     4813619.200 卤   404066.441    B/op
LinkedArrayBenchmark.testReusedLinked:路gc.count                            thrpt    5         885.000                 counts
LinkedArrayBenchmark.testReusedLinked:路gc.time                             thrpt    5        2996.000                   ms

LinkedArrayBenchmark.testLinked                                            thrpt    5           2.489 卤        0.077   ops/s
LinkedArrayBenchmark.testLinked:路gc.alloc.rate                             thrpt    5        4346.145 卤      145.163  MB/sec
LinkedArrayBenchmark.testLinked:路gc.alloc.rate.norm                        thrpt    5  1920000016.881 卤        1.402    B/op
LinkedArrayBenchmark.testLinked:路gc.churn.PS_Eden_Space                    thrpt    5        4347.414 卤      163.445  MB/sec
LinkedArrayBenchmark.testLinked:路gc.churn.PS_Eden_Space.norm               thrpt    5  1920547279.983 卤 12167953.775    B/op
LinkedArrayBenchmark.testLinked:路gc.churn.PS_Survivor_Space                thrpt    5          10.691 卤        1.312  MB/sec
LinkedArrayBenchmark.testLinked:路gc.churn.PS_Survivor_Space.norm           thrpt    5     4722251.934 卤   452198.476    B/op
LinkedArrayBenchmark.testLinked:路gc.count                                  thrpt    5        1417.000                 counts
LinkedArrayBenchmark.testLinked:路gc.time                                   thrpt    5        4794.000                     ms
  1. This part tests default capacity and the max size of List is 1000.
    @Benchmark
    public void testArrayCap1000() {
        ArrayList<SampleData> list = new ArrayList<SampleData>();
        for (int i=0; i<1000; i++) {
            list.add(new SampleData());
        }
    }

    @Benchmark
    public void testLinkedCap1000() {
        LinkedList<SampleData> list = new LinkedList<SampleData>();
        for (int i=0; i<1000; i++) {
            list.add(new SampleData());
        }
    }

Result:

Benchmark                                                                   Mode  Cnt           Score          Error   Units
LinkedArrayBenchmark.testArrayCap1000                                      thrpt    5      176522.532 卤     4448.276   ops/s
LinkedArrayBenchmark.testArrayCap1000:路gc.alloc.rate                       thrpt    5        6252.366 卤      157.348  MB/sec
LinkedArrayBenchmark.testArrayCap1000:路gc.alloc.rate.norm                  thrpt    5       39000.000 卤        0.001    B/op
LinkedArrayBenchmark.testArrayCap1000:路gc.churn.PS_Eden_Space              thrpt    5        6252.940 卤      161.485  MB/sec
LinkedArrayBenchmark.testArrayCap1000:路gc.churn.PS_Eden_Space.norm         thrpt    5       39003.545 卤       51.090    B/op
LinkedArrayBenchmark.testArrayCap1000:路gc.churn.PS_Survivor_Space          thrpt    5           0.803 卤        0.219  MB/sec
LinkedArrayBenchmark.testArrayCap1000:路gc.churn.PS_Survivor_Space.norm     thrpt    5           5.007 卤        1.286    B/op
LinkedArrayBenchmark.testArrayCap1000:路gc.count                            thrpt    5        1937.000                 counts
LinkedArrayBenchmark.testArrayCap1000:路gc.time                             thrpt    5        1473.000                     ms

LinkedArrayBenchmark.testLinkedCap1000                                     thrpt    5      101449.110 卤     7841.344   ops/s
LinkedArrayBenchmark.testLinkedCap1000:路gc.alloc.rate                      thrpt    5        4422.601 卤      342.269  MB/sec
LinkedArrayBenchmark.testLinkedCap1000:路gc.alloc.rate.norm                 thrpt    5       48000.000 卤        0.001    B/op
LinkedArrayBenchmark.testLinkedCap1000:路gc.churn.PS_Eden_Space             thrpt    5        4425.733 卤      336.180  MB/sec
LinkedArrayBenchmark.testLinkedCap1000:路gc.churn.PS_Eden_Space.norm        thrpt    5       48034.296 卤      229.819    B/op
LinkedArrayBenchmark.testLinkedCap1000:路gc.churn.PS_Survivor_Space         thrpt    5           0.872 卤        0.304  MB/sec
LinkedArrayBenchmark.testLinkedCap1000:路gc.churn.PS_Survivor_Space.norm    thrpt    5           9.466 卤        3.005    B/op
LinkedArrayBenchmark.testLinkedCap1000:路gc.count                           thrpt    5        1371.000                 counts
LinkedArrayBenchmark.testLinkedCap1000:路gc.time                            thrpt    5         997.000                     ms
  1. This part tests default capacity and the max size of List is 40000.
    @Benchmark
    public void testArrayCap40000() {
        ArrayList<SampleData> list = new ArrayList<SampleData>();
        for (int i=0; i<40000; i++) {
            list.add(new SampleData());
        }
    }

    @Benchmark
    public void testLinkedCap40000() {
        LinkedList<SampleData> list = new LinkedList<SampleData>();
        for (int i=0; i<40000; i++) {
            list.add(new SampleData());
        }
    }

Result:

Benchmark                                                                   Mode  Cnt           Score          Error   Units
LinkedArrayBenchmark.testArrayCap40000                                     thrpt    5        3367.247 卤      457.619   ops/s
LinkedArrayBenchmark.testArrayCap40000:路gc.alloc.rate                      thrpt    5        4677.556 卤      635.732  MB/sec
LinkedArrayBenchmark.testArrayCap40000:路gc.alloc.rate.norm                 thrpt    5     1529496.013 卤        0.002    B/op
LinkedArrayBenchmark.testArrayCap40000:路gc.churn.PS_Eden_Space             thrpt    5        4690.330 卤      655.901  MB/sec
LinkedArrayBenchmark.testArrayCap40000:路gc.churn.PS_Eden_Space.norm        thrpt    5     1533628.010 卤     7701.263    B/op
LinkedArrayBenchmark.testArrayCap40000:路gc.churn.PS_Survivor_Space         thrpt    5           6.110 卤        2.169  MB/sec
LinkedArrayBenchmark.testArrayCap40000:路gc.churn.PS_Survivor_Space.norm    thrpt    5        1995.479 卤      485.706    B/op
LinkedArrayBenchmark.testArrayCap40000:路gc.count                           thrpt    5        1473.000                 counts
LinkedArrayBenchmark.testArrayCap40000:路gc.time                            thrpt    5        1641.000                     ms

LinkedArrayBenchmark.testLinkedCap40000                                    thrpt    5        2367.759 卤      121.662   ops/s
LinkedArrayBenchmark.testLinkedCap40000:路gc.alloc.rate                     thrpt    5        4128.794 卤      211.930  MB/sec
LinkedArrayBenchmark.testLinkedCap40000:路gc.alloc.rate.norm                thrpt    5     1920000.018 卤        0.001    B/op
LinkedArrayBenchmark.testLinkedCap40000:路gc.churn.PS_Eden_Space            thrpt    5        4127.384 卤      224.263  MB/sec
LinkedArrayBenchmark.testLinkedCap40000:路gc.churn.PS_Eden_Space.norm       thrpt    5     1919330.567 卤    15068.179    B/op
LinkedArrayBenchmark.testLinkedCap40000:路gc.churn.PS_Survivor_Space        thrpt    5          10.019 卤        0.828  MB/sec
LinkedArrayBenchmark.testLinkedCap40000:路gc.churn.PS_Survivor_Space.norm   thrpt    5        4658.864 卤      272.178    B/op
LinkedArrayBenchmark.testLinkedCap40000:路gc.count                          thrpt    5        1310.000                 counts
LinkedArrayBenchmark.testLinkedCap40000:路gc.time                           thrpt    5        4550.000                     ms
  1. This part tests different initial capacity(1, 10, 8000, 40000). The max length is 40k. Here's a odd appearance. We can notice the initial capacity is 10(default value) will execute the most GC times and cost the most time. But its ops is better than others.
    (I have executed several times, the results almost are the same.)
    @Benchmark
    public void testArrayStart1() {
        List<SampleData> consumerList = new ArrayList<SampleData>(1);
        for (int pos = 0; pos < 40000; pos++) {
            consumerList.add(new SampleData());
        }
    }

    @Benchmark
    public void testArrayStart10() {
        List<SampleData> consumerList = new ArrayList<SampleData>(10);
        for (int pos = 0; pos < 40000; pos++) {
            consumerList.add(new SampleData());
        }
    }
    @Benchmark
    public void testArrayStart8000() {
        List<SampleData> consumerList = new ArrayList<SampleData>(8000);
        for (int pos = 0; pos < 40000; pos++) {
            consumerList.add(new SampleData());
        }
    }

    @Benchmark
    public void testArrayStart40000() {
        List<SampleData> consumerList = new ArrayList<SampleData>(40000);
        for (int pos = 0; pos < 40000; pos++) {
            consumerList.add(new SampleData());
        }
    }

Result:

LinkedArrayBenchmark.testArrayStart1                                       thrpt    5     3650.344 卤  430.214   ops/s
LinkedArrayBenchmark.testArrayStart1:路gc.alloc.rate                        thrpt    5     4814.170 卤  567.231  MB/sec
LinkedArrayBenchmark.testArrayStart1:路gc.alloc.rate.norm                   thrpt    5  1452104.012 卤    0.001    B/op
LinkedArrayBenchmark.testArrayStart1:路gc.churn.PS_Eden_Space               thrpt    5     4825.797 卤  575.542  MB/sec
LinkedArrayBenchmark.testArrayStart1:路gc.churn.PS_Eden_Space.norm          thrpt    5  1455598.022 卤 5557.754    B/op
LinkedArrayBenchmark.testArrayStart1:路gc.churn.PS_Survivor_Space           thrpt    5        5.943 卤    1.387  MB/sec
LinkedArrayBenchmark.testArrayStart1:路gc.churn.PS_Survivor_Space.norm      thrpt    5     1792.091 卤  297.976    B/op
LinkedArrayBenchmark.testArrayStart1:路gc.count                             thrpt    5     1513.000             counts
LinkedArrayBenchmark.testArrayStart1:路gc.time                              thrpt    5     1637.000                 ms

LinkedArrayBenchmark.testArrayStart10                                      thrpt    5     4557.648 卤  121.325   ops/s
LinkedArrayBenchmark.testArrayStart10:路gc.alloc.rate                       thrpt    5     6331.232 卤  168.013  MB/sec
LinkedArrayBenchmark.testArrayStart10:路gc.alloc.rate.norm                  thrpt    5  1529496.010 卤    0.001    B/op
LinkedArrayBenchmark.testArrayStart10:路gc.churn.PS_Eden_Space              thrpt    5     6347.599 卤  190.562  MB/sec
LinkedArrayBenchmark.testArrayStart10:路gc.churn.PS_Eden_Space.norm         thrpt    5  1533442.650 卤 6747.452    B/op
LinkedArrayBenchmark.testArrayStart10:路gc.churn.PS_Survivor_Space          thrpt    5        8.601 卤    1.989  MB/sec
LinkedArrayBenchmark.testArrayStart10:路gc.churn.PS_Survivor_Space.norm     thrpt    5     2078.243 卤  514.259    B/op
LinkedArrayBenchmark.testArrayStart10:路gc.count                            thrpt    5     1992.000             counts
LinkedArrayBenchmark.testArrayStart10:路gc.time                             thrpt    5     2371.000                 ms

LinkedArrayBenchmark.testArrayStart8000                                    thrpt    5     3822.186 卤  109.671   ops/s
LinkedArrayBenchmark.testArrayStart8000:路gc.alloc.rate                     thrpt    5     4797.774 卤  138.117  MB/sec
LinkedArrayBenchmark.testArrayStart8000:路gc.alloc.rate.norm                thrpt    5  1382080.011 卤    0.001    B/op
LinkedArrayBenchmark.testArrayStart8000:路gc.churn.PS_Eden_Space            thrpt    5     4807.450 卤  140.827  MB/sec
LinkedArrayBenchmark.testArrayStart8000:路gc.churn.PS_Eden_Space.norm       thrpt    5  1384866.917 卤 5337.475    B/op
LinkedArrayBenchmark.testArrayStart8000:路gc.churn.PS_Survivor_Space        thrpt    5        4.457 卤    0.342  MB/sec
LinkedArrayBenchmark.testArrayStart8000:路gc.churn.PS_Survivor_Space.norm   thrpt    5     1283.812 卤   64.992    B/op
LinkedArrayBenchmark.testArrayStart8000:路gc.count                          thrpt    5     1507.000             counts
LinkedArrayBenchmark.testArrayStart8000:路gc.time                           thrpt    5     1526.000                 ms

LinkedArrayBenchmark.testArrayStart40000                                   thrpt    5     4312.118 卤   37.028   ops/s
LinkedArrayBenchmark.testArrayStart40000:路gc.alloc.rate                    thrpt    5     4386.398 卤   37.389  MB/sec
LinkedArrayBenchmark.testArrayStart40000:路gc.alloc.rate.norm               thrpt    5  1120016.010 卤    0.001    B/op
LinkedArrayBenchmark.testArrayStart40000:路gc.churn.PS_Eden_Space           thrpt    5     4390.996 卤   48.359  MB/sec
LinkedArrayBenchmark.testArrayStart40000:路gc.churn.PS_Eden_Space.norm      thrpt    5  1121190.745 卤 9368.223    B/op
LinkedArrayBenchmark.testArrayStart40000:路gc.churn.PS_Survivor_Space       thrpt    5        5.880 卤    0.514  MB/sec
LinkedArrayBenchmark.testArrayStart40000:路gc.churn.PS_Survivor_Space.norm  thrpt    5     1501.392 卤  143.043    B/op
LinkedArrayBenchmark.testArrayStart40000:路gc.count                         thrpt    5     1378.000             counts
LinkedArrayBenchmark.testArrayStart40000:路gc.time                          thrpt    5     1602.000                 ms

LinkedArrayBenchmark.testArrayStart40000 thrpt 5 4.750 卤 1.010 ops/s

Why this ops so low?

Loop 1000 times in the method to make instance reused.

Update the benchmark result for fix some mistakes and add tests code.

FYI @hanahmily @peng-yongsheng @kezhenxu94 @JaredTan95 @zhaoyuguang @IanCao

According to all these tests, the ArrayList is much faster than LinkedList, especially in list reuse scenario, even including the GC time

Highlight this one

Benchmark                                                                   Mode  Cnt           Score          Error   Units
LinkedArrayBenchmark.testReusedArray                                       thrpt    5           4.099 卤        0.254   ops/s
LinkedArrayBenchmark.testReusedArray:路gc.alloc.rate                        thrpt    5        3577.493 卤      218.971  MB/sec
LinkedArrayBenchmark.testReusedArray:路gc.alloc.rate.norm                   thrpt    5   960569530.436 卤        0.529    B/op
LinkedArrayBenchmark.testReusedArray:路gc.churn.PS_Eden_Space               thrpt    5        3579.288 卤      227.314  MB/sec
LinkedArrayBenchmark.testReusedArray:路gc.churn.PS_Eden_Space.norm          thrpt    5   961045357.161 卤  7069943.693    B/op
LinkedArrayBenchmark.testReusedArray:路gc.churn.PS_Survivor_Space           thrpt    5           2.369 卤        0.343  MB/sec
LinkedArrayBenchmark.testReusedArray:路gc.churn.PS_Survivor_Space.norm      thrpt    5      636105.700 卤    95920.377    B/op
LinkedArrayBenchmark.testReusedArray:路gc.count                             thrpt    5        1133.000                 counts
LinkedArrayBenchmark.testReusedArray:路gc.time                              thrpt    5        3254.000                     ms

LinkedArrayBenchmark.testReusedLinked                                      thrpt    5           1.578 卤        0.068   ops/s
LinkedArrayBenchmark.testReusedLinked:路gc.alloc.rate                       thrpt    5        2753.590 卤      112.877  MB/sec
LinkedArrayBenchmark.testReusedLinked:路gc.alloc.rate.norm                  thrpt    5  1920000059.000 卤        0.001    B/op
LinkedArrayBenchmark.testReusedLinked:路gc.churn.PS_Eden_Space              thrpt    5        2752.897 卤      113.153  MB/sec
LinkedArrayBenchmark.testReusedLinked:路gc.churn.PS_Eden_Space.norm         thrpt    5  1919516672.000 卤   713769.991    B/op
LinkedArrayBenchmark.testReusedLinked:路gc.churn.PS_Survivor_Space          thrpt    5           6.904 卤        0.680  MB/sec
LinkedArrayBenchmark.testReusedLinked:路gc.churn.PS_Survivor_Space.norm     thrpt    5     4813619.200 卤   404066.441    B/op
LinkedArrayBenchmark.testReusedLinked:路gc.count                            thrpt    5         885.000                 counts
LinkedArrayBenchmark.testReusedLinked:路gc.time                             thrpt    5        2996.000                   ms

3x times faster.

I recommend you

  1. Use a 2k~ as ArrayList initial size(agent uses 1.5k as default), because not all OAPs run in the full payload.
  2. Use array reuse mechanism in DataCarrier consumer, especially in BulkConsumePool(OAP used).

Let's work on a PR to make this works. cc all @apache/skywalking-committers

I think, their GC profiling is unavalible in part 4 .

About the max capacity is 200k. ArrayList has the better ops and take more GC times, but cost less. It is amazing.

    @Benchmark
    public void testArrayList200K() {
        ArrayList<SampleData> list = new ArrayList<SampleData>(4000);
        for (int times=0; times<1000; times++) {
            for (int pos=0; pos<200000; pos++) {
                list.add(new SampleData());
            }
            list.clear();
        }
    }

    @Benchmark
    public void testReusedLinked200K() {
        LinkedList<SampleData> list = new LinkedList<SampleData>();
        for (int times=0; times<1000; times++) {
            for (int pos=0; pos<200000; pos++) {
                list.add(new SampleData());
            }
            list.clear();
        }
    }

    @Benchmark
    public void testLinked200K() {
        for (int times=0; times<1000; times++) {
            LinkedList<SampleData> list = new LinkedList<SampleData>();
            for (int pos=0; pos<200000; pos++) {
                list.add(new SampleData());
            }
        }
    }

Result:

Benchmark                                                                    Mode  Cnt           Score          Error   Units
LinkedArrayBenchmark.testArrayList200K                                      thrpt    5           0.812 卤        0.089   ops/s
LinkedArrayBenchmark.testArrayList200K:路gc.alloc.rate                       thrpt    5        3553.772 卤      398.861  MB/sec
LinkedArrayBenchmark.testArrayList200K:路gc.alloc.rate.norm                  thrpt    5  4802736145.200 卤       10.332    B/op
LinkedArrayBenchmark.testArrayList200K:路gc.churn.PS_Eden_Space              thrpt    5        3554.349 卤      392.149  MB/sec
LinkedArrayBenchmark.testArrayList200K:路gc.churn.PS_Eden_Space.norm         thrpt    5  4803581996.267 卤 34330566.135    B/op
LinkedArrayBenchmark.testArrayList200K:路gc.churn.PS_Survivor_Space          thrpt    5          24.179 卤        3.090  MB/sec
LinkedArrayBenchmark.testArrayList200K:路gc.churn.PS_Survivor_Space.norm     thrpt    5    32674873.111 卤  1225690.282    B/op
LinkedArrayBenchmark.testArrayList200K:路gc.count                            thrpt    5        1273.000                 counts
LinkedArrayBenchmark.testArrayList200K:路gc.time                             thrpt    5       11674.000                     ms

LinkedArrayBenchmark.testReusedLinked200K                                   thrpt    5           0.250 卤        0.007   ops/s
LinkedArrayBenchmark.testReusedLinked200K:路gc.alloc.rate                    thrpt    5        2196.510 卤       62.548  MB/sec
LinkedArrayBenchmark.testReusedLinked200K:路gc.alloc.rate.norm               thrpt    5  9600000176.000 卤        0.001    B/op
LinkedArrayBenchmark.testReusedLinked200K:路gc.churn.PS_Eden_Space           thrpt    5        2195.758 卤       44.272  MB/sec
LinkedArrayBenchmark.testReusedLinked200K:路gc.churn.PS_Eden_Space.norm      thrpt    5  9596847166.400 卤 99649380.997    B/op
LinkedArrayBenchmark.testReusedLinked200K:路gc.churn.PS_Survivor_Space       thrpt    5          24.604 卤        3.520  MB/sec
LinkedArrayBenchmark.testReusedLinked200K:路gc.churn.PS_Survivor_Space.norm  thrpt    5   107513992.533 卤 12501959.808    B/op
LinkedArrayBenchmark.testReusedLinked200K:路gc.count                         thrpt    5         922.000                 counts
LinkedArrayBenchmark.testReusedLinked200K:路gc.time                          thrpt    5       12103.000                     ms

LinkedArrayBenchmark.testLinked200K                                         thrpt    5           0.375 卤        0.011   ops/s
LinkedArrayBenchmark.testLinked200K:路gc.alloc.rate                          thrpt    5        3283.321 卤       88.875  MB/sec
LinkedArrayBenchmark.testLinked200K:路gc.alloc.rate.norm                     thrpt    5  9600000109.600 卤       13.776    B/op
LinkedArrayBenchmark.testLinked200K:路gc.churn.PS_Eden_Space                 thrpt    5        3284.087 卤       91.468  MB/sec
LinkedArrayBenchmark.testLinked200K:路gc.churn.PS_Eden_Space.norm            thrpt    5  9602229858.400 卤 15430474.683    B/op
LinkedArrayBenchmark.testLinked200K:路gc.churn.PS_Survivor_Space             thrpt    5          36.178 卤        6.896  MB/sec
LinkedArrayBenchmark.testLinked200K:路gc.churn.PS_Survivor_Space.norm        thrpt    5   105760358.400 卤 17865836.630    B/op
LinkedArrayBenchmark.testLinked200K:路gc.count                               thrpt    5        1231.000                 counts
LinkedArrayBenchmark.testLinked200K:路gc.time                                thrpt    5       16275.000                     ms

This extra gc.time is quiet little, comparing to 3x time OPs. Also, you should know, more GC may be caused by more OPs, think in this way, you do 3x times OPs, how many more SampleDatas do you create?

So, more GC conclusion actually is not quite right. The reason is more likely, Arraylist is always better. If you have change test in JVM 1.6

The same codes run in openJDK1.6.

This test is not on the same machine as above. So not using that to compare JDK version.

  1. Environment:
# JMH 1.16 (released 978 days ago, please consider updating!)
# VM version: JDK 1.6.0_38, VM 23.25-b01
# VM invoker: /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java
# VM options: -Xmx512m -Xms512m
# Warmup: 20 iterations, 1 s each, 5 calls per op
# Measurement: 5 iterations, 1 s each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Throughput, ops/time
  1. Result:
Benchmark                                           Mode  Cnt     Score   Error   Units
ListBenchmark.testArrayList200K                    thrpt    5     0.317 卤 0.057   ops/s
ListBenchmark.testArrayList200K:路gc.alloc.rate     thrpt    5       NaN          MB/sec
ListBenchmark.testArrayList200K:路gc.count          thrpt    5   145.000          counts
ListBenchmark.testArrayList200K:路gc.time           thrpt    5  1981.000              ms
ListBenchmark.testLinked200K                       thrpt    5     0.179 卤 0.005   ops/s
ListBenchmark.testLinked200K:路gc.alloc.rate        thrpt    5       NaN          MB/sec
ListBenchmark.testLinked200K:路gc.count             thrpt    5   307.000          counts
ListBenchmark.testLinked200K:路gc.time              thrpt    5  1757.000              ms
ListBenchmark.testReusedLinked200K                 thrpt    5     0.113 卤 0.002   ops/s
ListBenchmark.testReusedLinked200K:路gc.alloc.rate  thrpt    5       NaN          MB/sec
ListBenchmark.testReusedLinked200K:路gc.count       thrpt    5   307.000          counts
ListBenchmark.testReusedLinked200K:路gc.time        thrpt    5  1724.000              ms

Good to know, thanks. Let's work on the PR.

Finished, Thank all of you.

@kezhenxu94 Let's move this to WIKI

@dmsolr We have moved this to WIKI, https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=120739133, for archive materials. If you want to add anything, let me know.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

GreyZeng picture GreyZeng  路  5Comments

wu-sheng picture wu-sheng  路  3Comments

wu-sheng picture wu-sheng  路  5Comments

itziklavon picture itziklavon  路  4Comments

dingsongjie picture dingsongjie  路  4Comments