pulsar-edit / github

:octocat: Git and GitHub integration for Pulsar
MIT License
5 stars 3 forks source link

GitHub package sometimes causes stuttering when switching buffers #14

Open savetheclocktower opened 1 year ago

savetheclocktower commented 1 year ago

Thanks in advance for your bug report!

What happened?

In certain circumstances — one I can reliably reproduce, and others that are more sporadic — the GitHub package seems to be the cause of a stuttering behavior that occurs when a buffer is made active. It appears to block the UI while it's doing work: the editor is unresponsive to clicks, and syntax highlighting stops partway through the file. The stuttering stops after a couple seconds.

I did a performance profile and it seems to be because the app is spending an unusual amount of time shelling out to git. Here's a shot of one profile I did:

Screen Shot 2023-01-24 at 11 47 38 AM

I put in a conditional breakpoint just so I could log the actual shell commands that are being run:

Screen Shot 2023-01-24 at 11 35 08 AM

Here's what that looks like:

Screen Shot 2023-01-24 at 11 34 54 AM

I had it log the arguments to exec along with a timestamp. You can see that the invocations of exec are spread several seconds apart. In theory it's good that the package seems to be yielding to the UI several times in between, but in practice the UI is still unresponsive until all these shell commands are done running.

In all these instances, the stuttering is occurring when (a) I've got a specific project open; (b) I open my snippets.cson within that project via Pulsar → Snippets…. The stuttering occurs on first open and whenever I switch tabs to a different buffer and then return to the snippets.cson tab. It does not occur when I switch between buffers for files within my project, but I've noticed similar symptoms when opening a project for the first time.

I can only guess that the package has to do extra work when I switch to editing a file that's not an ancestor of the project's root directory — it has to get some repo metadata that evidently doesn't get cached.

Atom 1.60.0 doesn't exhibit this behavior. I wanted to ascertain that it was hitting that same code path, but I can't, because git-shell-out-strategy.js doesn't exist in the equivalent location in the Atom.app bundle, nor can I find that file within the devtools.

Disabling the GitHub package definitely fixes the snippets.cson issue, and seems to improve startup time when opening a project.

Pulsar version

1.101.0-beta

Which OS does this happen on?

🍎 macOS

OS details

11.7.2

Which CPU architecture are you running this on?

64-bit(x86_64)

What steps are needed to reproduce this?

  1. Open a project that does not contain ~/.atom/snippets.cson as an ancestor. Open a couple of source files for editing.
  2. Open your snippets file via the menu. Observe the stuttering.
  3. Switch to another tab. No stuttering should happen.
  4. Switch back to the snippets.cson tab. Stuttering will happen.

Additional Information:

No response

confused-Techie commented 1 year ago

Thanks a ton for contributing!

This is an issue we are aware of and have marked as a Notice currently. But do appreciate having some solid numbers to compare with later on,

savetheclocktower commented 1 year ago

Ah, lovely. Is there an issue somewhere I can track?

confused-Techie commented 1 year ago

Ah, lovely. Is there an issue somewhere I can track?

Not that I'm aware of just yet, just something we have been keeping a mental note of since the root cause hasn't been fully determined. But ideally this can now be the issue to track, so it's a good thing you put it in