Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

use a separate resultCache per project config file #1469

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

Open
staabm wants to merge 6 commits into phpstan:1.8.x
base: 1.8.x
Choose a base branch
Loading
from staabm:separate-caches

Conversation

@staabm
Copy link
Contributor

@staabm staabm commented Jun 23, 2022
edited
Loading

closes phpstan/phpstan#7379
closes phpstan/phpstan#7601

With this patch we see analysis time dropped to ~5 seconds from previous 2-3 minutes in mono-repo projects, which contain several phpstan.neon files.

herndlm, canvural, and lolaslade reacted with thumbs up emoji
Copy link
Contributor Author

@staabm staabm Jun 23, 2022
edited
Loading

Choose a reason for hiding this comment

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

while thinking about the idea suggested in phpstan/phpstan#7379 (comment) I came to this - in my eyes - even simpler solution to the problem.

instead of fiddling with all the different path-types involved we just use a separate resultCache-name per project-configuration file.

tbh the solutions seems to be to simple, so I think it might have some serious problems somewhere ;-).

(削除) in case we can proceed with this idea, I would check the current build errors and see how to actually test this change... (削除ここまで) at least the local testing on my project suggests that it is now using the result-cache where it didn't before.. so it seems to solve my problem at hand.

any feedback is welcome.

Copy link
Member

@ondrejmirtes ondrejmirtes Jun 23, 2022

Choose a reason for hiding this comment

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

The $resultCacheName parameter of restore method shouldn't be misused for this, its usage is reserved only for PHPStan Pro purposes. It puts the result cache file in a subdirectory, I don't want to complicate it like that.

But hey - the logic you're doing here depends on $projectConfigArray and that is entirely available in restore() method too, so you can do the logic based on that there. A lot of useful values that can be used in the hash computation logic are already in the constructor/can be asked for there so I think this idea has wings.

Copy link
Contributor Author

@staabm staabm Jun 24, 2022
edited
Loading

Choose a reason for hiding this comment

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

adjusted per feedack and manually tested locally.

do we need a automatic test for the case? if so where and what to test (might be a bit hard because of random file-names involved)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

btw: in the docs there is no resultCachePath mentioned.. should it be added?

https://phpstan.org/config-reference#caching

@staabm staabm marked this pull request as ready for review June 23, 2022 14:30
Copy link
Member

@ondrejmirtes ondrejmirtes Jun 23, 2022

Choose a reason for hiding this comment

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

The $resultCacheName parameter of restore method shouldn't be misused for this, its usage is reserved only for PHPStan Pro purposes. It puts the result cache file in a subdirectory, I don't want to complicate it like that.

But hey - the logic you're doing here depends on $projectConfigArray and that is entirely available in restore() method too, so you can do the logic based on that there. A lot of useful values that can be used in the hash computation logic are already in the constructor/can be asked for there so I think this idea has wings.

@staabm staabm marked this pull request as draft June 23, 2022 19:41
@staabm staabm marked this pull request as ready for review June 24, 2022 08:01
@clxmstaab clxmstaab force-pushed the separate-caches branch 4 times, most recently from 2c1a994 to 90d9217 Compare June 24, 2022 08:12
@staabm staabm force-pushed the separate-caches branch 3 times, most recently from c8658a0 to 67e8c4b Compare June 27, 2022 12:02
@staabm staabm changed the base branch from 1.7.x to 1.8.x June 29, 2022 14:41
@staabm staabm marked this pull request as draft June 29, 2022 14:57
@clxmstaab clxmstaab force-pushed the separate-caches branch 2 times, most recently from ea060a9 to c711f0d Compare June 30, 2022 15:17
@staabm staabm marked this pull request as ready for review June 30, 2022 15:19
Copy link
Contributor Author

staabm commented Jun 30, 2022

added a test-case. should be good to go.

Copy link
Contributor Author

@staabm staabm Jun 30, 2022
edited
Loading

Choose a reason for hiding this comment

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

since checking exactly which hashes are generated is a bit too much IMO, I just verified phpstan will create result-cache files including some suffix (aka. the hash), which it did not do before this change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the tmpDir case is already covered by an existing test which uses a tmpDir

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this condition is covered by #1475

Copy link
Contributor Author

Choose a reason for hiding this comment

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

only thing I am not 100% sure: what needs to be here in this hash.

maybe just the $this->analysedPaths are already enough, since these are the absolute paths within the system..?

@staabm staabm force-pushed the separate-caches branch 2 times, most recently from 286d1f6 to 3ac86ba Compare July 10, 2022 12:34
Copy link
Contributor Author

staabm commented Jul 10, 2022

@ondrejmirtes anything I can do to get this merged?

@staabm staabm marked this pull request as ready for review August 31, 2022 11:18
Copy link
Contributor

herndlm commented Aug 31, 2022

I'm looking forward to this feature too. I should be able to get rid of some local config entries most likely :)

Copy link
Contributor

herndlm commented Dec 19, 2022

sorry, for the "bump", but I just thought about this PR and was wondering about its state and/or if it was forgotten maybe :)

ivastly reacted with thumbs up emoji

Copy link
Member

I'm a bit afraid to touch this area because it's hard to test it.

jseparovic1 and ivastly reacted with eyes emoji

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@ondrejmirtes ondrejmirtes ondrejmirtes requested changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Name resultCache.php file more uniquely in global tmpDir Spontaneously started crashing for no obvious reason

AltStyle によって変換されたページ (->オリジナル) /