-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Replaced GAIResolver with twisted.names.client for the default resolver #5053
Conversation
bd0ce97
to
834290c
Compare
@Benjamin-L Hi, thanks for the patch! I'm going to hold off on merging this for two reasons:
As such, I would like if this was put behind a configuration option, so people can opt into it instead. |
That seems pretty reasonable. Amusingly, I ended up discovering that exact issue when trying to debug the sytest failures, but didn't find anything on the issue tracker for it. It's good to know it's already known. Another thing that I've found out since submitting this is that whether or not Putting this behind a config option seems like a good choice. I'm going to try to implement that and add a new commit. I'll call the option |
Codecov Report
@@ Coverage Diff @@
## develop #5053 +/- ##
===========================================
- Coverage 61.57% 61.56% -0.01%
===========================================
Files 332 332
Lines 34265 34267 +2
Branches 5648 5648
===========================================
+ Hits 21097 21098 +1
- Misses 11654 11655 +1
Partials 1514 1514 |
Codecov Report
@@ Coverage Diff @@
## develop #5053 +/- ##
===========================================
- Coverage 62.15% 61.56% -0.59%
===========================================
Files 336 332 -4
Lines 34659 34269 -390
Branches 5694 5649 -45
===========================================
- Hits 21541 21099 -442
- Misses 11583 11656 +73
+ Partials 1535 1514 -21 |
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.
+1 to what erik said. Please could you rename the option.
Also looks like a conflict has crept in - please could you merge in latest develop?
Otherwise this looks good to me.
ca00a32
to
c0aff07
Compare
I've pushed the renamed option, as well as adding it to the default config. Do you want me to squash the commits? |
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.
Thanks again for this. No need to squash the commits (we can do that when we merge the PR), but please take a look at the comments below.
I have a concern, however:
I note that the CI is failing (which is partly because the condition at https://github.com/matrix-org/synapse/pull/5053/files#diff-80846f8c47b65e25b3c6716a3eb1bbc8R135 is reversed, so that the option is being used when it shouldn't, but even so: I wouldn't expect the integration tests to fail).
It looks like, when we switch to twisted.names.client
, outbound requests to https://localhost:port
are only made to the IPv6 version of localhost (::1
), and it seems that sytest is only listening on IPv4. My expectation would be that we would attempt to connect to both IPv4 and IPv6. @hawkowl: is this the manifestation of twisted #9627?
@@ -46,6 +46,12 @@ pid_file: DATADIR/homeserver.pid | |||
# | |||
#cpu_affinity: 0xFFFFFFFF | |||
|
|||
# Whether to use the default system resolver (getaddrinfo) instead of the twisted |
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.
note that this is a generated file (the script to update it is scripts-dev/generate-sample-config
). Please could you update the source for it (in synapse/config/server.py
) and then run the script to update the sample config?
# asynchronous dns resolver. Using the async resolver can potentially improve | ||
# performance, but may also behave different from getaddrinfo. | ||
# Defaults to True. Uncomment to use the twisted resolver instead. | ||
#use_getaddrinfo_for_dns: False |
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.
while you're changing the source, please could you add a line with just #
between the text and the option, for consistency with the rest of the file.
@@ -0,0 +1 @@ | |||
Replace blocking getaddrinfo hostname resolver with the non-blocking resolver from twisted.names.client. |
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.
Replace blocking getaddrinfo hostname resolver with the non-blocking resolver from twisted.names.client. | |
Add an option to replace the blocking `getaddrinfo` hostname resolver with the non-blocking resolver from `twisted.names.client`. |
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.
(could call this a feature
rather than a misc
?)
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.
Also, feel free to add yourself as a contributor here, along the lines of the other entries in CHANGES.md.
@@ -127,6 +131,10 @@ def run(): | |||
change_resource_limit(soft_file_limit) | |||
if gc_thresholds: | |||
gc.set_threshold(*gc_thresholds) | |||
|
|||
if use_getaddrinfo_for_dns: |
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.
surely this condition is reversed?
@Benjamin-L any chance of taking another look at this? |
I'm going to assume this is abandoned. Please reopen it if not! |
I profiled synapse for a relatively small homeserver that is in several large rooms, and found that a huge chunk of time was being taken up by calls to
getaddrinfo
:It turns out that twisted defaults to using
twisted.internet._resolver.GAIResolver
for resolving hostnames. This is implemented with blockinggetaddrinfo
calls on a thread pool, but python appears to not allow running concurrentgetaddrinfo
anyway. This pull request replaces the default relsover withtwisted.names.client
, which is a user space non-blocking resolver.Signed-off-by: Benjamin Lee [email protected]
Pull Request Checklist