Skip to content

CPU usage spikes due to refreshing sidebar indicators in background #7955

Closed

Description

@Tilmannn

Description

CPU usage spikes dramatically exactly every 15 Minutes when GitHub Desktop is running in the background. Probably related to this issue, which has been closed: #5789 For me the problem persists in newer versions.
This happens with automatic GPU switching enabled or disabled, and with both integrated or discrete GPU.

Version

  • GitHub Desktop:
    GitHub Desktop 2.1.0
  • Operating system:
    MacOS Mojave

MacBook Pro Retina 15' mid-2015
2,5 GHz Intel Core i7, 4 cores
16 GB 1600 MHz DDR3
500GB SSD, 200GB free space

Steps to Reproduce

Problem persists when just running the application.

Expected Behavior

Actual Behavior

Additional Information

Bildschirmfoto 2019-07-15 um 17 23 53

### Logs

Activity

  1. changed the title [-]CPU usage[/-] [+]CPU usage spikes every 15 minutes when GitHub Desktop is running[/+] on Jul 15, 2019
  2. steveward commented on Jul 16, 2019

    @steveward
    Contributor

    Thanks for the report @Tilmannn. A few questions:

    • Do you notice GitHub Desktop's performance halting when you see these CPU spikes? There were reports of that in hangs often #4290.
    • Are you working with repositories that have a large number of branches?
    • Could you upload the log file from GitHub Desktop? That should show if there are any specific operations that are taking a long time to complete.

    Thanks for writing in. Could you send over the log file from GitHub Desktop so that I could get some more information about this error? To access the log files go to the file menu in GitHub Desktop and select Help > Show Logs in Finder (macOS) or Explorer (Windows).

    Thanks!

  3. added
    more-info-needed
    on Jul 16, 2019
  4. Tilmannn commented on Jul 16, 2019

    @Tilmannn
    Author

    Hi @steveward thanks for the reply.

    • GitHub Desktop appears to be workin ok during the spike
    • Not a large number of branches, but a large number of files. Could that be the issue? I checked the log files and noticed the spikes were when the application ran background fetch.
    • Log file is attached. I deleted the repository it couldn't fetch.

    2019-07-16.desktop.production.log

  5. shiftkey commented on Jul 30, 2019

    @shiftkey
    Member

    I checked the log files and noticed the spikes were when the application ran background fetch.

    This is an interesting clue, and we can see from the logs that you have ~38 tracked in the repository. This action is refreshing the details in our repository sidebar list, to help with two scenarios:

    • you have uncommitted changes in the repository, and might want to push them to the remote
    • there are new commits for the current branch, that you might want to work with

    The function that does this work is here:

    public async refreshAllSidebarIndicators() {
    const startTime = performance && performance.now ? performance.now() : null
    // keep a reference to the current set of repositories to avoid the array
    // changing while this is running
    const repositories = new Array<Repository>(...this.repositories)
    for (const repo of repositories) {
    await this.refreshIndicatorForRepository(repo)
    }
    if (startTime && repositories.length > 1) {
    const delta = performance.now() - startTime
    const timeInSeconds = (delta / 1000).toFixed(3)
    log.info(
    `Background fetch for ${
    repositories.length
    } repositories took ${timeInSeconds}sec`
    )
    }
    this.emitUpdate()
    }

    refreshIndicatorForRepository will run a git status as well as a background fetch (based on API results and it's current state) and git status appears to be an expensive call for some of these repositories:

    2019-07-16T09:01:54.694Z - info: [ui] Executing getStatus: git --no-optional-locks status --untracked-files=all --branch --porcelain=2 -z (took 9.513s)
    2019-07-16T09:01:58.530Z - info: [ui] Executing getStatus: git --no-optional-locks status --untracked-files=all --branch --porcelain=2 -z (took 1.143s)
    2019-07-16T09:02:07.834Z - info: [ui] Executing getStatus: git --no-optional-locks status --untracked-files=all --branch --porcelain=2 -z (took 4.797s)
    2019-07-16T09:02:12.429Z - info: [ui] Executing getStatus: git --no-optional-locks status --untracked-files=all --branch --porcelain=2 -z (took 1.108s)
    2019-07-16T09:02:17.729Z - info: [ui] Executing getStatus: git --no-optional-locks status --untracked-files=all --branch --porcelain=2 -z (took 2.415s)
    2019-07-16T09:02:21.279Z - info: [ui] Background fetch for 38 repositories took 47.906sec
    

    This fits with the "large number of files" clue, as git status can be expensive on repositories with a large working directory.

    One workaround to ease the load here would be to remove repositories from Desktop that you aren't using regularly, but I'm not sure how many of these 38 repositories you are using regularly.

  6. added
    performance
    and removed
    more-info-needed
    on Jul 30, 2019
  7. changed the title [-]CPU usage spikes every 15 minutes when GitHub Desktop is running[/-] [+]CPU usage spikes due to refreshing sidebar indicators in background[/+] on Jul 30, 2019
  8. steveward commented on Mar 5, 2021

    @steveward
    Contributor

    Background fetching can now be disabled by going to Preferences -> Advanced -> Background updates and deselecting the checkbox. @Tilmannn I'm going to close this issue out since it should be resolved by disabling background fetching, but let us know if anything has changed on your end.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    performance

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions