-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#12011 Speed up small TLS writes #12090
#12011 Speed up small TLS writes #12090
Conversation
…f-cpu' into 12011-performance-issue-in-tls-assert-that-each-written-chunk-of-a-data-is-not-a-str
…sue-in-tls-assert-that-each-written-chunk-of-a-data-is-not-a-str
Hi Itamar, Thanks for looking into this. Is this PR ready for review? Regards |
Yes, it's ready for review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Thanks. Only minor comments.
# This is kinda ugly, but speeds things up a lot in a hot path with | ||
# lots of small TLS writes. May become unnecessary in Python 3.13 or | ||
# later if JIT and/or inlining becomes a thing. | ||
self.write = self._aggregator.write # type: ignore[method-assign] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not pretty, but I think is the best option.
I think that, in the end, having the _AggregateSmallWrites
code using composition is nicer.
@@ -687,25 +687,6 @@ def connectionMade(self): | |||
|
|||
return self.writeBeforeHandshakeTest(SimpleSendingProtocol, data) | |||
|
|||
def test_writeUnicodeRaisesTypeError(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe leave this test as a reminder that passing bytes should never be supported again.
But I am also ok to have this removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is it doesn't fail in a useful way now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the important part is to make sure that it fails... in any way. Rather than ending up with a case in which the data is ignored... or something like that.
So even if the error is not explicit. I think that it still important to make sure that it fails.
The previous explicit error was a huge help for my in the past... but I am ok to have something less helful, in the name of performance.
I hope in the future mypy can help here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK I restored the test.
Co-authored-by: Adi Roiban <adiroiban@gmail.com>
…ssert-that-each-written-chunk-of-a-data-is-not-a-str' into 12011-performance-issue-in-tls-assert-that-each-written-chunk-of-a-data-is-not-a-str
…each-written-chunk-of-a-data-is-not-a-str
for more information, see https://pre-commit.ci
Fixes #12011.
Benchmark results with Python 3.11:
trunk
:This branch:
Benchmark: