-
Notifications
You must be signed in to change notification settings - Fork 596
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
Every AES encrypt/decrypt call is doing a heap allocation/free #47
Comments
Actually, it's doing multiple allocations. I checked in a custom allocator that will put them into an arena. It made the CBC encryption about 10% faster on a Ubuntu VM I'm using. We'll see what numbers @tycho comes up with for AES-GCM, on the allocation sizes we care about most. If it's not a decent win, maybe back it out or make it an option? Still, regardless of the numbers, it really bothers me to be making multiple heap calls per packet! Maybe the heap is fast nowadays and I'm just a dinosaur. |
^ For reference: 17c52cb |
The numbers are in! I am a dinosaur. I'll back out that "optimization". Closing this. |
I think the perf diff would depend on the heap implementation. Most modern implementations use a thread-local small allocation pool. |
FWIW Unreal isn't doing anything special around |
Unreal uses jmalloc for the whole engine though. |
This "optimization" did not make a significant enough improvement to warant the complexity. I belileve the real solution is to elevate the concept of a context to our Crypto API layer, and stop throwing around raw keys. Issue #47.
This just wraps whatever context is needed by the crypto provider. It should allow me to avoid paying the setup costs for each packet. (Issue #47) This should not only be a nice (small) optimization, it wil make it easier to support bcrypt (Issue #45). We should update the perf tests to do encrypt/decrypt a bunch of buffers using the same cipher parameters, using these objects, since this models our use case in this networking library. Next step is to use this in the CSteamNetworkConnectionBase, instead of storing raw keys.
Re-opening this issue. Just so I can officially close it for really realz. |
Because EVP_CIPHER_CTX.
Holy crap.
We should find a way to not do this.
Anybody know a (simple, portable) way to avoid this?
The text was updated successfully, but these errors were encountered: