-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Improve developer experience of code coverage performance improvements #3301
Comments
@sebastianheuer @hollodotme Do you think that this makes sense / could work? |
@sebastianbergmann Makes absolutely sense to me and actually I'd prefer this proposed approach, because the current implementation would need updates on every CI config to invoke phpunit twice (per test suite). |
+1, but wouldn't this still require two runs of phpunit? |
It would be slow on the first run and fast(er) on subsequent runs |
We may need to store a hash of |
Keeping an eye on the configuration and figuring out if a cache is still relevant (or even valid) for a new configuration is something I ran into, too. Things that popped up when working on the cache test reordering:
I have some sketches for an improved cache that behaves much nicer in such edge cases. |
One of the issues I'm seeing (while implementing this) is caused by the requirement to call |
@sebastianheuer Good point. So my question is how much the overall execution slows down, if the |
Dumping the whitelist is pretty quick, it would add maybe 2 seconds to the overall execution time. I remember @sebastianbergmann and I were discussing this behaviour during the code sprint, but it felt a bit weird. |
@hollodotme One thing I do not want is to restart PHPUnit. The complexity this would add does not, IMO, is not justified by also having the first run be fast(er). |
Yes, programs restarting themselves is kind of weird. Even though composer does that in some cases as far as I know. How about the idea to make that explicit for the user. Instead of EDIT: @sebastianbergmann Sorry, didn't see your comment while posting. |
@sebastianbergmann How would you have handled the second invocation regarding your initial proposal? Or did you mean that the first run dumps the file, but does not apply the Xdebug filter and is slower for that reason? |
@sebastianbergmann , https://github.com/composer/xdebug-handler may be interesting idea - not perfect match for this case, but it automate when and how CLI command shall be restarted |
@hollodotme That is exactly what I mean. |
@keradus I know about xdebug-handler, but even just using that (without having to implement the functionality ourselves) adds too much complexity, IMO. |
Another approach could be to blacklist PHPUnit's own code first before bootstrapping PHPUnit and setting a whitelist for the code under test before loading the tests. A quick proof-of-concept proved to bring almost the same speed improvements as the prepended whitelist. I do think that this approach would probably work best with the PHAR, as that contains all the dependencies, whereas only parts of PHPUnit would be blacklisted when installed via composer, as the project's vendor directory would not be part of the blacklist. While this will not give us the maximum benefit, it would not require any changes or additional steps on the user side. |
I like that approach @sebastianheuer! |
Can blacklist and whitelist be used together? |
According to Xdebug's documentation not, but then again it seems to work ;) Without knowing the internals I can only assume that the whitelist replaces the blacklist, which is okay in this case as all the backlisted code has already been loaded at that point in time so that no coverage information is collected. |
@sebastianheuer I don't think it is actually used in combination in your implementation. I think the second |
I would like to get input from @derickr on this. However, he is currently on vacation AFAIK. |
I think it's best to automatically restart PHPUnit, like Composer does, so that this benefits all users, even ones that have not heard of a cache at all. |
@sebastianheuer Can you implement this and send a pull request? |
I am going to release what we have right now (what @sebastianheuer implemented during the last code sprint) next week as part of PHPUnit 7.4. We can improve on this later. |
I am struggling a bit with implementing the composer-style restart. One of the simplest things I can imagine right now is calling |
Adding my two cents: Talking about Currently, it just silently does not a thing and we won't obviously check this part. |
@soullivaneuh There is not really something we can do about this (that makes sense), I am afraid. If your Xdebug does not have |
@sebastianbergmann Perhaps an early fork that generates file on a predefined location (before fork) which is later included? It could be a clean solution, where fork just executes dump. One step further could be to use shared memory + eval so that nothing is written do disc? |
Is there any comparison of this versus running Eg:
(options |
|
That's interesting, thanks, do you have any more info on those accuracy issues? |
Hints: If you dont use composers autoload (opcache and other caches OFF) the improvement is low but improves :-)
Well. This seems to be the vendor/phpunit/* stuff I would expect NOT implementing/ activate this improvment by default (or already in?). A flag for the phpunit.xml would be good! Kind regards |
I do not think that there is any value in pursuing this further. Personally, I stopped using Xdebug for code coverage a while ago and instead use PCOV. Eventually we may even want to remove |
With #3272 and #3290, the performance of the collection and processing of code coverage data is significantly improved when Xdebug 2.6 (or later) is used.
Right now, this requires PHPUnit to be invoked with
--dump-xdebug-filter
to generate a PHP script with whitelist configuration code for Xdebug any time the whitelist configuration is changed inphpunit.xml
. PHPUnit then needs to be invoked with--prepend
to load that generated PHP script before any other code is loaded.This ticket proposes the idea of removing the
--dump-xdebug-filter
and--prepend
options (right now this would not be a BC break as, at this point, they were never released) and instead always generate a.phpunit.xdebug.filter
PHP script in the directory in which PHPUnit is invoked (similar to.phpunit.result.cache
) and automatically load this file if it exists and Xdebug > 2.6 is used.The text was updated successfully, but these errors were encountered: