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

make no_std into an optional feature on protocols crates #932

Merged
merged 1 commit into from
Aug 9, 2024

Conversation

plebhash
Copy link
Collaborator

@plebhash plebhash commented May 25, 2024

Many of the low level libs under protocols are no_std. That is great, since it allows for potential firmware integrations using rust-embedded and targets without MMUs (e.g.: Xtensa ESP32, ARM Cortex-M, etc).

Some projects in the community even have some potential to leverage SRI protocols crates for firmware integration, e.g.: https://github.com/bitaxeorg/esp-miner-rs

However, for most common deployment scenarios (e.g.: x86-64), high level application code (e.g.: roles) has no hard requirement for no_std. Also, having it as a mandatory feature becomes a blocker to many desirable changes.

Copy link
Contributor

github-actions bot commented May 25, 2024

🐰Bencher

ReportFri, August 9, 2024 at 00:54:02 UTC
ProjectStratum v2 (SRI)
Branchfeat-optional-no-std
Testbedsv2
Click to view all benchmark results
BenchmarkLatencyLatency Results
nanoseconds (ns) | (Δ%)
Latency Upper Boundary
nanoseconds (ns) | (%)
client_sv2_handle_message_common✅ (view plot)44.19 (-0.80%)45.24 (97.67%)
client_sv2_handle_message_mining✅ (view plot)79.27 (+8.61%)80.66 (98.28%)
client_sv2_mining_message_submit_standard✅ (view plot)14.67 (+0.14%)14.69 (99.87%)
client_sv2_mining_message_submit_standard_serialize✅ (view plot)263.60 (-0.34%)284.04 (92.80%)
client_sv2_mining_message_submit_standard_serialize_deserialize✅ (view plot)588.18 (-0.99%)627.39 (93.75%)
client_sv2_open_channel✅ (view plot)166.92 (+0.57%)173.41 (96.26%)
client_sv2_open_channel_serialize✅ (view plot)269.03 (-4.82%)293.98 (91.51%)
client_sv2_open_channel_serialize_deserialize✅ (view plot)373.37 (-1.43%)424.58 (87.94%)
client_sv2_setup_connection✅ (view plot)160.48 (-2.23%)174.85 (91.78%)
client_sv2_setup_connection_serialize✅ (view plot)485.41 (+2.42%)507.30 (95.69%)
client_sv2_setup_connection_serialize_deserialize✅ (view plot)976.45 (+0.51%)1,038.81 (94.00%)

Bencher - Continuous Benchmarking
View Public Perf Page
Docs | Repo | Chat | Help

Copy link
Contributor

github-actions bot commented May 25, 2024

🐰Bencher

ReportFri, August 9, 2024 at 00:54:07 UTC
ProjectStratum v2 (SRI)
Branch932/merge
Testbedsv1
Click to view all benchmark results
BenchmarkLatencyLatency Results
nanoseconds (ns) | (Δ%)
Latency Upper Boundary
nanoseconds (ns) | (%)
client-submit-serialize✅ (view plot)6,411.60 (-7.23%)7,379.42 (86.88%)
client-submit-serialize-deserialize✅ (view plot)7,439.40 (-5.07%)8,336.26 (89.24%)
client-submit-serialize-deserialize-handle/client-submit-serialize-deserialize-handle✅ (view plot)8,006.70 (-4.73%)8,850.33 (90.47%)
client-sv1-authorize-serialize-deserialize-handle/client-sv1-authorize-serialize-deserialize-handle✅ (view plot)904.83 (+0.69%)926.49 (97.66%)
client-sv1-authorize-serialize-deserialize/client-sv1-authorize-serialize-deserialize✅ (view plot)707.64 (+1.47%)718.30 (98.52%)
client-sv1-authorize-serialize/client-sv1-authorize-serialize✅ (view plot)245.93 (-0.85%)255.05 (96.42%)
client-sv1-get-authorize/client-sv1-get-authorize✅ (view plot)157.89 (+0.48%)162.39 (97.23%)
client-sv1-get-submit✅ (view plot)6,183.30 (-7.40%)7,163.26 (86.32%)
client-sv1-get-subscribe/client-sv1-get-subscribe✅ (view plot)285.24 (+2.24%)291.90 (97.72%)
client-sv1-subscribe-serialize-deserialize-handle/client-sv1-subscribe-serialize-deserialize-handle✅ (view plot)770.15 (+2.99%)777.66 (99.03%)
client-sv1-subscribe-serialize-deserialize/client-sv1-subscribe-serialize-deserialize✅ (view plot)617.06 (+0.42%)637.50 (96.79%)
client-sv1-subscribe-serialize/client-sv1-subscribe-serialize✅ (view plot)202.24 (-2.07%)219.76 (92.03%)

