-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
refactor: change some hashbrown
RawTable
uses to HashTable
(round 2)
#13524
Conversation
@@ -216,18 +216,18 @@ impl GroupValues for GroupValuesRows { | |||
} | |||
std::mem::swap(&mut new_group_values, &mut group_values); | |||
|
|||
// SAFETY: self.map outlives iterator and is not modified concurrently |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Picking this one, but this pattern occurs multiple times:
That SAFETY
statement is just plain wrong: while iterating over the map, we erase elements from it. That is THE prime example for "concurrent modification of containers" and why Rust's lifetimes/reference system prevents that. I'm kinda surprised that this hasn't exploded yet.
The test failure (full logs here):
Is the order of |
It isn't / shouldn't be AFAIK |
Test was fixed in #13547 |
Changes look good, can we run some benchmark? |
8d3ca50
to
655bb3d
Compare
I will run benchmarks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for working on this @crepererum 🙏 and for the review @Dandandan
My benchmark run show no significant difference in my measurements
--------------------
Benchmark clickbench_1.json
--------------------
┏━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓
┃ Query ┃ main_base ┃ crepererum_issue13256_b ┃ Change ┃
┡━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩
│ QQuery 0 │ 0.69ms │ 0.70ms │ no change │
│ QQuery 1 │ 74.34ms │ 74.80ms │ no change │
│ QQuery 2 │ 128.56ms │ 129.12ms │ no change │
│ QQuery 3 │ 137.65ms │ 137.99ms │ no change │
│ QQuery 4 │ 983.51ms │ 1008.79ms │ no change │
│ QQuery 5 │ 1077.25ms │ 1092.78ms │ no change │
│ QQuery 6 │ 66.04ms │ 66.01ms │ no change │
│ QQuery 7 │ 84.05ms │ 81.62ms │ no change │
│ QQuery 8 │ 1055.63ms │ 1088.56ms │ no change │
│ QQuery 9 │ 1389.05ms │ 1366.73ms │ no change │
│ QQuery 10 │ 315.62ms │ 315.54ms │ no change │
│ QQuery 11 │ 350.14ms │ 349.13ms │ no change │
│ QQuery 12 │ 1085.67ms │ 1104.52ms │ no change │
│ QQuery 13 │ 1559.67ms │ 1529.49ms │ no change │
│ QQuery 14 │ 1013.55ms │ 1037.34ms │ no change │
│ QQuery 15 │ 1131.21ms │ 1137.18ms │ no change │
│ QQuery 16 │ 2108.99ms │ 2146.87ms │ no change │
│ QQuery 17 │ 1927.83ms │ 2000.34ms │ no change │
│ QQuery 18 │ 4072.99ms │ 4220.87ms │ no change │
│ QQuery 19 │ 125.13ms │ 125.87ms │ no change │
│ QQuery 20 │ 1384.71ms │ 1351.71ms │ no change │
│ QQuery 21 │ 1725.11ms │ 1731.10ms │ no change │
│ QQuery 22 │ 4297.71ms │ 4219.14ms │ no change │
│ QQuery 23 │ 10051.68ms │ 9978.79ms │ no change │
│ QQuery 24 │ 676.04ms │ 662.25ms │ no change │
│ QQuery 25 │ 592.05ms │ 579.24ms │ no change │
│ QQuery 26 │ 750.21ms │ 740.54ms │ no change │
│ QQuery 27 │ 2085.26ms │ 2066.92ms │ no change │
│ QQuery 28 │ 13592.24ms │ 13758.34ms │ no change │
│ QQuery 29 │ 589.33ms │ 575.83ms │ no change │
│ QQuery 30 │ 1058.22ms │ 1072.75ms │ no change │
│ QQuery 31 │ 1116.99ms │ 1123.70ms │ no change │
│ QQuery 32 │ 3966.33ms │ 3958.08ms │ no change │
│ QQuery 33 │ 4118.32ms │ 4251.35ms │ no change │
│ QQuery 34 │ 4127.26ms │ 4284.10ms │ no change │
│ QQuery 35 │ 1335.66ms │ 1401.46ms │ no change │
│ QQuery 36 │ 279.13ms │ 280.80ms │ no change │
│ QQuery 37 │ 179.19ms │ 191.29ms │ 1.07x slower │
│ QQuery 38 │ 189.74ms │ 188.54ms │ no change │
│ QQuery 39 │ 507.36ms │ 496.50ms │ no change │
│ QQuery 40 │ 86.52ms │ 86.86ms │ no change │
│ QQuery 41 │ 82.57ms │ 78.23ms │ +1.06x faster │
│ QQuery 42 │ 96.37ms │ 93.43ms │ no change │
└──────────────┴────────────┴─────────────────────────┴───────────────┘
--------------------
Benchmark clickbench_extended.json
--------------------
┏━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┓
┃ Query ┃ main_base ┃ crepererum_issue13256_b ┃ Change ┃
┡━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━┩
│ QQuery 0 │ 2616.05ms │ 2656.28ms │ no change │
│ QQuery 1 │ 768.66ms │ 759.74ms │ no change │
│ QQuery 2 │ 1520.15ms │ 1525.95ms │ no change │
│ QQuery 3 │ 736.90ms │ 716.34ms │ no change │
│ QQuery 4 │ 12290.21ms │ 12253.70ms │ no change │
│ QQuery 5 │ 18882.98ms │ 19339.49ms │ no change │
└──────────────┴────────────┴─────────────────────────┴───────────┘
--------------------
Benchmark clickbench_partitioned.json
--------------------
┏━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┓
┃ Query ┃ main_base ┃ crepererum_issue13256_b ┃ Change ┃
┡━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━┩
│ QQuery 0 │ 2.27ms │ 2.31ms │ no change │
│ QQuery 1 │ 40.86ms │ 42.68ms │ no change │
│ QQuery 2 │ 99.41ms │ 101.10ms │ no change │
│ QQuery 3 │ 105.82ms │ 107.33ms │ no change │
│ QQuery 4 │ 912.48ms │ 932.39ms │ no change │
│ QQuery 5 │ 932.55ms │ 946.37ms │ no change │
│ QQuery 6 │ 35.68ms │ 36.18ms │ no change │
│ QQuery 7 │ 44.92ms │ 45.18ms │ no change │
│ QQuery 8 │ 992.36ms │ 1047.04ms │ 1.06x slower │
│ QQuery 9 │ 1332.22ms │ 1352.60ms │ no change │
│ QQuery 10 │ 286.57ms │ 291.61ms │ no change │
│ QQuery 11 │ 329.27ms │ 325.90ms │ no change │
│ QQuery 12 │ 977.72ms │ 964.00ms │ no change │
│ QQuery 13 │ 1433.26ms │ 1455.66ms │ no change │
│ QQuery 14 │ 871.22ms │ 883.98ms │ no change │
│ QQuery 15 │ 1118.00ms │ 1084.07ms │ no change │
│ QQuery 16 │ 1985.56ms │ 1997.37ms │ no change │
│ QQuery 17 │ 1808.17ms │ 1837.13ms │ no change │
│ QQuery 18 │ 3932.35ms │ 4008.86ms │ no change │
│ QQuery 19 │ 93.24ms │ 96.37ms │ no change │
│ QQuery 20 │ 1247.59ms │ 1233.37ms │ no change │
│ QQuery 21 │ 1487.30ms │ 1467.18ms │ no change │
│ QQuery 22 │ 2625.24ms │ 2635.53ms │ no change │
│ QQuery 23 │ 8641.57ms │ 8514.93ms │ no change │
│ QQuery 24 │ 518.85ms │ 497.01ms │ no change │
│ QQuery 25 │ 424.50ms │ 422.18ms │ no change │
│ QQuery 26 │ 578.49ms │ 572.19ms │ no change │
│ QQuery 27 │ 1827.42ms │ 1830.38ms │ no change │
│ QQuery 28 │ 12999.73ms │ 13048.48ms │ no change │
│ QQuery 29 │ 525.24ms │ 534.30ms │ no change │
│ QQuery 30 │ 891.65ms │ 901.06ms │ no change │
│ QQuery 31 │ 939.15ms │ 955.63ms │ no change │
│ QQuery 32 │ 3878.81ms │ 3787.85ms │ no change │
│ QQuery 33 │ 3892.96ms │ 3955.76ms │ no change │
│ QQuery 34 │ 3901.67ms │ 3960.14ms │ no change │
│ QQuery 35 │ 1282.81ms │ 1317.85ms │ no change │
│ QQuery 36 │ 229.45ms │ 236.91ms │ no change │
│ QQuery 37 │ 95.41ms │ 94.21ms │ no change │
│ QQuery 38 │ 130.10ms │ 132.25ms │ no change │
│ QQuery 39 │ 432.79ms │ 443.89ms │ no change │
│ QQuery 40 │ 58.16ms │ 56.40ms │ no change │
│ QQuery 41 │ 47.15ms │ 48.55ms │ no change │
│ QQuery 42 │ 62.84ms │ 65.08ms │ no change │
└──────────────┴────────────┴─────────────────────────┴──────────────┘
--------------------
Benchmark tpch_sf1.json
--------------------
┏━━━━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓
┃ Query ┃ main_base ┃ crepererum_issue13256_b ┃ Change ┃
┡━━━━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩
│ QQuery 1 │ 228.38ms │ 227.79ms │ no change │
│ QQuery 2 │ 112.54ms │ 115.45ms │ no change │
│ QQuery 3 │ 127.05ms │ 126.53ms │ no change │
│ QQuery 4 │ 80.58ms │ 82.23ms │ no change │
│ QQuery 5 │ 162.71ms │ 160.40ms │ no change │
│ QQuery 6 │ 42.19ms │ 58.91ms │ 1.40x slower │
│ QQuery 7 │ 210.22ms │ 206.61ms │ no change │
│ QQuery 8 │ 162.94ms │ 152.35ms │ +1.07x faster │
│ QQuery 9 │ 230.90ms │ 244.31ms │ 1.06x slower │
│ QQuery 10 │ 212.76ms │ 205.23ms │ no change │
│ QQuery 11 │ 96.69ms │ 95.20ms │ no change │
│ QQuery 12 │ 111.59ms │ 115.83ms │ no change │
│ QQuery 13 │ 207.61ms │ 208.17ms │ no change │
│ QQuery 14 │ 72.29ms │ 71.52ms │ no change │
│ QQuery 15 │ 121.95ms │ 126.59ms │ no change │
│ QQuery 16 │ 72.63ms │ 69.59ms │ no change │
│ QQuery 17 │ 221.69ms │ 215.65ms │ no change │
│ QQuery 18 │ 350.26ms │ 298.38ms │ +1.17x faster │
│ QQuery 19 │ 114.20ms │ 112.13ms │ no change │
│ QQuery 20 │ 125.56ms │ 132.27ms │ 1.05x slower │
│ QQuery 21 │ 259.30ms │ 263.83ms │ no change │
│ QQuery 22 │ 64.92ms │ 69.56ms │ 1.07x slower │
└──────────────┴───────────┴─────────────────────────┴───────────────┘
if let Some(remaining) = group_index.checked_sub(n) { | ||
self.emit_group_index_list_buffer.push(remaining); | ||
} | ||
self.map.retain(|(_exist_hash, group_idx_view)| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯 for removing the unsafe
thanks for the reviews and tests 🙂 |
This seems quite big, is this reproducible? |
FYI @alamb |
I'll re-run In general, I found the timing accuracy of my test machine (GCP VM) is not great for <100ms queries. |
Hm, that's interesting! The results are not super reliable for me but mostly the noise is in the 5-7% range (running locally). |
Here is my next run (this time it seems to be faster)
|
It's as if it pingpongs between two machine "versions". |
I found no real changes:
|
Which issue does this PR close?
For #13433, but only parts of it.
Rationale for this change
Prepare
hashbrown
0.15 upgrade.What changes are included in this PR?
HashTableAllocExt
Are these changes tested?
Existing tests pass.
Are there any user-facing changes?
No.