Closed rbakhshi closed 6 months ago
Is it as slow at the hash function? The verify call is just a hash call with the existing salt and a time safe comparison of the resulting string
Correct, I traced it and the loop where it calls 'Key' functions seems to be the slow part. Which makes some sense as it runs for the number of rounds
but 3 second was a big jump from previous versions of .net
Are the times from running it in Windows or on a phone? Not really looked at maui with the usual msft-ui lasting 12 months before being killed off 😆
Average release build speed using the nuget package is 400ms for me
Thanks @ChrisMcKee for checking this on your side. Let me go back and dig a bit deeper to see what could be causing this. probably come up with the simplest possible scenario.
Will get back to you. Thanks again
All right, a couple of updates:
I will raise the second point to Xamarin/macios project. Thanks for looking at it. I guess this now close
Cool. Not looked at how it plays in aot; I've found dotnets idea of AOT a bit hit and miss. Thanks for the update. 👍
@rbakhshi Your issues regarding discrepancies between Debug and Release builds for iOS could be linked to this issue: https://github.com/dotnet/maui/issues/13019
hey @durandt that is what are doing right now but that means verify
method on bcrypt algorithm takes 2-4 seconds to run!
I am actually looking to run it in release mode to gain the optimum performance. I have raised a related issue here if you are interested: https://github.com/dotnet/runtime/issues/99248
Summary of what is wrong
Verify
method seems to take much longer in .net 8 using Android MAUI app.Details
We used same code on .NET5 and 6 and the time for
Verify
was negligible.Since porting our project to .NET8 I noticed login process takes much longer and narrowed it down to calling
Verify
method taking 3 seconds!Example code
Calling the above function with
111111
and hashed value of$2a$12$luf9xtzcPijRzyMnb1PxsuqFUsBba0ve.R.5k00XOsGf2awcHwj8a
takes 3 seconds. This is what I got from logs: