Skip to content

Investigate whether we can short-circuit fetch #1252

Open

Description

@niik

This is an idea that stems from Desktop Classic that we discussed but never investigated.

From https://github.com/github/availability/pull/357#issuecomment-130076518

Did you think about some cheaper way to check if there has been any traffic on a repo? For example, repo reference updates could be assigned some kind of unique ID, and your inquiry could be "get the latest push ID".

We do store a pushed_at field on every repository that is updated with each push. [...]

We expose the pushed_at timestamp in the API with repository get.
https://developer.github.com/v3/repos/#get

If this is reliable and works well we could use that to avoid doing a fetch at all for background updates unless something has changed on the remote. This could spare us a great deal of network traffic in some scenarios as git fetch always retrieves a list of all references (including our "hidden" pull refs) and then matches those against the local refspec (run git ls-remote for an idea of what that mean).

For a large repository with a massive amount of pull requests this can actually add up. A "noop" atom/atom fetch takes a little over 2 seconds on my machine and pulls down 341kb of refs. Getting the pushed_at using the API on the other hand takes 0.6 seconds and pulls down 2k of data.

This would apply to GitHub repositories only.

Activity

  1. joshaber commented on Apr 21, 2017

    @joshaber
    Contributor

    It'd also mean we'd only have to lock refs when we know something actually changed, relevant to #1128.

  2. niik commented on May 26, 2017

    @niik
    MemberAuthor

    If this is reliable and works well we could use that to avoid doing a fetch at all for background updates unless something has changed on the remote.

    I took a quick look at this and it does seem to work reliably for git pushes and web flow commits. It doesn't, however, update when a new PR is created from a fork, targeting the repository in question. For our use case I don't think that's necessary since we don't fetch those refs anyway but it's worth making a note of.

  3. shiftkey commented on Feb 4, 2018

    @shiftkey
    Member

    Getting the pushed_at using the API on the other hand takes 0.6 seconds and pulls down 2k of data.

    It's about the same time with GraphQL but can be trimmed down to ~60 bytes of output:

  4. j-f1 commented on Feb 4, 2018

    @j-f1
    Contributor

    With aliases, you can decrease it even more:

    query {
      _: repository(owner: "desktop", name: "desktop") {
        _: updatedAt
      }
    }
  5. removed their assignment
    on Oct 17, 2018
  6. added
    not-planned
    on Jul 8, 2024
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

    enhancementnot-planned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions