Skip to content

Name resultCache.php file more uniquely in global tmpDir #7379

Open

Description

@ondrejmirtes

Feature request

From: #7260

  1. Do not change anything if the project explicitly sets tmpDir. It usually means that the CI depends on %tmpDir%/resultCache.php to exist because they persist it across runs.
  2. Otherwise (if the tmpDir is the default system one which means it's gonna be shared across all projects), append something like current working directory hash to %resultCachePath%. So it's not going to be /tmp/phpstan/resultCache.php, but something like /tmp/phpstan/resultCache-xyz.php where xyz is derived from CWD.

Activity

  1. spaze commented on Jun 2, 2022

    @spaze
    Contributor

    Relevant comment from #7260 (comment):

    In my case, it should be a hash of a config file path, not just dir path. I'm using two .neon files in the same dir, they're each for a different part of the codebase, so they would share the same dir and the cache would be overwritten anyway.

  2. staabm commented on Jun 23, 2022

    @staabm
    Contributor

    we consider this issue a major problem for us, as we loose 2-3 minutes on every phpstan run, which leats to developers loosing focus.

    I looked into fixing this problem and found that %resultCachePath% is a variable managed by the injection container.
    do you have any hints on how this variable can/should be changed at runtime?

    I am not very experienced with the nette* stuff I have to admin.

    Thank you.

  3. ondrejmirtes commented on Jun 23, 2022

    @ondrejmirtes
    MemberAuthor

    Use a custom and different tmpDir in each of your projects. (Or contribute the proposed fix here ;))

  4. staabm commented on Jun 23, 2022

    @staabm
    Contributor

    Use a custom and different tmpDir in each of your projects.

    thats too much hassle, in a lot of files.

    Or contribute the proposed fix here ;)

    thats what I want to todo. could you help me with this:

    I looked into fixing this problem and found that %resultCachePath% is a variable managed by the injection container.
    do you have any hints on how this variable can/should be changed at runtime?

    ?

  5. ondrejmirtes commented on Jun 23, 2022

    @ondrejmirtes
    MemberAuthor

    There are two challenges:

    1. How to recognize if the tmpDir is the default one or if it got changed. This is where it happens: https://github.com/phpstan/phpstan-src/blob/adf7313ac266ef217cf144fc4901a2998ead4df2/src/Command/CommandHelper.php#L288-L291
    2. How to pass this information into ResultCacheManager. I think we could pass a simple boolean "isTmpDirDefault" and if it's true, we could deconstruct $this->cacheFilePath in ResultCacheManager and add some kind of hash there.

    We should also think about people that don't change their tmpDir but change their resultCachePath. We should not change the path in that case.

  6. staabm commented on Jun 30, 2022

    @staabm
    Contributor

    @spaze in phpstan/phpstan-src#1469 I have built a patch which uses a different resultcache per md5-hash of configured analyzedPath and bootstrapFiles (as we don't know the config file path at this places).

    Could you check this holds for your setup/use-case?

  7. spaze commented on Jun 30, 2022

    @spaze
    Contributor

    Could you check this holds for your setup/use-case?

    Cool, seems it should be fine, that combo is unique in my cases (e.g. paths 1, paths 2). Thanks!

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions