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

Split Sargon-OS crate #332

Merged
merged 16 commits into from
Jan 7, 2025
Merged

Split Sargon-OS crate #332

merged 16 commits into from
Jan 7, 2025

Conversation

CyonAlexRDX
Copy link
Contributor

@CyonAlexRDX CyonAlexRDX commented Jan 6, 2025

Note

target branch is not main

New crates:

  • app/signing-traits (split out from app/signing)
  • app/key-derivation-traits (split out from factors/keys-collector)
  • system/interactors - which depends on two previous, but NOT on app/signing / factors/keys-collector for max build speed
  • system/sub-system
  • system/profile-state-holder
  • system/os/os
  • system/os/factors
  • system/os/accounts
  • system/os/signing
  • system/os/transaction
  • system/os/security-center

Removed sargon from default-members

sargon crate is now essentially just an "umbrella crate" for re-exports, which Uniffi uses.
We should remove it once we start splitting the UniFFI crate.

Measurements / Speedups

Here are some stats. The results are great! With biggest speedup measured being 8.5x for some files for some operations!


-------------------------------
-------------------------------
echo "pub fn delete_this_fn() -> u8 { 0 }" | tee -a FILE >/dev/null && cargo check
-------------------------------
-------------------------------

>>> common_error.rs
`main`
10.96
`ac/split-sargon-os`
6.06s
🌈 2️⃣x speedup 🚀🚀

>>> profile.rs
`main`
9.96s
`ac/split-sargon-os`
3.31s
🌈 3️⃣x speedup 🚀🚀🚀

>>> profile_state_holder.rs
`main`
10.00s
`ac/split-sargon-os`
1.74s
🌈 6️⃣x speedup 🚀🚀🚀🚀🚀🚀

>>> sargon_os_transaction_submit.rs
`main`
9.98s
`ac/split-sargon-os`
1.18s
🌈 8️⃣x speedup 🚀🚀🚀🚀🚀🚀🚀🚀


======================
echo "pub fn delete_this_fn() -> u8 { 0 }" | tee -a FILE >/dev/null && cargo nextest run -- signing::valid
=====================
>>> profile_state_holder.rs
`main`
20.54s
`ac/split-sargon-os`
6.52s
🌈 3️⃣x speedup 🚀🚀🚀

>>> sargon_os_transaction_submit
`main`
18.50s
`ac/split-sargon-os`
4.32s
🌈 4️⃣x speedup 🚀🚀🚀🚀

>>> common_error.rs
`main`
18.42
`ac/split-sargon-os`
16.45s
✅ 15% speedup 👍







======================
// unit test inside common_error.rs
echo "pub fn delete_this_fn() -> u8 { 0 }" | tee -a FILE >/dev/null && cargo nextest run -- is_not_safe_to_show_error_message
=====================
>>> common_error.rs
`main`
18.19s
`ac/split-sargon-os`
2.65
🌈 7️⃣x speedup 🚀🚀🚀🚀🚀🚀🚀




===================
💡 Edit `profile.rs` in `sargon` module (`profile` **crate** on "ac/split" branch)
➡️ `cargo test` a single function in profile module (**crate** on "ac/split" branch)
======================
// 
echo "pub fn delete_this_fn() -> u8 { 0 }" | tee -a profie.rs >/dev/null && cargo nextest run -- check_if_profile_json_contains_legacy_p2p_links_when_empty_json_str
=====================
`main`
18.65s
`ac/split-sargon-os`
2.44s
🌈 8️⃣x speedup 🚀🚀🚀🚀🚀🚀🚀🚀



===================
💡 Edit `sargon/system/os/sargon_os` module (**crate** on "ac/split" branch)
➡️ `cargo check` it
===================
$ echo "pub fn delete_this_fn() -> u8 { 0 }" | tee -a crates/system/os/os/src/sargon_os.rs > /dev/null && cargo check
===========
`main`
12.01s
`ac/split-sargon-os`
1.76s
🌈 7️⃣x speedup 🚀🚀🚀🚀🚀🚀🚀



===================
💡 Edit `sargon/system/os/sargon_os` module (**crate** on "ac/split" branch)
➡️ `cargo build` `sargon-uniffi`
===================
$ echo "pub fn delete_this_fn() -> u8 { 0 }" | tee -a crates/system/os/os/src/sargon_os.rs > /dev/null && cargo build -p sargon-uniffi
===========
`main`
14.98s
`ac/split-sargon-os`
15.49s <-- MINOR degradation. But once we split Uniffi crate we will reap the rewards of Sargon being split.




===================
💡 Edit `sargon/system/os/sargon_os` module  (**crate** on "ac/split" branch)
➡️ `cargo test` `sargon-uniffi`
===================
$ echo "pub fn delete_this_fn() -> u8 { 0 }" | tee -a crates/system/os/os/src/sargon_os.rs > /dev/null && cargo test --package sargon-uniffi --lib --all-features -- hierarchical_deterministic::bip32::unsecurified_hardened::tests::test_new_unsecurified_hardened_from_global_key_space_overflow --exact
===========
`main`
17.11s
`ac/split-sargon-os`
14.5s
✅ 15% speedup 👍



=============
💡 Edit `sargon-uniffi` src 
➡️ `cargo check` `sargon-uniffi`
=============
$ echo "pub fn delet2e142_sthis_fn() -> u8 { 0 }" | tee -a crates/sargon-uniffi/src/system/sargon_os/sargon_os.rs > /dev/null && cargo check -p sargon-uniffi
==========
`main`
6.33s
`ac/split-sargon-os`
6.86s <-- MINOR degradation. But once we split Uniffi crate we will reap the rewards of Sargon being split.



=====
💡 Cargo clean 
➡️ `cargo build` `sargon-uniffi`
=====
cargo clean && cargo build -p sargon-uniffi
====

`main`
1m 49s
`ac/split-sargon-os`
1m 48s <--- Same

@CyonAlexRDX CyonAlexRDX marked this pull request as ready for review January 6, 2025 18:53
@CyonAlexRDX CyonAlexRDX changed the title Ac/split sargon os Split Sargon-OS crate Jan 6, 2025
@radixdlt radixdlt deleted a comment from Sajjon Jan 6, 2025
Copy link

codecov bot commented Jan 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.2%. Comparing base (ed1ea7e) to head (9661fd3).
Report is 1 commits behind head on ac/split.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           ac/split    #332     +/-   ##
==========================================
- Coverage      92.2%   92.2%   -0.1%     
==========================================
  Files          1143    1143             
  Lines         25775   25773      -2     
  Branches         79      79             
==========================================
- Hits          23781   23779      -2     
  Misses         1979    1979             
  Partials         15      15             
Flag Coverage Δ
kotlin 97.1% <ø> (ø)
swift 93.4% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...ctor_of_instances_required_to_sign_transactions.rs 70.5% <ø> (ø)
crates/common/short-string/src/email_address.rs 100.0% <ø> (ø)
crates/sargon_SPLIT_ME/src/lib.rs 100.0% <ø> (ø)
..._SPLIT_ME/src/test_diagnose_instance_duplicates.rs 100.0% <ø> (ø)

... and 58 files with indirect coverage changes

Copy link
Contributor

@GhenadieVP GhenadieVP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing work!

A bit unfortunate that we do have to declare lots of OS related traits, but it is what it is.

@CyonAlexRDX CyonAlexRDX merged commit 16162d6 into ac/split Jan 7, 2025
11 of 13 checks passed
@CyonAlexRDX CyonAlexRDX deleted the ac/split-sargon-os branch January 7, 2025 18:13
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.

4 participants