Skip to content

Conversation

@pjkaufman
Copy link
Collaborator

@pjkaufman pjkaufman commented Mar 16, 2024

Fixes #337
Relates to #927
Relates to #872
This should unblock #488 which gets us closer to #183

To make the linting experience better for users, it is better if we can run the linting logic on a separate thread from the main thread. This will allow the user to be able to work on things if linting a file is taking a while. Most rules can run in the web workers. But the ones that deal with moment or obsidian specific logic have to remain on the main thread since they cannot have their data passed to and from the web worker (this is a limitation due to the complexity of the moment object) and because the source code is not available at compile time which makes it impossible to inline the logic from obsidian. So we have to compromise a little here. But this should still be a net improvement for users with larger files or who use mass linting options on their vaults. This will need to be in BETA for some time if possible. So I will need to setup BRAT for this change.

TODO:

  • Swap out uses of the RulesRunner class for references to the lint file manager
  • Make sure linting on active file contents change works (i.e. just the YAML Timestamp Update)
    • No timestamp update when changes backed out before timeout hit
    • Timestamp updated when a single character is added and timeout hit
    • Timestamp updated when a single character is added and lint is run immediately after with no changes made
    • No timestamp update is made when yaml-timestamp or all are disabled rules in the frontmatter
  • Make sure linting on active file change works
    • Make sure linting on active file change works when custom commands are used and no change is made
    • Make sure linting on active file change works when custom commands are used and a change is made
  • Make sure regular linting works
    • Make sure regular linting works when custom commands are used and no change is made
    • Make sure regular linting works when custom commands are used and a change is made
  • Make sure linting a folder works
  • Make sure linting the vault works
  • Make sure linting on paste works
  • Make sure that linting a file with YAML frontmatter that says that all rules are disabled does not run custom commands
  • Make sure that regular rule disabling via the YAML frontmatter is respected
  • Remove old copy folder and files
  • Move linting functions to the utils folder as a lint or lint-runner file since it is just a set of related functions that are useful when running linting operations
    • These should mostly be used by the file lint manager, but we shall see
  • See about setting a timeout on how long the worker can run before it will throw an error to prevent an infinite loop from happening and not allowing more linting to happen
    • I am thinking that 5 or 10 minutes should be a good value to use as a measurement
    • This will help out with making sure that we prevent long running lints from happening unexpectedly
    • We may want a user override, but that can probably wait until users request it
  • Break up rules runner UTs into their own separate files to make sure that things still work as intended
    • Maybe add more UTs to see how things work together if possible
  • Make sure logs make sense
    • Make sure encountered an is converted into text that can be properly translated into other languages
    • Make sure to add logic for the disabled rules value being all gets logged properly around skipping the file
  • Look into high memory usage in worker

If we want to have more than 1 worker running at a time:

  • See about adding file name to logs in console log for lints since there may be 2+ workers now which will make things pretty hectic when it comes to making sure that logs are displayed back to back in the console

@pjkaufman pjkaufman self-assigned this Mar 16, 2024
@pjkaufman pjkaufman added the enhancement New feature or request label Mar 16, 2024
@pjkaufman
Copy link
Collaborator Author

I am going to beef up the integration test suite for this to make sure I have a higher degree of confidence that this is working as expected. Right now I am not entirely sure that I am at a good point to move forward with this PR since I am feeling a little overwhelmed thinking about all of the manual testing that will be needed. If I add enough ITs, it should give me a better feeling of certainty as to the reliability of these changes.

@pjkaufman
Copy link
Collaborator Author

I am going to start on this again and just try to get it ready for beta testing. I plan to focus on this unless really easy or really pressing issues pop up in the meantime.

…oad (if it stops working as I add things it needs to be addressed)
…ile working. Note that the logging is not working properly.
…quired for rules to run and added some more changes to get closer to getting the worker setup in place for all linting types
…d the old rules runner which should be replaced by the worker now
… issue with open file having changed to no longer default to making the opened file active, and other small changes
@pjkaufman
Copy link
Collaborator Author

I believe linting a file and folder are working. The log situation has yet to be ironed out. But it looks like changes are being made. I am still only testing using 1 web worker. When this goes live, I would like to have it be around 3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FR: Use Web Workers to Improve Lint All and Lint Folder Experience

1 participant