perf: make cloning SessionState faster by sharing most state behind an Arc - #24560
Conversation
|
@alamb could you start the |
SessionState faster by sharing must state behind an ArcSessionState faster by sharing most state behind an Arc
|
@jonathanc-n I hope it's ok that I've submitted a PR for this even though you're assigned. Happy to hear your feedback! |
SessionState faster by sharing most state behind an ArcSessionState faster by sharing most state behind an Arc
|
run benchmark sql_planner |
|
🤖 Benchmark running (GKE) | trigger CPU Details (lscpu)Comparing planner-perf-1 (d6dd73f) to f1f0449 (merge-base) diff Run configurationrun benchmark sql_plannerResults will be posted here when complete File an issue against this benchmark runner |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #24560 +/- ##
==========================================
+ Coverage 81.27% 81.34% +0.07%
==========================================
Files 1116 1117 +1
Lines 395017 397501 +2484
Branches 395017 397501 +2484
==========================================
+ Hits 321055 323363 +2308
- Misses 55166 55223 +57
- Partials 18796 18915 +119 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
🤖 Benchmark completed (GKE) | trigger Instance: Comparing planner-perf-1 (d6dd73f) to f1f0449 (merge-base) diff Run configurationrun benchmark sql_plannerCPU Details (lscpu)Details
Resource Usagesql_planner — base (merge-base)
sql_planner — branch
File an issue against this benchmark runner |
|
Nice, looks like some substantial wins |
|
run benchmark sql_planner |
|
🤖 Benchmark running (GKE) | trigger CPU Details (lscpu)Comparing planner-perf-1 (d6dd73f) to f1f0449 (merge-base) diff Run configurationrun benchmark sql_plannerResults will be posted here when complete File an issue against this benchmark runner |
|
🤖 Benchmark completed (GKE) | trigger Instance: Comparing planner-perf-1 (d6dd73f) to f1f0449 (merge-base) diff Run configurationrun benchmark sql_plannerCPU Details (lscpu)Details
Resource Usagesql_planner — base (merge-base)
sql_planner — branch
File an issue against this benchmark runner |
|
Amazing 🚀 ! |
|
Thank you @tschwarzinger and @Dandandan |
| /// [`SessionContext::state`]. | ||
| /// | ||
| /// [`SessionContext::state`]: crate::execution::context::SessionContext::state | ||
| execution_props: ExecutionProps, |
Which issue does this PR close?
Rationale for this change
Improve planner performance. See (#20495)
The solution I came up with is a bit different to the one discussed in the issue. Instead of avoiding cloning
SessionStatewe just make it cheap to clone it by wrapping most of the state in anArc. Cloning is only necessary when mutating the inner session state, if we're not the sole reference (Arc::make_mutas dicussed in the issue).I initially tried to wrap the entire
SessionStatein an Arc but we still need copying if we're not the only reference, asexecution_propsare changed for each query.What changes are included in this PR?
SessionStateInnerout of the session state and share it behind anArc<SessionStateInner>Are these changes tested?
Yes with existing tests
Are there any user-facing changes?
No, except faster performance