-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
Add ChaCha and Salsa intrinsics. #128
base: master
Are you sure you want to change the base?
Add ChaCha and Salsa intrinsics. #128
Conversation
This reverts commit cbf3778.
Codecov Report
@@ Coverage Diff @@
## master #128 +/- ##
===========================================
- Coverage 99.78% 89.02% -10.76%
===========================================
Files 14 26 +12
Lines 455 1421 +966
Branches 57 97 +40
===========================================
+ Hits 454 1265 +811
- Misses 1 146 +145
- Partials 0 10 +10
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Thanks for the contribution and for adding Salsa20 intrinsics too! There's also XSalsa20 over there but I haven't promoted those to stable since I felt it needed more tests. The target was to also support XSalsa20Poly1305. Regarding testing of intrinsics turned on and off, yes, it was something around Btw, do you have some benchmark numbers you can share to see the perf increase? I might need to take a look at why the Azure CI failed with Windows only. |
I've split Intrinsics up by chunk size and altered
I'll take a look, I've never used env variables in unit tests before, hopefully Google will help.
My numbers are from some benchmarks I did yesterday. Sorry about the quality, my laptops about to die 😅 SalsaChaCha |
Sounds good, thanks a lot for the effort you are putting into this.
If you run the benchmarks from Powershell or cmd via
Thanks for sharing those, the numbers look nice :) |
@TimothyMakkison my apologies for the late follow-up, it has been hectic over here. Thanks a ton for pulling this big task off, I added a few comments to the PR; most of them are minor stuff. I also noticed a PowerShell script but I didn't see it being called from DevOps, is it something you intended to do? The build defined in this project uses Cake, we could set the environment variable in there afaik; I will need to investigate further into that. Perhaps we can use that and just define tests that should be running with specific environment variables without the need to update the GitHub actions. Last but not least, I wonder if you could work on the coverage a little bit more since we dropped quite a lot with this PR, you can check codecov from above. |
Thanks for the review. I got sidetracked and forgot about this PR so it's unfinished.
Not sure what you mean by implicit, do you mean
Should I convert all the files in the solution to scoped namespaces?
Sorry I was using the benchmark code and powershell script for testing and forgot to remove them. I'll modify the cake file. Do you have an opinion on the refactor? The logic up to 202ff15 was fairly simple; the intrinsics code was added with pre processing and an IsSupported check. This has the advantage of not touching the api, keeping the code/code flow the same and adding minimal additional code and files. Commit 4d68791 separates the intrinsic and non intrinsic code from SalsaBase/ChaChaBase creating individual files for them, SalsaBase/ChaChaBase act as a facade calling the internal IChaChaCore interface for all methods. This has the disadvantage of adding a lot of code, altering a lot of code to keep the api the same, duplicating code and arguably being overly complex. I'll probably undo the refactor unless you prefer it, I thinks it's too complicated, harder to maintain, and isn't needed if the CI will test SIMD and non SIMD versions. Should also improve the code coverage and reduce duplication. |
No worries, I got a pile of work and also lost track about your PRs, sorry about that!
I think we can drop .NET 3 and just stick with the supported versions going forward. Supporting obsolete versions of .NET just adds a lot of maintainability headaches.
Yes, I mean adding to those the
I would opt to have consistency in all files whenever we can.
No worries, it was just a question since I didn't know the purpose of it, you could leave that one if you want.
Yeah, I agree with that. It added a lot of maintainability complexity, if we limit the scope of the supported .NET versions we can stick with the first logic you proposed. |
…ed more comments.
The "refactor" was added to make the code testable, with the CI and cake file this thankfully isn't needed. This pr is compatible with all the different versoins of .NET it just requires a couple of pre processor checks.
Do you think it would be worth getting someone who knows intrinsics to double check this? This was my first time using intrinisics/unsafe code in this way. |
…d the cake file and added more comments.
…/NaCl.Core into merge_intrinsics
Yeah, sounds great!
That would be nice but I really don't know anyone from my side. :/ |
I had the cunning idea of submitting a pr to the bouncycastle project. Give them a performance bump for large cipherstreams and have another set of eyes look at the implementations. Once I get a grasp of |
Added @macaba intrinsics implementation #58 for ChaCha20. Salsa20 has since been added to NaCl, so I created
Salsa20BaseIntrinsics
based on macaba's work. At minimum both got a 4x speed up.VariableLengthCiphers
tests, to ensure that the intrinsics methods work when using length specific methods.This pr will require a way of testing with and without intrinsics, I'm not sure how to do this but I think
COMPlus_EnableAVX
is related?A future update could speed up
ProcessKeyStreamblock
by using theProcessStream
method.