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 timestamp queries: ==, !=, !NULL #3351

Merged
merged 3 commits into from
Aug 16, 2019
Merged

Conversation

ironage
Copy link
Contributor

@ironage ironage commented Aug 16, 2019

Add TimestampNode specializations for: Equal, NotEqual, NotNull.

Here's the timestamp benchmarks for the naïve generic search:

QueryTimestampGreater (MemOnly, EncryptionOff):     min  23.37ms (-50.62%)           max  25.34ms (-57.52%)           med  24.10ms (-56.46%)           avg  24.05ms (-55.09%)           stddev   588us (-86.42%)
QueryTimestampGreater (MemOnly, EncryptionOn):      min  23.34ms (-51.32%)           max  24.95ms (-64.54%)           med  23.79ms (-57.59%)           avg  23.81ms (-57.64%)           stddev   522us (-92.59%)
QueryTimestampGreater (Full   , EncryptionOff):     min  23.38ms (-50.77%)           max     25ms (-58.04%)           med  23.91ms (-56.68%)           avg  23.86ms (-54.99%)           stddev   517us (-88.96%)
QueryTimestampGreater (Full   , EncryptionOn):      min  23.40ms (-50.35%)           max  24.31ms (-59.61%)           med  23.52ms (-56.52%)           avg  23.59ms (-55.92%)           stddev   282us (-93.13%)

QueryTimestampGreaterEqual (MemOnly, EncryptionOff):   min  23.32ms     max  23.81ms     median  23.63ms     avg  23.55ms     stddev    176us
QueryTimestampGreaterEqual (MemOnly, EncryptionOn):    min  23.25ms     max  24.65ms     median  23.58ms     avg  23.63ms     stddev    414us
QueryTimestampGreaterEqual (Full   , EncryptionOff):   min  23.15ms     max  23.59ms     median  23.35ms     avg  23.33ms     stddev    115us
QueryTimestampGreaterEqual (Full   , EncryptionOn):    min  23.27ms     max  23.89ms     median  23.38ms     avg  23.41ms     stddev    187us

QueryTimestampLess (MemOnly, EncryptionOff):           min  23.29ms     max  23.74ms     median  23.40ms     avg  23.45ms     stddev    162us
QueryTimestampLess (MemOnly, EncryptionOn):            min  23.50ms     max  24.61ms     median  23.89ms     avg  23.89ms     stddev    334us
QueryTimestampLess (Full   , EncryptionOff):           min  23.38ms     max  25.02ms     median  24.61ms     avg  24.22ms     stddev    671us
QueryTimestampLess (Full   , EncryptionOn):            min  23.50ms     max  24.21ms     median  23.68ms     avg  23.71ms     stddev    207us

QueryTimestampLessEqual (MemOnly, EncryptionOff):      min  23.30ms     max  23.52ms     median  23.37ms     avg  23.38ms     stddev     84us
QueryTimestampLessEqual (MemOnly, EncryptionOn):       min  23.24ms     max  24.01ms     median  23.54ms     avg  23.50ms     stddev    253us
QueryTimestampLessEqual (Full   , EncryptionOff):      min  23.09ms     max  26.57ms     median  23.43ms     avg  24.04ms     stddev   1.31ms
QueryTimestampLessEqual (Full   , EncryptionOn):       min  23.47ms     max  24.22ms     median  24.08ms     avg  23.95ms     stddev    260us

QueryTimestampEqual (MemOnly, EncryptionOff):          min  18.65ms     max  19.37ms     median  18.75ms     avg  18.80ms     stddev    212us
QueryTimestampEqual (MemOnly, EncryptionOn):           min  18.71ms     max  19.80ms     median  19.08ms     avg  19.04ms     stddev    360us
QueryTimestampEqual (Full   , EncryptionOff):          min  18.92ms     max  19.52ms     median  19.24ms     avg  19.18ms     stddev    223us
QueryTimestampEqual (Full   , EncryptionOn):           min  18.66ms     max  19.19ms     median  18.81ms     avg  18.82ms     stddev    170us

QueryTimestampNotEqual (MemOnly, EncryptionOff):       min  38.87ms     max  40.61ms     median  39.43ms     avg  39.41ms     stddev    560us
QueryTimestampNotEqual (MemOnly, EncryptionOn):        min  38.65ms     max  40.54ms     median  39.53ms     avg  39.50ms     stddev    581us
QueryTimestampNotEqual (Full   , EncryptionOff):       min  39.06ms     max  72.66ms     median  44.69ms     avg  47.36ms     stddev  11.43ms
QueryTimestampNotEqual (Full   , EncryptionOn):        min  38.35ms     max  42.08ms     median  39.75ms     avg  39.65ms     stddev   1.19ms

QueryTimestampNotNull (MemOnly, EncryptionOff):        min  24.29ms     max  25.24ms     median  24.73ms     avg  24.67ms     stddev    281us
QueryTimestampNotNull (MemOnly, EncryptionOn):         min  24.28ms     max  24.78ms     median  24.52ms     avg  24.49ms     stddev    153us
QueryTimestampNotNull (Full   , EncryptionOff):        min  24.19ms     max  25.64ms     median  24.77ms     avg  24.77ms     stddev    461us
QueryTimestampNotNull (Full   , EncryptionOn):         min  24.27ms     max  24.68ms     median  24.47ms     avg  24.46ms     stddev    128us

QueryTimestampEqualNull (MemOnly, EncryptionOff):      min  21.10ms     max  22.17ms     median  21.48ms     avg  21.49ms     stddev    369us
QueryTimestampEqualNull (MemOnly, EncryptionOn):       min  21.08ms     max  22.87ms     median  21.33ms     avg  21.53ms     stddev    606us
QueryTimestampEqualNull (Full   , EncryptionOff):      min     21ms     max  21.47ms     median  21.08ms     avg  21.11ms     stddev    151us
QueryTimestampEqualNull (Full   , EncryptionOn):       min  21.07ms     max  23.57ms     median  21.30ms     avg  21.48ms     stddev    755us

And here's the timestamp benchmarks for this branch:

QueryTimestampGreater (MemOnly, EncryptionOff):     min   7.06ms (-85.09%)           max   7.31ms (-87.74%)           med   7.17ms (-87.04%)           avg   7.17ms (-86.62%)           stddev    87us (-98.00%)
QueryTimestampGreater (MemOnly, EncryptionOn):      min   7.06ms (-85.28%)           max   7.23ms (-89.72%)           med   7.13ms (-87.28%)           avg   7.13ms (-87.32%)           stddev    61us (-99.14%)
QueryTimestampGreater (Full   , EncryptionOff):     min   7.05ms (-85.15%)           max   7.31ms (-87.73%)           med   7.12ms (-87.10%)           avg   7.13ms (-86.55%)           stddev    72us (-98.45%)
QueryTimestampGreater (Full   , EncryptionOn):      min   7.10ms (-84.95%)           max   7.37ms (-87.76%)           med   7.19ms (-86.70%)           avg   7.19ms (-86.56%)           stddev    94us (-97.70%)

QueryTimestampGreaterEqual (MemOnly, EncryptionOff):   min   7.20ms     max   7.69ms     median   7.31ms     avg   7.38ms     stddev    155us
QueryTimestampGreaterEqual (MemOnly, EncryptionOn):    min   7.20ms     max   7.36ms     median   7.28ms     avg   7.27ms     stddev     49us
QueryTimestampGreaterEqual (Full   , EncryptionOff):   min   7.20ms     max   7.92ms     median   7.28ms     avg   7.33ms     stddev    191us
QueryTimestampGreaterEqual (Full   , EncryptionOn):    min   7.81ms     max  23.72ms     median  10.88ms     avg  12.02ms     stddev   4.66ms

QueryTimestampLess (MemOnly, EncryptionOff):           min   6.54ms     max   7.68ms     median   6.75ms     avg   6.82ms     stddev    350us
QueryTimestampLess (MemOnly, EncryptionOn):            min   6.54ms     max   7.25ms     median   6.78ms     avg   6.78ms     stddev    186us
QueryTimestampLess (Full   , EncryptionOff):           min   6.58ms     max   8.57ms     median   7.54ms     avg   7.49ms     stddev    508us
QueryTimestampLess (Full   , EncryptionOn):            min   6.55ms     max   7.44ms     median   6.67ms     avg   6.70ms     stddev    240us

QueryTimestampLessEqual (MemOnly, EncryptionOff):      min   6.72ms     max   7.23ms     median   6.90ms     avg   6.91ms     stddev    123us
QueryTimestampLessEqual (MemOnly, EncryptionOn):       min   6.99ms     max   8.63ms     median   7.79ms     avg   7.72ms     stddev    578us
QueryTimestampLessEqual (Full   , EncryptionOff):      min   6.69ms     max   8.42ms     median   6.83ms     avg   7.01ms     stddev    526us
QueryTimestampLessEqual (Full   , EncryptionOn):       min   6.72ms     max   7.07ms     median   6.78ms     avg   6.82ms     stddev    108us

QueryTimestampEqual (MemOnly, EncryptionOff):          min   1.08ms     max   1.54ms     median   1.10ms     avg   1.12ms     stddev     71us
QueryTimestampEqual (MemOnly, EncryptionOn):           min   1.10ms     max   1.28ms     median   1.10ms     avg   1.11ms     stddev     30us
QueryTimestampEqual (Full   , EncryptionOff):          min   1.08ms     max   1.30ms     median   1.10ms     avg   1.11ms     stddev     39us
QueryTimestampEqual (Full   , EncryptionOn):           min   1.10ms     max   1.84ms     median   1.11ms     avg   1.15ms     stddev    110us

QueryTimestampNotEqual (MemOnly, EncryptionOff):       min  25.91ms     max  31.94ms     median  26.37ms     avg  27.03ms     stddev   1.89ms
QueryTimestampNotEqual (MemOnly, EncryptionOn):        min  25.75ms     max  28.38ms     median  26.68ms     avg  26.57ms     stddev    885us
QueryTimestampNotEqual (Full   , EncryptionOff):       min  25.94ms     max  27.66ms     median  26.72ms     avg  26.70ms     stddev    551us
QueryTimestampNotEqual (Full   , EncryptionOn):        min  25.54ms     max  26.70ms     median     26ms     avg  25.96ms     stddev    363us

QueryTimestampNotNull (MemOnly, EncryptionOff):        min  12.58ms     max  13.13ms     median  12.73ms     avg  12.76ms     stddev    172us
QueryTimestampNotNull (MemOnly, EncryptionOn):         min  12.74ms     max  13.64ms     median  13.10ms     avg  13.14ms     stddev    310us
QueryTimestampNotNull (Full   , EncryptionOff):        min  12.71ms     max  14.40ms     median  13.60ms     avg  13.38ms     stddev    584us
QueryTimestampNotNull (Full   , EncryptionOn):         min  12.75ms     max  13.73ms     median  13.38ms     avg  13.26ms     stddev    333us

QueryTimestampEqualNull (MemOnly, EncryptionOff):      min   3.66ms     max   4.07ms     median   3.75ms     avg   3.79ms     stddev    126us
QueryTimestampEqualNull (MemOnly, EncryptionOn):       min   3.66ms     max   3.91ms     median   3.68ms     avg   3.71ms     stddev     63us
QueryTimestampEqualNull (Full   , EncryptionOff):      min   3.65ms     max   3.78ms     median   3.68ms     avg   3.69ms     stddev     36us
QueryTimestampEqualNull (Full   , EncryptionOn):       min   3.67ms     max   3.86ms     median   3.72ms     avg   3.73ms     stddev     60us

@ironage ironage requested a review from jedelbo August 16, 2019 00:10
@ironage ironage self-assigned this Aug 16, 2019
@jedelbo
Copy link
Contributor

jedelbo commented Aug 16, 2019

I was able to squeeze it a bit more. A simple optimization in Array::find_optimized paid well off.
These are the improvements compared to the commit that gave the numbers above.

QueryTimestampGreater (MemOnly, EncryptionOff):     min   7.80ms (-5.85%)            max   7.93ms (-4.78%)            med   7.81ms (-6.06%)            avg   7.82ms (-5.89%)            stddev    36us (+114.87%)     
QueryTimestampGreater (MemOnly, EncryptionOn):      min   7.82ms (-5.51%)            max   7.96ms (-4.28%)            med   7.91ms (-4.66%)            avg   7.91ms (-4.62%)            stddev    37us (+224.19%)     
QueryTimestampGreater (Full   , EncryptionOff):     min   7.81ms (-5.74%)            max   7.85ms (-7.33%)            med   7.83ms (-6.54%)            avg   7.83ms (-6.71%)            stddev    11us (-86.54%)      
QueryTimestampGreater (Full   , EncryptionOn):      min   7.82ms (-5.70%)            max   7.89ms (-5.45%)            med   7.84ms (-5.65%)            avg   7.84ms (-5.61%)            stddev    18us (+13.93%)      

QueryTimestampGreaterEqual (MemOnly, EncryptionOff):     min   7.64ms (-8.30%)            max   7.73ms (-8.67%)            med   7.64ms (-8.33%)            avg   7.65ms (-8.34%)            stddev    26us (-32.48%)      
QueryTimestampGreaterEqual (MemOnly, EncryptionOn):      min   7.64ms (-8.19%)            max   7.75ms (-7.53%)            med   7.66ms (-8.06%)            avg   7.68ms (-7.94%)            stddev    40us (+94.54%)      
QueryTimestampGreaterEqual (Full   , EncryptionOff):     min   7.62ms (-9.13%)            max   7.69ms (-11.20%)           med   7.63ms (-10.79%)           avg   7.64ms (-10.22%)           stddev    19us (-82.88%)      
QueryTimestampGreaterEqual (Full   , EncryptionOn):      min   7.64ms (-8.00%)            max   7.69ms (-8.91%)            med   7.66ms (-8.61%)            avg   7.66ms (-8.47%)            stddev    14us (-66.94%)      

QueryTimestampLess (MemOnly, EncryptionOff):             min   7.66ms (-9.38%)            max   7.72ms (-8.82%)            med   7.69ms (-9.16%)            avg   7.68ms (-9.18%)            stddev    20us (+241.73%)     
QueryTimestampLess (MemOnly, EncryptionOn):              min   7.70ms (-9.25%)            max   7.73ms (-9.73%)            med   7.72ms (-9.70%)            avg   7.71ms (-9.56%)            stddev    10us (-58.71%)      
QueryTimestampLess (Full   , EncryptionOff):             min   7.68ms (-9.22%)            max   7.76ms (-8.68%)            med   7.71ms (-9.02%)            avg   7.70ms (-9.08%)            stddev    27us (+53.37%)      
QueryTimestampLess (Full   , EncryptionOn):              min   7.68ms (-9.26%)            max   7.75ms (-8.65%)            med   7.70ms (-9.12%)            avg   7.70ms (-9.08%)            stddev    26us (+168.02%)     

QueryTimestampLessEqual (MemOnly, EncryptionOff):        min   7.73ms (-6.85%)            max   7.78ms (-6.50%)            med   7.75ms (-6.63%)            avg   7.75ms (-6.68%)            stddev    19us (+120.61%)     
QueryTimestampLessEqual (MemOnly, EncryptionOn):         min   7.74ms (-6.98%)            max   7.78ms (-7.23%)            med   7.76ms (-6.98%)            avg   7.76ms (-7.01%)            stddev    16us (-17.55%)      
QueryTimestampLessEqual (Full   , EncryptionOff):        min   7.73ms (-6.92%)            max   7.81ms (-7.99%)            med   7.75ms (-8.06%)            avg   7.75ms (-7.82%)            stddev    23us (-66.96%)      
QueryTimestampLessEqual (Full   , EncryptionOn):         min   7.75ms (-7.05%)            max   7.84ms (-6.63%)            med   7.79ms (-6.75%)            avg   7.79ms (-6.79%)            stddev    33us (+75.85%)      

QueryTimestampEqual (MemOnly, EncryptionOff):            min    882us (-40.98%)           max    938us (-38.51%)           med    884us (-40.94%)           avg    885us (-40.93%)           stddev     6us (+0.78%)       
QueryTimestampEqual (MemOnly, EncryptionOn):             min    893us (-40.74%)           max    900us (-43.82%)           med    895us (-40.79%)           avg    895us (-41.29%)           stddev     2us (-93.73%)      
QueryTimestampEqual (Full   , EncryptionOff):            min    882us (-40.99%)           max    967us (-39.88%)           med    884us (-41.10%)           avg    887us (-41.56%)           stddev    11us (-63.36%)      
QueryTimestampEqual (Full   , EncryptionOn):             min    894us (-40.69%)           max    934us (-42.52%)           med    895us (-42.43%)           avg    897us (-42.03%)           stddev     5us (-82.14%)      

QueryTimestampNotEqual (MemOnly, EncryptionOff):         min  13.43ms (-54.78%)           max  13.59ms (-54.49%)           med  13.54ms (-54.55%)           avg  13.50ms (-54.67%)           stddev    59us (+19.57%)      
QueryTimestampNotEqual (MemOnly, EncryptionOn):          min  13.44ms (-54.89%)           max  13.58ms (-54.56%)           med  13.54ms (-54.61%)           avg  13.50ms (-54.73%)           stddev    56us (+73.53%)      
QueryTimestampNotEqual (Full   , EncryptionOff):         min  13.39ms (-55.16%)           max  13.54ms (-55.09%)           med  13.52ms (-54.81%)           avg  13.47ms (-55.01%)           stddev    64us (-25.45%)      
QueryTimestampNotEqual (Full   , EncryptionOn):          min  13.47ms (-55.60%)           max  13.64ms (-56.20%)           med  13.60ms (-56.09%)           avg  13.56ms (-56.07%)           stddev    68us (-70.62%)      

QueryTimestampNotNull (MemOnly, EncryptionOff):          min  14.25ms (-5.77%)            max  14.31ms (-8.73%)            med  14.30ms (-5.77%)            avg  14.28ms (-6.17%)            stddev    28us (-83.88%)      
QueryTimestampNotNull (MemOnly, EncryptionOn):           min  14.19ms (-5.96%)            max  14.28ms (-7.43%)            med  14.24ms (-6.14%)            avg  14.23ms (-6.28%)            stddev    31us (-75.08%)      
QueryTimestampNotNull (Full   , EncryptionOff):          min  14.23ms (-5.67%)            max  14.30ms (-6.65%)            med  14.26ms (-5.80%)            avg  14.26ms (-5.86%)            stddev    26us (-65.96%)      
QueryTimestampNotNull (Full   , EncryptionOn):           min  14.20ms (-6.02%)            max  14.29ms (-5.86%)            med  14.27ms (-5.82%)            avg  14.26ms (-5.88%)            stddev    26us (+14.03%)      

QueryTimestampEqualNull (MemOnly, EncryptionOff):        min   3.87ms (-9.52%)            max   3.90ms (-9.52%)            med   3.88ms (-9.34%)            avg   3.88ms (-9.38%)            stddev     8us (-6.84%)       
QueryTimestampEqualNull (MemOnly, EncryptionOn):         min   3.87ms (-9.61%)            max   3.90ms (-9.13%)            med   3.89ms (-9.51%)            avg   3.89ms (-9.51%)            stddev     7us (+139.19%)     
QueryTimestampEqualNull (Full   , EncryptionOff):        min   3.87ms (-9.65%)            max   3.90ms (-9.42%)            med   3.88ms (-9.31%)            avg   3.88ms (-9.40%)            stddev    10us (+90.95%)      
QueryTimestampEqualNull (Full   , EncryptionOn):         min   3.88ms (-9.66%)            max   3.90ms (-10.66%)           med   3.89ms (-9.46%)            avg   3.89ms (-9.60%)            stddev     7us (-59.88%)      

@jedelbo jedelbo force-pushed the js/timestamp-query-equality branch from 20b8ee8 to ed9e86a Compare August 16, 2019 08:50
@jedelbo jedelbo force-pushed the js/timestamp-query-equality branch from f1222a5 to c289987 Compare August 16, 2019 11:15
@jedelbo jedelbo requested a review from finnschiermer August 16, 2019 11:25
@jedelbo jedelbo merged commit 08fd373 into master Aug 16, 2019
@jedelbo jedelbo deleted the js/timestamp-query-equality branch August 16, 2019 11:42
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants