Our heap profiles say that we're using a HUGE amount of storage for RSA onion keys. That's pretty sad, considering that we only use them for legacy v2 hidden service stuff.
Maybe we can only parse them on-demand, when we need them?
Maybe (if the openssl format is much more expensive than the raw asn1) we can store them in asn1, and only convert them to EVP_PKEY objects when we need them?
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Child items ...
Show closed items
Linked items 0
Link issues together to show that they're related.
Learn more.
I can confirm that there's a blow-up here -- I ran an experiment with openssl to see how much space it uses to store an RSA that it has loaded from an ASN1 string.
The asn.1 string was 140 bytes long. OpenSSL allocated a total of 408 bytes in order to hold the RSA object and its lock, not counting the malloc headers. (It grabbed one RSA object, one lock, 2 BIGNUM objects, and 2 bitvectors inside the BIGNUMs.)
In experimental context: we used 5.9MB out of 24.7MB total for storing crypto_pk_t and its contents. If we can cut that down by a factor of (140/408), we'll save 3.9 MB, or 15% of our total memory used -- not counting the malloc overhead!
Nice! I expect that the memory savings will be even better than expected in the commit message, since the "408 vs 140" calculation doesn't include malloc overhead.
I suggested a few small changes on the ticket, and found (what I think is) one real bug.
Question: Have you tested this for memory leaks? I didn't see any, but that would be the kind of bug I'd want to watch out for here.
Nice! I expect that the memory savings will be even better than expected in the commit message, since the "408 vs 140" calculation doesn't include malloc overhead.
I suggested a few small changes on the ticket, and found (what I think is) one real bug.
Question: Have you tested this for memory leaks? I didn't see any, but that would be the kind of bug I'd want to watch out for here.
I have not run this under valgrind but no leaks occur in the test. There are a LOT of code path in the unit tests that touches the md/ri and I know because I had a leak during development and noticed very quickly.