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

Profiling/improving our tests #2379

Open
roman-khimov opened this issue Mar 1, 2022 · 5 comments
Open

Profiling/improving our tests #2379

roman-khimov opened this issue Mar 1, 2022 · 5 comments
Labels
enhancement Improving existing functionality I4 No visible changes S2 Regular significance test Unit tests U4 Nothing urgent

Comments

@roman-khimov
Copy link
Member

We've got a lot of tests which is very good except they take a heck lot of time to run. There were some optimizations already done previously (most notably in #2001), but it's time to make another round. First of all, the most resource-demanding tests need to be identified and then we'll think on whether and how they can be improved.

@roman-khimov roman-khimov added the test Unit tests label Mar 1, 2022
@fyrchik
Copy link
Contributor

fyrchik commented Mar 2, 2022

Packages where tests take more than 5 seconds (on my machine):

  1. compiler compiler: optimize tests #2382
  2. cli -- the biggest (80 seconds), designed to perform end-to-end testing, runs blockchain, waits for blocks. Not sure if we can do anything about it.
  3. wallet -- probably stays as it is, most of the time is spent in crypto routines
  4. vm -- TestUT, most of the time spent in execute.
  5. core

@roman-khimov
Copy link
Member Author

cli -- the biggest (80 seconds), designed to perform end-to-end testing, runs blockchain, waits for blocks. Not sure if we can do anything about it.

It can be split into subpackages which can then be run in parallel (the effect was seen in #1472 already).

My current list is:

ok      github.com/nspcc-dev/neo-go/cli 86.593s coverage: 80.0% of statements
...
ok      github.com/nspcc-dev/neo-go/pkg/compiler        37.964s coverage: 92.0% of statements
...
ok      github.com/nspcc-dev/neo-go/pkg/crypto/keys     7.564s  coverage: 80.8% of statements
...
ok      github.com/nspcc-dev/neo-go/pkg/services/notary 5.021s  coverage: 93.0% of statements
ok      github.com/nspcc-dev/neo-go/pkg/services/oracle 13.095s coverage: 74.7% of statements
...
ok      github.com/nspcc-dev/neo-go/pkg/services/stateroot      8.760s  coverage: 84.3% of statements
...
ok      github.com/nspcc-dev/neo-go/pkg/vm      16.205s coverage: 82.0% of statements
...
ok      github.com/nspcc-dev/neo-go/pkg/wallet  9.996s  coverage: 79.0% of statements

@roman-khimov roman-khimov added this to the v0.99.3 milestone Jun 9, 2022
@roman-khimov roman-khimov modified the milestones: v0.99.3, v0.99.4 Sep 2, 2022
@roman-khimov
Copy link
Member Author

It can be split into subpackages

Argh.

?       github.com/nspcc-dev/neo-go/cli [no test files]
ok      github.com/nspcc-dev/neo-go/cli/app     0.036s  coverage: 100.0% of statements
ok      github.com/nspcc-dev/neo-go/cli/cmdargs 0.011s  coverage: 60.8% of statements
ok      github.com/nspcc-dev/neo-go/cli/flags   0.009s  coverage: 97.7% of statements
?       github.com/nspcc-dev/neo-go/cli/input   [no test files]
ok      github.com/nspcc-dev/neo-go/cli/options 0.033s  coverage: 50.0% of statements
?       github.com/nspcc-dev/neo-go/cli/paramcontext    [no test files]
ok      github.com/nspcc-dev/neo-go/cli/query   2.155s  coverage: 45.3% of statements
ok      github.com/nspcc-dev/neo-go/cli/server  1.373s  coverage: 67.8% of statements
ok      github.com/nspcc-dev/neo-go/cli/smartcontract   8.819s  coverage: 94.3% of statements
ok      github.com/nspcc-dev/neo-go/cli/util    0.006s  coverage: 10.9% of statements
?       github.com/nspcc-dev/neo-go/cli/vm      [no test files]
ok      github.com/nspcc-dev/neo-go/cli/wallet  72.103s coverage: 88.2% of statements

roman-khimov added a commit that referenced this issue Oct 5, 2022
Refs. #2379, but not completely solves it, one package seriously outweights
others:

?       github.com/nspcc-dev/neo-go/cli [no test files]
ok      github.com/nspcc-dev/neo-go/cli/app     0.036s  coverage: 100.0% of statements
ok      github.com/nspcc-dev/neo-go/cli/cmdargs 0.011s  coverage: 60.8% of statements
ok      github.com/nspcc-dev/neo-go/cli/flags   0.009s  coverage: 97.7% of statements
?       github.com/nspcc-dev/neo-go/cli/input   [no test files]
ok      github.com/nspcc-dev/neo-go/cli/options 0.033s  coverage: 50.0% of statements
?       github.com/nspcc-dev/neo-go/cli/paramcontext    [no test files]
ok      github.com/nspcc-dev/neo-go/cli/query   2.155s  coverage: 45.3% of statements
ok      github.com/nspcc-dev/neo-go/cli/server  1.373s  coverage: 67.8% of statements
ok      github.com/nspcc-dev/neo-go/cli/smartcontract   8.819s  coverage: 94.3% of statements
ok      github.com/nspcc-dev/neo-go/cli/util    0.006s  coverage: 10.9% of statements
?       github.com/nspcc-dev/neo-go/cli/vm      [no test files]
ok      github.com/nspcc-dev/neo-go/cli/wallet  72.103s coverage: 88.2% of statements

Still a nice thing to have.
roman-khimov added a commit that referenced this issue Oct 5, 2022
Refs. #2379, but not completely solves it, one package seriously outweights
others:

?       github.com/nspcc-dev/neo-go/cli [no test files]
ok      github.com/nspcc-dev/neo-go/cli/app     0.036s  coverage: 100.0% of statements
ok      github.com/nspcc-dev/neo-go/cli/cmdargs 0.011s  coverage: 60.8% of statements
ok      github.com/nspcc-dev/neo-go/cli/flags   0.009s  coverage: 97.7% of statements
?       github.com/nspcc-dev/neo-go/cli/input   [no test files]
ok      github.com/nspcc-dev/neo-go/cli/options 0.033s  coverage: 50.0% of statements
?       github.com/nspcc-dev/neo-go/cli/paramcontext    [no test files]
ok      github.com/nspcc-dev/neo-go/cli/query   2.155s  coverage: 45.3% of statements
ok      github.com/nspcc-dev/neo-go/cli/server  1.373s  coverage: 67.8% of statements
ok      github.com/nspcc-dev/neo-go/cli/smartcontract   8.819s  coverage: 94.3% of statements
ok      github.com/nspcc-dev/neo-go/cli/util    0.006s  coverage: 10.9% of statements
?       github.com/nspcc-dev/neo-go/cli/vm      [no test files]
ok      github.com/nspcc-dev/neo-go/cli/wallet  72.103s coverage: 88.2% of statements

Still a nice thing to have.
roman-khimov added a commit that referenced this issue Oct 5, 2022
Refs. #2379, but not completely solves it, one package seriously outweights
others:

?       github.com/nspcc-dev/neo-go/cli [no test files]
ok      github.com/nspcc-dev/neo-go/cli/app     0.036s  coverage: 100.0% of statements
ok      github.com/nspcc-dev/neo-go/cli/cmdargs 0.011s  coverage: 60.8% of statements
ok      github.com/nspcc-dev/neo-go/cli/flags   0.009s  coverage: 97.7% of statements
?       github.com/nspcc-dev/neo-go/cli/input   [no test files]
ok      github.com/nspcc-dev/neo-go/cli/options 0.033s  coverage: 50.0% of statements
?       github.com/nspcc-dev/neo-go/cli/paramcontext    [no test files]
ok      github.com/nspcc-dev/neo-go/cli/query   2.155s  coverage: 45.3% of statements
ok      github.com/nspcc-dev/neo-go/cli/server  1.373s  coverage: 67.8% of statements
ok      github.com/nspcc-dev/neo-go/cli/smartcontract   8.819s  coverage: 94.3% of statements
ok      github.com/nspcc-dev/neo-go/cli/util    0.006s  coverage: 10.9% of statements
?       github.com/nspcc-dev/neo-go/cli/vm      [no test files]
ok      github.com/nspcc-dev/neo-go/cli/wallet  72.103s coverage: 88.2% of statements

Still a nice thing to have.
roman-khimov added a commit that referenced this issue Oct 6, 2022
Refs. #2379, but not completely solves it, one package seriously outweights
others:

?       github.com/nspcc-dev/neo-go/cli [no test files]
ok      github.com/nspcc-dev/neo-go/cli/app     0.036s  coverage: 100.0% of statements
ok      github.com/nspcc-dev/neo-go/cli/cmdargs 0.011s  coverage: 60.8% of statements
ok      github.com/nspcc-dev/neo-go/cli/flags   0.009s  coverage: 97.7% of statements
?       github.com/nspcc-dev/neo-go/cli/input   [no test files]
ok      github.com/nspcc-dev/neo-go/cli/options 0.033s  coverage: 50.0% of statements
?       github.com/nspcc-dev/neo-go/cli/paramcontext    [no test files]
ok      github.com/nspcc-dev/neo-go/cli/query   2.155s  coverage: 45.3% of statements
ok      github.com/nspcc-dev/neo-go/cli/server  1.373s  coverage: 67.8% of statements
ok      github.com/nspcc-dev/neo-go/cli/smartcontract   8.819s  coverage: 94.3% of statements
ok      github.com/nspcc-dev/neo-go/cli/util    0.006s  coverage: 10.9% of statements
?       github.com/nspcc-dev/neo-go/cli/vm      [no test files]
ok      github.com/nspcc-dev/neo-go/cli/wallet  72.103s coverage: 88.2% of statements

Still a nice thing to have.
@roman-khimov roman-khimov modified the milestones: v0.99.4, v0.99.5 Oct 6, 2022
@roman-khimov roman-khimov modified the milestones: v0.99.5, v0.100.0 Nov 10, 2022
@roman-khimov roman-khimov modified the milestones: v0.100.0, v0.100.1 Nov 25, 2022
roman-khimov added a commit that referenced this issue Dec 2, 2022
I do see some reduced testing time for cli components with this setting even
though it doesn't affect the overall time for me. Maybe it'll be beneficial in
some cases. Refs. #2379.
roman-khimov added a commit that referenced this issue Dec 2, 2022
I do see some reduced testing time for cli components with this setting even
though it doesn't affect the overall time for me. Maybe it'll be beneficial in
some cases. Refs. #2379.
@roman-khimov
Copy link
Member Author

Block verification can be disabled in most of tests to remove some crypto overhead.

@roman-khimov roman-khimov added this to the v0.103.0 milestone Feb 17, 2023
@roman-khimov roman-khimov modified the milestones: v0.103.0, v0.104.0 May 24, 2023
@fyfyrchik
Copy link
Contributor

Btw, I have recently stumbled upon https://github.com/gotestyourself/gotestsum which is quite useful

$ go test -json -count=1 ./pkg/... | gotestsum tool slowest --threshold 1s
github.com/nspcc-dev/neo-go/pkg/services/rpcsrv TestClient_Wait 22.53s
github.com/nspcc-dev/neo-go/pkg/services/rpcsrv TestSubClientWaitWithMissedEvent 15.21s
github.com/nspcc-dev/neo-go/pkg/services/rpcsrv TestSubClientWait 9.4s
...

@roman-khimov roman-khimov added U4 Nothing urgent enhancement Improving existing functionality S2 Regular significance I4 No visible changes and removed refactoring labels Dec 21, 2023
@roman-khimov roman-khimov removed this from the v0.105.0 milestone Dec 21, 2023
@roman-khimov roman-khimov added this to the v0.107.0 milestone Mar 8, 2024
roman-khimov added a commit that referenced this issue Mar 9, 2024
We have more and more timeouts happening for test runs, so 10m is not enough
for busy GH machines sometime. I think we can just give them a bit more time.

Refs. #2379 though.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
@roman-khimov roman-khimov removed this from the v0.107.0 milestone Mar 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improving existing functionality I4 No visible changes S2 Regular significance test Unit tests U4 Nothing urgent
Projects
None yet
Development

No branches or pull requests

3 participants