DiffOperations: Move the timeout logic inside the diff cache

In this change we do the following:

1) We move the timeout logic from DiffOperations to the
GitFileDiffCache. The timeout is enforced while computing the file
header (similar to the old diff cache, see [2]). If the computation
times out, we cache negative results. We enforce the timeout with a
boolean variable (see (2)). The FileDiffCache (which wraps the
GitFileDiffCache and performs extra logic, e.g. computing rebase edits)
will also cache negative results.

2) Add an extra boolean field to the GitFileDiffCacheKey and the
FileDiffCacheKey called "useTimeout". We only enforce timeouts if the
diff algorithm uses the Myers diff fallback.

The new logic now goes as follows: DiffOperations requests diffs using
the HISTOGRAM_WITH_MYERS algorithm and with useTimeout=true. If we get
back negative results (meaning that the computation times out), we
request the diffs again using the HISTOGRAM_NO_FALLBACK and with
useTimeouts=false (we don't want to enforce timeouts in this case). This
logic is matching what was done in old diff cache.

The reasonning behind this change is the following:

* The timeout logic in the old diff cache was added in the past (many
years ago) because of a bug in the Myers diff algorithm in JGit that
causes an infinite loop. See Ib00de070 and [1]. It looks like the bug
isn't fixed yet. The timeout was only employed while computing the file
header (see [2]) so was not enforced on the whole diff computation. [1]
suggets that if the JGit bug in Myers diff is fixed then we can remove
the timeouts in Gerrit, i.e. we did introduce the timeout logic in
Gerrit as a workaround for this bug.

* It wasn't a good idea to keep the timeout logic in DiffOperations:
This caused the @DiffExecutor to create new threads with every request
to get the diff, whether it's cached or not, and caused an overload to
the diff executor. With the logic of this change, once the result is
cached (whether positive or negative), we will not have to go through
the cache loader (or the timeout) logic again.

[1] bugs.chromium.org/p/gerrit/issues/detail?id=487
[2] https://gerrit.googlesource.com/gerrit/+/0dc27d2a5b512fdcb7ce5f95b412e174fe33c7d2/java/com/google/gerrit/server/patch/filediff/PatchListLoader.java#530

Change-Id: I680454cf93f78b90025bab95ed3717c74dbf32bf
13 files changed
tree: 9152df5d5495e7a4ecd7a896b92ea3558526858e
  1. .settings/
  2. .ts-out/
  3. antlr3/
  4. contrib/
  5. Documentation/
  6. e2e-tests/
  7. java/
  8. javatests/
  9. lib/
  10. modules/
  11. plugins/
  12. polygerrit-ui/
  13. prolog/
  14. prologtests/
  15. proto/
  16. resources/
  17. tools/
  18. webapp/
  19. .bazelignore
  20. .bazelproject
  21. .bazelrc
  22. .bazelversion
  23. .editorconfig
  24. .git-blame-ignore-revs
  25. .gitignore
  26. .gitmodules
  27. .gitreview
  28. .mailmap
  29. .pydevproject
  30. .zuul.yaml
  31. BUILD
  32. COPYING
  33. INSTALL
  34. Jenkinsfile
  35. package.json
  36. README.md
  37. SUBMITTING_PATCHES
  38. version.bzl
  39. WORKSPACE
  40. yarn.lock
README.md

Gerrit Code Review

Gerrit is a code review and project management tool for Git based projects.

Build Status Maven Central

Objective

Gerrit makes reviews easier by showing changes in a side-by-side display, and allowing inline comments to be added by any reviewer.

Gerrit simplifies Git based project maintainership by permitting any authorized user to submit changes to the master Git repository, rather than requiring all approved changes to be merged in by hand by the project maintainer.

Documentation

For information about how to install and use Gerrit, refer to the documentation.

Source

Our canonical Git repository is located on googlesource.com. There is a mirror of the repository on Github.

Reporting bugs

Please report bugs on the issue tracker.

Contribute

Gerrit is the work of hundreds of contributors. We appreciate your help!

Please read the contribution guidelines.

Note that we do not accept Pull Requests via the Github mirror.

Getting in contact

The Developer Mailing list is repo-discuss on Google Groups.

License

Gerrit is provided under the Apache License 2.0.

Build

Install Bazel and run the following:

    git clone --recurse-submodules https://gerrit.googlesource.com/gerrit
    cd gerrit && bazel build release

Install binary packages (Deb/Rpm)

The instruction how to configure GerritForge/BinTray repositories is here

On Debian/Ubuntu run:

    apt-get update & apt-get install gerrit=<version>-<release>

NOTE: release is a counter that starts with 1 and indicates the number of packages that have been released with the same version of the software.

On CentOS/RedHat run:

    yum clean all && yum install gerrit-<version>[-<release>]

On Fedora run:

    dnf clean all && dnf install gerrit-<version>[-<release>]

Use pre-built Gerrit images on Docker

Docker images of Gerrit are available on DockerHub

To run a CentOS 8 based Gerrit image:

    docker run -p 8080:8080 gerritcodereview/gerrit[:version]-centos8

To run a Ubuntu 20.04 based Gerrit image:

    docker run -p 8080:8080 gerritcodereview/gerrit[:version]-ubuntu20

NOTE: release is optional. Last released package of the version is installed if the release number is omitted.