Bencher - Continuous Benchmarking
View Public Perf Page
Docs | Repo | Chat | Help

Copy link
Contributor

github-actions bot commented May 25, 2024

🐰Bencher

ReportFri, August 9, 2024 at 00:54:19 UTC
ProjectStratum v2 (SRI)
Branchfeat-optional-no-std
Testbedsv1

🚨 2 ALERTS: Threshold Boundary Limits exceeded!
BenchmarkMeasure (units)ViewValueLower BoundaryUpper Boundary
serialize_deserialize_authorizeRAM Accesses (accesses)🚨 (view plot | view alert)299.00 (+1.38%)298.03 (100.33%)
serialize_deserialize_handle_authorizeRAM Accesses (accesses)🚨 (view plot | view alert)369.00 (+1.38%)367.45 (100.42%)

Click to view all benchmark results
BenchmarkEstimated CyclesEstimated Cycles Results
estimated cycles | (Δ%)
Estimated Cycles Upper Boundary
estimated cycles | (%)
InstructionsInstructions Results
instructions | (Δ%)
Instructions Upper Boundary
instructions | (%)
L1 AccessesL1 Accesses Results
accesses | (Δ%)
L1 Accesses Upper Boundary
accesses | (%)
L2 AccessesL2 Accesses Results
accesses | (Δ%)
L2 Accesses Upper Boundary
accesses | (%)
RAM AccessesRAM Accesses Results
accesses | (Δ%)
RAM Accesses Upper Boundary
accesses | (%)
get_authorize✅ (view plot)8,538.00 (+1.19%)8,725.07 (97.86%)✅ (view plot)3,746.00 (+0.15%)3,854.74 (97.18%)✅ (view plot)5,248.00 (+0.06%)5,400.69 (97.17%)✅ (view plot)7.00 (-11.91%)10.38 (67.45%)✅ (view plot)93.00 (+3.25%)94.08 (98.85%)
get_submit✅ (view plot)95,509.00 (-0.05%)96,137.16 (99.35%)✅ (view plot)59,439.00 (-0.05%)59,776.31 (99.44%)✅ (view plot)85,359.00 (-0.05%)85,833.31 (99.45%)✅ (view plot)49.00 (-10.94%)62.56 (78.33%)✅ (view plot)283.00 (+0.32%)287.67 (98.38%)
get_subscribe✅ (view plot)7,991.00 (+0.18%)8,268.59 (96.64%)✅ (view plot)2,841.00 (+0.39%)2,939.32 (96.65%)✅ (view plot)3,971.00 (+0.43%)4,098.99 (96.88%)✅ (view plot)13.00 (-19.47%)19.80 (65.67%)✅ (view plot)113.00 (+0.33%)116.92 (96.65%)
serialize_authorize✅ (view plot)12,291.00 (+0.69%)12,502.77 (98.31%)✅ (view plot)5,317.00 (+0.10%)5,425.74 (98.00%)✅ (view plot)7,411.00 (+0.05%)7,564.04 (97.98%)✅ (view plot)10.00 (-7.44%)13.36 (74.84%)✅ (view plot)138.00 (+1.78%)140.26 (98.39%)
serialize_deserialize_authorize✅ (view plot)24,588.00 (+0.48%)24,710.40 (99.50%)✅ (view plot)9,898.00 (-0.02%)10,025.45 (98.73%)✅ (view plot)13,958.00 (-0.06%)14,149.89 (98.64%)✅ (view plot)33.00 (-9.68%)41.58 (79.37%)🚨 (view plot | view alert)299.00 (+1.38%)298.03 (100.33%)
serialize_deserialize_handle_authorize✅ (view plot)30,327.00 (+0.59%)30,350.93 (99.92%)✅ (view plot)12,101.00 (+0.05%)12,209.74 (99.11%)✅ (view plot)17,117.00 (-0.00%)17,279.04 (99.06%)✅ (view plot)59.00 (+0.33%)64.68 (91.22%)🚨 (view plot | view alert)369.00 (+1.38%)367.45 (100.42%)
serialize_deserialize_handle_submit✅ (view plot)126,372.00 (-0.03%)127,026.75 (99.48%)✅ (view plot)73,224.00 (-0.04%)73,617.68 (99.47%)✅ (view plot)104,947.00 (-0.04%)105,508.32 (99.47%)✅ (view plot)120.00 (-0.41%)131.20 (91.46%)✅ (view plot)595.00 (+0.03%)599.17 (99.30%)
serialize_deserialize_handle_subscribe✅ (view plot)27,491.00 (+0.13%)27,600.97 (99.60%)✅ (view plot)9,643.00 (+0.11%)9,741.32 (98.99%)✅ (view plot)13,641.00 (+0.13%)13,774.95 (99.03%)✅ (view plot)61.00 (-7.30%)73.78 (82.68%)✅ (view plot)387.00 (+0.31%)388.56 (99.60%)
serialize_deserialize_submit✅ (view plot)114,999.00 (-0.07%)115,648.79 (99.44%)✅ (view plot)68,001.00 (-0.08%)68,400.22 (99.42%)✅ (view plot)97,559.00 (-0.09%)98,146.90 (99.40%)✅ (view plot)65.00 (-6.28%)75.30 (86.32%)✅ (view plot)489.00 (+0.18%)492.37 (99.32%)
serialize_deserialize_subscribe✅ (view plot)22,922.00 (+0.20%)23,110.46 (99.18%)✅ (view plot)8,195.00 (+0.11%)8,297.00 (98.77%)✅ (view plot)11,542.00 (+0.11%)11,682.13 (98.80%)✅ (view plot)36.00 (-8.53%)44.05 (81.72%)✅ (view plot)320.00 (+0.46%)321.51 (99.53%)
serialize_submit✅ (view plot)99,826.00 (-0.07%)100,465.39 (99.36%)✅ (view plot)61,483.00 (-0.05%)61,825.66 (99.45%)✅ (view plot)88,206.00 (-0.05%)88,686.80 (99.46%)✅ (view plot)49.00 (-11.88%)62.33 (78.62%)✅ (view plot)325.00 (+0.10%)329.16 (98.74%)
serialize_subscribe✅ (view plot)11,328.00 (+0.02%)11,604.49 (97.62%)✅ (view plot)4,188.00 (+0.26%)4,286.32 (97.71%)✅ (view plot)5,828.00 (+0.27%)5,958.17 (97.82%)✅ (view plot)15.00 (-8.30%)18.95 (79.17%)✅ (view plot)155.00 (-0.13%)159.74 (97.03%)

Bencher - Continuous Benchmarking
View Public Perf Page
Docs | Repo | Chat | Help

Copy link
Contributor

github-actions bot commented May 25, 2024

🐰Bencher

ReportFri, August 9, 2024 at 00:54:05 UTC
ProjectStratum v2 (SRI)
Branchfeat-optional-no-std
Testbedsv2

🚨 9 ALERTS: Threshold Boundary Limits exceeded!
BenchmarkMeasure (units)ViewValueLower BoundaryUpper Boundary
client_sv2_handle_message_commonEstimated Cycles (estimated cycles)🚨 (view plot | view alert)2,153.00 (+4.87%)2,139.64 (100.62%)
client_sv2_handle_message_commonL2 Accesses (accesses)🚨 (view plot | view alert)12.00 (+68.37%)11.38 (105.49%)
client_sv2_handle_message_commonRAM Accesses (accesses)🚨 (view plot | view alert)39.00 (+6.19%)38.83 (100.44%)
client_sv2_mining_message_submit_standard_serialize_deserializeInstructions (instructions)🚨 (view plot | view alert)10,591.00 (+0.45%)10,572.33 (100.18%)
client_sv2_mining_message_submit_standard_serialize_deserializeL1 Accesses (accesses)🚨 (view plot | view alert)15,405.00 (+0.41%)15,380.13 (100.16%)
client_sv2_open_channel_serialize_deserializeInstructions (instructions)🚨 (view plot | view alert)8,027.00 (+0.52%)8,012.93 (100.18%)
client_sv2_open_channel_serialize_deserializeL1 Accesses (accesses)🚨 (view plot | view alert)11,676.00 (+0.51%)11,654.06 (100.19%)
client_sv2_setup_connection_serialize_deserializeInstructions (instructions)🚨 (view plot | view alert)14,855.00 (+0.29%)14,840.35 (100.10%)
client_sv2_setup_connection_serialize_deserializeL1 Accesses (accesses)🚨 (view plot | view alert)21,815.00 (+0.28%)21,791.21 (100.11%)

Click to view all benchmark results
BenchmarkEstimated CyclesEstimated Cycles Results
estimated cycles | (Δ%)
Estimated Cycles Upper Boundary
estimated cycles | (%)
InstructionsInstructions Results
instructions | (Δ%)
Instructions Upper Boundary
instructions | (%)
L1 AccessesL1 Accesses Results
accesses | (Δ%)
L1 Accesses Upper Boundary
accesses | (%)
L2 AccessesL2 Accesses Results
accesses | (Δ%)
L2 Accesses Upper Boundary
accesses | (%)
RAM AccessesRAM Accesses Results
accesses | (Δ%)
RAM Accesses Upper Boundary
accesses | (%)
client_sv2_handle_message_common🚨 (view plot | view alert)2,153.00 (+4.87%)2,139.64 (100.62%)✅ (view plot)473.00 (+0.48%)486.30 (97.27%)✅ (view plot)728.00 (-0.55%)754.92 (96.43%)🚨 (view plot | view alert)12.00 (+68.37%)11.38 (105.49%)🚨 (view plot | view alert)39.00 (+6.19%)38.83 (100.44%)
client_sv2_handle_message_mining✅ (view plot)8,213.00 (+0.19%)8,335.50 (98.53%)✅ (view plot)2,143.00 (+0.72%)2,171.70 (98.68%)✅ (view plot)3,168.00 (+0.72%)3,216.52 (98.49%)✅ (view plot)36.00 (-6.34%)43.56 (82.65%)✅ (view plot)139.00 (+0.10%)141.95 (97.92%)
client_sv2_mining_message_submit_standard✅ (view plot)6,340.00 (+0.99%)6,392.44 (99.18%)✅ (view plot)1,756.00 (+0.36%)1,763.52 (99.57%)✅ (view plot)2,555.00 (+0.04%)2,575.79 (99.19%)✅ (view plot)22.00 (+24.61%)23.03 (95.54%)✅ (view plot)105.00 (+1.09%)106.96 (98.17%)
client_sv2_mining_message_submit_standard_serialize✅ (view plot)14,821.00 (+0.30%)15,033.95 (98.58%)✅ (view plot)4,700.00 (+0.13%)4,707.52 (99.84%)✅ (view plot)6,756.00 (+0.02%)6,775.17 (99.72%)✅ (view plot)52.00 (+9.58%)52.64 (98.79%)✅ (view plot)223.00 (+0.25%)229.93 (96.99%)
client_sv2_mining_message_submit_standard_serialize_deserialize✅ (view plot)27,595.00 (+0.41%)27,847.92 (99.09%)🚨 (view plot | view alert)10,591.00 (+0.45%)10,572.33 (100.18%)🚨 (view plot | view alert)15,405.00 (+0.41%)15,380.13 (100.16%)✅ (view plot)86.00 (+2.63%)89.44 (96.16%)✅ (view plot)336.00 (+0.34%)345.28 (97.31%)
client_sv2_open_channel✅ (view plot)4,353.00 (-2.99%)4,616.80 (94.29%)✅ (view plot)1,461.00 (+0.05%)1,474.33 (99.10%)✅ (view plot)2,158.00 (+0.24%)2,173.03 (99.31%)✅ (view plot)12.00 (+0.15%)15.20 (78.92%)✅ (view plot)61.00 (-6.13%)68.40 (89.18%)
client_sv2_open_channel_serialize✅ (view plot)14,084.00 (-0.90%)14,459.78 (97.40%)✅ (view plot)5,064.00 (+0.02%)5,077.33 (99.74%)✅ (view plot)7,324.00 (+0.08%)7,339.43 (99.79%)✅ (view plot)36.00 (-3.27%)41.93 (85.86%)✅ (view plot)188.00 (-1.92%)198.85 (94.54%)
client_sv2_open_channel_serialize_deserialize✅ (view plot)22,631.00 (-0.04%)23,020.50 (98.31%)🚨 (view plot | view alert)8,027.00 (+0.52%)8,012.93 (100.18%)🚨 (view plot | view alert)11,676.00 (+0.51%)11,654.06 (100.19%)✅ (view plot)77.00 (+4.85%)82.02 (93.88%)✅ (view plot)302.00 (-0.81%)314.86 (95.92%)
client_sv2_setup_connection✅ (view plot)4,723.00 (+0.51%)4,765.81 (99.10%)✅ (view plot)1,502.00 (+0.05%)1,515.33 (99.12%)✅ (view plot)2,273.00 (-0.16%)2,299.43 (98.85%)✅ (view plot)14.00 (+51.28%)14.09 (99.36%)✅ (view plot)68.00 (+0.16%)69.63 (97.67%)
client_sv2_setup_connection_serialize✅ (view plot)16,180.00 (-0.50%)16,489.23 (98.12%)✅ (view plot)5,963.00 (+0.01%)5,976.33 (99.78%)✅ (view plot)8,655.00 (-0.00%)8,677.37 (99.74%)✅ (view plot)49.00 (+9.42%)49.40 (99.18%)✅ (view plot)208.00 (-1.40%)217.48 (95.64%)
client_sv2_setup_connection_serialize_deserialize✅ (view plot)35,550.00 (+0.04%)35,746.14 (99.45%)🚨 (view plot | view alert)14,855.00 (+0.29%)14,840.35 (100.10%)🚨 (view plot | view alert)21,815.00 (+0.28%)21,791.21 (100.11%)✅ (view plot)101.00 (+1.33%)112.63 (89.68%)✅ (view plot)378.00 (-0.40%)384.54 (98.30%)

