Maybe make relay_digest_matches() not use tor_malloc()
relay_digest_matches() is used in
relay_crypt() and it is called for a huge portion of cells that come through the relay.
Roughly speaking, if a relay is at 10MB/s and with cells of size 514 bytes, we are talking about a bit less than 20k cells per second meaning more than a million
tor_malloc(20) per minute. This is the place:
backup_digest = crypto_digest_dup(digest);
I think we should find a way to avoid this especially in the fast path of tor in order to avoid memory fragmentation as much as possible.
We could either use the stack, a static value or
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information