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

Performance: only load files once #8008

Closed
kkmuffme opened this issue May 25, 2022 · 2 comments · Fixed by #8011
Closed

Performance: only load files once #8008

kkmuffme opened this issue May 25, 2022 · 2 comments · Fixed by #8011

Comments

@kkmuffme
Copy link
Contributor

FileProvider.php function getContents

When logging the $file_path directly before:

return (string)file_get_contents($file_path);

I can see the same files getting opened multiple times between 2-100s of times. 90% of file_get_contents calls here are duplicates, which means psalm could be 4% faster if that didn't happen.

We check if the file was opened before, but this is useless, since it's always empty:

if (isset($this->open_files[$file_path_lc])) {
            return $this->open_files[$file_path_lc];
}

Changing $open_files to a static and using self::$open_files should fix this.
I tried this - however weirdly enough, $open_files still is always empty.

Any idea why this is happening though? (I can provide a PR with the static, however it has the same issue)

@psalm-github-bot
Copy link

Hey @kkmuffme, can you reproduce the issue on https://psalm.dev ?

@kkmuffme
Copy link
Contributor Author

No, this is an psalm internal issue.

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

Successfully merging a pull request may close this issue.

1 participant