-
Notifications
You must be signed in to change notification settings - Fork 63
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
LFFormatter
is slow
#1342
Comments
While working on #1389, I noticed that the |
Update -- I think the real problem is that the Spotless format task restarts the jar for every file, which is bad. This should be an easy fix. |
This problem became pressing now as we now expect contributors to run I added this issue to the 0.5.0 milestone as I think it needs to be addressed ASAP. |
A fix for this is in progress. Until it is merged I recommend to
|
Can we configure spotless such that it does not format the LF files when running the gradle task? I mean, we do have lff and if it is the preferred method for formatting files is lff, then why have a redundant gradle task? We can quite as well run |
Spotless provides some features, such as ensuring that the formatter is idempotent and checking that files are formatted, without actually formatting them. In order for these to work, we have to plug the LF formatter into Spotless. |
This is an issue extracted from the review of #1227.
Code formatting should be fast. This is feasible because formatting should be linear in the length of a file, and file lengths should always be bounded in practice (e.g., no more than a few thousand lines). It is necessary because it is common for programmers to set VS Code to "format on save" so that the code on their screen is never ugly for long, even if they are too lazy to format anything by hand.
However, the algorithm used in
LFFormatter
is not fast, nor is it even linear in the length of a file. It has undergone zero performance optimization because it is good enough to format the toy examples in our test suite and because when I wrote it, I was primarily concerned with rapidly setting an example of how LF files should be formatted. It should be easy to optimize the algorithm and at least give it an acceptable time complexity.If we cannot make the algorithm faster than a typical human reaction time for all non-pathological files, then we should provide a way to cancel the formatting process in the IDE. This is easy to do using the cancel indicator object.
The text was updated successfully, but these errors were encountered: