Skip to content

DX: allow for progressive cache#7132

Merged
keradus merged 4 commits intoPHP-CS-Fixer:masterfrom
keradus:prog_cache
Jul 14, 2023
Merged

DX: allow for progressive cache#7132
keradus merged 4 commits intoPHP-CS-Fixer:masterfrom
keradus:prog_cache

Conversation

@keradus
Copy link
Copy Markdown
Member

@keradus keradus commented Jul 9, 2023

so, if fixing was interrupted in the middle, we can start from previous moment and not from scratch

@keradus keradus marked this pull request as ready for review July 9, 2023 00:33
Copy link
Copy Markdown
Member

@Wirone Wirone left a comment

Choose a reason for hiding this comment

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

Shouldn't it be tested somehow? But I am not sure it's possible to simulate process interruption... Other workarounds would rather trigger regular cache write.

In terms of configurable interval - for large codebases and/or inefficient file systems it should be possible to opt-out from this feature. Also I believe there's no need to write cache multiple times in CI (if it's used, I don't remember).

*/
final class FileCacheManager implements CacheManagerInterface
{
public const WRITE_FREQUENCY = 10;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Wouldn't it be better to have it dynamic (configurable)? Then it would be easier to test it, but also possible to fine-tune through config?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

for tests - I would suggest to go this part when we would have the good idea for test here.

for fine-tuning - I didn't see the need for that part, actually. I followed YAGNI here. happy to have this configurable if the needs pop up

@@ -32,6 +32,8 @@
*/
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Shouldn't it be tested somehow? But I am not sure it's possible to simulate process interruption...

@Wirone , I failed to do that while remaining sane. happy for contributions here, if anyone has good idea.

Copy link
Copy Markdown
Member

@Wirone Wirone Jul 10, 2023

Choose a reason for hiding this comment

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

Yeah, I tried to come up with test scenario for that and found it hard too 😉. The only thing that could reflect interruption, would be something like this:

  • trigger fix command in a process with timeout, and include some dummy fixer in the ruleset, which would do a sleep() for specific file and cause the timeout, but also would leave some mark it was done (creating file?)
  • trigger another fix with the same config, so cache is not invalidated, but this time there wouldn't be sleep() and it would go to the end

Test should verify if second run contains S statuses for files processed before timeouted file.

Of course there should be more than 10 files processed in the first run OR write interval should be configurable 😉.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

OR write interval should be configurable 😉.

no changes on my side:

for tests - I would suggest to go this part when we would have the good idea for test here.


Yeah, I tried to come up with test scenario for that and found it hard too 😉.

yeah, we can craft sth like this, but maybe it's overkill...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Decision is yours 🙂.

@keradus keradus merged commit 221ffbe into PHP-CS-Fixer:master Jul 14, 2023
@keradus keradus deleted the prog_cache branch July 14, 2023 09:41
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.

3 participants