Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize method HttpStatusClass.valueOf(int) #13543

Merged
merged 11 commits into from Sep 21, 2023

Conversation

laosijikaichele
Copy link
Contributor

@laosijikaichele laosijikaichele commented Aug 10, 2023

Motivation:

The method HttpStatusClass.valueOf(int) can be optimized by replacing 'if branches' with 'switch cases'.
The 'switch cases' can be optimized by JIT to run faster than 'if branches'.
Refer https://stackoverflow.com/a/98024.

Modification:

Replace 'if-branches' with 'switch case'.

Result:

Remove the 'if-branches'.

@chrisvest
Copy link
Contributor

Integer division is pretty slow, while branches are often predictable.

I don't think this will be a beneficial change, unless you have a benchmark showing that it's worthwhile.

@laosijikaichele
Copy link
Contributor Author

laosijikaichele commented Aug 11, 2023

Integer division is pretty slow, while branches are often predictable.

I don't think this will be a beneficial change, unless you have a benchmark showing that it's worthwhile.

OK,I will do a benchmark to check.

@@ -56,22 +56,20 @@ public boolean contains(int code) {
* Returns the class of the specified HTTP status code.
*/
public static HttpStatusClass valueOf(int code) {
if (INFORMATIONAL.contains(code)) {
return INFORMATIONAL;
switch (code / 100) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any JMH number? and tableswitch may slower than hand arranged if else.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think 'tableswitch' is faster than 'if else' in most common cases. U may mean the 'lookupswitch'?

Copy link
Contributor

@franz1981 franz1981 Aug 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depending the number of cases (below 10), the JIT just use a binary-like cascade of if, regardless the bytecode used.
The real problem is the division, given are pretty heavy

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@franz1981 The number of cases threshold may depends on the CPU type, for example, the 'MinJumpTableSize' is 5 in sparc: https://github.com/openjdk/jdk8u/blob/master/hotspot/src/cpu/sparc/vm/c2_globals_sparc.hpp#L60.
Further, in common cases, I think the binary-search is faster than the non-optimized 'if-else'.

Copy link
Contributor

@franz1981 franz1981 Aug 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, sorry, I tried remember by heart it, but I am biased toward my poor old X86 laptop :P
Said that, I believe bothering about the bytecode used isn't the key point here....but it's a fun exercise to microbench it, to be sure. And it requires some perfasm analysis.

Further, in common cases, I think the binary-search is faster than the non-optimized 'if-else'.

It really depends by the use cases
See #13473 benchmarks and impl for reference

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's why the SERVER_ERROR is the last.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@franz1981 , Appreciate for the benchmarks reference, will check it. As you said, the division may be the real bottleneck. I will run the benchmark to verify it.
@He-Pin , I think put SERVER_ERROR the last doesn't mean it will be faster than binary-search, it depends by the use cases.
If the CPU load goes heavy and cause more SERVER_ERROR code, then put SERVER_ERROR the last will amplify the load and make things going worse.

@laosijikaichele
Copy link
Contributor Author

laosijikaichele commented Aug 12, 2023

Done a preliminary benchmark, now with 'switch-case':

Benchmark                           (size)   Mode  Cnt   Score   Error   Units
HttpStatusValueOfBenchmark.ofValue      25  thrpt   40  13.558 ± 0.576  ops/us
HttpStatusValueOfBenchmark.ofValue      32  thrpt   40  11.040 ± 0.076  ops/us
HttpStatusValueOfBenchmark.ofValue      63  thrpt   40   5.540 ± 0.065  ops/us
HttpStatusValueOfBenchmark.ofValue      95  thrpt   40   3.676 ± 0.043  ops/us

Before:

Benchmark                           (size)   Mode  Cnt  Score   Error   Units
HttpStatusValueOfBenchmark.ofValue      25  thrpt   40  9.835 ± 0.214  ops/us
HttpStatusValueOfBenchmark.ofValue      32  thrpt   40  5.896 ± 1.576  ops/us
HttpStatusValueOfBenchmark.ofValue      63  thrpt   40  4.059 ± 0.060  ops/us
HttpStatusValueOfBenchmark.ofValue      95  thrpt   40  2.584 ± 0.025  ops/us

Seems switch-case is doing faster than if-else under current test case.

Besides, the newest commit that replace the 'switch-case' with 'array-index-lookup', seems gain more performance:

Benchmark                           (size)   Mode  Cnt   Score   Error   Units
HttpStatusValueOfBenchmark.ofValue      25  thrpt   40  15.787 ± 0.193  ops/us
HttpStatusValueOfBenchmark.ofValue      32  thrpt   40  12.238 ± 0.126  ops/us
HttpStatusValueOfBenchmark.ofValue      63  thrpt   40   6.270 ± 0.050  ops/us
HttpStatusValueOfBenchmark.ofValue      95  thrpt   40   4.197 ± 0.038  ops/us

With Java:

openjdk version "17.0.8" 2023-07-18
OpenJDK Runtime Environment (build 17.0.8+7-Ubuntu-120.04.2)
OpenJDK 64-Bit Server VM (build 17.0.8+7-Ubuntu-120.04.2, mixed mode, sharing)

And

dual processor: AMD EPYC 7763 64-Core Processor 2.45GHz

This is a very initial benchmark, any suggestion will be welcome. @franz1981 @chrisvest @He-Pin

@franz1981
Copy link
Contributor

franz1981 commented Aug 13, 2023

Yep @langchristian96 the main things are:

  • I didn't verified if switch cases branches are JIT profiled or not, so worth trying to "pollute" the profile by making on SetUp +10000 benchmark iterations which can take different branches with equal distributed probability (look at my pr benchmark for the confuseJIT Param true) which can arrange the branches in different ways
  • verify from the branch predictor perspective if the sequence of inputs is long enough. I see you have done it, but there are no branch mispredict count nor enough samples, at a first look.

Last but not least:

  • profile with perfasm
  • profile with async profiler
  • gather numbers with perfnorm and a Linux box

If using a Numa platform please run the full benchmark with numactl --localalloc -N 0 and disable turbo frequency (you can use the latency profile with tuned from RHEL If you wish).

A number isn't meaningful if you don't know how/why has happened, IMHO.
The typical mistake is to assume averything to be inlined: verify it, it can produce dramatic difference in perf!

Note: given that 100 is a constant from JIT perspective maybe there is some math trick (eg reciprocal multiplication) aiming to replace the division with something more appropriate, given that is stored into an int. The perfasm analysis should be done to verify it

@laosijikaichele
Copy link
Contributor Author

@franz1981 Great suggestions, I will do the furthering tests to check.

@laosijikaichele
Copy link
Contributor Author

laosijikaichele commented Aug 15, 2023

Been busy recently... Here is the latest update so far:

Note: given that 100 is a constant from JIT perspective maybe there is some math trick (eg reciprocal multiplication) aiming to replace the division with something more appropriate, given that is stored into an int. The perfasm analysis should be done to verify it

@franz1981 You are right, the JIT did some constant divisor optimizations.
Please see the following assembly code of method HttpStatusClass.valueOf(int) which uses code / 100:

C2-2

The quoted lines does the optimization of code / 100:

0x00007f068908efaf:   sar    $0x1f,%esi
0x00007f068908efb2:   imul   $0x51eb851f,%r10,%r10
0x00007f068908efb9:   sar    $0x25,%r10
0x00007f068908efbd:   mov    %r10d,%r11d
0x00007f068908efc0:   sub    %esi,%r11d

It can be translated to Java code like:

int fast_div100(int code) {
        // 1374389535L hex is 0x51eb851f
        return (int)(((code * 1374389535L) >> 37) - (code >> 31))
    }

Which means: code / 100 can be optimized to ((code * 1374389535L) >> 37) - (code >> 31).
If code >= 0, then it can be optimized to (code * 1374389535L) >> 37.

And the GCC did the similar optimization: https://gcc.godbolt.org/z/3EqjGdfoW.

Will keep updating when further tests done. :)

@chrisvest
Copy link
Contributor

@laosijikaichele Is this ready for review, or do you have more changes planned?

@laosijikaichele
Copy link
Contributor Author

@laosijikaichele Is this ready for review, or do you have more changes planned?

@chrisvest , Sorry for the delay, there are some more changes and tests to be committed, hopefully within 12 hours will be done. :)

@chrisvest
Copy link
Contributor

Okay. No need to commit to any deadline. Just ping me when I should take a look.

@franz1981
Copy link
Contributor

Just for reference, the optimization seems to happen at https://github.com/openjdk/jdk/blob/5726d31e56530bbe7dee61ae04b126e20cb3611d/src/hotspot/share/opto/divnode.cpp#L408-L411 which still reference Hacker's Delight

@laosijikaichele
Copy link
Contributor Author

laosijikaichele commented Aug 25, 2023

Thanks for the suggestions from @franz1981 , I updated the benchmark code, added 'equal branch distributed' to the set-up method, added 'perf profile' which included 'branch-misses' info.

Base line code:
The method HttpStatusClass.valueOf(int code) on 4.1-branch, which uses 'if-else'.

There are 2 optimizations committed for benchmark:

  1. Use 'switch-case' to replace 'if-else': [commit].
  2. Use 'array-index' to replace 'if-else': [commit].

The test inputs:
The input for the method HttpStatusClass.valueOf(int code): We generated random int values into int[] array , the percentages of each code type in the int[] array are:

INFORMATIONAL(1xx): 38%
SUCCESS(2xx): 30%
REDIRECTION(3xx): 15%
CLIENT_ERROR(4xx): 10%
SERVER_ERROR(5xx): 5%
UNKNOWN: 2%.

As you can see, the percentages are from big to small, which is based on the 'if-else' sequence of 4.1-branch code.
Note: the code sequences in int[] array are unsorted.

There are 5 different int[] array sizes to test(1300, 2600, 5300, 11000, 23000):

@Param({"1300", "2600", "5300", "11000", "23000"})
private int size;

The hardware info(no NUMA):

Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz

The benchmark result details are pretty long, you can directly scroll down to the end, there are summary tables. :)

First, benchmark with JDK-17:

openjdk version "17.0.8" 2023-07-18
OpenJDK Runtime Environment (build 17.0.8+7-Ubuntu-122.04)
OpenJDK 64-Bit Server VM (build 17.0.8+7-Ubuntu-122.04, mixed mode, sharing)

Base line(if-else), with JDK-17:

Benchmark                                                 (size)   Mode  Cnt        Score   Error      Units
HttpStatusValueOfBenchmark.valueOf                          1300  thrpt   20      131.519 ± 2.942     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      1300  thrpt    2        0.279          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      1300  thrpt    2        3.588          insns/clk
HttpStatusValueOfBenchmark.valueOf:branch-misses            1300  thrpt    2        5.088               #/op
HttpStatusValueOfBenchmark.valueOf:branches                 1300  thrpt    2    15639.515               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   1300  thrpt    2    23763.447               #/op
HttpStatusValueOfBenchmark.valueOf:instructions             1300  thrpt    2    85214.426               #/op

HttpStatusValueOfBenchmark.valueOf                          2600  thrpt   20       67.074 ± 0.198     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      2600  thrpt    2        0.275          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      2600  thrpt    2        3.642          insns/clk
HttpStatusValueOfBenchmark.valueOf:branch-misses            2600  thrpt    2       23.855               #/op
HttpStatusValueOfBenchmark.valueOf:branches                 2600  thrpt    2    31228.699               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   2600  thrpt    2    46808.875               #/op
HttpStatusValueOfBenchmark.valueOf:instructions             2600  thrpt    2   170460.118               #/op

HttpStatusValueOfBenchmark.valueOf                          5300  thrpt   20       23.719 ± 0.183     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      5300  thrpt    2        0.377          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      5300  thrpt    2        2.650          insns/clk
HttpStatusValueOfBenchmark.valueOf:branch-misses            5300  thrpt    2     1009.944               #/op
HttpStatusValueOfBenchmark.valueOf:branches                 5300  thrpt    2    65246.724               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   5300  thrpt    2   131437.990               #/op
HttpStatusValueOfBenchmark.valueOf:instructions             5300  thrpt    2   348279.930               #/op

HttpStatusValueOfBenchmark.valueOf                         11000  thrpt   20        9.228 ± 0.263     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                     11000  thrpt    2        0.478          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                     11000  thrpt    2        2.092          insns/clk
HttpStatusValueOfBenchmark.valueOf:branch-misses           11000  thrpt    2     5452.731               #/op
HttpStatusValueOfBenchmark.valueOf:branches                11000  thrpt    2   136786.030               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                  11000  thrpt    2   339681.590               #/op
HttpStatusValueOfBenchmark.valueOf:instructions            11000  thrpt    2   710474.678               #/op

HttpStatusValueOfBenchmark.valueOf                         23000  thrpt   20        4.655 ± 0.020     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                     23000  thrpt    2        0.539          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                     23000  thrpt    2        1.856          insns/clk
HttpStatusValueOfBenchmark.valueOf:branch-misses           23000  thrpt    2    13694.097               #/op
HttpStatusValueOfBenchmark.valueOf:branches                23000  thrpt    2   276757.705               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                  23000  thrpt    2   675187.667               #/op
HttpStatusValueOfBenchmark.valueOf:instructions            23000  thrpt    2  1253442.981               #/op

'Switch-case', with JDK-17:

Benchmark                                                 (size)   Mode  Cnt        Score   Error      Units
HttpStatusValueOfBenchmark.valueOf                          1300  thrpt   20      161.250 ± 0.830     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      1300  thrpt    2        0.275          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      1300  thrpt    2        3.633          insns/clk
HttpStatusValueOfBenchmark.valueOf:branch-misses            1300  thrpt    2        5.743               #/op
HttpStatusValueOfBenchmark.valueOf:branches                 1300  thrpt    2    14420.318               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   1300  thrpt    2    19361.700               #/op
HttpStatusValueOfBenchmark.valueOf:instructions             1300  thrpt    2    70347.321               #/op

HttpStatusValueOfBenchmark.valueOf                          2600  thrpt   20       79.798 ± 0.471     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      2600  thrpt    2        0.278          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      2600  thrpt    2        3.599          insns/clk
HttpStatusValueOfBenchmark.valueOf:branch-misses            2600  thrpt    2       30.426               #/op
HttpStatusValueOfBenchmark.valueOf:branches                 2600  thrpt    2    29104.266               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   2600  thrpt    2    39423.181               #/op
HttpStatusValueOfBenchmark.valueOf:instructions             2600  thrpt    2   141862.892               #/op

HttpStatusValueOfBenchmark.valueOf                          5300  thrpt   20       23.555 ± 0.215     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      5300  thrpt    2        0.459          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      5300  thrpt    2        2.177          insns/clk
HttpStatusValueOfBenchmark.valueOf:branch-misses            5300  thrpt    2     1686.810               #/op
HttpStatusValueOfBenchmark.valueOf:branches                 5300  thrpt    2    58947.304               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   5300  thrpt    2   132482.394               #/op
HttpStatusValueOfBenchmark.valueOf:instructions             5300  thrpt    2   288379.781               #/op

HttpStatusValueOfBenchmark.valueOf                         11000  thrpt   20        9.437 ± 0.311     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                     11000  thrpt    2        0.553          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                     11000  thrpt    2        1.807          insns/clk
HttpStatusValueOfBenchmark.valueOf:branch-misses           11000  thrpt    2     5412.350               #/op
HttpStatusValueOfBenchmark.valueOf:branches                11000  thrpt    2   123103.269               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                  11000  thrpt    2   330926.151               #/op
HttpStatusValueOfBenchmark.valueOf:instructions            11000  thrpt    2   597979.829               #/op

HttpStatusValueOfBenchmark.valueOf                         23000  thrpt   20        4.352 ± 0.018     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                     23000  thrpt    2        0.604          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                     23000  thrpt    2        1.655          insns/clk
HttpStatusValueOfBenchmark.valueOf:branch-misses           23000  thrpt    2    13947.359               #/op
HttpStatusValueOfBenchmark.valueOf:branches                23000  thrpt    2   257070.003               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                  23000  thrpt    2   716677.551               #/op
HttpStatusValueOfBenchmark.valueOf:instructions            23000  thrpt    2  1186074.755               #/op

Compare with base line, the throughput of 'switch-case' increase[+]/decrease[-]:

+22.60% (array size:1300)
+18.97% (array size:2600)
-0.69% (array size:5300)
+2.26% (array size:11000)
-6.50% (array size:23000)

'Array-index', with JDK-17:

Benchmark                                                 (size)   Mode  Cnt        Score   Error      Units
HttpStatusValueOfBenchmark.valueOf                          1300  thrpt   20      175.958 ± 0.999     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      1300  thrpt    2        0.235          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      1300  thrpt    2        4.262          insns/clk
HttpStatusValueOfBenchmark.valueOf:branch-misses            1300  thrpt    2        2.057               #/op
HttpStatusValueOfBenchmark.valueOf:branches                 1300  thrpt    2    13069.050               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   1300  thrpt    2    17709.650               #/op
HttpStatusValueOfBenchmark.valueOf:instructions             1300  thrpt    2    75476.114               #/op

HttpStatusValueOfBenchmark.valueOf                          2600  thrpt   20       87.094 ± 3.085     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      2600  thrpt    2        0.237          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      2600  thrpt    2        4.214          insns/clk
HttpStatusValueOfBenchmark.valueOf:branch-misses            2600  thrpt    2        2.753               #/op
HttpStatusValueOfBenchmark.valueOf:branches                 2600  thrpt    2    26124.758               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   2600  thrpt    2    35788.424               #/op
HttpStatusValueOfBenchmark.valueOf:instructions             2600  thrpt    2   150823.850               #/op

HttpStatusValueOfBenchmark.valueOf                          5300  thrpt   20       43.040 ± 1.331     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      5300  thrpt    2        0.237          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      5300  thrpt    2        4.219          insns/clk
HttpStatusValueOfBenchmark.valueOf:branch-misses            5300  thrpt    2        9.164               #/op
HttpStatusValueOfBenchmark.valueOf:branches                 5300  thrpt    2    53139.396               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   5300  thrpt    2    72699.008               #/op
HttpStatusValueOfBenchmark.valueOf:instructions             5300  thrpt    2   306674.898               #/op

HttpStatusValueOfBenchmark.valueOf                         11000  thrpt   20       20.933 ± 0.393     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                     11000  thrpt    2        0.233          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                     11000  thrpt    2        4.288          insns/clk
HttpStatusValueOfBenchmark.valueOf:branch-misses           11000  thrpt    2       11.235               #/op
HttpStatusValueOfBenchmark.valueOf:branches                11000  thrpt    2   110627.409               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                  11000  thrpt    2   148914.901               #/op
HttpStatusValueOfBenchmark.valueOf:instructions            11000  thrpt    2   638481.799               #/op

HttpStatusValueOfBenchmark.valueOf                         23000  thrpt   20        9.981 ± 0.180     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                     23000  thrpt    2        0.234          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                     23000  thrpt    2        4.271          insns/clk
HttpStatusValueOfBenchmark.valueOf:branch-misses           23000  thrpt    2       43.469               #/op
HttpStatusValueOfBenchmark.valueOf:branches                23000  thrpt    2   231324.252               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                  23000  thrpt    2   313845.745               #/op
HttpStatusValueOfBenchmark.valueOf:instructions            23000  thrpt    2  1340556.559               #/op

Compare with base line, the throughput of 'array-index' increase[+]/decrease[-]:

+33.78% (array size:1300)
+29.84% (array size:2600)
+81.45% (array size:5300)
+126.84% (array size:11000)
+114.41% (array size:23000)

Secondly, on the same hardware, benchmark with JDK-8:

openjdk version "1.8.0_382"
OpenJDK Runtime Environment (build 1.8.0_382-8u382-ga-1~22.04.1-b05)
OpenJDK 64-Bit Server VM (build 25.382-b05, mixed mode)

Base line(if-else), with JDK-8:

Benchmark                                                 (size)   Mode  Cnt       Score   Error      Units
HttpStatusValueOfBenchmark.valueOf                          1300  thrpt   20     286.719 ± 2.993     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      1300  thrpt    2       0.374          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      1300  thrpt    2       2.675          insns/clk
HttpStatusValueOfBenchmark.valueOf:branch-misses            1300  thrpt    2       6.694               #/op
HttpStatusValueOfBenchmark.valueOf:branches                 1300  thrpt    2    7710.627               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   1300  thrpt    2   10829.147               #/op
HttpStatusValueOfBenchmark.valueOf:instructions             1300  thrpt    2   28963.902               #/op

HttpStatusValueOfBenchmark.valueOf                          2600  thrpt   20     142.640 ± 1.182     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      2600  thrpt    2       0.374          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      2600  thrpt    2       2.671          insns/clk
HttpStatusValueOfBenchmark.valueOf:branch-misses            2600  thrpt    2      18.954               #/op
HttpStatusValueOfBenchmark.valueOf:branches                 2600  thrpt    2   15481.766               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   2600  thrpt    2   21748.083               #/op
HttpStatusValueOfBenchmark.valueOf:instructions             2600  thrpt    2   58079.836               #/op

HttpStatusValueOfBenchmark.valueOf                          5300  thrpt   20      41.421 ± 2.828     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      5300  thrpt    2       0.628          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      5300  thrpt    2       1.601          insns/clk
HttpStatusValueOfBenchmark.valueOf:branch-misses            5300  thrpt    2    1441.204               #/op
HttpStatusValueOfBenchmark.valueOf:branches                 5300  thrpt    2   33452.641               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   5300  thrpt    2   75574.314               #/op
HttpStatusValueOfBenchmark.valueOf:instructions             5300  thrpt    2  120312.431               #/op

HttpStatusValueOfBenchmark.valueOf                         11000  thrpt   20      13.735 ± 0.211     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                     11000  thrpt    2       0.908          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                     11000  thrpt    2       1.101          insns/clk
HttpStatusValueOfBenchmark.valueOf:branch-misses           11000  thrpt    2    6172.375               #/op
HttpStatusValueOfBenchmark.valueOf:branches                11000  thrpt    2   69610.599               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                  11000  thrpt    2  227083.864               #/op
HttpStatusValueOfBenchmark.valueOf:instructions            11000  thrpt    2  250042.128               #/op

HttpStatusValueOfBenchmark.valueOf                         23000  thrpt   20       6.277 ± 0.230     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                     23000  thrpt    2       0.991          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                     23000  thrpt    2       1.009          insns/clk
HttpStatusValueOfBenchmark.valueOf:branch-misses           23000  thrpt    2   15502.596               #/op
HttpStatusValueOfBenchmark.valueOf:branches                23000  thrpt    2  140809.627               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                  23000  thrpt    2  500889.304               #/op
HttpStatusValueOfBenchmark.valueOf:instructions            23000  thrpt    2  505507.702               #/op

'Switch-case', with JDK-8:

Benchmark                                                 (size)   Mode  Cnt       Score   Error      Units
HttpStatusValueOfBenchmark.valueOf                          1300  thrpt   20     297.019 ± 2.689     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      1300  thrpt    2       0.308          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      1300  thrpt    2       3.242          insns/clk
HttpStatusValueOfBenchmark.valueOf:branch-misses            1300  thrpt    2       3.462               #/op
HttpStatusValueOfBenchmark.valueOf:branches                 1300  thrpt    2    6472.441               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   1300  thrpt    2   10457.223               #/op
HttpStatusValueOfBenchmark.valueOf:instructions             1300  thrpt    2   33907.208               #/op

HttpStatusValueOfBenchmark.valueOf                          2600  thrpt   20     148.223 ± 0.800     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      2600  thrpt    2       0.309          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      2600  thrpt    2       3.241          insns/clk
HttpStatusValueOfBenchmark.valueOf:branch-misses            2600  thrpt    2      10.710               #/op
HttpStatusValueOfBenchmark.valueOf:branches                 2600  thrpt    2   13022.574               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   2600  thrpt    2   21090.030               #/op
HttpStatusValueOfBenchmark.valueOf:instructions             2600  thrpt    2   68350.495               #/op

HttpStatusValueOfBenchmark.valueOf                          5300  thrpt   20      68.160 ± 1.059     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      5300  thrpt    2       0.329          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      5300  thrpt    2       3.041          insns/clk
HttpStatusValueOfBenchmark.valueOf:branch-misses            5300  thrpt    2     111.259               #/op
HttpStatusValueOfBenchmark.valueOf:branches                 5300  thrpt    2   26379.397               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   5300  thrpt    2   45515.479               #/op
HttpStatusValueOfBenchmark.valueOf:instructions             5300  thrpt    2  138381.712               #/op

HttpStatusValueOfBenchmark.valueOf                         11000  thrpt   20      14.447 ± 0.180     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                     11000  thrpt    2       0.748          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                     11000  thrpt    2       1.337          insns/clk
HttpStatusValueOfBenchmark.valueOf:branch-misses           11000  thrpt    2    4471.509               #/op
HttpStatusValueOfBenchmark.valueOf:branches                11000  thrpt    2   55153.787               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                  11000  thrpt    2  216430.368               #/op
HttpStatusValueOfBenchmark.valueOf:instructions            11000  thrpt    2  289333.114               #/op

HttpStatusValueOfBenchmark.valueOf                         23000  thrpt   20       5.679 ± 0.077     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                     23000  thrpt    2       0.985          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                     23000  thrpt    2       1.015          insns/clk
HttpStatusValueOfBenchmark.valueOf:branch-misses           23000  thrpt    2   14079.228               #/op
HttpStatusValueOfBenchmark.valueOf:branches                23000  thrpt    2  114742.570               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                  23000  thrpt    2  547560.912               #/op
HttpStatusValueOfBenchmark.valueOf:instructions            23000  thrpt    2  555620.202               #/op

Compare with base line, the throughput of 'switch-case' increase[+]/decrease[-]:

+3.59% (array size:1300)
+3.91% (array size:2600)
+64.55% (array size:5300)
+5.18% (array size:11000)
-9.52% (array size:23000)

'Array-index', with JDK-8:

Benchmark                                                 (size)   Mode  Cnt       Score   Error      Units
HttpStatusValueOfBenchmark.valueOf                          1300  thrpt   20     315.261 ± 2.114     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      1300  thrpt    2       0.246          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      1300  thrpt    2       4.070          insns/clk
HttpStatusValueOfBenchmark.valueOf:branch-misses            1300  thrpt    2       1.349               #/op
HttpStatusValueOfBenchmark.valueOf:branches                 1300  thrpt    2    3899.444               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   1300  thrpt    2    9797.913               #/op
HttpStatusValueOfBenchmark.valueOf:instructions             1300  thrpt    2   39874.539               #/op

HttpStatusValueOfBenchmark.valueOf                          2600  thrpt   20     156.217 ± 5.934     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      2600  thrpt    2       0.249          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      2600  thrpt    2       4.022          insns/clk
HttpStatusValueOfBenchmark.valueOf:branch-misses            2600  thrpt    2       2.425               #/op
HttpStatusValueOfBenchmark.valueOf:branches                 2600  thrpt    2    7809.014               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   2600  thrpt    2   19883.892               #/op
HttpStatusValueOfBenchmark.valueOf:instructions             2600  thrpt    2   79958.063               #/op

HttpStatusValueOfBenchmark.valueOf                          5300  thrpt   20      76.816 ± 2.532     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      5300  thrpt    2       0.248          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      5300  thrpt    2       4.029          insns/clk
HttpStatusValueOfBenchmark.valueOf:branch-misses            5300  thrpt    2       7.094               #/op
HttpStatusValueOfBenchmark.valueOf:branches                 5300  thrpt    2   16016.494               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   5300  thrpt    2   40675.435               #/op
HttpStatusValueOfBenchmark.valueOf:instructions             5300  thrpt    2  163887.242               #/op

HttpStatusValueOfBenchmark.valueOf                         11000  thrpt   20      37.055 ± 1.122     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                     11000  thrpt    2       0.248          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                     11000  thrpt    2       4.035          insns/clk
HttpStatusValueOfBenchmark.valueOf:branch-misses           11000  thrpt    2      10.367               #/op
HttpStatusValueOfBenchmark.valueOf:branches                11000  thrpt    2   33206.531               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                  11000  thrpt    2   84177.343               #/op
HttpStatusValueOfBenchmark.valueOf:instructions            11000  thrpt    2  339608.457               #/op

HttpStatusValueOfBenchmark.valueOf                         23000  thrpt   20      17.893 ± 0.043     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                     23000  thrpt    2       0.247          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                     23000  thrpt    2       4.054          insns/clk
HttpStatusValueOfBenchmark.valueOf:branch-misses           23000  thrpt    2      32.761               #/op
HttpStatusValueOfBenchmark.valueOf:branches                23000  thrpt    2   69715.362               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                  23000  thrpt    2  175346.247               #/op
HttpStatusValueOfBenchmark.valueOf:instructions            23000  thrpt    2  710780.901               #/op

Compare with base line, the throughput of 'array-index' increase[+]/decrease[-]:

+9.95% (array size:1300)
+9.51% (array size:2600)
+85.45% (array size:5300)
+169.78% (array size:11000)
+185.05% (array size:23000)

Summary of the benchmark results:

  1. Throughput:
JDK-17 Throughput(ops/ms) Throughput(ops/ms) Throughput(ops/ms)
size Base-line(if-else) Switch-case Array-index
1300 131.519 161.250 (+22.60% ) 175.958 (+33.78%)
2600 67.074 79.798 (+18.97%) 87.094 (+29.84%)
5300 23.719 23.555 (-0.69%) 43.040 (+81.45%)
11000 9.228 9.437 (+2.26%) 20.933 (+126.84%)
23000 4.655 4.352 (-6.50%) 9.981 (+114.41%)
JDK-8 Throughput(ops/ms) Throughput(ops/ms) Throughput(ops/ms)
size Base-line(if-else) Switch-case Array-index
1300 286.719 297.019 (+3.59%) 315.261 (+9.95%)
2600 142.640 148.223 (+3.91%) 156.217 (+9.51%)
5300 41.421 68.160 (+64.55%) 76.816 (+85.45%)
11000 13.735 14.447 (+5.18%) 37.055 (+169.78%)
23000 6.277 5.679 (-9.52%) 17.893 (+185.05%)
  1. Branch-misses:
JDK-17 Branch-misses(%) Branch-misses(%) Branch-misses(%)
size Base-line(if-else) Switch-case Array-index
1300 0.032% 0.039% 0.015%
2600 0.076% 0.104% 0.011%
5300 1.54% 2.86% 0.017%
11000 3.98% 4.39% 0.010%
23000 4.94% 5.42% 0.019%
JDK-8 Branch-misses(%) Branch-misses(%) Branch-misses(%)
size Base-line(if-else) Switch-case Array-index
1300 0.087% 0.053% 0.035%
2600 0.122% 0.082% 0.031%
5300 4.308% 0.421% 0.044%
11000 8.867% 8.107% 0.031%
23000 11.01% 12.27% 0.047%

Based on the current benchmark results. I think the 'array-index' optimization could gain more performance improvement, and is more worthy to use. WDYT? @chrisvest @franz1981

@franz1981
Copy link
Contributor

franz1981 commented Aug 25, 2023

Lovely analysis, is it clear now (and many thanks for the great job!) that, assuming a fair and sensible distribution of branches/if based on input data:

  • as the branch misses increases (due to more input data) the delta with array version grow, as expected (but is nice to see the correlation being that obvious)

I'm already happy re the state of this PR: the lookup table is pretty small too, so I won't be too concerned about the cache accesses, and sadly I'm not aware of mechanisms to verify the impact, but let me briefly explain it so maybe you'll find something, if you are curious.

Lookup table approaches often wins, in cases like these, where the outcome of the lookup can vary and is not very predictable, but at the same time, the numbers on a microbenchs often deal with an artificial state of the caches in the local core, which doesn't happen in the real world, where you can have already plenty of other data in it, due to the domain logic execution; unless the real code perform some tight encoding loop performing lookups (which would amortize the initial miss, if any).
It means that a micro bench hammering a specific lookup table, unless it contains other memory intensive fetches, won't likely evict the cache line which contains the table itself, making the cost of accessing it as fast as L1 loads (hits).

I have no idea how to simulate a different behaviour, actually, but collecting perfnorm numbers and check how the counters related cache accesses change across the different type of tests, is still informative (eg the switch one maybe got more icache hits/load/accesses while the lookup version will do it with the dcache, instead).

@nitsanw we spoken about this very quickly in the last call some time ago

@franz1981
Copy link
Contributor

franz1981 commented Aug 25, 2023

Just some additional notes @laosijikaichele

I've re read a nice article from @nitsanw to better comment (and apologize too):

  • the cumulative effects of the microbenchmarks lead to have few nanos/op cost, which means that the diff between the approaches, in the current written scenario, is rather small (despite the cumulative one point to a larger number!)
  • the input sequence could be computed by using some xor shift approaches, to avoid fetching from the array (fetching the array itself etc etc)
  • writing the result into the array is not awesome (because it has some cost, re storing and re card marking, likely): it would be better to use BlackHole::consume, although it could still have larger/dominant cost. It could be a nice idea to compute an overall result into some local variable, which will likely be a register eg if the result not null some 1 or 0 (which is highly predictable)
  • using a loop, although I initially wasn't super happy about it, could be a good move, given that's a nano bench and the JMH infra (which count ops) couldn't handle it lightweight enough, but at the same time, loop striping (which means adding intermediate safepoint poll) and loop unrolling can still play some role into the cost per op. By performing some educated guess inspecting the assembly we can see how many ins)tr each lookup perform in the different cases, and guess where the dominant cost would be (better than guessing, checking with -prof perf)

In short: right now the nano benchmark still have some "noisy" infra, but numbers suggest some effect which lead to think that one approach is better than the others: I'm still not sure the nano benchmark is noisy-free enough to capture the reality (and I have no idea if it can - a static analysis of assembly can produce probably a more valuable insight in that).

@laosijikaichele
Copy link
Contributor Author

@franz1981 Thanks a lot for the suggestions, I will do more adjustment and try to reduce the 'noise', will update this when have further progress.

@laosijikaichele
Copy link
Contributor Author

laosijikaichele commented Sep 4, 2023

@franz1981 , thanks for the suggestions, the benchmark code has been optimized to try to reduce 'noise':

  1. Replace the input array to custom circular link, which can avoid loop-unrolling. The input circular link is still needed, because we need to pre-generate codes based on the percentages.
  2. Use BlackHole.consume(result) instead of writing the result into array, which is more similar to the real world scenario: get the code type and use(consume) it.
  3. Annotate the setUp() method with Level.Invocation instead of Level.Iteration, to generate different input data per invocation, to avoid loop the same input sequence per invocation inside a Level.Iteration.
  4. Reuse the custom circular link objects(only change the CircularLink.value per setUp()), to avoid create too many link objects.
  5. Optimize the code generation logic, to make every code be generated based on a percentage ratio.

The test environments/params are still the same with previous, with the new optimized benchmark code, test it again:

Base line(if-else), with JDK-17:

Benchmark                                                 (size)   Mode  Cnt        Score   Error      Units
HttpStatusValueOfBenchmark.valueOf                          1300  thrpt   20       88.647 ± 4.712     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      1300  thrpt    2        1.301          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      1300  thrpt    2        0.773          insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses    1300  thrpt    2     6804.878               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads          1300  thrpt    2    79337.726               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores         1300  thrpt    2     4315.030               #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses    1300  thrpt    2       59.364               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses          1300  thrpt    2        8.748               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads                1300  thrpt    2      140.152               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses         1300  thrpt    2        0.962               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores               1300  thrpt    2        9.188               #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses            1300  thrpt    2    18270.264               #/op
HttpStatusValueOfBenchmark.valueOf:branches                 1300  thrpt    2   139085.415               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   1300  thrpt    2   556911.689               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses         1300  thrpt    2        5.855               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads               1300  thrpt    2    79692.716               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses        1300  thrpt    2        0.893               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores              1300  thrpt    2     4502.367               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses         1300  thrpt    2        1.153               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads               1300  thrpt    2        5.352               #/op
HttpStatusValueOfBenchmark.valueOf:instructions             1300  thrpt    2   428740.540               #/op

HttpStatusValueOfBenchmark.valueOf                          2600  thrpt   20       47.270 ± 0.227     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      2600  thrpt    2        1.165          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      2600  thrpt    2        0.858          insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses    2600  thrpt    2     8138.352               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads          2600  thrpt    2    91579.801               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores         2600  thrpt    2     8625.461               #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses    2600  thrpt    2       57.278               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses          2600  thrpt    2       12.324               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads                2600  thrpt    2      159.719               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses         2600  thrpt    2        0.644               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores               2600  thrpt    2       11.620               #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses            2600  thrpt    2    21051.281               #/op
HttpStatusValueOfBenchmark.valueOf:branches                 2600  thrpt    2   154193.883               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   2600  thrpt    2   630304.256               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses         2600  thrpt    2        6.433               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads               2600  thrpt    2    91287.725               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses        2600  thrpt    2        0.835               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores              2600  thrpt    2     8318.422               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses         2600  thrpt    2        1.440               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads               2600  thrpt    2        3.980               #/op
HttpStatusValueOfBenchmark.valueOf:instructions             2600  thrpt    2   541025.333               #/op

HttpStatusValueOfBenchmark.valueOf                          5300  thrpt   20       23.289 ± 0.179     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      5300  thrpt    2        1.102          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      5300  thrpt    2        0.907          insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses    5300  thrpt    2    10194.561               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads          5300  thrpt    2   115379.649               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores         5300  thrpt    2    16744.429               #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses    5300  thrpt    2       90.057               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses          5300  thrpt    2       12.774               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads                5300  thrpt    2      206.633               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses         5300  thrpt    2        0.749               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores               5300  thrpt    2       11.445               #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses            5300  thrpt    2    26871.064               #/op
HttpStatusValueOfBenchmark.valueOf:branches                 5300  thrpt    2   185153.067               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   5300  thrpt    2   832257.485               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses         5300  thrpt    2       10.758               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads               5300  thrpt    2   115081.405               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses        5300  thrpt    2        1.841               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores              5300  thrpt    2    16256.099               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses         5300  thrpt    2        3.880               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads               5300  thrpt    2        5.215               #/op
HttpStatusValueOfBenchmark.valueOf:instructions             5300  thrpt    2   755220.756               #/op

HttpStatusValueOfBenchmark.valueOf                         11000  thrpt   20       10.574 ± 0.536     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                     11000  thrpt    2        1.081          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                     11000  thrpt    2        0.927          insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses   11000  thrpt    2    14566.157               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads         11000  thrpt    2   168202.902               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores        11000  thrpt    2    34033.617               #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses   11000  thrpt    2      154.166               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses         11000  thrpt    2       25.551               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads               11000  thrpt    2      329.612               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses        11000  thrpt    2        0.244               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores              11000  thrpt    2       14.682               #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses           11000  thrpt    2    39413.710               #/op
HttpStatusValueOfBenchmark.valueOf:branches                11000  thrpt    2   252922.724               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                  11000  thrpt    2  1301121.601               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses        11000  thrpt    2       14.768               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads              11000  thrpt    2   167514.112               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses       11000  thrpt    2        2.912               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores             11000  thrpt    2    33528.474               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses        11000  thrpt    2        8.620               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads              11000  thrpt    2        9.012               #/op
HttpStatusValueOfBenchmark.valueOf:instructions            11000  thrpt    2  1203910.857               #/op

HttpStatusValueOfBenchmark.valueOf                         23000  thrpt   20        5.078 ± 0.268     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                     23000  thrpt    2        1.029          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                     23000  thrpt    2        0.973          insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses   23000  thrpt    2    23630.327               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads         23000  thrpt    2   276252.727               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores        23000  thrpt    2    70498.975               #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses   23000  thrpt    2      212.699               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses         23000  thrpt    2       34.426               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads               23000  thrpt    2      497.856               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses        23000  thrpt    2        2.224               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores              23000  thrpt    2       16.197               #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses           23000  thrpt    2    66233.487               #/op
HttpStatusValueOfBenchmark.valueOf:branches                23000  thrpt    2   392267.907               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                  23000  thrpt    2  2214285.096               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses        23000  thrpt    2       19.401               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads              23000  thrpt    2   276750.603               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses       23000  thrpt    2        5.516               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores             23000  thrpt    2    70270.573               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses        23000  thrpt    2       27.179               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads              23000  thrpt    2       14.888               #/op
HttpStatusValueOfBenchmark.valueOf:instructions            23000  thrpt    2  2152717.663               #/op

'Switch-case', with JDK-17:

Benchmark                                                 (size)   Mode  Cnt        Score   Error      Units
HttpStatusValueOfBenchmark.valueOf                          1300  thrpt   20       90.367 ± 1.140     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      1300  thrpt    2        1.291          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      1300  thrpt    2        0.776          insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses    1300  thrpt    2     6781.311               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads          1300  thrpt    2    77238.088               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores         1300  thrpt    2     4866.341               #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses    1300  thrpt    2       66.201               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses          1300  thrpt    2        6.831               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads                1300  thrpt    2      149.460               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses         1300  thrpt    2        0.234               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores               1300  thrpt    2        5.162               #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses            1300  thrpt    2    17452.406               #/op
HttpStatusValueOfBenchmark.valueOf:branches                 1300  thrpt    2    94990.661               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   1300  thrpt    2   583186.813               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses         1300  thrpt    2        4.395               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads               1300  thrpt    2    76370.488               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses        1300  thrpt    2        0.679               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores              1300  thrpt    2     4138.889               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses         1300  thrpt    2        1.189               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads               1300  thrpt    2        3.560               #/op
HttpStatusValueOfBenchmark.valueOf:instructions             1300  thrpt    2   451717.839               #/op

HttpStatusValueOfBenchmark.valueOf                          2600  thrpt   20       44.604 ± 0.308     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      2600  thrpt    2        1.272          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      2600  thrpt    2        0.786          insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses    2600  thrpt    2     8101.700               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads          2600  thrpt    2    88196.267               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores         2600  thrpt    2     8370.898               #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses    2600  thrpt    2       65.254               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses          2600  thrpt    2       13.076               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads                2600  thrpt    2      172.757               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses         2600  thrpt    2        1.397               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores               2600  thrpt    2       10.632               #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses            2600  thrpt    2    20594.901               #/op
HttpStatusValueOfBenchmark.valueOf:branches                 2600  thrpt    2   108595.538               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   2600  thrpt    2   711526.230               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses         2600  thrpt    2        8.382               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads               2600  thrpt    2    88763.068               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses        2600  thrpt    2        1.013               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores              2600  thrpt    2     8247.311               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses         2600  thrpt    2        2.945               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads               2600  thrpt    2        4.336               #/op
HttpStatusValueOfBenchmark.valueOf:instructions             2600  thrpt    2   559459.122               #/op

HttpStatusValueOfBenchmark.valueOf                          5300  thrpt   20       21.818 ± 0.104     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      5300  thrpt    2        1.189          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      5300  thrpt    2        0.841          insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses    5300  thrpt    2    10218.876               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads          5300  thrpt    2   113125.541               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores         5300  thrpt    2    16725.889               #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses    5300  thrpt    2       99.442               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses          5300  thrpt    2        9.002               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads                5300  thrpt    2      222.095               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses         5300  thrpt    2        0.451               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores               5300  thrpt    2       13.579               #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses            5300  thrpt    2    26427.131               #/op
HttpStatusValueOfBenchmark.valueOf:branches                 5300  thrpt    2   138526.171               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   5300  thrpt    2   936581.499               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses         5300  thrpt    2       12.870               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads               5300  thrpt    2   112142.730               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses        5300  thrpt    2        3.068               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores              5300  thrpt    2    16260.419               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses         5300  thrpt    2        4.858               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads               5300  thrpt    2        7.054               #/op
HttpStatusValueOfBenchmark.valueOf:instructions             5300  thrpt    2   787887.396               #/op

HttpStatusValueOfBenchmark.valueOf                         11000  thrpt   20       10.712 ± 0.194     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                     11000  thrpt    2        1.059          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                     11000  thrpt    2        0.945          insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses   11000  thrpt    2    14519.599               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads         11000  thrpt    2   164557.345               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores        11000  thrpt    2    33972.053               #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses   11000  thrpt    2      111.996               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses         11000  thrpt    2       26.066               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads               11000  thrpt    2      307.454               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses        11000  thrpt    2        0.607               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores              11000  thrpt    2       25.688               #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses           11000  thrpt    2    37440.670               #/op
HttpStatusValueOfBenchmark.valueOf:branches                11000  thrpt    2   201134.821               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                  11000  thrpt    2  1345514.795               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses        11000  thrpt    2       13.778               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads              11000  thrpt    2   163649.172               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses       11000  thrpt    2        2.869               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores             11000  thrpt    2    33380.714               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses        11000  thrpt    2        7.428               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads              11000  thrpt    2       10.737               #/op
HttpStatusValueOfBenchmark.valueOf:instructions            11000  thrpt    2  1270829.647               #/op

HttpStatusValueOfBenchmark.valueOf                         23000  thrpt   20        5.229 ± 0.006     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                     23000  thrpt    2        0.964          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                     23000  thrpt    2        1.037          insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses   23000  thrpt    2    23601.830               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads         23000  thrpt    2   273336.747               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores        23000  thrpt    2    70083.267               #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses   23000  thrpt    2      215.063               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses         23000  thrpt    2       39.904               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads               23000  thrpt    2      518.962               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses        23000  thrpt    2        2.258               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores              23000  thrpt    2       23.118               #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses           23000  thrpt    2    59120.783               #/op
HttpStatusValueOfBenchmark.valueOf:branches                23000  thrpt    2   332700.497               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                  23000  thrpt    2  2202942.403               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses        23000  thrpt    2       15.383               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads              23000  thrpt    2   273882.242               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses       23000  thrpt    2        4.138               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores             23000  thrpt    2    69879.462               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses        23000  thrpt    2        9.655               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads              23000  thrpt    2       13.523               #/op
HttpStatusValueOfBenchmark.valueOf:instructions            23000  thrpt    2  2285052.312               #/op

'Array-index', with JDK-17:

Benchmark                                                 (size)   Mode  Cnt        Score    Error      Units
HttpStatusValueOfBenchmark.valueOf                          1300  thrpt   20      351.810 ±  2.263     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      1300  thrpt    2        0.476           clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      1300  thrpt    2        2.100           insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses    1300  thrpt    2     6758.304                #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads          1300  thrpt    2    91390.090                #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores         1300  thrpt    2     4125.053                #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses    1300  thrpt    2       23.620                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses          1300  thrpt    2        4.753                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads                1300  thrpt    2      107.825                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses         1300  thrpt    2        0.166                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores               1300  thrpt    2        6.961                #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses            1300  thrpt    2     3650.040                #/op
HttpStatusValueOfBenchmark.valueOf:branches                 1300  thrpt    2    74689.042                #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   1300  thrpt    2   234083.612                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses         1300  thrpt    2        2.790                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads               1300  thrpt    2    90854.632                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses        1300  thrpt    2        0.284                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores              1300  thrpt    2     4027.251                #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses         1300  thrpt    2        1.993                #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads               1300  thrpt    2        0.747                #/op
HttpStatusValueOfBenchmark.valueOf:instructions             1300  thrpt    2   491485.144                #/op

HttpStatusValueOfBenchmark.valueOf                          2600  thrpt   20      172.320 ± 13.360     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      2600  thrpt    2        0.507           clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      2600  thrpt    2        1.972           insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses    2600  thrpt    2     8064.628                #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads          2600  thrpt    2   103865.037                #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores         2600  thrpt    2     8356.259                #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses    2600  thrpt    2       48.646                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses          2600  thrpt    2        5.305                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads                2600  thrpt    2      118.596                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses         2600  thrpt    2        0.344                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores               2600  thrpt    2        6.011                #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses            2600  thrpt    2     5052.070                #/op
HttpStatusValueOfBenchmark.valueOf:branches                 2600  thrpt    2    87062.175                #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   2600  thrpt    2   304198.504                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses         2600  thrpt    2        2.200                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads               2600  thrpt    2   103958.839                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses        2600  thrpt    2        0.363                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores              2600  thrpt    2     8003.511                #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses         2600  thrpt    2        2.531                #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads               2600  thrpt    2        2.754                #/op
HttpStatusValueOfBenchmark.valueOf:instructions             2600  thrpt    2   600009.363                #/op

