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

Introduce FilteringResultsCollector #1430

Merged
merged 12 commits into from Nov 21, 2020

Conversation

sanmai
Copy link
Member

@sanmai sanmai commented Nov 18, 2020

This PR:

  • Adds FilteringResultsCollector that excludes unneeded mutation results depending on logging/debugging configuration.
  • Covered by tests
  • Benchmarks

I'm not too happy about TargetDetectionStatusesProvider because it does what individual loggers should provide, but that should do it for now. Changing the loggers to supply this information to TargetDetectionStatusesProvider will require fairly substantial refactoring with otherwise uncertain benefits.

Follow-up to #1425

Blackfire is a bit flacky, here are the screenshots.

  • Versus the current master
  • Versus 0.20.1

@sanmai sanmai marked this pull request as ready for review November 19, 2020 09:26
src/Container.php Outdated Show resolved Hide resolved
@sanmai sanmai removed the request for review from maks-rafalko November 19, 2020 15:13
@sanmai sanmai marked this pull request as draft November 19, 2020 15:13
@sanmai sanmai marked this pull request as ready for review November 20, 2020 02:02
Copy link
Member

@theofidry theofidry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm 👍. Again I cannot focus on the code details atm but the general idea looks good to me.

I however have one reserve but I think it's your plans anyway: I don't think the current TargetDetectionStatusesProvider make any sense.

Its role – if I understand correctly, is to provide which status to filter by to the filter for the collector, collector that is tailored for the loggers.

I guess we can add:

interface MutationTestingResultsLogger {
  // ...

  /**
   * @return string[]
   */
  getUsedDetectionStatuses(): array;
}

So the logger registry can combine all of them without having to know any details. However the tricky part is to achieve that since we are creating the loggers lazily by passing the factory to the subscriber...

So maybe we will need a LoggerProxy which takes the factory and instantiate the underlying loggers underneath. This way both the subscriber and the provider can consume this proxy (which can implement the interface of the logger even).

I'm also wondering about the name, what do you think of renaming TargetDetectionStatusesProvider to LoggerDetectionStatusDetector?

I also wonder if it would make sense to start documenting this part of our application, this is starting to be a complex piece of the app with a lot of indirections...

Copy link
Member

@maks-rafalko maks-rafalko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌

I also wonder if it would make sense to start documenting this part of our application, this is starting to be a complex piece of the app with a lot of indirections...

agree. Any good examples of how to do it?

@sanmai
Copy link
Member Author

sanmai commented Nov 20, 2020

@theofidry I'm 100% on board with you on the state of TargetDetectionStatusesProvider. I tried to go this getUsedDetectionStatuses() route, but found, like you said, even if some of the loggers would implement such method, it is difficult to get to them both because they're created after the fact, and because they're behind several layer of abstraction.

I'm also wondering about the name, what do you think of renaming TargetDetectionStatusesProvider to LoggerDetectionStatusDetector?

This is a certainly more appropriate name considering the current state of affairs, but I named it such because it is supposed to feed from loggers. It is not supposed to detect anything, in a perfect world. What do you think about LoggerDetectionStatusProvider?

I'll update the code to link to your review.

@sanmai
Copy link
Member Author

sanmai commented Nov 21, 2020

I'm going to merge this for now, to see if I can do more in this direction in a next PR.

@sanmai sanmai merged commit 5070460 into infection:master Nov 21, 2020
@sanmai sanmai deleted the pr/2020-11/cus-collector branch November 21, 2020 11:16
@theofidry
Copy link
Member

theofidry commented Nov 21, 2020

It is not supposed to detect anything, in a perfect world. What do you think about LoggerDetectionStatusProvider?

I was seeing more as "detect/find out what detection status the loggers are gonna use"

like you said, even if some of the loggers would implement such method, it is difficult to get to them both because they're created after the fact, and because they're behind several layer of abstraction.

But with this LoggerProxy we can fix that right? (understood that this would be done in a separate PR)

@sanmai sanmai mentioned this pull request Jan 18, 2021
2 tasks
sanmai added a commit that referenced this pull request Jan 22, 2021
In the light of #1430 it doesn't make sense to keep Infection suggesting logging at all times. Keeping old behavior will mean that Infection will use 66% more memory where it could not.
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 this pull request may close these issues.

None yet

3 participants