Skip to content
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

Massive performance disparity for Keystore between SPM and XCProject #535

Closed
mloit opened this issue Apr 19, 2022 · 2 comments
Closed

Massive performance disparity for Keystore between SPM and XCProject #535

mloit opened this issue Apr 19, 2022 · 2 comments

Comments

@mloit
Copy link
Contributor

mloit commented Apr 19, 2022

This has been on my todo list for a while to look into, though my concentration has been primarily on EIP-1559 support until now. Just posting this issue as a note that I am trying to chase this issue down.

There is a massive difference in performance/execution time for the Keystore tests depending on if you build the project in XCode using SPM (package.swift) or as a native XCode Project (web3swift.xcodeproject/project.pbxproj)

When run as build for macOS on my machine I get the following execution times for the web3swiftKeystoreTests set
SPM: Executed 21 tests, with 0 failures (0 unexpected) in 385.086 (385.096) seconds
XCP: Executed 21 tests, with 0 failures (0 unexpected) in 8.492 (8.496) seconds

#532 inspired me to accelerate looking into this

@mloit
Copy link
Contributor Author

mloit commented Apr 19, 2022

I've been doing some digging on this. It looks like it may be related to #457, and an issue with Scrypt within CryptoSwift. It comes down to debug builds vs release builds resulting in massive differences in performance. I suspect the disparity in the test results is a result of The XCProject using pre-compiled versions of the libraries that were built in release mode, even though we are building ourselves in debug mode. While SPM always builds form source, so it will be building the external dependencies in the same mode as we are building ourselves. I'll need to create some sort of other external test to confirm this, as we cannot build for test in release mode.

ref: https://github.com/krzyzanowskim/CryptoSwift/issues/884

@mloit
Copy link
Contributor Author

mloit commented Apr 28, 2022

I can confirm that the issue lies between debug and release builds. I created a simple test app to create a private key.
The issue is also exclusively when building via SPM, as SPM builds everything from source, using the app's build settings. XCode projects include the libraries as frameworks, which are build in release mode, so even a debug app, does not see the same performance hit.

Debug Build/Run: 7.790989995002747
Release Build/Run: 0.10214793682098389

Unfortunately there is nothing we can do about this right now, and it's also not really an issue as it affects debugging only.

We can explore removing our dependence on CryptoSwift in 3.0.

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

No branches or pull requests

1 participant