This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Experimental Federation Speedup #9702
Experimental Federation Speedup #9702
Changes from 13 commits
588631f
5ea99b1
79a5fd9
a30d979
027a574
daa9712
831ceda
2506f63
73e2c78
44fcea4
30e3338
fbfcadb
fc7e650
16c39da
621d637
632be5c
43f9e28
dc6730a
ad796a3
e7e6c67
9165cb5
bbf52d5
7a33b4c
a89cd8e
4551879
95ceb32
5703cd0
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
small warning: if we change this
[]
comprehension into a generator (()
), python will start throwing errors about async iterators, because to work with an async iterator/generator in a sub-comprehension, you have to prefix everyfor
withasync for
.I had split it before i realised it didn't solve the problem, and then i set this small generator to
[]
, which fixed it, but kept the split.This'll be a small memory tradeoff for readability, as this'd create a list of
len(events)
, but then the surrounding generator will filter out allNone
values, which will have itself take up no space until it is consumed by the dict comprehensionso this is a
len(events)
list ofOptional[Tuple[Eventbase, Collection[str]]
, then comprehended down intoDict[EventBase, Collection[str]]
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.
This is actually fairly cheap, the memory for
EventBase
is already allocated, and it being an object, it's simply referenced.Each list takes
64
bytes up-front*, and then8
bytes with each pointer, this means that for the absolute worst-case scenario (100 events destined for#matrix
, with around 2k servers), it'll be about1728000
bytes (2000 * (64 + (8*100))
),1.7
Mb, excluding memory use for destination strings (which are immutably referenced) anddict
internals for mapping.(sending 1 event to 2000 servers that way is
144000
bytes, 144kb, btw)(* the
64
bytes is the up-front cost for a python list, python's objects are quite large that way. That number is for python 3.6, and in python 3.7 they're72
bytes, but in python 3.8 they're58
bytes. Lists use C pointers, which are8
bytes each.)