HttpStatusValueOfBenchmark.valueOf                          5300  thrpt   20       86.100 ±  1.027     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      5300  thrpt    2        0.547           clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      5300  thrpt    2        1.829           insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses    5300  thrpt    2    10207.976                #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads          5300  thrpt    2   131354.375                #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores         5300  thrpt    2    16326.936                #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses    5300  thrpt    2       49.401                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses          5300  thrpt    2        7.129                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads                5300  thrpt    2      161.713                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses         5300  thrpt    2        0.590                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores               5300  thrpt    2        6.642                #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses            5300  thrpt    2     7978.894                #/op
HttpStatusValueOfBenchmark.valueOf:branches                 5300  thrpt    2   114037.761                #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   5300  thrpt    2   450042.400                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses         5300  thrpt    2        5.275                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads               5300  thrpt    2   130723.241                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses        5300  thrpt    2        0.688                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores              5300  thrpt    2    16388.802                #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses         5300  thrpt    2        2.795                #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads               5300  thrpt    2        5.158                #/op
HttpStatusValueOfBenchmark.valueOf:instructions             5300  thrpt    2   823320.509                #/op

HttpStatusValueOfBenchmark.valueOf                         11000  thrpt   20       39.900 ±  0.203     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                     11000  thrpt    2        0.585           clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                     11000  thrpt    2        1.709           insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses   11000  thrpt    2    14424.964                #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads         11000  thrpt    2   187849.835                #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores        11000  thrpt    2    33617.205                #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses   11000  thrpt    2       99.285                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses         11000  thrpt    2        9.399                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads               11000  thrpt    2      252.323                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses        11000  thrpt    2        1.118                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores              11000  thrpt    2       11.318                #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses           11000  thrpt    2    14124.109                #/op
HttpStatusValueOfBenchmark.valueOf:branches                11000  thrpt    2   169040.216                #/op
HttpStatusValueOfBenchmark.valueOf:cycles                  11000  thrpt    2   760532.817                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses        11000  thrpt    2        9.709                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads              11000  thrpt    2   186943.007                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses       11000  thrpt    2        2.131                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores             11000  thrpt    2    33211.940                #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses        11000  thrpt    2        2.994                #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads              11000  thrpt    2        4.288                #/op
HttpStatusValueOfBenchmark.valueOf:instructions            11000  thrpt    2  1299737.873                #/op

HttpStatusValueOfBenchmark.valueOf                         23000  thrpt   20       19.062 ±  0.070     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                     23000  thrpt    2        0.604           clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                     23000  thrpt    2        1.656           insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses   23000  thrpt    2    23531.924                #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads         23000  thrpt    2   308634.991                #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores        23000  thrpt    2    69955.565                #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses   23000  thrpt    2      150.987                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses         23000  thrpt    2       15.635                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads               23000  thrpt    2      408.822                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses        23000  thrpt    2        2.005                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores              23000  thrpt    2       20.015                #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses           23000  thrpt    2    26670.769                #/op
HttpStatusValueOfBenchmark.valueOf:branches                23000  thrpt    2   287131.523                #/op
HttpStatusValueOfBenchmark.valueOf:cycles                  23000  thrpt    2  1414287.395                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses        23000  thrpt    2       15.133                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads              23000  thrpt    2   309198.660                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses       23000  thrpt    2        3.735                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores             23000  thrpt    2    69828.042                #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses        23000  thrpt    2        8.342                #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads              23000  thrpt    2       11.027                #/op
HttpStatusValueOfBenchmark.valueOf:instructions            23000  thrpt    2  2342453.996                #/op

Base line(if-else), with JDK-8:

Benchmark                                                 (size)   Mode  Cnt        Score   Error      Units
HttpStatusValueOfBenchmark.valueOf                          1300  thrpt   20       55.473 ± 0.310     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      1300  thrpt    2        0.885          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      1300  thrpt    2        1.131          insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses    1300  thrpt    2     6847.236               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads          1300  thrpt    2   263737.685               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores         1300  thrpt    2   127042.389               #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses    1300  thrpt    2       62.178               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses          1300  thrpt    2        7.348               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads                1300  thrpt    2      117.378               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses         1300  thrpt    2        1.597               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores               1300  thrpt    2        9.722               #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses            1300  thrpt    2    17495.733               #/op
HttpStatusValueOfBenchmark.valueOf:branches                 1300  thrpt    2   190408.744               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   1300  thrpt    2   820954.456               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses         1300  thrpt    2       12.975               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads               1300  thrpt    2   263678.476               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses        1300  thrpt    2        2.645               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores              1300  thrpt    2   126767.180               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses         1300  thrpt    2        5.734               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads               1300  thrpt    2        8.253               #/op
HttpStatusValueOfBenchmark.valueOf:instructions             1300  thrpt    2   928403.633               #/op

HttpStatusValueOfBenchmark.valueOf                          2600  thrpt   20       27.922 ± 0.072     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      2600  thrpt    2        0.893          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      2600  thrpt    2        1.119          insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses    2600  thrpt    2     8130.721               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads          2600  thrpt    2   287963.546               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores         2600  thrpt    2   141189.312               #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses    2600  thrpt    2       67.347               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses          2600  thrpt    2        7.172               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads                2600  thrpt    2      144.674               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses         2600  thrpt    2        0.357               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores               2600  thrpt    2       12.510               #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses            2600  thrpt    2    20319.711               #/op
HttpStatusValueOfBenchmark.valueOf:branches                 2600  thrpt    2   209170.577               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   2600  thrpt    2   943433.972               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses         2600  thrpt    2       10.848               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads               2600  thrpt    2   289175.872               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses        2600  thrpt    2        3.052               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores              2600  thrpt    2   141327.475               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses         2600  thrpt    2        7.759               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads               2600  thrpt    2        8.096               #/op
HttpStatusValueOfBenchmark.valueOf:instructions             2600  thrpt    2  1055924.298               #/op

HttpStatusValueOfBenchmark.valueOf                          5300  thrpt   20       13.893 ± 0.090     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      5300  thrpt    2        0.863          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      5300  thrpt    2        1.159          insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses    5300  thrpt    2    10183.406               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads          5300  thrpt    2   340867.112               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores         5300  thrpt    2   170910.932               #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses    5300  thrpt    2       86.289               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses          5300  thrpt    2        5.560               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads                5300  thrpt    2      158.153               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses         5300  thrpt    2        0.523               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores               5300  thrpt    2       14.195               #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses            5300  thrpt    2    25463.157               #/op
HttpStatusValueOfBenchmark.valueOf:branches                 5300  thrpt    2   249798.014               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   5300  thrpt    2  1184111.539               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses         5300  thrpt    2       16.420               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads               5300  thrpt    2   341360.113               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses        5300  thrpt    2        2.461               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores              5300  thrpt    2   171227.310               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses         5300  thrpt    2        8.201               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads               5300  thrpt    2        8.529               #/op
HttpStatusValueOfBenchmark.valueOf:instructions             5300  thrpt    2  1372085.428               #/op

HttpStatusValueOfBenchmark.valueOf                         11000  thrpt   20        6.591 ± 0.054     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                     11000  thrpt    2        0.854          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                     11000  thrpt    2        1.171          insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses   11000  thrpt    2    14480.925               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads         11000  thrpt    2   450843.544               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores        11000  thrpt    2   234152.836               #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses   11000  thrpt    2       98.653               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses         11000  thrpt    2       12.214               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads               11000  thrpt    2      227.674               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses        11000  thrpt    2        0.888               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores              11000  thrpt    2       30.233               #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses           11000  thrpt    2    36960.585               #/op
HttpStatusValueOfBenchmark.valueOf:branches                11000  thrpt    2   333718.501               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                  11000  thrpt    2  1698805.807               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses        11000  thrpt    2       17.732               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads              11000  thrpt    2   450921.655               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses       11000  thrpt    2        3.689               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores             11000  thrpt    2   234148.503               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses        11000  thrpt    2       10.586               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads              11000  thrpt    2       14.120               #/op
HttpStatusValueOfBenchmark.valueOf:instructions            11000  thrpt    2  1988632.604               #/op

HttpStatusValueOfBenchmark.valueOf                         23000  thrpt   20        3.181 ± 0.009     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                     23000  thrpt    2        0.845          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                     23000  thrpt    2        1.183          insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses   23000  thrpt    2    23548.164               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads         23000  thrpt    2   684079.217               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores        23000  thrpt    2   366276.387               #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses   23000  thrpt    2      163.177               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses         23000  thrpt    2       23.000               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads               23000  thrpt    2      364.021               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses        23000  thrpt    2        0.639               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores              23000  thrpt    2       22.542               #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses           23000  thrpt    2    61385.921               #/op
HttpStatusValueOfBenchmark.valueOf:branches                23000  thrpt    2   511893.802               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                  23000  thrpt    2  2776280.741               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses        23000  thrpt    2       19.896               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads              23000  thrpt    2   682219.257               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses       23000  thrpt    2        4.703               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores             23000  thrpt    2   366090.442               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses        23000  thrpt    2       18.760               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads              23000  thrpt    2       23.364               #/op
HttpStatusValueOfBenchmark.valueOf:instructions            23000  thrpt    2  3285268.479               #/op

'Switch-case', with JDK-8:

Benchmark                                                 (size)   Mode  Cnt        Score   Error      Units
HttpStatusValueOfBenchmark.valueOf                          1300  thrpt   20       54.296 ± 0.171     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      1300  thrpt    2        1.178          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      1300  thrpt    2        0.849          insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses    1300  thrpt    2     6870.258               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads          1300  thrpt    2   199256.171               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores         1300  thrpt    2   125758.386               #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses    1300  thrpt    2       91.079               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses          1300  thrpt    2       13.223               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads                1300  thrpt    2      171.542               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses         1300  thrpt    2        0.323               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores               1300  thrpt    2       11.409               #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses            1300  thrpt    2    19145.028               #/op
HttpStatusValueOfBenchmark.valueOf:branches                 1300  thrpt    2   146554.036               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   1300  thrpt    2   960582.802               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses         1300  thrpt    2       13.878               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads               1300  thrpt    2   198440.576               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses        1300  thrpt    2        2.163               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores              1300  thrpt    2   125094.015               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses         1300  thrpt    2        7.479               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads               1300  thrpt    2        7.649               #/op
HttpStatusValueOfBenchmark.valueOf:instructions             1300  thrpt    2   815596.561               #/op

HttpStatusValueOfBenchmark.valueOf                          2600  thrpt   20       27.533 ± 0.052     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      2600  thrpt    2        1.124          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      2600  thrpt    2        0.890          insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses    2600  thrpt    2     8155.178               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads          2600  thrpt    2   221647.323               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores         2600  thrpt    2   138528.767               #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses    2600  thrpt    2      104.596               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses          2600  thrpt    2       12.179               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads                2600  thrpt    2      176.919               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses         2600  thrpt    2        0.197               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores               2600  thrpt    2       17.734               #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses            2600  thrpt    2    21251.567               #/op
HttpStatusValueOfBenchmark.valueOf:branches                 2600  thrpt    2   164739.041               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   2600  thrpt    2  1074212.828               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses         2600  thrpt    2       12.904               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads               2600  thrpt    2   221399.936               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses        2600  thrpt    2        2.242               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores              2600  thrpt    2   138952.741               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses         2600  thrpt    2        9.982               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads               2600  thrpt    2        7.682               #/op
HttpStatusValueOfBenchmark.valueOf:instructions             2600  thrpt    2   955615.504               #/op

HttpStatusValueOfBenchmark.valueOf                          5300  thrpt   20       13.567 ± 0.051     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      5300  thrpt    2        1.074          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      5300  thrpt    2        0.931          insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses    5300  thrpt    2    10209.250               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads          5300  thrpt    2   266778.838               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores         5300  thrpt    2   165507.274               #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses    5300  thrpt    2       84.737               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses          5300  thrpt    2        8.308               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads                5300  thrpt    2      187.715               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses         5300  thrpt    2        1.097               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores               5300  thrpt    2       13.588               #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses            5300  thrpt    2    26438.190               #/op
HttpStatusValueOfBenchmark.valueOf:branches                 5300  thrpt    2   201848.771               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   5300  thrpt    2  1333970.832               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses         5300  thrpt    2       15.841               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads               5300  thrpt    2   268061.549               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses        5300  thrpt    2        2.347               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores              5300  thrpt    2   165975.040               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses         5300  thrpt    2        9.552               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads               5300  thrpt    2        8.434               #/op
HttpStatusValueOfBenchmark.valueOf:instructions             5300  thrpt    2  1241931.656               #/op

HttpStatusValueOfBenchmark.valueOf                         11000  thrpt   20        6.524 ± 0.045     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                     11000  thrpt    2        1.003          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                     11000  thrpt    2        0.997          insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses   11000  thrpt    2    14527.794               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads         11000  thrpt    2   365549.985               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores        11000  thrpt    2   223376.894               #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses   11000  thrpt    2      167.054               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses         11000  thrpt    2       18.855               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads               11000  thrpt    2      292.128               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses        11000  thrpt    2        2.287               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores              11000  thrpt    2       28.619               #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses           11000  thrpt    2    36691.931               #/op
HttpStatusValueOfBenchmark.valueOf:branches                11000  thrpt    2   281190.972               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                  11000  thrpt    2  1858718.735               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses        11000  thrpt    2       23.830               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads              11000  thrpt    2   365623.345               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses       11000  thrpt    2        2.823               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores             11000  thrpt    2   223141.589               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses        11000  thrpt    2        9.709               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads              11000  thrpt    2       12.365               #/op
HttpStatusValueOfBenchmark.valueOf:instructions            11000  thrpt    2  1852682.347               #/op

HttpStatusValueOfBenchmark.valueOf                         23000  thrpt   20        3.132 ± 0.004     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                     23000  thrpt    2        0.941          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                     23000  thrpt    2        1.063          insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses   23000  thrpt    2    23601.306               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads         23000  thrpt    2   570259.066               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores        23000  thrpt    2   344144.828               #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses   23000  thrpt    2      224.514               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses         23000  thrpt    2       25.781               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads               23000  thrpt    2      408.898               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses        23000  thrpt    2        0.541               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores              23000  thrpt    2       24.835               #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses           23000  thrpt    2    57647.534               #/op
HttpStatusValueOfBenchmark.valueOf:branches                23000  thrpt    2   446708.951               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                  23000  thrpt    2  2938963.193               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses        23000  thrpt    2       30.947               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads              23000  thrpt    2   569661.417               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses       23000  thrpt    2        5.154               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores             23000  thrpt    2   343251.747               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses        23000  thrpt    2       18.905               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads              23000  thrpt    2       20.630               #/op
HttpStatusValueOfBenchmark.valueOf:instructions            23000  thrpt    2  3123979.225               #/op

'Array-index', with JDK-8:

Benchmark                                                 (size)   Mode  Cnt        Score   Error      Units
HttpStatusValueOfBenchmark.valueOf                          1300  thrpt   20      155.716 ± 1.297     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      1300  thrpt    2        0.462          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      1300  thrpt    2        2.164          insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses    1300  thrpt    2     6673.341               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads          1300  thrpt    2   178650.023               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores         1300  thrpt    2   126834.080               #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses    1300  thrpt    2       19.336               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses          1300  thrpt    2        3.090               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads                1300  thrpt    2       61.814               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses         1300  thrpt    2        1.050               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores               1300  thrpt    2       10.515               #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses            1300  thrpt    2     3985.833               #/op
HttpStatusValueOfBenchmark.valueOf:branches                 1300  thrpt    2   125948.521               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   1300  thrpt    2   374535.333               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses         1300  thrpt    2        4.470               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads               1300  thrpt    2   178016.648               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses        1300  thrpt    2        0.541               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores              1300  thrpt    2   126632.079               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses         1300  thrpt    2        1.598               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads               1300  thrpt    2        4.123               #/op
HttpStatusValueOfBenchmark.valueOf:instructions             1300  thrpt    2   810604.803               #/op

HttpStatusValueOfBenchmark.valueOf                          2600  thrpt   20       78.775 ± 0.365     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      2600  thrpt    2        0.479          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      2600  thrpt    2        2.090          insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses    2600  thrpt    2     8077.424               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads          2600  thrpt    2   200418.304               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores         2600  thrpt    2   141436.050               #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses    2600  thrpt    2       29.354               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses          2600  thrpt    2        2.985               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads                2600  thrpt    2       78.442               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses         2600  thrpt    2        0.678               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores               2600  thrpt    2        7.737               #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses            2600  thrpt    2     5437.120               #/op
HttpStatusValueOfBenchmark.valueOf:branches                 2600  thrpt    2   143581.112               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   2600  thrpt    2   459592.906               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses         2600  thrpt    2        5.355               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads               2600  thrpt    2   199479.178               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses        2600  thrpt    2        0.867               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores              2600  thrpt    2   141117.616               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses         2600  thrpt    2        2.133               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads               2600  thrpt    2        4.188               #/op
HttpStatusValueOfBenchmark.valueOf:instructions             2600  thrpt    2   960420.285               #/op

HttpStatusValueOfBenchmark.valueOf                          5300  thrpt   20       38.559 ± 0.159     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      5300  thrpt    2        0.503          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      5300  thrpt    2        1.986          insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses    5300  thrpt    2    10118.254               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads          5300  thrpt    2   242701.935               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores         5300  thrpt    2   170987.108               #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses    5300  thrpt    2       43.269               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses          5300  thrpt    2        3.042               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads                5300  thrpt    2      105.413               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses         5300  thrpt    2        0.617               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores               5300  thrpt    2        8.202               #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses            5300  thrpt    2     8237.542               #/op
HttpStatusValueOfBenchmark.valueOf:branches                 5300  thrpt    2   177477.236               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   5300  thrpt    2   632339.629               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses         5300  thrpt    2        7.476               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads               5300  thrpt    2   243764.633               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses        5300  thrpt    2        1.040               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores              5300  thrpt    2   171552.115               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses         5300  thrpt    2        2.508               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads               5300  thrpt    2        5.483               #/op
HttpStatusValueOfBenchmark.valueOf:instructions             5300  thrpt    2  1256099.605               #/op

HttpStatusValueOfBenchmark.valueOf                         11000  thrpt   20       18.647 ± 0.091     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                     11000  thrpt    2        0.529          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                     11000  thrpt    2        1.889          insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses   11000  thrpt    2    14468.394               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads         11000  thrpt    2   334419.656               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores        11000  thrpt    2   234093.940               #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses   11000  thrpt    2       64.423               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses         11000  thrpt    2        8.258               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads               11000  thrpt    2      178.880               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses        11000  thrpt    2        0.400               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores              11000  thrpt    2       20.162               #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses           11000  thrpt    2    14183.461               #/op
HttpStatusValueOfBenchmark.valueOf:branches                11000  thrpt    2   250789.685               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                  11000  thrpt    2   989115.773               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses        11000  thrpt    2       16.436               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads              11000  thrpt    2   333931.838               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses       11000  thrpt    2        2.472               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores             11000  thrpt    2   233655.480               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses        11000  thrpt    2        4.709               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads              11000  thrpt    2        6.385               #/op
HttpStatusValueOfBenchmark.valueOf:instructions            11000  thrpt    2  1868924.005               #/op

HttpStatusValueOfBenchmark.valueOf                         23000  thrpt   20        8.904 ± 0.152     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                     23000  thrpt    2        0.549          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                     23000  thrpt    2        1.822          insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses   23000  thrpt    2    23546.590               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads         23000  thrpt    2   527145.999               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores        23000  thrpt    2   366820.911               #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses   23000  thrpt    2      115.482               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses         23000  thrpt    2       12.813               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads               23000  thrpt    2      268.680               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses        23000  thrpt    2        0.943               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores              23000  thrpt    2       23.522               #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses           23000  thrpt    2    26613.750               #/op
HttpStatusValueOfBenchmark.valueOf:branches                23000  thrpt    2   404116.536               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                  23000  thrpt    2  1734496.096               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses        23000  thrpt    2       22.455               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads              23000  thrpt    2   524816.209               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses       23000  thrpt    2        4.489               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores             23000  thrpt    2   365244.906               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses        23000  thrpt    2       12.598               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads              23000  thrpt    2       12.737               #/op
HttpStatusValueOfBenchmark.valueOf:instructions            23000  thrpt    2  3160634.201               #/op

In summary on chart, the X-axis is 'input link size', the Y-axis is 'throughput':

JDK-17

JDK-8

According to the results, the 'array-index' optimization still gain the most improvement.
The 'switch-case' results is similar to the baseline(if-else).

@franz1981 , WDYT?

Copy link
Contributor

@chrisvest chrisvest left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work, @laosijikaichele.

And interesting find that the array version is that much faster than the alternatives.

@normanmaurer
Copy link
Member

This is all really interesting stuff..Thanks for all the work and education.

@@ -0,0 +1,215 @@
/*
* Copyright 2019 The Netty Project
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2023

CircularLink cl = polluteDistributeHead;
do {
bh.consume(HttpStatusClass.valueOf(cl.value));
} while ((cl = cl.next) != polluteDistributeHead);
Copy link
Contributor

@franz1981 franz1981 Sep 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you have used the CircularList linked-list?
It is even more dangerous than using arrays of inputs: thes nodes will likely be more scattered on the heap (or causing trouble to the GC to compact them) and (very important) introduce a data deps which prevent prefetching of next input data (in short, the CPU cannot speculate the next data(s) to be read.
Said that, I am already happy with the current status of the code...so we can move this on

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@franz1981 , the reason we used the 'CircularList' is to try avoiding the 'loop unrolling' you mentioned. I will change the input from 'CircularList' to normal int arrays and test it again, then compare the results. I will add the new results soon.

@laosijikaichele
Copy link
Contributor Author

laosijikaichele commented Sep 7, 2023

As @franz1981 concerned about the impact of using the 'CircularList' as inputs, I changed the inputs to normal int arrays(commit), and the input arrays are also being re-used on each invocation to avoid GC.
The new test results:

Base line(if-else), with JDK-17:

Benchmark                                                 (size)   Mode  Cnt        Score   Error      Units
HttpStatusValueOfBenchmark.valueOf                          1300  thrpt   20       88.061 ± 2.852     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      1300  thrpt    2        1.400          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      1300  thrpt    2        0.715          insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses    1300  thrpt    2     1258.240               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads          1300  thrpt    2    27249.387               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores         1300  thrpt    2     4524.629               #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses    1300  thrpt    2       43.237               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses          1300  thrpt    2        3.980               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads                1300  thrpt    2       20.147               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses         1300  thrpt    2        0.378               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores               1300  thrpt    2        3.240               #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses            1300  thrpt    2    18306.968               #/op
HttpStatusValueOfBenchmark.valueOf:branches                 1300  thrpt    2   140072.760               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   1300  thrpt    2   545127.573               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses         1300  thrpt    2        4.055               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads               1300  thrpt    2    25966.510               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses        1300  thrpt    2        0.617               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores              1300  thrpt    2     4282.249               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses         1300  thrpt    2        3.058               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads               1300  thrpt    2        4.761               #/op
HttpStatusValueOfBenchmark.valueOf:instructions             1300  thrpt    2   389477.979               #/op

HttpStatusValueOfBenchmark.valueOf                          2600  thrpt   20       45.569 ± 0.275     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      2600  thrpt    2        1.257          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      2600  thrpt    2        0.796          insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses    2600  thrpt    2     1306.285               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads          2600  thrpt    2    33128.420               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores         2600  thrpt    2     8418.118               #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses    2600  thrpt    2       68.437               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses          2600  thrpt    2       13.789               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads                2600  thrpt    2       39.680               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses         2600  thrpt    2        0.274               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores               2600  thrpt    2        4.129               #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses            2600  thrpt    2    21204.863               #/op
HttpStatusValueOfBenchmark.valueOf:branches                 2600  thrpt    2   156675.286               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   2600  thrpt    2   618559.084               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses         2600  thrpt    2        3.826               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads               2600  thrpt    2    32482.905               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses        2600  thrpt    2        0.599               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores              2600  thrpt    2     8030.218               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses         2600  thrpt    2        1.262               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads               2600  thrpt    2        2.750               #/op
HttpStatusValueOfBenchmark.valueOf:instructions             2600  thrpt    2   492183.047               #/op

HttpStatusValueOfBenchmark.valueOf                          5300  thrpt   20       20.988 ± 0.040     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      5300  thrpt    2        1.208          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      5300  thrpt    2        0.828          insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses    5300  thrpt    2     1552.678               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads          5300  thrpt    2    47218.008               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores         5300  thrpt    2    16778.963               #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses    5300  thrpt    2       90.715               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses          5300  thrpt    2        9.355               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads                5300  thrpt    2       50.842               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses         5300  thrpt    2        1.501               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores               5300  thrpt    2       12.170               #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses            5300  thrpt    2    27215.467               #/op
HttpStatusValueOfBenchmark.valueOf:branches                 5300  thrpt    2   191204.616               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   5300  thrpt    2   858476.990               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses         5300  thrpt    2        8.819               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads               5300  thrpt    2    47112.784               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses        5300  thrpt    2        1.764               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores              5300  thrpt    2    16331.096               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses         5300  thrpt    2        4.045               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads               5300  thrpt    2        5.451               #/op
HttpStatusValueOfBenchmark.valueOf:instructions             5300  thrpt    2   710496.494               #/op

HttpStatusValueOfBenchmark.valueOf                         11000  thrpt   20       10.566 ± 0.332     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                     11000  thrpt    2        1.071          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                     11000  thrpt    2        0.934          insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses   11000  thrpt    2     2609.221               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads         11000  thrpt    2    76327.081               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores        11000  thrpt    2    33605.187               #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses   11000  thrpt    2      105.793               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses         11000  thrpt    2       15.215               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads               11000  thrpt    2       61.351               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses        11000  thrpt    2        1.166               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores              11000  thrpt    2       13.566               #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses           11000  thrpt    2    39383.180               #/op
HttpStatusValueOfBenchmark.valueOf:branches                11000  thrpt    2   262408.593               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                  11000  thrpt    2  1245730.630               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses        11000  thrpt    2       10.762               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads              11000  thrpt    2    76995.450               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses       11000  thrpt    2        2.177               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores             11000  thrpt    2    33589.150               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses        11000  thrpt    2        9.840               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads              11000  thrpt    2       10.028               #/op
HttpStatusValueOfBenchmark.valueOf:instructions            11000  thrpt    2  1163529.640               #/op

HttpStatusValueOfBenchmark.valueOf                         23000  thrpt   20        5.047 ± 0.178     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                     23000  thrpt    2        0.996          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                     23000  thrpt    2        1.005          insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses   23000  thrpt    2     4266.004               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads         23000  thrpt    2   139945.051               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores        23000  thrpt    2    70396.613               #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses   23000  thrpt    2      129.772               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses         23000  thrpt    2       13.535               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads               23000  thrpt    2       92.453               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses        23000  thrpt    2        2.301               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores              23000  thrpt    2       29.405               #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses           23000  thrpt    2    65615.006               #/op
HttpStatusValueOfBenchmark.valueOf:branches                23000  thrpt    2   414836.935               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                  23000  thrpt    2  2116323.070               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses        23000  thrpt    2       20.488               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads              23000  thrpt    2   141426.754               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses       23000  thrpt    2        3.179               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores             23000  thrpt    2    71335.932               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses        23000  thrpt    2       21.708               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads              23000  thrpt    2       15.379               #/op
HttpStatusValueOfBenchmark.valueOf:instructions            23000  thrpt    2  2125321.815               #/op

'Switch-case', with JDK-17:

Benchmark                                                 (size)   Mode  Cnt        Score   Error      Units
HttpStatusValueOfBenchmark.valueOf                          1300  thrpt   20       96.000 ± 2.987     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      1300  thrpt    2        1.400          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      1300  thrpt    2        0.717          insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses    1300  thrpt    2     1213.319               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads          1300  thrpt    2    23746.924               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores         1300  thrpt    2     4390.785               #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses    1300  thrpt    2       56.852               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses          1300  thrpt    2        8.193               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads                1300  thrpt    2       37.271               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses         1300  thrpt    2        0.925               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores               1300  thrpt    2        5.546               #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses            1300  thrpt    2    19279.161               #/op
HttpStatusValueOfBenchmark.valueOf:branches                 1300  thrpt    2    96440.005               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   1300  thrpt    2   578478.957               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses         1300  thrpt    2        3.484               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads               1300  thrpt    2    23614.998               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses        1300  thrpt    2        0.691               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores              1300  thrpt    2     4321.377               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses         1300  thrpt    2        2.626               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads               1300  thrpt    2        3.047               #/op
HttpStatusValueOfBenchmark.valueOf:instructions             1300  thrpt    2   413714.748               #/op

HttpStatusValueOfBenchmark.valueOf                          2600  thrpt   20       48.438 ± 1.758     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      2600  thrpt    2        1.295          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      2600  thrpt    2        0.774          insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses    2600  thrpt    2     1305.184               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads          2600  thrpt    2    29658.077               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores         2600  thrpt    2     8575.957               #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses    2600  thrpt    2       64.246               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses          2600  thrpt    2       10.596               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads                2600  thrpt    2       51.063               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses         2600  thrpt    2        0.935               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores               2600  thrpt    2       12.688               #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses            2600  thrpt    2    22031.453               #/op
HttpStatusValueOfBenchmark.valueOf:branches                 2600  thrpt    2   111329.397               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   2600  thrpt    2   674161.977               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses         2600  thrpt    2        5.738               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads               2600  thrpt    2    29782.757               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses        2600  thrpt    2        1.072               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores              2600  thrpt    2     8211.938               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses         2600  thrpt    2        3.313               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads               2600  thrpt    2        3.456               #/op
HttpStatusValueOfBenchmark.valueOf:instructions             2600  thrpt    2   520935.317               #/op

HttpStatusValueOfBenchmark.valueOf                          5300  thrpt   20       22.863 ± 0.057     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      5300  thrpt    2        1.211          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      5300  thrpt    2        0.826          insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses    5300  thrpt    2     1543.938               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads          5300  thrpt    2    44220.826               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores         5300  thrpt    2    16535.545               #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses    5300  thrpt    2       85.276               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses          5300  thrpt    2        6.618               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads                5300  thrpt    2       37.867               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses         5300  thrpt    2        1.126               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores               5300  thrpt    2       11.040               #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses            5300  thrpt    2    27359.333               #/op
HttpStatusValueOfBenchmark.valueOf:branches                 5300  thrpt    2   144282.300               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   5300  thrpt    2   900673.202               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses         5300  thrpt    2        6.883               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads               5300  thrpt    2    43926.442               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses        5300  thrpt    2        1.239               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores              5300  thrpt    2    16510.590               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses         5300  thrpt    2        4.485               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads               5300  thrpt    2        5.456               #/op
HttpStatusValueOfBenchmark.valueOf:instructions             5300  thrpt    2   743626.643               #/op

HttpStatusValueOfBenchmark.valueOf                         11000  thrpt   20       11.461 ± 0.356     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                     11000  thrpt    2        1.025          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                     11000  thrpt    2        0.977          insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses   11000  thrpt    2     2603.763               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads         11000  thrpt    2    72442.197               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores        11000  thrpt    2    33517.947               #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses   11000  thrpt    2       86.674               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses         11000  thrpt    2        9.013               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads               11000  thrpt    2       46.014               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses        11000  thrpt    2        1.636               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores              11000  thrpt    2       15.034               #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses           11000  thrpt    2    37606.087               #/op
HttpStatusValueOfBenchmark.valueOf:branches                11000  thrpt    2   211738.313               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                  11000  thrpt    2  1263242.610               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses        11000  thrpt    2        9.470               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads              11000  thrpt    2    73431.345               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses       11000  thrpt    2        3.561               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores             11000  thrpt    2    33823.850               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses        11000  thrpt    2       10.236               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads              11000  thrpt    2       10.173               #/op
HttpStatusValueOfBenchmark.valueOf:instructions            11000  thrpt    2  1233460.676               #/op

HttpStatusValueOfBenchmark.valueOf                         23000  thrpt   20        5.292 ± 0.014     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                     23000  thrpt    2        0.960          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                     23000  thrpt    2        1.042          insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses   23000  thrpt    2     4236.314               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads         23000  thrpt    2   133105.042               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores        23000  thrpt    2    70666.498               #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses   23000  thrpt    2      197.259               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses         23000  thrpt    2       22.955               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads               23000  thrpt    2      125.611               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses        23000  thrpt    2        0.866               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores              23000  thrpt    2       19.617               #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses           23000  thrpt    2    59112.158               #/op
HttpStatusValueOfBenchmark.valueOf:branches                23000  thrpt    2   355464.914               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                  23000  thrpt    2  2144275.179               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses        23000  thrpt    2       16.781               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads              23000  thrpt    2   132574.017               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses       23000  thrpt    2        3.471               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores             23000  thrpt    2    70071.703               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses        23000  thrpt    2       13.680               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads              23000  thrpt    2       23.134               #/op
HttpStatusValueOfBenchmark.valueOf:instructions            23000  thrpt    2  2234280.744               #/op

'Array-index', with JDK-17:

Benchmark                                                 (size)   Mode  Cnt        Score    Error      Units
HttpStatusValueOfBenchmark.valueOf                          1300  thrpt   20      369.531 ± 20.506     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      1300  thrpt    2        0.449           clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      1300  thrpt    2        2.228           insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses    1300  thrpt    2     1141.824                #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads          1300  thrpt    2    37612.776                #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores         1300  thrpt    2     4152.717                #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses    1300  thrpt    2       31.475                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses          1300  thrpt    2        3.698                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads                1300  thrpt    2       13.699                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses         1300  thrpt    2        0.440                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores               1300  thrpt    2        2.323                #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses            1300  thrpt    2     3344.661                #/op
HttpStatusValueOfBenchmark.valueOf:branches                 1300  thrpt    2    67173.782                #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   1300  thrpt    2   216840.673                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses         1300  thrpt    2        2.957                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads               1300  thrpt    2    37427.450                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses        1300  thrpt    2        0.268                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores              1300  thrpt    2     4050.876                #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses         1300  thrpt    2        0.913                #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads               1300  thrpt    2        0.621                #/op
HttpStatusValueOfBenchmark.valueOf:instructions             1300  thrpt    2   482667.677                #/op

HttpStatusValueOfBenchmark.valueOf                          2600  thrpt   20      179.607 ±  3.744     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      2600  thrpt    2        0.472           clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      2600  thrpt    2        2.120           insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses    2600  thrpt    2     1218.981                #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads          2600  thrpt    2    45319.895                #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores         2600  thrpt    2     8029.340                #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses    2600  thrpt    2       34.397                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses          2600  thrpt    2        5.031                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads                2600  thrpt    2       17.244                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses         2600  thrpt    2        0.221                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores               2600  thrpt    2        1.542                #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses            2600  thrpt    2     4721.882                #/op
HttpStatusValueOfBenchmark.valueOf:branches                 2600  thrpt    2    80253.349                #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   2600  thrpt    2   279536.052                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses         2600  thrpt    2        2.822                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads               2600  thrpt    2    45101.291                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses        2600  thrpt    2        0.311                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores              2600  thrpt    2     7984.823                #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses         2600  thrpt    2        0.979                #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads               2600  thrpt    2        2.544                #/op
HttpStatusValueOfBenchmark.valueOf:instructions             2600  thrpt    2   592489.271                #/op

HttpStatusValueOfBenchmark.valueOf                          5300  thrpt   20       96.029 ±  5.017     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      5300  thrpt    2        0.494           clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      5300  thrpt    2        2.025           insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses    5300  thrpt    2     1436.204                #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads          5300  thrpt    2    62687.304                #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores         5300  thrpt    2    17167.298                #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses    5300  thrpt    2       35.607                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses          5300  thrpt    2        5.122                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads                5300  thrpt    2       25.536                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses         5300  thrpt    2        1.246                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores               5300  thrpt    2        6.056                #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses            5300  thrpt    2     7593.793                #/op
HttpStatusValueOfBenchmark.valueOf:branches                 5300  thrpt    2   108677.999                #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   5300  thrpt    2   406616.185                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses         5300  thrpt    2        5.755                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads               5300  thrpt    2    62925.440                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses        5300  thrpt    2        0.628                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores              5300  thrpt    2    17137.966                #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses         5300  thrpt    2        1.958                #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads               5300  thrpt    2        2.978                #/op
HttpStatusValueOfBenchmark.valueOf:instructions             5300  thrpt    2   823556.900                #/op

HttpStatusValueOfBenchmark.valueOf                         11000  thrpt   20       50.361 ±  0.252     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                     11000  thrpt    2        0.532           clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                     11000  thrpt    2        1.881           insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses   11000  thrpt    2     2551.228                #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads         11000  thrpt    2    96498.776                #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores        11000  thrpt    2    33913.871                #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses   11000  thrpt    2       56.245                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses         11000  thrpt    2        9.867                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads               11000  thrpt    2       27.524                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses        11000  thrpt    2        0.688                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores              11000  thrpt    2        8.881                #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses           11000  thrpt    2    14073.930                #/op
HttpStatusValueOfBenchmark.valueOf:branches                11000  thrpt    2   167644.997                #/op
HttpStatusValueOfBenchmark.valueOf:cycles                  11000  thrpt    2   687166.800                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses        11000  thrpt    2        3.912                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads              11000  thrpt    2    96313.055                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses       11000  thrpt    2        0.656                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores             11000  thrpt    2    33562.219                #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses        11000  thrpt    2        3.304                #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads              11000  thrpt    2        4.565                #/op
HttpStatusValueOfBenchmark.valueOf:instructions            11000  thrpt    2  1292786.134                #/op

HttpStatusValueOfBenchmark.valueOf                         23000  thrpt   20       24.068 ±  0.067     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                     23000  thrpt    2        0.548           clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                     23000  thrpt    2        1.825           insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses   23000  thrpt    2     4135.228                #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads         23000  thrpt    2   169270.972                #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores        23000  thrpt    2    69791.358                #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses   23000  thrpt    2      103.025                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses         23000  thrpt    2       15.896                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads               23000  thrpt    2       54.290                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses        23000  thrpt    2        2.125                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores              23000  thrpt    2       18.525                #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses           23000  thrpt    2    26436.454                #/op
HttpStatusValueOfBenchmark.valueOf:branches                23000  thrpt    2   291377.752                #/op
HttpStatusValueOfBenchmark.valueOf:cycles                  23000  thrpt    2  1285458.169                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses        23000  thrpt    2       11.689                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads              23000  thrpt    2   168858.474                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses       23000  thrpt    2        2.608                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores             23000  thrpt    2    69817.716                #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses        23000  thrpt    2        6.213                #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads              23000  thrpt    2        8.106                #/op
HttpStatusValueOfBenchmark.valueOf:instructions            23000  thrpt    2  2345979.703                #/op

Base line(if-else), with JDK-8:

Benchmark                                                 (size)   Mode  Cnt        Score   Error      Units
HttpStatusValueOfBenchmark.valueOf                          1300  thrpt   20       57.972 ± 0.333     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      1300  thrpt    2        0.775          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      1300  thrpt    2        1.291          insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses    1300  thrpt    2     1166.639               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads          1300  thrpt    2   230427.135               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores         1300  thrpt    2   129782.335               #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses    1300  thrpt    2       46.275               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses          1300  thrpt    2        6.808               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads                1300  thrpt    2       22.639               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses         1300  thrpt    2        0.342               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores               1300  thrpt    2        4.395               #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses            1300  thrpt    2    16932.187               #/op
HttpStatusValueOfBenchmark.valueOf:branches                 1300  thrpt    2   192014.903               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   1300  thrpt    2   750217.972               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses         1300  thrpt    2        7.090               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads               1300  thrpt    2   229694.096               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses        1300  thrpt    2        0.972               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores              1300  thrpt    2   129278.052               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses         1300  thrpt    2        2.537               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads               1300  thrpt    2        4.623               #/op
HttpStatusValueOfBenchmark.valueOf:instructions             1300  thrpt    2   968538.369               #/op

HttpStatusValueOfBenchmark.valueOf                          2600  thrpt   20       29.093 ± 0.111     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      2600  thrpt    2        0.777          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      2600  thrpt    2        1.287          insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses    2600  thrpt    2     1270.698               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads          2600  thrpt    2   254393.378               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores         2600  thrpt    2   146464.254               #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses    2600  thrpt    2       65.121               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses          2600  thrpt    2        6.249               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads                2600  thrpt    2       24.400               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses         2600  thrpt    2        0.564               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores               2600  thrpt    2        6.278               #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses            2600  thrpt    2    19523.646               #/op
HttpStatusValueOfBenchmark.valueOf:branches                 2600  thrpt    2   212633.145               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   2600  thrpt    2   868565.604               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses         2600  thrpt    2        8.041               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads               2600  thrpt    2   253937.839               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses        2600  thrpt    2        1.061               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores              2600  thrpt    2   146426.731               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses         2600  thrpt    2        4.024               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads               2600  thrpt    2        4.559               #/op
HttpStatusValueOfBenchmark.valueOf:instructions             2600  thrpt    2  1118040.069               #/op

HttpStatusValueOfBenchmark.valueOf                          5300  thrpt   20       14.308 ± 0.058     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      5300  thrpt    2        0.767          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      5300  thrpt    2        1.303          insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses    5300  thrpt    2     1488.250               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads          5300  thrpt    2   303334.659               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores         5300  thrpt    2   181576.431               #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses    5300  thrpt    2       69.701               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses          5300  thrpt    2        5.409               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads                5300  thrpt    2       30.078               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses         5300  thrpt    2        0.232               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores               5300  thrpt    2        8.265               #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses            5300  thrpt    2    24971.216               #/op
HttpStatusValueOfBenchmark.valueOf:branches                 5300  thrpt    2   254778.082               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   5300  thrpt    2  1095470.412               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses         5300  thrpt    2        9.528               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads               5300  thrpt    2   302079.310               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses        5300  thrpt    2        1.546               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores              5300  thrpt    2   181050.745               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses         5300  thrpt    2        6.224               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads               5300  thrpt    2        7.561               #/op
HttpStatusValueOfBenchmark.valueOf:instructions             5300  thrpt    2  1427395.928               #/op

HttpStatusValueOfBenchmark.valueOf                         11000  thrpt   20        6.906 ± 0.020     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                     11000  thrpt    2        0.757          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                     11000  thrpt    2        1.320          insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses   11000  thrpt    2     2589.176               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads         11000  thrpt    2   408125.826               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores        11000  thrpt    2   255978.158               #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses   11000  thrpt    2      125.810               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses         11000  thrpt    2       12.531               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads               11000  thrpt    2       53.705               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses        11000  thrpt    2        0.449               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores              11000  thrpt    2       15.978               #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses           11000  thrpt    2    36349.904               #/op
HttpStatusValueOfBenchmark.valueOf:branches                11000  thrpt    2   344452.535               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                  11000  thrpt    2  1575752.953               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses        11000  thrpt    2       11.628               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads              11000  thrpt    2   407897.938               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses       11000  thrpt    2        1.365               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores             11000  thrpt    2   256079.676               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses        11000  thrpt    2        7.485               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads              11000  thrpt    2        7.754               #/op
HttpStatusValueOfBenchmark.valueOf:instructions            11000  thrpt    2  2080739.210               #/op

HttpStatusValueOfBenchmark.valueOf                         23000  thrpt   20        3.291 ± 0.010     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                     23000  thrpt    2        0.754          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                     23000  thrpt    2        1.327          insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses   23000  thrpt    2     4159.710               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads         23000  thrpt    2   626649.380               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores        23000  thrpt    2   411718.960               #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses   23000  thrpt    2      167.010               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses         23000  thrpt    2        8.810               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads               23000  thrpt    2       76.692               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses        23000  thrpt    2        0.601               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores              23000  thrpt    2       18.288               #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses           23000  thrpt    2    60571.570               #/op
HttpStatusValueOfBenchmark.valueOf:branches                23000  thrpt    2   532439.316               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                  23000  thrpt    2  2603895.660               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses        23000  thrpt    2       18.224               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads              23000  thrpt    2   628271.731               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses       23000  thrpt    2        3.365               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores             23000  thrpt    2   413120.313               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses        23000  thrpt    2       14.006               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads              23000  thrpt    2       17.847               #/op
HttpStatusValueOfBenchmark.valueOf:instructions            23000  thrpt    2  3454654.114               #/op

'Switch-case', with JDK-8:

Benchmark                                                 (size)   Mode  Cnt        Score   Error      Units
HttpStatusValueOfBenchmark.valueOf                          1300  thrpt   20       62.665 ± 0.284     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      1300  thrpt    2        1.018          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      1300  thrpt    2        0.982          insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses    1300  thrpt    2     1187.060               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads          1300  thrpt    2   130971.966               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores         1300  thrpt    2   129530.677               #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses    1300  thrpt    2       51.665               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses          1300  thrpt    2        1.868               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads                1300  thrpt    2       17.846               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses         1300  thrpt    2        0.554               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores               1300  thrpt    2        3.600               #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses            1300  thrpt    2    19065.102               #/op
HttpStatusValueOfBenchmark.valueOf:branches                 1300  thrpt    2   147871.052               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   1300  thrpt    2   803300.883               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses         1300  thrpt    2       10.488               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads               1300  thrpt    2   131141.245               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses        1300  thrpt    2        0.918               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores              1300  thrpt    2   129506.389               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses         1300  thrpt    2        3.388               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads               1300  thrpt    2        5.688               #/op
HttpStatusValueOfBenchmark.valueOf:instructions             1300  thrpt    2   789060.146               #/op

HttpStatusValueOfBenchmark.valueOf                          2600  thrpt   20       31.626 ± 0.098     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      2600  thrpt    2        0.975          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      2600  thrpt    2        1.026          insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses    2600  thrpt    2     1289.045               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads          2600  thrpt    2   148864.027               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores         2600  thrpt    2   146052.171               #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses    2600  thrpt    2       67.756               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses          2600  thrpt    2        4.358               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads                2600  thrpt    2       26.335               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses         2600  thrpt    2        1.040               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores               2600  thrpt    2        8.898               #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses            2600  thrpt    2    21064.076               #/op
HttpStatusValueOfBenchmark.valueOf:branches                 2600  thrpt    2   165964.272               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   2600  thrpt    2   902109.877               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses         2600  thrpt    2       11.518               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads               2600  thrpt    2   149606.599               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses        2600  thrpt    2        0.891               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores              2600  thrpt    2   146635.243               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses         2600  thrpt    2        4.470               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads               2600  thrpt    2        7.055               #/op
HttpStatusValueOfBenchmark.valueOf:instructions             2600  thrpt    2   925641.080               #/op

HttpStatusValueOfBenchmark.valueOf                          5300  thrpt   20       15.562 ± 0.023     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      5300  thrpt    2        0.925          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      5300  thrpt    2        1.081          insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses    5300  thrpt    2     1511.829               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads          5300  thrpt    2   187090.480               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores         5300  thrpt    2   181551.507               #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses    5300  thrpt    2       76.421               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses          5300  thrpt    2        7.306               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads                5300  thrpt    2       33.667               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses         5300  thrpt    2        0.440               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores               5300  thrpt    2        6.130               #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses            5300  thrpt    2    26330.857               #/op
HttpStatusValueOfBenchmark.valueOf:branches                 5300  thrpt    2   207139.562               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   5300  thrpt    2  1138611.428               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses         5300  thrpt    2       12.266               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads               5300  thrpt    2   186958.733               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses        5300  thrpt    2        1.431               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores              5300  thrpt    2   181749.222               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses         5300  thrpt    2        5.581               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads               5300  thrpt    2        6.609               #/op
HttpStatusValueOfBenchmark.valueOf:instructions             5300  thrpt    2  1230800.495               #/op

HttpStatusValueOfBenchmark.valueOf                         11000  thrpt   20        7.463 ± 0.010     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                     11000  thrpt    2        0.868          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                     11000  thrpt    2        1.153          insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses   11000  thrpt    2     2558.149               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads         11000  thrpt    2   267802.141               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores        11000  thrpt    2   256694.834               #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses   11000  thrpt    2       82.868               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses         11000  thrpt    2        6.051               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads               11000  thrpt    2       40.301               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses        11000  thrpt    2        0.377               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores              11000  thrpt    2        9.937               #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses           11000  thrpt    2    36579.836               #/op
HttpStatusValueOfBenchmark.valueOf:branches                11000  thrpt    2   291988.735               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                  11000  thrpt    2  1614872.020               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses        11000  thrpt    2       18.646               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads              11000  thrpt    2   267141.576               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses       11000  thrpt    2        2.761               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores             11000  thrpt    2   255672.466               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses        11000  thrpt    2        8.040               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads              11000  thrpt    2       12.071               #/op
HttpStatusValueOfBenchmark.valueOf:instructions            11000  thrpt    2  1861380.373               #/op

HttpStatusValueOfBenchmark.valueOf                         23000  thrpt   20        3.572 ± 0.017     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                     23000  thrpt    2        0.816          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                     23000  thrpt    2        1.226          insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses   23000  thrpt    2     4189.172               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads         23000  thrpt    2   435818.968               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores        23000  thrpt    2   412160.749               #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses   23000  thrpt    2      212.512               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses         23000  thrpt    2       20.875               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads               23000  thrpt    2       91.249               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses        23000  thrpt    2        1.103               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores              23000  thrpt    2       37.833               #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses           23000  thrpt    2    57712.128               #/op
HttpStatusValueOfBenchmark.valueOf:branches                23000  thrpt    2   470013.454               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                  23000  thrpt    2  2600201.506               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses        23000  thrpt    2       19.742               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads              23000  thrpt    2   435120.046               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses       23000  thrpt    2        1.957               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores             23000  thrpt    2   412037.408               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses        23000  thrpt    2       10.126               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads              23000  thrpt    2       10.960               #/op
HttpStatusValueOfBenchmark.valueOf:instructions            23000  thrpt    2  3187735.116               #/op

'Array-index', with JDK-8:

Benchmark                                                 (size)   Mode  Cnt        Score   Error      Units
HttpStatusValueOfBenchmark.valueOf                          1300  thrpt   20      158.451 ± 0.903     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      1300  thrpt    2        0.435          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      1300  thrpt    2        2.297          insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses    1300  thrpt    2     1133.240               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads          1300  thrpt    2   158430.816               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores         1300  thrpt    2   130146.661               #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses    1300  thrpt    2       25.781               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses          1300  thrpt    2        1.872               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads                1300  thrpt    2       14.889               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses         1300  thrpt    2        0.744               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores               1300  thrpt    2        1.619               #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses            1300  thrpt    2     4045.910               #/op
HttpStatusValueOfBenchmark.valueOf:branches                 1300  thrpt    2   128109.935               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   1300  thrpt    2   364117.380               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses         1300  thrpt    2        4.405               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads               1300  thrpt    2   157672.024               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses        1300  thrpt    2        0.483               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores              1300  thrpt    2   129463.369               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses         1300  thrpt    2        1.416               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads               1300  thrpt    2        1.889               #/op
HttpStatusValueOfBenchmark.valueOf:instructions             1300  thrpt    2   836302.171               #/op

HttpStatusValueOfBenchmark.valueOf                          2600  thrpt   20       79.759 ± 1.155     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      2600  thrpt    2        0.447          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      2600  thrpt    2        2.237          insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses    2600  thrpt    2     1234.160               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads          2600  thrpt    2   173730.094               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores         2600  thrpt    2   147497.903               #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses    2600  thrpt    2       32.713               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses          2600  thrpt    2        1.860               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads                2600  thrpt    2       10.774               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses         2600  thrpt    2        0.479               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores               2600  thrpt    2        1.934               #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses            2600  thrpt    2     5444.160               #/op
HttpStatusValueOfBenchmark.valueOf:branches                 2600  thrpt    2   145883.064               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   2600  thrpt    2   439150.339               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses         2600  thrpt    2        4.080               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads               2600  thrpt    2   173022.232               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses        2600  thrpt    2        0.453               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores              2600  thrpt    2   146993.082               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses         2600  thrpt    2        1.104               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads               2600  thrpt    2        2.934               #/op
HttpStatusValueOfBenchmark.valueOf:instructions             2600  thrpt    2   982364.396               #/op

HttpStatusValueOfBenchmark.valueOf                          5300  thrpt   20       39.025 ± 0.124     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      5300  thrpt    2        0.462          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      5300  thrpt    2        2.164          insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses    5300  thrpt    2     1442.429               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads          5300  thrpt    2   205367.826               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores         5300  thrpt    2   180985.464               #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses    5300  thrpt    2       41.446               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses          5300  thrpt    2        2.317               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads                5300  thrpt    2       14.482               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses         5300  thrpt    2        0.421               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores               5300  thrpt    2        2.766               #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses            5300  thrpt    2     8209.410               #/op
HttpStatusValueOfBenchmark.valueOf:branches                 5300  thrpt    2   182735.155               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   5300  thrpt    2   588299.969               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses         5300  thrpt    2        3.974               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads               5300  thrpt    2   205354.932               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses        5300  thrpt    2        0.415               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores              5300  thrpt    2   181310.445               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses         5300  thrpt    2        1.923               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads               5300  thrpt    2        4.201               #/op
HttpStatusValueOfBenchmark.valueOf:instructions             5300  thrpt    2  1273194.438               #/op

HttpStatusValueOfBenchmark.valueOf                         11000  thrpt   20       18.828 ± 0.044     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                     11000  thrpt    2        0.482          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                     11000  thrpt    2        2.075          insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses   11000  thrpt    2     2519.149               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads         11000  thrpt    2   291041.963               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores        11000  thrpt    2   255654.984               #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses   11000  thrpt    2       62.275               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses         11000  thrpt    2        4.879               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads               11000  thrpt    2       25.058               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses        11000  thrpt    2        0.816               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores              11000  thrpt    2       12.282               #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses           11000  thrpt    2    14278.326               #/op
HttpStatusValueOfBenchmark.valueOf:branches                11000  thrpt    2   262032.119               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                  11000  thrpt    2   929954.024               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses        11000  thrpt    2        9.091               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads              11000  thrpt    2   290842.502               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses       11000  thrpt    2        1.380               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores             11000  thrpt    2   255726.037               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses        11000  thrpt    2        6.505               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads              11000  thrpt    2        7.034               #/op
HttpStatusValueOfBenchmark.valueOf:instructions            11000  thrpt    2  1929766.936               #/op

HttpStatusValueOfBenchmark.valueOf                         23000  thrpt   20        9.006 ± 0.056     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                     23000  thrpt    2        0.496          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                     23000  thrpt    2        2.017          insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses   23000  thrpt    2     4090.001               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads         23000  thrpt    2   471753.651               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores        23000  thrpt    2   412284.819               #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses   23000  thrpt    2      120.954               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses         23000  thrpt    2        6.473               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads               23000  thrpt    2       56.927               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses        23000  thrpt    2        0.414               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores              23000  thrpt    2       14.344               #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses           23000  thrpt    2    26707.273               #/op
HttpStatusValueOfBenchmark.valueOf:branches                23000  thrpt    2   427953.896               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                  23000  thrpt    2  1642028.816               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses        23000  thrpt    2       15.795               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads              23000  thrpt    2   470339.776               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses       23000  thrpt    2        2.401               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores             23000  thrpt    2   411527.936               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses        23000  thrpt    2        8.894               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads              23000  thrpt    2       10.929               #/op
HttpStatusValueOfBenchmark.valueOf:instructions            23000  thrpt    2  3311189.011               #/op

In summary on chart, the X-axis is 'input array size', the Y-axis is 'throughput':

benchmark-0907-JDK-17

benchmark-0907-JDK-8

Compare with using 'CircularLink':
The 'throughput' results do not have significant differences.
The ratio of 'L1-dcache-load-misses / L1-dcache-load' is significant lower than using 'CircularLink'. I think that's because the normal int arrays are more fitted to 'L1-dcache' than 'CircularLink' objects.
@franz1981

return SERVER_ERROR;
}
return UNKNOWN;
return statusArray[code / 100];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So array is super fast:)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

@laosijikaichele
Copy link
Contributor Author

laosijikaichele commented Sep 7, 2023

As we noticed before, the JIT optimized the division with constant divisor to 'multiplication & bit-shift & subtraction' operations. We can translate the optimized assembly to Java method:

    // return dividend / 100
    int fast_div100(int dividend) {
        return (int) (((dividend * 1374389535L) >> 37) - (dividend >> 31));
    }

If dividend >= 0, which means if dividend is unsigned, then the - (dividend >> 31) part can be eliminated. The method becomes to:

    // dividend >= 0
    // return dividend / 100
    int fast_div100(int dividend) {
        return (int) ((code * 1374389535L) >> 37);
    }

Because Java does not have unsigned value, we can verify this in the GCC compiler explorer, please check the example: https://godbolt.org/z/T9adqWbP3.

For method HttpStatusClass.valueOf(int code):

public static HttpStatusClass valueOf(int code) {
        if (UNKNOWN.contains(code)) {
            return UNKNOWN;
        }
        return statusArray[code / 100];
    }

When goes to return statusArray[code / 100];, we already know that the code MUST be positive, which means it must be a unsigned value, so we can replace code / 100 to call a custom division method without - (dividend >> 31):

    public static HttpStatusClass valueOf(int code) {
        if (UNKNOWN.contains(code)) {
            return UNKNOWN;
        }
        return statusArray[fast_div100(code)];
    }
    // Custom division method
    private static int fast_div100(int dividend) {
        return (int) ((dividend * 1374389535L) >> 37);
    }

With this custom div method committed, test it again:

'Array-with-custom-div' with JDK-17:

Benchmark                                                 (size)   Mode  Cnt        Score    Error      Units
HttpStatusValueOfBenchmark.valueOf                          1300  thrpt   20      506.348 ±  2.084     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      1300  thrpt    2        0.450           clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      1300  thrpt    2        2.225           insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses    1300  thrpt    2     1125.719                #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads          1300  thrpt    2    37444.312                #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores         1300  thrpt    2     4032.705                #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses    1300  thrpt    2       13.370                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses          1300  thrpt    2        2.213                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads                1300  thrpt    2        6.154                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses         1300  thrpt    2        0.229                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores               1300  thrpt    2        2.232                #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses            1300  thrpt    2     2358.919                #/op
HttpStatusValueOfBenchmark.valueOf:branches                 1300  thrpt    2    66887.522                #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   1300  thrpt    2   167487.407                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses         1300  thrpt    2       64.566                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads               1300  thrpt    2    37658.707                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses        1300  thrpt    2        0.112                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores              1300  thrpt    2     4066.867                #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses         1300  thrpt    2        1.694                #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads               1300  thrpt    2        1.337                #/op
HttpStatusValueOfBenchmark.valueOf:instructions             1300  thrpt    2   372571.528                #/op

HttpStatusValueOfBenchmark.valueOf                          2600  thrpt   20      256.395 ±  1.231     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      2600  thrpt    2        0.470           clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      2600  thrpt    2        2.128           insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses    2600  thrpt    2     1222.654                #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads          2600  thrpt    2    45373.817                #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores         2600  thrpt    2     8013.781                #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses    2600  thrpt    2       21.204                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses          2600  thrpt    2        4.048                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads                2600  thrpt    2       13.691                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses         2600  thrpt    2        0.385                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores               2600  thrpt    2        2.066                #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses            2600  thrpt    2     3970.329                #/op
HttpStatusValueOfBenchmark.valueOf:branches                 2600  thrpt    2    80396.347                #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   2600  thrpt    2   229239.357                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses         2600  thrpt    2       82.491                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads               2600  thrpt    2    45293.680                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses        2600  thrpt    2        0.192                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores              2600  thrpt    2     7966.844                #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses         2600  thrpt    2        1.323                #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads               2600  thrpt    2        1.352                #/op
HttpStatusValueOfBenchmark.valueOf:instructions             2600  thrpt    2   487711.763                #/op

HttpStatusValueOfBenchmark.valueOf                          5300  thrpt   20      134.831 ± 14.326     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      5300  thrpt    2        0.546           clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      5300  thrpt    2        1.832           insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses    5300  thrpt    2     1458.265                #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads          5300  thrpt    2    62093.673                #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores         5300  thrpt    2    16840.324                #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses    5300  thrpt    2       30.608                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses          5300  thrpt    2        4.155                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads                5300  thrpt    2       22.869                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses         5300  thrpt    2        1.069                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores               5300  thrpt    2        7.423                #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses            5300  thrpt    2     7821.095                #/op
HttpStatusValueOfBenchmark.valueOf:branches                 5300  thrpt    2   108450.556                #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   5300  thrpt    2   378635.017                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses         5300  thrpt    2      136.327                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads               5300  thrpt    2    62076.834                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses        5300  thrpt    2        0.427                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores              5300  thrpt    2    16763.977                #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses         5300  thrpt    2        2.954                #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads               5300  thrpt    2        3.704                #/op
HttpStatusValueOfBenchmark.valueOf:instructions             5300  thrpt    2   693525.083                #/op

HttpStatusValueOfBenchmark.valueOf                         11000  thrpt   20       77.550 ±  0.934     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                     11000  thrpt    2        0.574           clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                     11000  thrpt    2        1.744           insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses   11000  thrpt    2     2539.834                #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads         11000  thrpt    2    96408.530                #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores        11000  thrpt    2    33662.650                #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses   11000  thrpt    2       82.521                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses         11000  thrpt    2        8.724                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads               11000  thrpt    2       40.443                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses        11000  thrpt    2        0.240                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores              11000  thrpt    2        8.681                #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses           11000  thrpt    2    14144.432                #/op
HttpStatusValueOfBenchmark.valueOf:branches                11000  thrpt    2   167679.623                #/op
HttpStatusValueOfBenchmark.valueOf:cycles                  11000  thrpt    2   647767.703                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses        11000  thrpt    2      308.605                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads              11000  thrpt    2    96352.551                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses       11000  thrpt    2        0.810                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores             11000  thrpt    2    33596.853                #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses        11000  thrpt    2        3.422                #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads              11000  thrpt    2        3.768                #/op
HttpStatusValueOfBenchmark.valueOf:instructions            11000  thrpt    2  1129406.159                #/op

HttpStatusValueOfBenchmark.valueOf                         23000  thrpt   20       37.338 ±  0.164     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                     23000  thrpt    2        0.577           clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                     23000  thrpt    2        1.733           insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses   23000  thrpt    2     4114.635                #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads         23000  thrpt    2   168801.495                #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores        23000  thrpt    2    69703.908                #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses   23000  thrpt    2      139.519                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses         23000  thrpt    2       20.467                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads               23000  thrpt    2       73.063                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses        23000  thrpt    2        2.224                #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores              23000  thrpt    2       20.427                #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses           23000  thrpt    2    26388.758                #/op
HttpStatusValueOfBenchmark.valueOf:branches                23000  thrpt    2   291179.006                #/op
HttpStatusValueOfBenchmark.valueOf:cycles                  23000  thrpt    2  1214422.715                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses        23000  thrpt    2      335.245                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads              23000  thrpt    2   168764.159                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses       23000  thrpt    2        2.163                #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores             23000  thrpt    2    69571.701                #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses        23000  thrpt    2        6.388                #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads              23000  thrpt    2        8.081                #/op
HttpStatusValueOfBenchmark.valueOf:instructions            23000  thrpt    2  2104425.336                #/op

'Array-with-custom-div' with JDK-8:

Benchmark                                                 (size)   Mode  Cnt        Score   Error      Units
HttpStatusValueOfBenchmark.valueOf                          1300  thrpt   20      179.837 ± 3.731     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      1300  thrpt    2        0.455          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      1300  thrpt    2        2.199          insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses    1300  thrpt    2     1142.052               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads          1300  thrpt    2   160562.083               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores         1300  thrpt    2   131690.282               #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses    1300  thrpt    2       19.788               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses          1300  thrpt    2        1.421               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads                1300  thrpt    2        8.132               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses         1300  thrpt    2        0.483               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores               1300  thrpt    2        3.238               #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses            1300  thrpt    2     4098.956               #/op
HttpStatusValueOfBenchmark.valueOf:branches                 1300  thrpt    2   127466.328               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   1300  thrpt    2   340586.242               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses         1300  thrpt    2      115.042               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads               1300  thrpt    2   161154.091               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses        1300  thrpt    2        0.221               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores              1300  thrpt    2   132845.605               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses         1300  thrpt    2        1.479               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads               1300  thrpt    2        1.755               #/op
HttpStatusValueOfBenchmark.valueOf:instructions             1300  thrpt    2   748953.512               #/op

HttpStatusValueOfBenchmark.valueOf                          2600  thrpt   20       89.616 ± 0.944     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      2600  thrpt    2        0.466          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      2600  thrpt    2        2.147          insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses    2600  thrpt    2     1215.287               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads          2600  thrpt    2   173665.823               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores         2600  thrpt    2   145443.601               #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses    2600  thrpt    2       25.680               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses          2600  thrpt    2        4.276               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads                2600  thrpt    2       10.964               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses         2600  thrpt    2        0.493               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores               2600  thrpt    2        6.837               #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses            2600  thrpt    2     5375.869               #/op
HttpStatusValueOfBenchmark.valueOf:branches                 2600  thrpt    2   145953.329               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   2600  thrpt    2   412511.818               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses         2600  thrpt    2      102.383               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads               2600  thrpt    2   173550.432               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses        2600  thrpt    2        0.349               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores              2600  thrpt    2   145524.980               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses         2600  thrpt    2        2.109               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads               2600  thrpt    2        3.464               #/op
HttpStatusValueOfBenchmark.valueOf:instructions             2600  thrpt    2   885452.285               #/op

HttpStatusValueOfBenchmark.valueOf                          5300  thrpt   20       43.568 ± 0.199     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                      5300  thrpt    2        0.485          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                      5300  thrpt    2        2.063          insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses    5300  thrpt    2     1448.960               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads          5300  thrpt    2   205786.541               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores         5300  thrpt    2   181459.514               #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses    5300  thrpt    2       51.507               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses          5300  thrpt    2        6.118               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads                5300  thrpt    2       19.962               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses         5300  thrpt    2        0.348               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores               5300  thrpt    2        3.501               #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses            5300  thrpt    2     8225.201               #/op
HttpStatusValueOfBenchmark.valueOf:branches                 5300  thrpt    2   183277.190               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                   5300  thrpt    2   572368.901               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses         5300  thrpt    2       61.119               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads               5300  thrpt    2   205416.121               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses        5300  thrpt    2        0.511               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores              5300  thrpt    2   181821.317               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses         5300  thrpt    2        2.305               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads               5300  thrpt    2        3.293               #/op
HttpStatusValueOfBenchmark.valueOf:instructions             5300  thrpt    2  1180572.936               #/op

HttpStatusValueOfBenchmark.valueOf                         11000  thrpt   20       20.873 ± 0.599     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                     11000  thrpt    2        0.501          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                     11000  thrpt    2        1.996          insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses   11000  thrpt    2     2532.227               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads         11000  thrpt    2   291040.611               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores        11000  thrpt    2   256272.624               #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses   11000  thrpt    2       49.394               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses         11000  thrpt    2        5.321               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads               11000  thrpt    2       20.760               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses        11000  thrpt    2        0.979               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores              11000  thrpt    2        9.573               #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses           11000  thrpt    2    14178.992               #/op
HttpStatusValueOfBenchmark.valueOf:branches                11000  thrpt    2   261740.822               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                  11000  thrpt    2   902443.642               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses        11000  thrpt    2       74.012               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads              11000  thrpt    2   290384.264               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses       11000  thrpt    2        1.224               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores             11000  thrpt    2   255595.292               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses        11000  thrpt    2        3.538               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads              11000  thrpt    2        6.335               #/op
HttpStatusValueOfBenchmark.valueOf:instructions            11000  thrpt    2  1800873.198               #/op

HttpStatusValueOfBenchmark.valueOf                         23000  thrpt   20       10.061 ± 0.057     ops/ms
HttpStatusValueOfBenchmark.valueOf:CPI                     23000  thrpt    2        0.513          clks/insn
HttpStatusValueOfBenchmark.valueOf:IPC                     23000  thrpt    2        1.949          insns/clk
HttpStatusValueOfBenchmark.valueOf:L1-dcache-load-misses   23000  thrpt    2     4138.236               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-loads         23000  thrpt    2   471142.440               #/op
HttpStatusValueOfBenchmark.valueOf:L1-dcache-stores        23000  thrpt    2   412247.033               #/op
HttpStatusValueOfBenchmark.valueOf:L1-icache-load-misses   23000  thrpt    2      134.540               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-load-misses         23000  thrpt    2       13.156               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-loads               23000  thrpt    2       59.931               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-store-misses        23000  thrpt    2        1.529               #/op
HttpStatusValueOfBenchmark.valueOf:LLC-stores              23000  thrpt    2       16.210               #/op
HttpStatusValueOfBenchmark.valueOf:branch-misses           23000  thrpt    2    26603.627               #/op
HttpStatusValueOfBenchmark.valueOf:branches                23000  thrpt    2   427746.134               #/op
HttpStatusValueOfBenchmark.valueOf:cycles                  23000  thrpt    2  1596351.826               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-load-misses        23000  thrpt    2       85.160               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-loads              23000  thrpt    2   472427.336               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-store-misses       23000  thrpt    2        2.502               #/op
HttpStatusValueOfBenchmark.valueOf:dTLB-stores             23000  thrpt    2   412546.697               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-load-misses        23000  thrpt    2        6.846               #/op
HttpStatusValueOfBenchmark.valueOf:iTLB-loads              23000  thrpt    2        8.816               #/op
HttpStatusValueOfBenchmark.valueOf:instructions            23000  thrpt    2  3110759.553               #/op

Add this results to previous results, and sumarry on chart, the X-axis is 'input array size', the Y-axis is 'throughput':

JDK-17-fastdiv

jdk-8-fastdiv

With JDK-17, the 'Array-with-custom-div' version improves '37% - 54%' than 'Array' version.
With JDK-8, the 'Array-with-custom-div' version improves '11% - 13%' than 'Array' version.

This 'Array-with-custom-div' optimization may seem a little aggressive, because we introduced a custom division method, but still, we can discuss about this. @franz1981 @chrisvest

@franz1981
Copy link
Contributor

franz1981 commented Sep 7, 2023

I am all in to make it faster, for sure @laosijikaichele and good finding!
Just interested to know, although not an exact math what is the average cost in ns per input data?
A bunch of nanoseconds, hence it should be as fast as being limited by the L1 access, for the top results.

@laosijikaichele
Copy link
Contributor Author

@franz1981 Did you mean we change the @OutputTimeUnit(TimeUnit.MILLISECONDS) to @OutputTimeUnit(TimeUnit.NANOSECONDS) ?

…measure single invocation throughput of HttpStatusClass.valueOf()
@laosijikaichele
Copy link
Contributor Author

laosijikaichele commented Sep 11, 2023

The benchmark classHttpStatusValueOfBenchmark has updated:

  1. Use annotation @OperationsPerInvocation to measure single invocation throughputs of HttpStatusClass.valueOf().
  2. To further reduce the 'noise', disabled branch pollute operation in setup method, to let benchmark methods make most use of possible optimizations.
  3. There is a profiling-optimization for 'tableswitch' with JDK-11 and above, it is by default enabled and may affect the performance of 'tableswitch', so we added a test case that disable this profiling-optimization when use JDK-17 and then compare the results.

Following are the test results:

Base line(if-else), with JDK-17:

Benchmark                                  Mode  Cnt    Score   Error   Units
HttpStatusValueOfBenchmark.valueOf_1300   thrpt   20  120.867 ± 0.850  ops/us
HttpStatusValueOfBenchmark.valueOf_2600   thrpt   20  123.677 ± 0.074  ops/us
HttpStatusValueOfBenchmark.valueOf_5300   thrpt   20  124.752 ± 2.543  ops/us
HttpStatusValueOfBenchmark.valueOf_11000  thrpt   20  125.210 ± 0.130  ops/us
HttpStatusValueOfBenchmark.valueOf_23000  thrpt   20  131.178 ± 0.193  ops/us

'Switch-case', with JDK-17:

Benchmark                                  Mode  Cnt    Score   Error   Units
HttpStatusValueOfBenchmark.valueOf_1300   thrpt   20  115.128 ± 0.118  ops/us
HttpStatusValueOfBenchmark.valueOf_2600   thrpt   20  114.923 ± 1.509  ops/us
HttpStatusValueOfBenchmark.valueOf_5300   thrpt   20  116.291 ± 1.467  ops/us
HttpStatusValueOfBenchmark.valueOf_11000  thrpt   20  115.821 ± 0.882  ops/us
HttpStatusValueOfBenchmark.valueOf_23000  thrpt   20  112.154 ± 1.555  ops/us

'Switch-case-no-profiling', with JDK-17:

Benchmark                                  Mode  Cnt    Score   Error   Units
HttpStatusValueOfBenchmark.valueOf_1300   thrpt   20  123.920 ± 0.215  ops/us
HttpStatusValueOfBenchmark.valueOf_2600   thrpt   20  124.431 ± 0.141  ops/us
HttpStatusValueOfBenchmark.valueOf_5300   thrpt   20  121.036 ± 0.650  ops/us
HttpStatusValueOfBenchmark.valueOf_11000  thrpt   20  120.601 ± 0.121  ops/us
HttpStatusValueOfBenchmark.valueOf_23000  thrpt   20  120.910 ± 0.340  ops/us

'Array', with JDK-17:

Benchmark                                  Mode  Cnt    Score   Error   Units
HttpStatusValueOfBenchmark.valueOf_1300   thrpt   20  484.202 ± 1.185  ops/us
HttpStatusValueOfBenchmark.valueOf_2600   thrpt   20  553.962 ± 1.544  ops/us
HttpStatusValueOfBenchmark.valueOf_5300   thrpt   20  557.224 ± 1.719  ops/us
HttpStatusValueOfBenchmark.valueOf_11000  thrpt   20  554.014 ± 2.165  ops/us
HttpStatusValueOfBenchmark.valueOf_23000  thrpt   20  555.318 ± 1.611  ops/us

'Array-with-custom-div' with JDK-17:

Benchmark                                  Mode  Cnt    Score    Error   Units
HttpStatusValueOfBenchmark.valueOf_1300   thrpt   20  681.207 ±  3.309  ops/us
HttpStatusValueOfBenchmark.valueOf_2600   thrpt   20  763.344 ±  2.298  ops/us
HttpStatusValueOfBenchmark.valueOf_5300   thrpt   20  807.552 ±  1.848  ops/us
HttpStatusValueOfBenchmark.valueOf_11000  thrpt   20  853.116 ± 20.162  ops/us
HttpStatusValueOfBenchmark.valueOf_23000  thrpt   20  863.378 ± 13.488  ops/us

Base line(if-else), with JDK-8:

Benchmark                                  Mode  Cnt   Score   Error   Units
HttpStatusValueOfBenchmark.valueOf_1300   thrpt   20  80.801 ± 0.404  ops/us
HttpStatusValueOfBenchmark.valueOf_2600   thrpt   20  81.841 ± 0.073  ops/us
HttpStatusValueOfBenchmark.valueOf_5300   thrpt   20  81.643 ± 0.320  ops/us
HttpStatusValueOfBenchmark.valueOf_11000  thrpt   20  81.399 ± 0.120  ops/us
HttpStatusValueOfBenchmark.valueOf_23000  thrpt   20  81.467 ± 0.129  ops/us

'Switch-case', with JDK-8:

Benchmark                                  Mode  Cnt   Score   Error   Units
HttpStatusValueOfBenchmark.valueOf_1300   thrpt   20  87.672 ± 0.282  ops/us
HttpStatusValueOfBenchmark.valueOf_2600   thrpt   20  86.791 ± 0.059  ops/us
HttpStatusValueOfBenchmark.valueOf_5300   thrpt   20  88.164 ± 0.833  ops/us
HttpStatusValueOfBenchmark.valueOf_11000  thrpt   20  88.219 ± 0.307  ops/us
HttpStatusValueOfBenchmark.valueOf_23000  thrpt   20  88.518 ± 0.103  ops/us

'Array', with JDK-8:

Benchmark                                  Mode  Cnt    Score   Error   Units
HttpStatusValueOfBenchmark.valueOf_1300   thrpt   20  231.177 ± 0.684  ops/us
HttpStatusValueOfBenchmark.valueOf_2600   thrpt   20  232.800 ± 0.655  ops/us
HttpStatusValueOfBenchmark.valueOf_5300   thrpt   20  231.575 ± 3.036  ops/us
HttpStatusValueOfBenchmark.valueOf_11000  thrpt   20  226.650 ± 1.271  ops/us
HttpStatusValueOfBenchmark.valueOf_23000  thrpt   20  226.053 ± 2.643  ops/us

'Array-with-custom-div' with JDK-8:

Benchmark                                  Mode  Cnt    Score   Error   Units
HttpStatusValueOfBenchmark.valueOf_1300   thrpt   20  269.054 ± 0.998  ops/us
HttpStatusValueOfBenchmark.valueOf_2600   thrpt   20  270.983 ± 0.774  ops/us
HttpStatusValueOfBenchmark.valueOf_5300   thrpt   20  270.140 ± 3.017  ops/us
HttpStatusValueOfBenchmark.valueOf_11000  thrpt   20  260.893 ± 0.640  ops/us
HttpStatusValueOfBenchmark.valueOf_23000  thrpt   20  260.780 ± 0.750  ops/us

In summary on chart, the X-axis is 'input array size', the Y-axis is 'throughput':

JDK-17-0911

JDK-8-0911

There are two notable things:

  1. With JDK-8, the 'switch' improves +6% ~ +8% than 'if/else' version.
  2. With JDK-17, although the 'Switch-case-no-profiling' is about -8% ~ +3% than 'if/else', but the 'Switch-case-no-profiling' improves +4% ~ +8% than 'Switch'. So under current dataset, when use 'switch', the default profiling-optimization is hurting the performance.
    @chrisvest , @franz1981

PS: When do the benchmark with JDK-17, the switch-profiling-optimization can be disabled by adding
-XX:+UnlockDiagnosticVMOptions -XX:-UseSwitchProfiling

@laosijikaichele
Copy link
Contributor Author

laosijikaichele commented Sep 14, 2023

In case of anyone interested about the switch-profiling with JDK-17, there is a new issue created for OpenJDK, please refer https://bugs.openjdk.org/browse/JDK-8316275.

@chrisvest chrisvest merged commit 1420272 into netty:4.1 Sep 21, 2023
14 checks passed
@chrisvest
Copy link
Contributor

@laosijikaichele thanks

chrisvest pushed a commit that referenced this pull request Sep 21, 2023
Motivation:

The method `HttpStatusClass.valueOf(int)` can be optimized by replacing
if-branches with array lookup.
The array lookup is faster, because dividing by a fixed constant of 100 well by the JIT.

Modification:

Replace if-branches with array lookup and optimized division.

Result:

Faster lookup of HTTP status code class.

---------

Co-authored-by: laosijikaichele <laosijikaichele>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants