perf: small optimization for already closed done chan in xcotenxt.WithDone#2171
perf: small optimization for already closed done chan in xcotenxt.WithDone#2171asmyasnikov wants to merge 10 commits into
Conversation
summaryInferred base version: v3.139.6 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2171 +/- ##
==========================================
- Coverage 75.64% 75.59% -0.05%
==========================================
Files 437 437
Lines 45030 45047 +17
==========================================
- Hits 34063 34055 -8
- Misses 9019 9039 +20
- Partials 1948 1953 +5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR optimizes internal/xcontext.WithDone() for the case where the provided done channel is already closed, avoiding creation of a cancelable child context and associated AfterFunc setup.
Changes:
- Added a lightweight
doneAlreadySignaledCtxfast-path that returns an already-done context whendoneis closed. - Introduced a package-level pre-closed
Done()channel and a no-op cancel func for the fast-path. - Added benchmarks for
WithDoneto measure the closed/open channel cases.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| internal/xcontext/done.go | Adds a fast-path context wrapper + shared closed channel to reduce allocations when done is already closed. |
| internal/xcontext/done_test.go | Adds benchmarks for WithDone performance/allocations across scenarios. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Agent-Logs-Url: https://github.com/ydb-platform/ydb-go-sdk/sessions/75555471-87c8-4085-b271-485b514ea94d Co-authored-by: asmyasnikov <14202262+asmyasnikov@users.noreply.github.com>
…al double-close Agent-Logs-Url: https://github.com/ydb-platform/ydb-go-sdk/sessions/87d0f664-4bc2-45ed-a0f1-a408829b77a7 Co-authored-by: asmyasnikov <14202262+asmyasnikov@users.noreply.github.com>
Agent-Logs-Url: https://github.com/ydb-platform/ydb-go-sdk/sessions/5ba4693b-3d6f-4686-af23-8d2eb86d013c Co-authored-by: asmyasnikov <14202262+asmyasnikov@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Agent-Logs-Url: https://github.com/ydb-platform/ydb-go-sdk/sessions/c1654250-ea69-47bc-aea6-fc94b5275605 Co-authored-by: asmyasnikov <14202262+asmyasnikov@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Agent-Logs-Url: https://github.com/ydb-platform/ydb-go-sdk/sessions/cbb5b62f-cc66-4b68-bc94-274821075b51 Co-authored-by: asmyasnikov <14202262+asmyasnikov@users.noreply.github.com>
Agent-Logs-Url: https://github.com/ydb-platform/ydb-go-sdk/sessions/cbb5b62f-cc66-4b68-bc94-274821075b51 Co-authored-by: asmyasnikov <14202262+asmyasnikov@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
🌋 SLO Test Results🟡 8 workload(s) tested — 2 workload(s) exceeded warning thresholds
Threshold violations: database-sql-query:
native-table:
Generated by ydb-slo-action |
Pull request type
Please check the type of change your PR introduces:
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Other information