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

Speed up multisig ut #908

Merged
merged 3 commits into from
Jul 11, 2019
Merged

Speed up multisig ut #908

merged 3 commits into from
Jul 11, 2019

Conversation

shargon
Copy link
Member

@shargon shargon commented Jul 10, 2019

No description provided.

@codecov-io
Copy link

codecov-io commented Jul 10, 2019

Codecov Report

Merging #908 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #908   +/-   ##
=======================================
  Coverage   45.16%   45.16%           
=======================================
  Files         178      178           
  Lines       12608    12608           
=======================================
  Hits         5695     5695           
  Misses       6913     6913

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1d949c8...6b6c6ab. Read the comment docs.

@erikzhang
Copy link
Member

Can this really speed up multisig ut?

Copy link
Member

@vncoelho vncoelho left a comment

Choose a reason for hiding this comment

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

Sounds good, Shargon.
Good idea.

@erikzhang
Copy link
Member

@vncoelho Did you test it?

@vncoelho
Copy link
Member

Yes, worked normally.
But I did not benchmark...

I am having problems with #905
There was a failed test that passed yesterday.
I am trying to double check it.

@erikzhang
Copy link
Member

Worked normally only, or faster?

@vncoelho
Copy link
Member

I did not benchmark, @erikzhang.
It passed the tests. But makes sense to be faster.

For being sure about that we would need to run a loop and count the time. Do you think that we should do that for being sure before merging, @shargon?

@erikzhang
Copy link
Member

We should do that for being sure before approving. @vncoelho

@vncoelho
Copy link
Member

vncoelho commented Jul 10, 2019

Let's check it out.
Results are coming.

@vncoelho
Copy link
Member

For replications of the following loop:

                double avgTime = 0;
                int nIter = 10;
                for (int i = 0; i < nIter; i++)
                {
                    Stopwatch sw0 = new Stopwatch();
                    sw0.Start();

                    var aa = walletA.CreateAccount();
                    var bb = walletB.CreateAccount();

                    sw0.Stop();
                    TimeSpan elapsed = sw0.Elapsed;
                    avgTime += elapsed.Seconds;
                }
                Console.WriteLine($"Elapsed={avgTime / nIter}");
                avgTime = 0;
                for (int i = 0; i < nIter; i++)
                {
                    Stopwatch sw0 = new Stopwatch();
                    sw0.Start();

                    var ta = new Task<WalletAccount>(() => walletA.CreateAccount());
                    var tb = new Task<WalletAccount>(() => walletA.CreateAccount());
                    ta.Start();
                    tb.Start();
                    Task.WaitAll(ta, tb);

                    var aa = ta.Result;
                    var bb = tb.Result;
                    sw0.Stop();
                    TimeSpan elapsed = sw0.Elapsed;
                    avgTime += elapsed.Seconds;
                }
                Console.WriteLine($"ElapsedNew={avgTime/nIter}");

For nIter = 10

 Elapsed=6.2
 ElapsedNew=3.1

For nIter = 100

 Elapsed=61
 ElapsedNew=32

I also learned to run with a filter, now I am dominating these dotnet tests! ahueahueaea
dotnet test --verbosity n --filter "FullyQualifiedName~Neo.UnitTests.UT_Transaction" ./neo.UnitTests/neo.UnitTests.csproj
Ui Flai...average 0,6s gain with this PR... :D

@shargon
Copy link
Member Author

shargon commented Jul 10, 2019

from 8 seconds to 6 in my laptop

@shargon
Copy link
Member Author

shargon commented Jul 10, 2019

You should take into account that ut culture run this in several times, so the optimization is better

@i359
Copy link

i359 commented Jul 11, 2019

@vncoelho,Pls double check the below code,and re-test, thanks!

var tb = new Task(() => walletA.CreateAccount());
maybe is var tb = new Task(() => walletB.CreateAccount());

@vncoelho
Copy link
Member

vncoelho commented Jul 11, 2019

That is true, @i359, you are right. Thanks for taking a careful look!

But results will be similar. I think that I will not re-run this, because the result matched the theoretical expectation...aheuahuea

@i359
Copy link

i359 commented Jul 11, 2019

@vncoelho, The following test results are amazing, and it is recommended to use the modified code to
re-test,that's scientific rigour, right? thanks!

For nIter = 10
Elapsed=6.2
ElapsedNew=3.1

@vncoelho
Copy link
Member

Sometimes science is made of empirical tests...aheuahuea
Thanks for contributing, @i359.

@i359
Copy link

i359 commented Jul 11, 2019

@vncoelho, the below code only create walletA, no create walletB, so save about half time,
it is recommended to use the modified code to re-test,thanks!

var ta = new Task(() => walletA.CreateAccount());
var tb = new Task(() => walletA.CreateAccount());

@vncoelho
Copy link
Member

You are blowing my mind now, it is 1am here.
I am going to re-run for nIter=10 and go to sleep...aheuahea

@vncoelho
Copy link
Member

vncoelho commented Jul 11, 2019

I run the tests 2 times until remember that we need to fail for printing messages...aheuahea

Here it is, @i359. The same result... O.o 💃

 Elapsed=6
 ElapsedNew=3

Anyway, it is always good to wonder.
Thanks for the insight.
@i359, it would be great if you could help the investigation for finding other places in the UT that a similar strategy could be applied.

@shargon shargon merged commit 7e36bf8 into neo-project:master Jul 11, 2019
@shargon shargon deleted the speed-up branch July 11, 2019 09:39
@shargon
Copy link
Member Author

shargon commented Jul 11, 2019

i have a mistake...

@shargon shargon mentioned this pull request Jul 11, 2019
@shargon
Copy link
Member Author

shargon commented Jul 11, 2019

Please if some mistake are found, remove the approve 🙏

@vncoelho
Copy link
Member

@i359, I thought the mistake was just on my loop for testing...

Thacryba pushed a commit to simplitech/neo that referenced this pull request Feb 17, 2020
)

* Update introduction.md

* Update and rename format.md to common.md

* Update common.md

* Update common.md

* Remove redundant content.

* Remove redundant content.

* Minor change.

* Minor change.

* Minor change.

* Minor change.

* Minor change.

* Minor change.

* Minor change.

* Minor change.

* Minor fix.

* Fix JSON format.

* Fix JSON format.

* Fix JSON format.

* Fix JSON format.

* Fix format.

* Fix JSON format.

* Fix JSON format.

* Fix JSON format.

* Fix JSON format.

* Fix JSON format.

* Fix JSON format.

* Minor fix.

* Minor fix.

* Minor fix.

* Minor fix.

* Fix content and format.

* Fix content and format.

* Fix content.

* Minor fix.

* Fix content.

* Fix content.

* Minor fix.

* Minor fix.

* Fix content.

* Fix content.

* Minor fix.

* Minor fix.

* Minor fix.

* Minor fix.
Tommo-L pushed a commit to Tommo-L/neo that referenced this pull request Jun 22, 2020
* Speedup multisign ut

* Start tasks
lock9 added a commit to linkd-academy/neo that referenced this pull request Dec 5, 2023
lock9 added a commit to linkd-academy/neo that referenced this pull request Dec 5, 2023
lock9 added a commit to linkd-academy/neo that referenced this pull request Dec 5, 2023
shargon pushed a commit that referenced this pull request Dec 7, 2023
* Neo Node Migration

* Added blockchain show block/transactions/contracts commands #905 (cschuchardt88)
Added icon to applications #908 (cschuchardt88)

* Update README.md
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.

5 participants