Skip to content

Bump curve25519 test (do not merge) #2683

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

Closed

Conversation

samkim-crypto
Copy link

Experimental PR to test CI on curve25519-dalek upgrade.

@samkim-crypto samkim-crypto marked this pull request as draft August 21, 2024 09:10
@samkim-crypto samkim-crypto force-pushed the bump-curve25519-test branch 3 times, most recently from d1ec56f to fa9163b Compare August 22, 2024 08:27
@samkim-crypto
Copy link
Author

Sorry for the delay on this, but here is what I have found about the curve25519-dalek crate v4 slow-down:

  • The slow down only occurs for the simd backend. It seems that with dalek-v3, the serial backend is chosen as default (hence no slow-down) while with dalek-v4, the simd backend is chosen as default (hence slowdown). If we override the default to the serial backend for dalek-v4, the slow-down does not occur.
  • The simd slow-down occurs only in debug mode. If we actually test with release builds, then the dalek-v4 (or more precisely the simd backend) is actually ~30% faster.

We will generally always build with release mode for deployed code, so I think it is safe to make the upgrade to dalek-v4 (and it will actually be faster by ~30%). In the meanwhile, I will dig into the specific debug_assertions that may be causing the slow-down.

The question is how we should satisfy the CI tests. One option is to have the following line in .cargo/config.toml:

[target.'cfg(debug_assertions)']
rustflags = ['--cfg=curve25519_dalek_backend="serial"']

But .cargo is part of gitignore and it will not be ideal to add .cargo/config.toml to the repo. One option is to write .cargo/config.toml during the execution of downstream-project-spl-common.sh as is done in fa9163b above. We can see that the downstream CI now passes.

Wdyt @yihau @ilya-bobyr?

@yihau
Copy link
Member

yihau commented Aug 23, 2024

I think removing it from gitignore or writing it in the runtime are both work for me.

I’m just curious, which part got slow? iirc we encountered a POH record timeout. do we have any idea why the transaction execution time increase?

@samkim-crypto
Copy link
Author

Transaction execution times do not increase with release build. It should actually be faster.

The transaction execution in tests increases because there the code is run in debug mode. It seems like there are a bunch of expensive debug_asserts that should be optimized away in release builds.

@samkim-crypto samkim-crypto force-pushed the bump-curve25519-test branch 4 times, most recently from 3ea5ef0 to 589e98a Compare August 30, 2024 02:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants