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

Terrible performance on Windows if home directory is on network share #447

Closed
InvisibleSmiley opened this issue Jan 22, 2020 · 8 comments
Closed

Comments

@InvisibleSmiley
Copy link

  • PHP Depend version: 2.6.1
  • PHP Version: 7.3.12
  • Installation type: Composer
  • Operating System / Distribution & Version: Windows 10
  • no pdepend.xml / pdepend.xml.dist in directory to be checked with PHPMD

Current Behavior

Calling PHPMD (2.8.1) with a simple file takes ~6 seconds on Windows if your home directory is on a network share.

Expected Behavior

The performance should be equal (or very similar) to that if a pdepend.xml / pdepend.xml.dist is present in the directory to be checked with PHPMD (~0.4 seconds).

Steps To Reproduce:

  • have the home directory of your Windows user on a network share (common corporate setup)
  • set up current PHPMD (using PHP Depend) for a project
  • make sure the project contains no pdepend.xml / pdepend.xml.dist file
  • let PHPMD check some file
@tvbeek
Copy link
Member

tvbeek commented Jan 22, 2020

Thanks for the report, I have one question: do you run PHPMD from your home directory or from your project root?

@InvisibleSmiley
Copy link
Author

InvisibleSmiley commented Jan 22, 2020

I have one question: do you run PHPMD from your home directory or from your project root?

I run it from the project root which is a subdirectory of my Windows user's profile directory (which itself is a directory below C:\Users and equal to %USERPROFILE%).
The path CMD starts in is H: (equal to %HOMEDRIVE%) which is connected to the network share (network path equal to %HOMESHARE%).

Example:

  • Windows user profile: C:\Users\foo
  • Repo "bar" root: C:\Users\foo\bar
  • Windows user home on network share: H:

@kylekatarnls
Copy link
Member

PDepend user cache lies in HOME as it is for composer or many CLI tools. If the access to your HOME directory is slow (which is possibly the root cause and should be handled anyway by your company as an IT issue) you can override it to use a local directory:

HOME=C:\phpmd phpmd ...

You should compare with some other tools that use the same principle such as: composer config user.name -g which is supposed to read ~/.composer directory. If it is either slow, then you're more likely have a bandwidth issue not related to PDepend/PHPMD.

@InvisibleSmiley
Copy link
Author

InvisibleSmiley commented Jan 22, 2020

PDepend user cache lies in HOME as it is for composer or many CLI tools. If the access to your HOME directory is slow (which is possibly the root cause and should be handled anyway by your company as an IT issue) you can override it to use a local directory:

HOME=C:\phpmd phpmd ...

I set the HOME environment variable to my Windows user profile directory (say C:\Users\foo) long ago, ever since I found that this accelerates starting commands like vim from Git Bash. Note that my Windows user profile directory is on the internal SSD. No performance problems due to network or slow HDD there.

@kylekatarnls
Copy link
Member

Found it:

        if ((PHP_OS === 'Darwin') || (PHP_OS === 'CYGWIN') || (false === stripos(PHP_OS, 'win'))) {
            return getenv('HOME');
        }
        return getenv('HOMEDRIVE') . getenv('HOMEPATH');

This is how PDepend find the home path. I guess we should first get getenv('HOME') for Windows too and only fallback to HOMEDRIVE + HOMEPATH if it's empty.

@kylekatarnls kylekatarnls added the Good first issue If you want to help, this may be a good start label Jan 22, 2020
@InvisibleSmiley
Copy link
Author

Found it:

        if ((PHP_OS === 'Darwin') || (PHP_OS === 'CYGWIN') || (false === stripos(PHP_OS, 'win'))) {
            return getenv('HOME');
        }
        return getenv('HOMEDRIVE') . getenv('HOMEPATH');

This is how PDepend find the home path. I guess we should first get getenv('HOME') for Windows too and only fallback to HOMEDRIVE + HOMEPATH if it's empty.

Makes sense, sounds good to me! :)

@kylekatarnls
Copy link
Member

On the next version or yet in dev-master you can now set custom directory to HOME for any OS.

@ravage84
Copy link
Contributor

ravage84 commented Apr 9, 2020

@InvisibleSmiley I am going to close this issue as the related PR has been merged.

We identified a general issue with the file caching mechanism of PDepend, which we will track in another issue.

Please try to make use of the now available HOME environment variable to work around your specific problem.
In general I would try to stay away from working on a network share as often as I can.

@ravage84 ravage84 closed this as completed Apr 9, 2020
@ravage84 ravage84 added Cache and removed Good first issue If you want to help, this may be a good start labels Apr 17, 2020
@ravage84 ravage84 added this to the 2.x (unspecific) milestone May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

4 participants