Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Skip formatting generated files #4296
Skip formatting generated files #4296
Changes from all commits
34a4e37
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not ideal to have another file system read (IIRC we're up to at least 3 due with this plus the parser and one for newline checks) 🤔
Would it be feasible to get the first line without the file system hit, maybe via the parse session data? Pperhaps it won't matter that much given the default is false, and/or could potentially be updated later
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(forgive me for the intrusion, i was recently doing work in this area and learned this: unless you're very low on memory, recently-accessed files are cached by the kernel and effectively free to access; the slowest part will be parsing)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no worries at all!
agreed, that's basically a given, and understand the main point about not strictly hitting the fs. though the intent of my original question wasn't really about a parsing/AST construction vs. additional file reads, it's whether the additional file read is necessary given that the file's already been read and loaded from the preceding parsing stage and available for use
do you know if that (especially the
effectively free
bit) holds true everywhere, for example Windows, CI environments, some of the tier 2/3 targets, etc?I'm not terribly familiar in that space, so entirely possible this approach is better than an alternative like using the span from the associated mod to get the first line from the snippet for the file, either more performant/negligible difference due to the caching or other reasons, and/or simpler from a code readability and management perspective 🤷♂️
Also readily admit such a question may be unnecessary/premature optimization, but figured I'd ask anyway 😄
minor edits for clarity
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, I agree that reusing data that is already and easily available is preferable. I just wanted to note that the performance implications of rereading a file may not be as high as it may appear, and that there are probably bigger bottlenecks. But I totally agree with you, no need to do extra work if you don't have to.
Re environments: most modern kernels (~last 20 years) have a page cache; this applies to windows as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, but I suppose I should've phrased my question better.
Was wondering more so if you thought there'd always be sufficient available memory to guarantee/near-guaranatee cache hit in all scenarios. I know even on my laptops I can get really memory constrained (as I tend to use lower end machines and still go overboard with multi tasking 😆), but a lot of CI environments can be pretty low on resources and one of the things I learned during the conversations on the compiler frontend for rls/ra is that there's plenty of folks doing their inner dev loop on some pretty resource constrainted environments, and even some remote workflows.
I genuinely don't know, but wouldn't be surprised if running in some of the more resource constrained environments (or those that purged more aggressively) and/or larger workspace projects could result in some cache misses and i/o hits.
I'm quickly getting out my depth though and will happily defer to @topecongiro on whether it's worth considering an alternative 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I first tried by using the span of
ast::Mod
, though it turned out that the span may not contain the comment at the beginning or the end of the file. I think that there are ways to get a correct span, though I opted for a simpler implementation this time.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works for me!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider adding a test for string w/o
@generated
or not on the first line.