-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Deprecations cause SourceMapper
to scan all <source/>
files
#6111
Comments
SourceMapper
to scan all <source/>
files
Thankyou! unfortuantely it doesn't seem to fix the issue. I added some screen recording with some diagnostic output below recording.mp4This runs a specific test with |
This comment has been minimized.
This comment has been minimized.
I cannot reproduce this: diff --git a/src/TextUI/Configuration/SourceMapper.php b/src/TextUI/Configuration/SourceMapper.php
index cbe8aa4c65..d173a17ee7 100644
--- a/src/TextUI/Configuration/SourceMapper.php
+++ b/src/TextUI/Configuration/SourceMapper.php
@@ -9,6 +9,8 @@
*/
namespace PHPUnit\TextUI\Configuration;
+use const FILE_APPEND;
+use function file_put_contents;
use function realpath;
use SebastianBergmann\FileIterator\Facade as FileIteratorFacade;
use SplObjectStorage;
@@ -30,6 +32,8 @@ final class SourceMapper
*/
public function map(Source $source): array
{
+ file_put_contents('/tmp/debug.txt', '*', FILE_APPEND);
+
if (self::$files === null) {
self::$files = new SplObjectStorage;
}
|
Thanks - the problem is not that I'll attempt to create a reproduction repo :) |
We need to perform this operation at least once. Before PHPUnit 11.5.4 it was performed for each deprecation. |
Here is a "reproduction" repository: https://github.com/dantleech/phpunit-6111 I think I understand why it's called, but wonder if it could be more efficient? We get the issue after upgrading from 10.5.37 (At the extreme I guess the |
Maybe For me, this issue was about unnecessarily doing the same work multiple times. This has been fixed, so I will close this issue now. |
I'd certainly consider contributing here! For me, in this project, it compromises the core value of PHPUnit - i.e. the tool is introducing latency due to a deprecation being issued (in our initial case 16 seconds) - this interupts the TDD cycle and is a source of confusion. While we may be able to optimise our That said I think there is more than one option:
Options 4 and 5 would be transparent improvements with option 5 being the most risky and challenging. I actually have poor solution to this exact problem in one of my open source projects so I'd have another reason for approaching that. I appreciate the time you've spent on this issue, let me know if you'd like me to contribute on any of the options above, and I may well attempt option 5 in my open-source project in anycase! |
"Do nothing" is not ideal, of course. "Defer processing" is not possible. We need to know the information that is (currently) expensive to determine at the time an "Opt-out" might be feasible. This would mean, of course, that the events that are emitted by the test runner (in the error handler) will not know whether the issue was triggered in/by first-party or third-party code. I am not entirely sure I understand "Do not traverse the entire tree for each Finally, "Compile all include/exclude rules to a single regex" seems like the ideal solution. On the code coverage side, we have had sebastianbergmann/php-code-coverage#386 open for almost ten years. So far, I have not dared working on this. As you correctly state, this is the "the most risky and challenging" option. TL;DR: Yes, I would appreciate any contribution you would like to make on "Do not traverse the entire tree for each And I will try to look into if/how "opt-out" could be tackled. |
This POC "compresses" the direcrories to a map of paths to prefixes,suffixes tuples. This can reduce the overhead of scanning paths when multiple directory elements are defined with the same path but differnet prefixes or suffixes. For example: ```xml <exclude> <directory suffix="Controller.php">src/</directory> <directory suffix="Factory.php">src/</directory> <directory suffix="Bus.php">src/</directory> <directory suffix="Car.php">src/</directory> </exclude> ``` Would be resolved as: ```php [ 'src/' => [ [], // no prefixes ['Controller.php', 'Factory.php', 'Bus.php', 'Car.php'], ], ], ``` The File Iterator already accepts an array of suffixes or prefixes.
This PR aggregates `<directory/>` entires to a map of paths to prefixes and suffixes. This can reduce the overhead of scanning paths when multiple `<directory/>` elements are defined with the same path but differnet prefixes or suffixes.
This PR aggregates the directories to a map of paths to tuples containing prefixes and suffixes. This will reduce the overhead of scanning paths when multiple directory elements are defined with the same path but differnet prefixes or suffixes. Addresses sebastianbergmann#6111
This PR aggregates the directories to a map of paths to tuples containing prefixes and suffixes. This will reduce the overhead of scanning paths when multiple directory elements are defined with the same path but differnet prefixes or suffixes. Addresses sebastianbergmann#6111
This PR aggregates the directories to a map of paths to tuples containing prefixes and suffixes. This will reduce the overhead of scanning paths when multiple directory elements are defined with the same path but differnet prefixes or suffixes. Addresses sebastianbergmann#6111
This PR aggregates the directories to a map of paths to tuples containing prefixes and suffixes. This will reduce the overhead of scanning paths when multiple directory elements are defined with the same path but differnet prefixes or suffixes. Addresses #6111
Summary
Hi 👋
When deprecations are encountered the
SouceMapper
recursively scans all files for each<source>
include and exclude paths.This causes a siginficant pause in PHPUnit as it scans all these files, initially for 16 seconds until we isolated the issue and refined the
<source>
list - now it's "only" 3 seconds.Current behavior
Scans all files when a deprecation is encountered.
How to reproduce
Add a
<source>
configuration:https://github.com/sebastianbergmann/phpunit/blob/main/src/Runner/ErrorHandler.php#L178
Expected behavior
That a triggered deprecation would not scan all the files and block the test run for N seconds.
The text was updated successfully, but these errors were encountered: