Skip to content

JAVA-1308: CodecRegistry performance improvements#806

Merged
adutra merged 1 commit into
3.xfrom
java1308
Feb 16, 2017
Merged

JAVA-1308: CodecRegistry performance improvements#806
adutra merged 1 commit into
3.xfrom
java1308

Conversation

@adutra

@adutra adutra commented Feb 15, 2017

Copy link
Copy Markdown
Contributor

Opened this PR to explore another idea to improve CodecRegistry performance: use an EnumMap instead of Guava's ImmutableMap.

Here are my benchmark results:

EnumMap
Benchmark                                          Mode  Cnt       Score       Error   Units
CodecRegistryBenchmark.benchmarkCqlType           thrpt    5  295929.901 ± 15920.012  ops/ms
CodecRegistryBenchmark.benchmarkCqlTypeJavaType   thrpt    5  280676.140 ± 18111.264  ops/ms
CodecRegistryBenchmark.benchmarkCqlTypeJavaType2  thrpt    5  264239.794 ± 16157.046  ops/ms
CodecRegistryBenchmark.benchmarkCqlTypeValue      thrpt    5  231166.054 ± 20440.135  ops/ms
CodecRegistryBenchmark.benchmarkValue             thrpt    5  352292.682 ±  3457.407  ops/ms

ImmutableMap
Benchmark                                          Mode  Cnt       Score       Error   Units
CodecRegistryBenchmark.benchmarkCqlType           thrpt    5  236313.000 ± 12701.398  ops/ms
CodecRegistryBenchmark.benchmarkCqlTypeJavaType   thrpt    5  215917.116 ±  8664.283  ops/ms
CodecRegistryBenchmark.benchmarkCqlTypeJavaType2  thrpt    5  231635.771 ± 22187.916  ops/ms
CodecRegistryBenchmark.benchmarkCqlTypeValue      thrpt    5  120391.569 ± 10049.849  ops/ms
CodecRegistryBenchmark.benchmarkValue             thrpt    5  136206.073 ±  4016.883  ops/ms

pre-JAVA-1308
Benchmark                                          Mode  Cnt      Score      Error   Units
CodecRegistryBenchmark.benchmarkCqlType           thrpt    5   7568.787 ±  935.573  ops/ms
CodecRegistryBenchmark.benchmarkCqlTypeJavaType   thrpt    5   7537.136 ±  448.218  ops/ms
CodecRegistryBenchmark.benchmarkCqlTypeJavaType2  thrpt    5   7586.622 ± 1134.851  ops/ms
CodecRegistryBenchmark.benchmarkCqlTypeValue      thrpt    5  41315.849 ± 1726.394  ops/ms
CodecRegistryBenchmark.benchmarkValue             thrpt    5   2012.092 ±   47.753  ops/ms

Benchmark code here.

Note: benchmarkCqlTypeValue and benchmarkValue are a bit biased in my implementation because they test the best-case scenario (the codec to find is the first in the array).

@adutra adutra added this to the 3.2.0 milestone Feb 15, 2017
@olim7t

olim7t commented Feb 15, 2017

Copy link
Copy Markdown
Contributor

As an aside, the "Allow edits from maintainers" checkbox is checked by default when external users create a pull request, we should be able to push to their branch instead of opening another PR.

@tolbertam tolbertam left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice improvement! 👍

Separate the built-in codecs so that they can be backed by a static EnumMap instead of Guava Cache.
@adutra adutra merged commit 668992b into 3.x Feb 16, 2017
@adutra adutra deleted the java1308 branch February 16, 2017 10:03
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.

3 participants