Use mypyc to compile websocket reader - #13559
Dreamsorcerer wants to merge 19 commits into
Conversation
Merging this PR will degrade performance by 21.8%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ❌ | test_read_one_hundred_masked_large_binary_websocket_messages |
60.2 ms | 86.2 ms | -30.24% |
| ❌ | test_read_and_drain_one_hundred_websocket_text_messages |
1.1 ms | 1.3 ms | -12.34% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing mypyc (876981a) with master (deab032)
Footnotes
-
83 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
|
| # cannot be relied on anywhere. Cost: the reader and its buffers | ||
| # are reclaimed by full GC passes, not refcounting. Never break | ||
| # this cycle manually; remove when the mypyc issue is resolved. | ||
| self._gc_cycle = self |
There was a problem hiding this comment.
This is resulting in GBs of memory use, while removing it is resulting in numerous segfaults. Do not merge until this is fixed.
|
Does mypyc also have a coveragepy plugin like Cython? |
I don't think so, but it's literally the same code now, as it's just compiling the Python code. So we already have coverage from that. |
|
If we get to fully converting to mypyc, then I think the only part we'd need to worry about coverage is on the main HTTP parser, as that'd be separate code that uses llhttp. |
|
I'm not so sure — once that code's in a C-extension, it'll start getting optimized on the compiler level and there will be fewer guarantees that it's getting executed. So we'll need to make sure to execute exactly the same tests against both implementations at all times (otherwise, the metrics would be unreliable). |
I'm not sure I follow. The compiler would optimise out parts of C-level code, it'd not give us any real change at the Python level as that'd just be instrumented calls which would always be called.
We already do this. Again, the only discrepancies we need to worry about is the llhttp vs pure Python HTTP parser. But, before we could even consider that, mypyc needs to do native optimisations of ctypes calls. |
No description provided.