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

Option to cache results in between the runs #534

Closed
hakamairi opened this issue Nov 15, 2017 · 9 comments · Fixed by #1011
Closed

Option to cache results in between the runs #534

hakamairi opened this issue Nov 15, 2017 · 9 comments · Fixed by #1011
Milestone

Comments

@hakamairi
Copy link

Similar to phpcs --cache, would it be possible, and if so is it planed to give user an option to cache the phpmd results in order to improve performance of consecutive executions?

@leandromacedo
Copy link

Any news regarding this? This would be really useful!

@tvbeek
Copy link
Member

tvbeek commented Aug 29, 2019

There is currently not any active plan to implement this. But feel free to create a PR for this function.

@ravage84 ravage84 added this to the Future milestone Apr 17, 2020
@mlavrinenko
Copy link

Can using pdepend.xml be considered as a workaround?

<?xml version="1.0"?>
<symfony:container xmlns:symfony="http://symfony.com/schema/dic/services"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://pdepend.org/schema/dic/pdepend"
    xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
    <config>
        <cache>
            <driver>memory</driver>
        </cache>
    </config>
</symfony:container>

I've just created the file and it gave me x2 of execution speed.
ps. The file driver is available too, but almost as slow as regular execution (though I'm using ssd)

@mhnaufal
Copy link

mhnaufal commented May 4, 2023

Can using pdepend.xml be considered as a workaround?

<?xml version="1.0"?>
<symfony:container xmlns:symfony="http://symfony.com/schema/dic/services"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://pdepend.org/schema/dic/pdepend"
    xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
    <config>
        <cache>
            <driver>memory</driver>
        </cache>
    </config>
</symfony:container>

I've just created the file and it gave me x2 of execution speed. ps. The file driver is available too, but almost as slow as regular execution (though I'm using ssd)

But here in the PHPDepend docs (https://github.com/pdepend/pdepend/blob/2.13.0/src/site/rst/documentation/handbook/configuration/index.rst#cache) said that the use of memory driver "will force to parse the source on every call", it means there is no cache in there. Am I right, or anything I miss about on the docs?

@AJenbo
Copy link
Member

AJenbo commented May 4, 2023

it creates a runtime cache which will prevent repeat calculations during a single run

@frankdekker
Copy link
Contributor

frankdekker commented Jun 1, 2023

Is this still open for implementation? I might be interested in adding a result caching feature.

Flags:
--cache or --cache=.phpmd.cache.php. will default to .phpmd.cache.php if --cache is used

Store:

  • sha hash of the phpmd config
  • sha hash of the cli arguments
  • composer.lock
  • php version
  • all files that were inspected with sha hash of the contents of that file.
  • all issues that were found during inspection for that file
  • ... anything else?

Usage

  • compare the phpmd config + cli hashes are equal
  • compare the php version is equal
  • for each file compare the file content hash. If equal report the issues from the cache instead of running the inspection.
  • After completion persist the cache results back to .phpmd.cache.php or the file specified by --cache=<file>

Nice to have

  • cli toggle to do file modified timestamp compare instead of sha hash of the contents?

@AJenbo
Copy link
Member

AJenbo commented Jun 1, 2023

That would be fantastic!

PHP version is probably best to have in there as there are feature levels that won't be analyzed if not supported. Though it probably can't analyze a file that uses unsupported features.
You should probably also make a check on the installed version of PHPMD and it's dependencies.

@frankdekker
Copy link
Contributor

That would be fantastic!

PHP version is probably best to have in there as there are feature levels that won't be analyzed if not supported. Though it probably can't analyze a file that uses unsupported features. You should probably also make a check on the installed version of PHPMD and it's dependencies.

Updated the above comment. made phpversion mandatory, added composer.lock

@ndench
Copy link

ndench commented Jun 7, 2023

Sounds like a good plan @frankdekker!

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

Successfully merging a pull request may close this issue.

9 participants