Bencher - Continuous Benchmarking
View Public Perf Page
Docs | Repo | Chat | Help

@plebhash plebhash changed the title no_std as an optional feature on protocols crates make no_std into an optional feature on protocols crates May 25, 2024
Copy link
Contributor

@jbesraa jbesraa left a comment

Choose a reason for hiding this comment

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

I am not fully sure adding anyhow is a great solution for our error handling.
We could maintain different errors internally and expose one single error that maps to the rest. Our minimum for adding a new crate should be more than "it makes this thing slightly easier", in this case its preferable to write our own code.
Disadvantages of adding anyhow could be: slower compiling time, we could be imposing anyhow for downstream users, its more appropriate for app layer..

@plebhash
Copy link
Collaborator Author

I am not fully sure adding anyhow is a great solution for our error handling. We could maintain different errors internally and expose one single error that maps to the rest. Our minimum for adding a new crate should be more than "it makes this thing slightly easier", in this case its preferable to write our own code. Disadvantages of adding anyhow could be: slower compiling time, we could be imposing anyhow for downstream users, its more appropriate for app layer..

that's actually a good point, and @rrybarczyk just made a similar argument just a while ago.

@plebhash plebhash closed this Jun 12, 2024
@rrybarczyk
Copy link
Collaborator

A little late to the party, but as @plebhash pointed out, I also think we should handle our own errors in the roles rather than using anyhow.

@plebhash
Copy link
Collaborator Author

plebhash commented Aug 9, 2024

anyhow is not the only motivation.

I'm trying to unblock #985 (comment) and it seems that this (amongst other reasons) is a blocker there.

regardless of anyhow, this is not only a desirable change, but an urgent one.

@plebhash plebhash reopened this Aug 9, 2024
@plebhash plebhash merged commit c428ea8 into stratum-mining:dev Aug 9, 2024
32 checks passed
@plebhash plebhash mentioned this pull request Aug 18, 2024
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.

3 participants