libsm icon indicating copy to clipboard operation
libsm copied to clipboard

load gmul table from disk

Open FullyRobert opened this issue 1 year ago • 1 comments

pr #45 and issues #37 both mention that loading gmul_table from disk is an elegant way. In this pr, I modify the g_table function, introduced Serde crate to serialize the table, and store it in the file gmul_table. When the gmul function needs to use g_table, it can easily load the file and deserialize it as a table struct.

Benchmark tests have found that the performance improvement of the gmul function using the load approach is not significant (about 2-5%), probably because a large number of gmul operations amortizes the precomputed gtable time. In any case, loading gtable from the hard disk is effective in reducing warming time, and the loading time is nearly zero( 300mb/s for serde deserialize procedure)

Hope my code can be well-reviewed, and I will add more commit to implement it.

Test result:

test sm2::ecc::internal_benches::bench_gmul ... bench: 50,762 ns/iter (+/- 791) test sm2::ecc::internal_benches::bench_gmul_load ... bench: 48,357 ns/iter (+/- 1,143)

FullyRobert avatar Oct 12 '22 10:10 FullyRobert

a clippy error found in error.rs never occurred before, but I never modify this part of code

FullyRobert avatar Oct 12 '22 10:10 FullyRobert