Commit 0351c4f
authored
Improve IdentifierIndex firstIndexOf performance (#1615)
* Improve IdentifierIndex firstIndexOf performance
Avoids doing two hasmap lookups and instead does a
single one, thus improving performances (CPU) of rougthly
33%.
In applications reading lots of rows and not managing manually indexes
(which is tricky, boiler plate and error prone),
IdentifierIndex::firstIndexOf is typically a CPU hotspots. In reactive
applications it might even run on the driver event loop. As such,
performances gains here are welcome.
## Before
```
Benchmark Mode Cnt Score Error Units
IdentifierIndexBench.complexGetFirst avgt 5 0.046 ± 0.005 us/op
IdentifierIndexBench.simpleGetFirst avgt 5 0.046 ± 0.002 us/op
```
## After
```
Benchmark Mode Cnt Score Error Units
IdentifierIndexBench.complexGetFirst avgt 5 0.028 ± 0.002 us/op
IdentifierIndexBench.simpleGetFirst avgt 5 0.030 ± 0.002 us/op
```
* Use ImmutableListMultimap within IdentifierIndex
This unlocks massive performance gains upon reads, for a minor slow
down at instanciation time, which won't be felt by applications relying
on prepared statements.
## Before
```
Benchmark Mode Cnt Score Error Units
IdentifierIndexBench.complexAllIndices avgt 5 0.007 ± 0.001 us/op
IdentifierIndexBench.complexGetFirst avgt 5 0.026 ± 0.002 us/op
IdentifierIndexBench.createComplex avgt 5 0.759 ± 0.059 us/op
IdentifierIndexBench.createSimple avgt 5 0.427 ± 0.048 us/op
IdentifierIndexBench.simpleAllIndices avgt 5 0.007 ± 0.001 us/op
IdentifierIndexBench.simpleGetFirst avgt 5 0.027 ± 0.002 us/op
```
## After
```
Benchmark Mode Cnt Score Error Units
IdentifierIndexBench.complexAllIndices avgt 5 0.004 ± 0.001 us/op
IdentifierIndexBench.complexGetFirst avgt 5 0.005 ± 0.001 us/op
IdentifierIndexBench.createComplex avgt 5 0.680 ± 0.020 us/op
IdentifierIndexBench.createSimple avgt 5 0.538 ± 0.096 us/op
IdentifierIndexBench.simpleAllIndices avgt 5 0.004 ± 0.001 us/op
IdentifierIndexBench.simpleGetFirst avgt 5 0.005 ± 0.001 us/op
```1 parent 0a61884 commit 0351c4f
File tree
1 file changed
+14
-7
lines changed- core/src/main/java/com/datastax/oss/driver/internal/core/data
1 file changed
+14
-7
lines changedLines changed: 14 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
23 | 25 | | |
24 | 26 | | |
| 27 | + | |
25 | 28 | | |
26 | 29 | | |
27 | 30 | | |
| |||
40 | 43 | | |
41 | 44 | | |
42 | 45 | | |
43 | | - | |
44 | | - | |
45 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
46 | 49 | | |
47 | 50 | | |
48 | 51 | | |
| |||
51 | 54 | | |
52 | 55 | | |
53 | 56 | | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
54 | 61 | | |
55 | 62 | | |
56 | 63 | | |
| |||
68 | 75 | | |
69 | 76 | | |
70 | 77 | | |
71 | | - | |
72 | | - | |
| 78 | + | |
| 79 | + | |
73 | 80 | | |
74 | 81 | | |
75 | 82 | | |
| |||
79 | 86 | | |
80 | 87 | | |
81 | 88 | | |
82 | | - | |
83 | | - | |
| 89 | + | |
| 90 | + | |
84 | 91 | | |
85 | 92 | | |
0 commit comments