-
Notifications
You must be signed in to change notification settings - Fork 2
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
Better serialization of binary values and singletons #844
Conversation
Guys, sorry for changing this PR almost entirely. I added a custom serialization that brought the performance back and even gained a bit more. The current benchmarking results are the following Communication: Stats for party Identity("bob"):
Rounds: 53
Bytes sent: 845
Bytes received: 875
Stats for party Identity("charlie"):
Rounds: 53
Bytes sent: 862
Bytes received: 832
Stats for party Identity("alice"):
Rounds: 53
Bytes sent: 845
Bytes received: 845 Running time (in comparison to the one above): gr_ready_made_hnsw/gr-big-hnsw-insertions/1
time: [2.0494 ms 2.0767 ms 2.1024 ms]
gr_ready_made_hnsw/gr-big-hnsw-searches/1
time: [3.0304 ms 3.0676 ms 3.0967 ms]
gr_ready_made_hnsw/gr-big-hnsw-insertions/10
time: [74.011 ms 74.983 ms 76.775 ms]
gr_ready_made_hnsw/gr-big-hnsw-searches/10
time: [45.616 ms 46.257 ms 47.247 ms]
gr_ready_made_hnsw/gr-big-hnsw-insertions/100
time: [1.0943 s 1.1229 s 1.1492 s]
change: [-25.943% -23.699% -21.898%] (p = 0.00 < 0.05)
gr_ready_made_hnsw/gr-big-hnsw-searches/100
time: [662.72 ms 687.23 ms 712.31 ms]
change: [-26.357% -23.826% -20.564%] (p = 0.00 < 0.05)
gr_ready_made_hnsw/gr-big-hnsw-insertions/1000
time: [2.9798 s 3.0148 s 3.0564 s]
change: [-25.662% -24.840% -23.886%] (p = 0.00 < 0.05)
gr_ready_made_hnsw/gr-big-hnsw-searches/1000
time: [1.8064 s 1.8388 s 1.8704 s]
change: [-22.091% -20.095% -18.120%] (p = 0.00 < 0.05)
gr_ready_made_hnsw/gr-big-hnsw-insertions/10000
time: [5.6744 s 5.7518 s 5.8269 s]
change: [-23.766% -22.686% -21.621%] (p = 0.00 < 0.05)
gr_ready_made_hnsw/gr-big-hnsw-searches/10000
time: [3.0832 s 3.1271 s 3.1760 s]
change: [-25.487% -24.297% -23.200%] (p = 0.00 < 0.05)
gr_ready_made_hnsw/gr-big-hnsw-insertions/100000
time: [6.7998 s 6.8641 s 6.9288 s]
change: [-26.099% -24.969% -23.805%] (p = 0.00 < 0.05)
gr_ready_made_hnsw/gr-big-hnsw-searches/100000
time: [3.4343 s 3.5064 s 3.5838 s]
change: [-31.274% -29.707% -27.821%] (p = 0.00 < 0.05) |
nice, have a few more suggestions that might help a bit more with perf |
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.
Nice! See minor comments, but looks good to me if Daniel has finished suggesting optimizations.
@@ -18,20 +17,250 @@ pub enum NetworkValue { | |||
} | |||
|
|||
impl NetworkValue { | |||
fn get_descriptor_byte(&self) -> u8 { | |||
match self { | |||
NetworkValue::PrfKey(_) => 0x01, |
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.
Do these descriptor bytes start at 1 because the network byte stream looks for 0 to indicate EOF or something similar?
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 was thinking to leave it for some special message, e.g., "abort"
Instead of sending single values as
VecRingT
, we serialize them as individual elements. This is especially beneficial when doing bitwise comparisons, where sending a single bit required 5 bytes of serialized data. This change reduces it to 2. For u64, the size is reduced from 20 to 10 bytes.In addition, this PR replaces
bincode
withbitcode
, which is about 15% more compact for theNetworkValue
enum. The total gain is about 37%.Communication cost per party to insert 1 vector into a database of size 1 (i.e., one call to
eval_distance
and one call toless_than
) is given below.Before:
After:
bitcode
is slower thanbincode
, which is reflected in a 5-25% increase in running time for both insertion and search.