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

JGit should run its bookkeeping in the background #4116

Merged
merged 5 commits into from
Feb 3, 2023

Conversation

hubertp
Copy link
Contributor

@hubertp hubertp commented Feb 2, 2023

Pull Request Description

JGit ops generally run fast (as in a few milliseconds) except for the first commit. The initialization + first commit was taking at least 3.5 seconds constistenly, but only in the first test case. Now, this led to frequent timeouts down the chain when the request was expected to finish fast.
The bookkeeping involved some timestamping and other expensive calls in order to calculate clock drift. The default appears to be to run it in a blocking mode, hence adding at least 3 seconds to the first command call.

Setting the job to run in the background makes the cost of the repo initialization acceptable (~300 milliseconds on a cold JVM). The other commands are unaffected and take < 10 milliseconds.

Important Notes

Added a test to ensure that we don't introduce the regression. Marked it as potentially flaky because it uses timestamps and it is therefore prone to random system hiccups.

Checklist

Please include the following checklist in your PR:

  • The documentation has been updated if necessary.
  • All code conforms to the
    Scala,
    Java,
    and
    Rust
    style guides.
  • All code has been tested:
    • Unit tests have been written where possible.
    • If GUI codebase was changed: Enso GUI was tested when built using BOTH
      ./run ide build and ./run ide watch.

JGit ops generally run fast (as in a few milliseconds) except for the
first commit. The initialization + first commit was taking at least 3.5
seconds constistenly, but only in the first test case.
Now, this led to frequent timeouts down the chain when the request was
expected to finish fast.
The bookkeeping involved some timestamping and other expensive calls in
order to calculate clock drift. The default appears to be to run it in a
blocking mode, hence adding at least 3 seconds to the first command
call.

Setting the job to run in the background makes the cost of the repo
initialization, acceptable (200-400 milliseconds on a cold JVM). The
other commands are unaffected and take < 10 milliseconds.
@hubertp hubertp added the CI: No changelog needed Do not require a changelog entry for this PR. label Feb 2, 2023
@hubertp
Copy link
Contributor Author

hubertp commented Feb 2, 2023

As per (very hidden) documentation:

whether FileStore attributes should be determined asynchronously. If false access to cached attributes may block for some seconds for the first call per FileStore

I just wish they set it to true by default 🤦

@hubertp hubertp added the CI: Ready to merge This PR is eligible for automatic merge label Feb 2, 2023
@hubertp hubertp added the CI: Clean build required CI runners will be cleaned before and after this PR is built. label Feb 2, 2023
Copy link
Member

@JaroslavTulach JaroslavTulach left a comment

Choose a reason for hiding this comment

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

Doing "something sooner" is a classical way to improve UI responsiveness. Your change just uses FileStoreAttributes.setBackground(true), but I think we should do more. It is clear the JGit integration is going to be needed once user starts editing the program. We should pre-initialize the JGit infrastructure during startup.

In NetBeans (I know, I know) we tried to open and show main window as soon as possible. That gives the user early response, allow him to explore the IDE and choose what to do next. However that moment isn't "end of startup" - behind the scene we slowly (with low priority) continue initializing systems the user will likely need. For example we may perform a dry run of a Java parser, pre-load all menu items, initialize version control system support.

References:

I believe we should have something similar. A set of warm up tasks that get triggered by Akka as soon as the startup is "finished" (e.g. nodes are colored) and initialize JGit and its repository for now.

@hubertp
Copy link
Contributor Author

hubertp commented Feb 3, 2023

Doing "something sooner" is a classical way to improve UI responsiveness. Your change just uses FileStoreAttributes.setBackground(true), but I think we should do more. It is clear the JGit integration is going to be needed once user starts editing the program. We should pre-initialize the JGit infrastructure during startup.

Not necessarily. Files are obviously always saved periodically, independently of recording the history of the project. So user doesn't have to use ctrl+s.
Having said that, I agree that we could delay some of the initialization and there should be a pattern to do this across different micro-services that combine language-server.

I would still ask to get this one in as it currently interferes when normal startup execution expectations. At the same time a bigger overhaul of startup sequence is being planned, obviously.

@mergify mergify bot merged commit 50f376e into develop Feb 3, 2023
@mergify mergify bot deleted the wip/hubert/high-startup-jgit-184359934 branch February 3, 2023 10:37
@jdunkerley jdunkerley linked an issue Feb 7, 2023 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: Clean build required CI runners will be cleaned before and after this PR is built. CI: No changelog needed Do not require a changelog entry for this PR. CI: Ready to merge This PR is eligible for automatic merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

jgit insists on creating config files when initializing the project
3 participants