Repository navigation
Conversation
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)?
There was a problem hiding this comment.
btw: in the docs there is no resultCachePath mentioned.. should it be added?
There was a problem hiding this comment.
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.
b235560 to
1f38eba
Compare
2c1a994 to
90d9217
Compare
c8658a0 to
67e8c4b
Compare
67e8c4b to
b6dda79
Compare
3af7989 to
3c8cace
Compare
ea060a9 to
c711f0d
Compare
c711f0d to
7bebfdf
Compare
|
added a test-case. should be good to go. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
the tmpDir case is already covered by an existing test which uses a tmpDir
There was a problem hiding this comment.
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..?
286d1f6 to
3ac86ba
Compare
|
@ondrejmirtes anything I can do to get this merged? |
46831b1 to
9e98a7e
Compare
9e98a7e to
e24b20e
Compare
|
I'm looking forward to this feature too. I should be able to get rid of some local config entries most likely :) |
|
sorry, for the "bump", but I just thought about this PR and was wondering about its state and/or if it was forgotten maybe :) |
|
I'm a bit afraid to touch this area because it's hard to test it. |
|
Still live on current 2.2.x, and a bit broader than the issues describe. Two configs in one project, run alternately: every run after the first reports On the "hard to test" worry: it is much easier to pin now than in 2022. The result-cache e2e blocks are plain shell, so alternating two configs and asserting Two things I noticed in the patch while reproducing:
Deriving the name from the same |
|
Hey, this is very close to my current interest and headspace so I can think about it clearly. Can you please open a new issue and describe what we learnt meanwhile, what use cases should this solve and how does the recent relativization of paths in the result cache relate to this? (It might solve some of the use cases.) Also I think the git worktrees might be relevant here. What I have to say about this now is that thanks to relative paths, even if we don't set a local tmpDir and just use the system one, if we copy a project to a different directory on disk, PHPStan should be able to reuse the same result cache without invalidation (when the projects are very similar). But of course if something in the meta changes we need to have a separate result cache so that's where the discussion should start. Feel free to mention these points in the description too, we will build on them too. |
|
Opened as phpstan/phpstan#15163, with your points in the description. Your hunch about relative paths checks out in the strongest form: a project copied to a different directory, PHPStan in its own The worktree measurements are in there too, along with the two remaining thrash cases and a suggestion for where the file name could come from. |
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.