Skip to content

run-tests: add skip cache to improve performance #6681

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

Closed
wants to merge 1 commit into from

Conversation

MaxSem
Copy link
Contributor

@MaxSem MaxSem commented Feb 11, 2021

Currently every --SKIPIF-- section in every test file results in 1
extra execution of PHP, every --EXTENSIONS-- section - in 2 executions.
This is quite wasteful, as skip checking code is extremely repetitive
and extensions are fixed for every binary/ini/command parameters
combination.

This patch adds caching to all such checks.

On my machine, the gains are quite noticeable: 36s instead of 43s
with -j16, 292s instead of 337s without concurrency. Cache stats are
3780 hits, 1247 misses in the latter case. In the future, tests could
be adjusted to have more uniform skip checks to improve performance even
more.

@MaxSem MaxSem changed the title WIP: run-tests: add skip cache run-tests: add skip cache to improve performance Feb 11, 2021
@MaxSem MaxSem marked this pull request as ready for review February 12, 2021 13:11

if (isset($this->skips[$key][$code])) {
$this->hits++;
return $this->skips[$key][$code];
Copy link
Member

Choose a reason for hiding this comment

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

If keepFile is enabled and we have a cache hit, then we'll not keep the file (by dint of not creating it in the first place).

Might make sense to simply not cache if keepFile is enabled?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just made it save the file on early exit.

Currently every --SKIPIF-- section in every test file results in 1
extra execution of PHP, every --EXTENSIONS-- section - in 2 executions.
This is quite wasteful, as skip checking code is extremely repetitive
and extensions are fixed for every binary/ini/command parameters
combination.

This patch adds caching to all such checks.

On my machine, the gains are quite noticeable: 36s instead of 43s
with -j16, 292s instead of 337s without concurrency. Cache stats are
3780 hits, 1247 misses in the latter case. In the future, tests could
be adjusted to have more uniform skip checks to improve performance even
more.
@php-pulls php-pulls closed this in dda0cea Feb 23, 2021
@nikic
Copy link
Member

nikic commented Feb 24, 2021

There's a failure of ext/mysqli/tests/mysqli_pam_sha256_public_key_option_invalid.phpt on some jobs that I think is related to this change (https://dev.azure.com/phpazuredevops/PHP/_build/results?buildId=14943&view=ms.vss-test-web.build-test-results-tab&runId=340192&paneView=debug&resultId=107434).

@MaxSem MaxSem deleted the skip-cache branch February 24, 2021 09:39
@MaxSem
Copy link
Contributor Author

MaxSem commented Feb 24, 2021

Looking.

@MaxSem
Copy link
Contributor Author

MaxSem commented Feb 24, 2021

@nikic, since tests are running faster now, the race condition with various mysqli tests recreating the same table is more likely to occur. Also, this extension's tests frequently mix skip checks with database setup for tests, making it possible to run a test without setting up tables for it, but that's not a cause for that particular failure because the test has unique skipif code.

I'll try to address these issues soon.

@nikic
Copy link
Member

nikic commented Feb 24, 2021

@MaxSem mysqli tests don't run in parallel -- there shouldn't be race conditions there.

@MaxSem
Copy link
Contributor Author

MaxSem commented Feb 24, 2021

Hmm, how 'bout we put a temporary plug to avoid caching mysqli tests to see if it fixes nightlies? Meanwhile, these tests need fixing anyway to even work with recent mysql...

MaxSem added a commit to MaxSem/php-src that referenced this pull request Feb 24, 2021
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.

2 participants