pydevd_comm.py start_client() does not set TCP_NODELAY on the connections it opens
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- python
- Domain
- devtools, networking
Research direction
Start in 3rdparty/debugpy/DEBUGPY/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_comm.py at start_client(), and inspect how the socket is configured before the connection is opened. Confirm the connection used by debugpy --connect enables TCP_NODELAY and preserves the existing fallback behavior when the option is unavailable. Done means the source and an established connection reflect the expected setting.
Written by the indexing model from the issue text.
Description
Environment data
- debugpy version: 1.8.20
- OS and version: Linux and MacOS
- Python version (& distribution if applicable, e.g. Anaconda): 3.11 and later
- Using VS Code or Visual Studio: No
Actual behavior
TCP_NODELAY is not set on the connections debugpy opens
Expected behavior
TCP_NODELAY is set on the connections debugpy opens
Steps to reproduce:
A connection established with debugpy --connect does not set TCP_NODELAY on the socket connection, which can cause latency when sending responses and events. This is can be verified simply by inspecting the pydevd_comm.py source code, or by using external tools to inspect the connection once it has been established.
We patched our copy of debugpy 1.8.20 as follows:
% diff --git a/3rdparty/debugpy/DEBUGPY/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_comm.py b/3rdparty/debugpy/DEBUGPY/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_comm.py
index 64ac454f29..812bf59eb0 100644
--- a/3rdparty/debugpy/DEBUGPY/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_comm.py
+++ b/3rdparty/debugpy/DEBUGPY/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_comm.py
@@ -524,6 +524,15 @@ def start_client(host, port):
except (AttributeError, OSError):
pass # May not be available everywhere.
+ try:
+ # TVT-46072: "Missing TCP_NODELAY on debugpy's DAP tracer connection
+ # causes Nagle-induced latency in Python debugging". Disable Nagle's
+ # algorithm so small DAP messages are sent immediately instead of
+ # being buffered, reducing round-trip latency.
+ s.setsockopt(socket_module.IPPROTO_TCP, socket_module.TCP_NODELAY, 1)
+ except (AttributeError, OSError):
+ pass # May not be available everywhere.
+
try:
# 10 seconds default timeout
timeout = int(os.environ.get("PYDEVD_CONNECT_TIMEOUT", 10))
%
- Dominant language
- Python
- Stars
- 2.5k
- Forks
- 202
- Avg merge
- 5d 1h
- Merged PRs (30d)
- 1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/debugpy
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 45/100
All issues in microsoft/debugpy
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
use-agent-os/agent-os#3314 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
BasedHardware/omi#15662 · 1 comment ·
-
documentation help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
AiursoftWeb/AnduinOS-2#19 ·