Ensure shard config option is actually configurable, #5061
Ensure shard config option is actually configurable, #5061ian-r-rose wants to merge 3 commits intodask:mainfrom
Conversation
defaults are only evaluated once.
jrbourbeau
left a comment
There was a problem hiding this comment.
Thanks @ian-r-rose! I left a couple of small comments, but overall this looks good 👍
|
|
||
| from ..utils import nbytes | ||
|
|
||
| BIG_BYTES_SHARD_SIZE = dask.utils.parse_bytes(dask.config.get("distributed.comm.shard")) |
There was a problem hiding this comment.
It looks like we need to inline this elsewhere. We're getting
E ImportError: cannot import name 'BIG_BYTES_SHARD_SIZE' from 'distributed.protocol.utils' (/home/runner/work/distributed/distributed/distributed/protocol/utils.py)in CI
|
|
||
|
|
||
| def test_frame_split_is_configurable(): | ||
| frame = b"1234abcd" * (2 ** 20) # 8 MiB |
There was a problem hiding this comment.
Can we add a small assert here to ensure/confirm that frame is 8 MiB?
In [1]: frame = b"1234abcd" * (2 ** 20) # 8 MiB
In [2]: from dask.utils import parse_bytes
In [3]: from dask.sizeof import sizeof
In [4]: assert sizeof(frame) == parse_bytes("8 MiB")There was a problem hiding this comment.
Sure, happy to do that. I sort of figured that the test itself functioned as an assert (3*3 ~ 8 and 2*5 ~ 8), but an assertion is more explicit
| >>> frame_split_size([b'12345', b'678'], n=3) # doctest: +SKIP | ||
| [b'123', b'45', b'678'] | ||
| """ | ||
| n = n or dask.utils.parse_bytes(dask.config.get("distributed.comm.shard")) |
There was a problem hiding this comment.
This happens several times on every message sent. There may be thousands of messages per second. It may be worth considering performance here
In [1]: import dask, distributed
In [2]: %timeit dask.utils.parse_bytes(dask.config.get("distributed.comm.shard"))
2.2 µs ± 8.69 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)
In [3]: %timeit dask.config.get("distributed.comm.shard") # maybe we choose to add an lru cache on parse_bytes
755 ns ± 4.08 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)This makes me slightly nervous
There was a problem hiding this comment.
To solve our immediate pain my preference would be something like #5052
There was a problem hiding this comment.
Hmm, that's a good point. Perhaps we can read the config somewhat higher in the stack and pass it down to the protocol machinery
There was a problem hiding this comment.
Passing down the shard size is also done in the linked PR.
Doing this per-message would be good, and probably reduce the pain by 4x or so. It's still at a level that we might want to avoid though.
This just isn't that common of a use case. I don't think that people are likely to be dynamically changing shard size. I think that we want to set a conservative default for websockets, and then use environment variables / config options stored in yaml for other cases.
There was a problem hiding this comment.
That's fair. I agree it's not a common use-case, and it's not worth incurring the performance hit.
The semi-configurability of the shard size did cause me some pain today when I was testing some things, and for a while was running in circles trying to figure out why the config changes wasn't taking effect.
|
Yeah, understood. I was slightly anticipating that when I pushed up the
other PR. I should have pinged you on that earlier.
…On Wed, Jul 14, 2021 at 10:53 AM Ian Rose ***@***.***> wrote:
Closed #5061 <#5061>.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#5061 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACKZTFMGFNOSNBVFODU2ULTXXFJDANCNFSM5AL3CGPA>
.
|
Supersedes #5052 . In addition to making the default websocket maximum-frame-size smaller, this makes the specific value configurable. It's somewhat redundant with distributed.comm.shard, but the constraints on websockets are sufficiently different that a separate config seems okay. This does not implement the fix in #5061, as that would read a config value for every frame, which is costly. So the config value will in general not be changed after import time.
Since function defaults are only evaluated once, this isn't actually configurable after
distributedis imported.black distributed/flake8 distributed/isort distributed