Repository navigation
SwiftQUIC: PERF: Create a reusable buffer to run xor operations - #242
agnosticdev wants to merge 3 commits into
Conversation
|
The original objective of this code was to compose a bit string only for the packets that are in flight, so the total number of packets doesn't matter, what matters is the packets in flight. The second objective was to be able to swap bit strings in a non costly (i.e., non copying) way. In a language like C, the array wouldn't be recreated at all and it would be a simple pointer swap. Is there an existing data structure in Swift that would do this? |
What I am doing here is very similar to a pointer swap because Recovery creates the reference type and then its passed in and used by reference in AckBitstringIterator and AckBitstringSequence. So multiple instances are not being created. Its using the original one the key state for Recovery is holding. |
Today when xor operation are run in Recovery to find acked packets AckBitstringSequence will create a fresh array each time to compute words.
When there are many packets in-flight this gets really expensive. This change creates a re-usable buffer called AckBitstringXORBuffer that avoids creating that array each time.
So I am using a class here because AckBitstringSequence needs to conform to Sequence and in those cases having a struct or a non-copyable struct does not work.
I did not see a CPU impact due to the addition of the class in Recovery.
The memory impact here is we save 101k for QUICTransfer running 1000 iterations.
The more packets the more the savings will be!
So this:
Now becomes:
Here is the CPU usage: