Cache all parsed config values to avoid reparsing them

The code-owners plugin has quite a lot of configuration parameters that
are accessed frequently. If reading config parameters is slow, this can
sum up to a significant amount of latency.

What we have done so far is that CodeOwnersPluginConfigSnapshot which
reads the project specific plugin configuration is cached for the time
of the request (see change If541bc329). This avoids loading the
code-owners.config file from this project and the parent projects again
and again. However whenever a config parameter is needed, we still
reparse it each time. Parsing a config parameter means inspecting the
Config that was read from the code-owners.config files and if necessary
fall-back to inspecting the Config that was read from gerrit.config.
With this change we do the parsing only once and cache the result in
CodeOwnersPluginConfigSnapshot.

In addition to project specific configuration parameters that are
handled by CodeOwnersPluginConfigSnapshot there are also a couple of
global configuration parameters that are handled in
CodeOwnersPluginConfiguration. For the global parameters we have the
same problem that they are reparsed on each access. E.g. the allowed
email domains are parsed each time a code owner email is resolved to an
account. This can be the reason why the step that resolves code owner
emails to accounts is rather slow. To address this we follow the example
of CodeOwnersPluginConfigSnapshot and add a
CodeOwnersPluginGlobalConfigSnapshot class that handles the reading of
the global config parameters. Same as CodeOwnersPluginConfigSnapshot it
is cached for the request time and internally it caches the parsed
config values so that they need to parsed only once.

To make it clearer that CodeOwnersPluginConfigSnapshot is about reading
project-specific configuration parameters, it is renamed to
CodeOwnersPluginProjectConfigSnapshot.

Change-Id: I6e4c608133717b598d356d1ce76246eb19b08c4b
Signed-off-by: Edwin Kempin <ekempin@google.com>
17 files changed
tree: 5cdd5457ae0010558dcab855edacc756e12fa058
  1. java/
  2. javatests/
  3. proto/
  4. resources/
  5. test/
  6. ui/
  7. .eslintrc.json
  8. .gitignore
  9. .gitreview
  10. bower.json
  11. BUILD
  12. LICENSE
  13. package-lock.json
  14. package.json
  15. README.md
README.md

Gerrit Code Review code-owners plugin

This plugin provides support for defining code owners for files in a repository.

If the code-owners plugin is enabled, changes can only be submitted if all touched files are covered by approvals from code owners.

Also see resources/Documentation/about.md.

IMPORTANT: Before installing/enabling the plugin follow the instructions from the setup guide, see resources/Documentation/setup-guide.md.