Skip to content

Add create_datagram_endpoint api - #52

Merged
tarasko merged 53 commits into
masterfrom
create_datagram_endpoint
Jul 26, 2026
Merged

Add create_datagram_endpoint api#52
tarasko merged 53 commits into
masterfrom
create_datagram_endpoint

Conversation

@tarasko

@tarasko tarasko commented Jul 21, 2026

Copy link
Copy Markdown
Owner

No description provided.

@codspeed-hq

codspeed-hq Bot commented Jul 21, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 40 untouched benchmarks


Comparing create_datagram_endpoint (bdc00fc) with master (389e0f9)

Open in CodSpeed

@tarasko

tarasko commented Jul 22, 2026

Copy link
Copy Markdown
Owner Author

@codspeedbot explain why this is faster

@codspeed-hq

codspeed-hq Bot commented Jul 22, 2026

Copy link
Copy Markdown

@codspeedbot explain why this is faster

Why test_benchmark_sendfile[tcp-large] is ~10.5% faster

I compared the flame graphs of the two runs behind the report (HEAD 11566a2 vs master ebd3b00). Here's what's actually driving the 3.1 ms → 2.8 ms change.

1. The write / sendfile path was refactored in this PR

The improvement is concentrated in the sendfile submission path, wrapped by __Pyx_PyObject_FastCallDict.constprop.1 (called from SocketTransport._try_sendfile):

Metric BASE (ebd3b00) HEAD (11566a2)
Self time 175.1 µs 104.9 µs
Total time 313.7 µs 188.5 µs
Self-time cache misses 30.7 µs 18.6 µs

This lines up with the transport rewrite in the diff: SocketTransport was split into a SocketTransportBase, the write/watermark logic was reorganized (_maybe_pause_protocol / _ensure_writer / _drop_writer inlined helpers), and notably the large inline aiofn_iovec _iovecs[256] array was removed from the transport struct. Shrinking that per-transport structure improves data-cache locality, which shows up as the drop in cache-miss time above.

2. The event loop did slightly less work

The uv__io_poll__on_uvpoll_event path dropped from 1.4 ms (45%) to 1.1 ms (40%), with one fewer poll event (4 → 3) and one fewer protocol callback cycle (14 → 15 vs the base's counts). So part of the win is simply a marginally different number of loop iterations to move the same data.

3. Not everything changed — and an important caveat

The dominant cost, __memset_avx2_unaligned_erms (~13% self time, from protocol/loop __init__), is essentially flat (390 µs → 387 µs), as are the pure-Python protocol callbacks buffer_updated and get_buffer. So the source changes explain the improvement in the write path specifically, not a wholesale speedup.

⚠️ CodSpeed also flagged that the base and head ran in different runtime environments — the transport, ssl_transport, and utils shared libraries have different build IDs. In Simulation mode the cache model is derived from the runner's CPU, so a different toolchain/runner can shift the estimate on identical source. This means some fraction of the reported +10.51% is attributable to that environment difference rather than your code, and the exact percentage should be read with that in mind.

Bottom line: the real, code-attributable win is the leaner transport struct (better cache locality in the sendfile path) plus slightly fewer event-loop iterations; the headline number is somewhat inflated by a cross-environment comparison.

Summary
  • Warming up the performance wizard...
  • Handling comment — Comment handling finished successfully

Was this response helpful? React with 👍 or 👎 to help us improve CodSpeedBot.

@tarasko
tarasko merged commit c108d42 into master Jul 26, 2026
37 checks passed
@tarasko
tarasko deleted the create_datagram_endpoint branch July 26, 2026 02:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant