Speed up presubmit by caching code-owners check [chromium/tools/depot_tools : main]

0 views
Skip to first unread message

Josiah Kiehl (Gerrit)

unread,
Dec 4, 2025, 8:28:16 PM (2 days ago) Dec 4
to Yiwei Zhang, chromium...@chromium.org, chops-source-team...@google.com
Attention needed from Yiwei Zhang

Josiah Kiehl added 1 comment

Patchset-level comments
File-level comment, Patchset 2 (Latest):
Josiah Kiehl . unresolved

We might also want to do this for IsCodeOwnersEnabledOnHost, but I figured I'd get buy in on this CL before doing that.

Open in Gerrit

Related details

Attention is currently required from:
  • Yiwei Zhang
Submit Requirements:
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/tools/depot_tools
Gerrit-Branch: main
Gerrit-Change-Id: I1a3631074d1bcbb1a254caa6654fd8434f069aa2
Gerrit-Change-Number: 7227749
Gerrit-PatchSet: 2
Gerrit-Owner: Josiah Kiehl <ki...@google.com>
Gerrit-Reviewer: Yiwei Zhang <yiwz...@google.com>
Gerrit-Attention: Yiwei Zhang <yiwz...@google.com>
Gerrit-Comment-Date: Fri, 05 Dec 2025 01:28:13 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
unsatisfied_requirement
open
diffy

Yiwei Zhang (Gerrit)

unread,
Dec 5, 2025, 1:05:17 PM (15 hours ago) Dec 5
to Josiah Kiehl, LUCI CQ, chromium...@chromium.org, chops-source-team...@google.com
Attention needed from Josiah Kiehl

Yiwei Zhang added 1 comment

Patchset-level comments
File-level comment, Patchset 3 (Latest):
Yiwei Zhang . unresolved

I think caching is a good idea given the enablement of code owners plugin should never changes. However, I'm wondering if there's any particular reason to cache the result in git config rather than in memory (e.g. using @functools.lru_cache decorator) ?

Open in Gerrit

Related details

Attention is currently required from:
  • Josiah Kiehl
Submit Requirements:
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/tools/depot_tools
Gerrit-Branch: main
Gerrit-Change-Id: I1a3631074d1bcbb1a254caa6654fd8434f069aa2
Gerrit-Change-Number: 7227749
Gerrit-PatchSet: 3
Gerrit-Owner: Josiah Kiehl <ki...@google.com>
Gerrit-Reviewer: Josiah Kiehl <ki...@google.com>
Gerrit-Reviewer: Yiwei Zhang <yiwz...@google.com>
Gerrit-Attention: Josiah Kiehl <ki...@google.com>
Gerrit-Comment-Date: Fri, 05 Dec 2025 18:05:15 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
unsatisfied_requirement
open
diffy

Josiah Kiehl (Gerrit)

unread,
Dec 5, 2025, 1:31:37 PM (14 hours ago) Dec 5
to LUCI CQ, Yiwei Zhang, chromium...@chromium.org, chops-source-team...@google.com
Attention needed from Yiwei Zhang

Josiah Kiehl added 1 comment

Patchset-level comments
Yiwei Zhang . unresolved

I think caching is a good idea given the enablement of code owners plugin should never changes. However, I'm wondering if there's any particular reason to cache the result in git config rather than in memory (e.g. using @functools.lru_cache decorator) ?

Josiah Kiehl

I was thinking it would be nice to persist on disk somewhere, and the git config is a convenient place to store it per-repository. If we store it in memory, we'll have to make the call once every presubmit time we run a script?

Open in Gerrit

Related details

Attention is currently required from:
  • Yiwei Zhang
Submit Requirements:
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/tools/depot_tools
Gerrit-Branch: main
Gerrit-Change-Id: I1a3631074d1bcbb1a254caa6654fd8434f069aa2
Gerrit-Change-Number: 7227749
Gerrit-PatchSet: 3
Gerrit-Owner: Josiah Kiehl <ki...@google.com>
Gerrit-Reviewer: Josiah Kiehl <ki...@google.com>
Gerrit-Reviewer: Yiwei Zhang <yiwz...@google.com>
Gerrit-Attention: Yiwei Zhang <yiwz...@google.com>
Gerrit-Comment-Date: Fri, 05 Dec 2025 18:31:35 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Yiwei Zhang <yiwz...@google.com>
unsatisfied_requirement
open
diffy

Yiwei Zhang (Gerrit)

unread,
Dec 5, 2025, 4:51:38 PM (11 hours ago) Dec 5
to Josiah Kiehl, LUCI CQ, chromium...@chromium.org, chops-source-team...@google.com
Attention needed from Josiah Kiehl

Yiwei Zhang added 1 comment

Patchset-level comments
Yiwei Zhang . unresolved

I think caching is a good idea given the enablement of code owners plugin should never changes. However, I'm wondering if there's any particular reason to cache the result in git config rather than in memory (e.g. using @functools.lru_cache decorator) ?

Josiah Kiehl

I was thinking it would be nice to persist on disk somewhere, and the git config is a convenient place to store it per-repository. If we store it in memory, we'll have to make the call once every presubmit time we run a script?

Yiwei Zhang

That also might not work well with non-git environment. Stepping back a little bit, it looks like we did cache the result at [the caller](https://source.chromium.org/chromium/chromium/tools/depot_tools/+/main:presubmit_support.py;l=598-602;drc=2e88a3f08bd8c4a0014eae82729beca935f7f188). Therefore, it should just make the call once for each presubmit run. Are you saying that the call itself could just take 1.5s?

Open in Gerrit

Related details

Attention is currently required from:
  • Josiah Kiehl
Submit Requirements:
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/tools/depot_tools
Gerrit-Branch: main
Gerrit-Change-Id: I1a3631074d1bcbb1a254caa6654fd8434f069aa2
Gerrit-Change-Number: 7227749
Gerrit-PatchSet: 3
Gerrit-Owner: Josiah Kiehl <ki...@google.com>
Gerrit-Reviewer: Josiah Kiehl <ki...@google.com>
Gerrit-Reviewer: Yiwei Zhang <yiwz...@google.com>
Gerrit-Attention: Josiah Kiehl <ki...@google.com>
Gerrit-Comment-Date: Fri, 05 Dec 2025 21:51:35 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Yiwei Zhang <yiwz...@google.com>
Comment-In-Reply-To: Josiah Kiehl <ki...@google.com>
unsatisfied_requirement
open
diffy

Josiah Kiehl (Gerrit)

unread,
Dec 5, 2025, 5:09:09 PM (11 hours ago) Dec 5
to LUCI CQ, Yiwei Zhang, chromium...@chromium.org, chops-source-team...@google.com
Attention needed from Josiah Kiehl

Josiah Kiehl added 1 comment

Patchset-level comments
Yiwei Zhang . unresolved

I think caching is a good idea given the enablement of code owners plugin should never changes. However, I'm wondering if there's any particular reason to cache the result in git config rather than in memory (e.g. using @functools.lru_cache decorator) ?

Josiah Kiehl

I was thinking it would be nice to persist on disk somewhere, and the git config is a convenient place to store it per-repository. If we store it in memory, we'll have to make the call once every presubmit time we run a script?

Josiah Kiehl

I believe you're right, it only makes one call per process, but it typically takes 0.7s from my glinux cloudtop, though it can take as much as 1.5s in the worst case. This log is in nearly 100% of my `git cl presubmit` runs:

```
Running presubmit commit checks on branch optimize_check_for_commit_objects ...
checking owners took a long time: 0.7s
```

I suppose we do need a different place to put the config for cog/jj environments... I'm not sure where that would be tho, off hand. I will ponder unless you have an idea.

Open in Gerrit

Related details

Attention is currently required from:
  • Josiah Kiehl
Submit Requirements:
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/tools/depot_tools
Gerrit-Branch: main
Gerrit-Change-Id: I1a3631074d1bcbb1a254caa6654fd8434f069aa2
Gerrit-Change-Number: 7227749
Gerrit-PatchSet: 3
Gerrit-Owner: Josiah Kiehl <ki...@google.com>
Gerrit-Reviewer: Josiah Kiehl <ki...@google.com>
Gerrit-Reviewer: Yiwei Zhang <yiwz...@google.com>
Gerrit-Attention: Josiah Kiehl <ki...@google.com>
Gerrit-Comment-Date: Fri, 05 Dec 2025 22:09:06 +0000
unsatisfied_requirement
open
diffy

Josiah Kiehl (Gerrit)

unread,
Dec 5, 2025, 5:15:51 PM (10 hours ago) Dec 5
to LUCI CQ, Yiwei Zhang, chromium...@chromium.org, chops-source-team...@google.com
Attention needed from Yiwei Zhang

Josiah Kiehl added 1 comment

Patchset-level comments
Yiwei Zhang . unresolved

I think caching is a good idea given the enablement of code owners plugin should never changes. However, I'm wondering if there's any particular reason to cache the result in git config rather than in memory (e.g. using @functools.lru_cache decorator) ?

Josiah Kiehl

I was thinking it would be nice to persist on disk somewhere, and the git config is a convenient place to store it per-repository. If we store it in memory, we'll have to make the call once every presubmit time we run a script?

Josiah Kiehl

I believe you're right, it only makes one call per process, but it typically takes 0.7s from my glinux cloudtop, though it can take as much as 1.5s in the worst case. This log is in nearly 100% of my `git cl presubmit` runs:

```
Running presubmit commit checks on branch optimize_check_for_commit_objects ...
checking owners took a long time: 0.7s
```

I suppose we do need a different place to put the config for cog/jj environments... I'm not sure where that would be tho, off hand. I will ponder unless you have an idea.

Josiah Kiehl

Another possibility is that the latency is serverside and the server itself is taking this long and needs to cache the response or make it cacheable or something of that nature.

Open in Gerrit

Related details

Attention is currently required from:
  • Yiwei Zhang
Submit Requirements:
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/tools/depot_tools
Gerrit-Branch: main
Gerrit-Change-Id: I1a3631074d1bcbb1a254caa6654fd8434f069aa2
Gerrit-Change-Number: 7227749
Gerrit-PatchSet: 3
Gerrit-Owner: Josiah Kiehl <ki...@google.com>
Gerrit-Reviewer: Josiah Kiehl <ki...@google.com>
Gerrit-Reviewer: Yiwei Zhang <yiwz...@google.com>
Gerrit-Attention: Yiwei Zhang <yiwz...@google.com>
Gerrit-Comment-Date: Fri, 05 Dec 2025 22:15:48 +0000
unsatisfied_requirement
open
diffy

Josiah Kiehl (Gerrit)

unread,
Dec 5, 2025, 7:37:21 PM (8 hours ago) Dec 5
to LUCI CQ, Yiwei Zhang, chromium...@chromium.org, chops-source-team...@google.com
Attention needed from Yiwei Zhang

Josiah Kiehl added 1 comment

Patchset-level comments
Yiwei Zhang . unresolved

I think caching is a good idea given the enablement of code owners plugin should never changes. However, I'm wondering if there's any particular reason to cache the result in git config rather than in memory (e.g. using @functools.lru_cache decorator) ?

Josiah Kiehl

I was thinking it would be nice to persist on disk somewhere, and the git config is a convenient place to store it per-repository. If we store it in memory, we'll have to make the call once every presubmit time we run a script?

Josiah Kiehl

I believe you're right, it only makes one call per process, but it typically takes 0.7s from my glinux cloudtop, though it can take as much as 1.5s in the worst case. This log is in nearly 100% of my `git cl presubmit` runs:

```
Running presubmit commit checks on branch optimize_check_for_commit_objects ...
checking owners took a long time: 0.7s
```

I suppose we do need a different place to put the config for cog/jj environments... I'm not sure where that would be tho, off hand. I will ponder unless you have an idea.

Josiah Kiehl

Another possibility is that the latency is serverside and the server itself is taking this long and needs to cache the response or make it cacheable or something of that nature.

Josiah Kiehl

Digging deeper, I figured out why I was seeing it take 1.5s when the config request usually takes 0.7s.... it's because my benchmark code was capturing the handshake request as well, which happens the first time any request is made, so it's actually 2 requests when the request is not cached, and both of those requests are 0.7s+ in latency, so caching does indeed save a consistent 1.5s per `git cl presubmit` run on my cloudtop, which maths out to a >200x performance improvement.

```
--- Run 1 (Cache Disabled / First Run) ---
BENCHMARK_REQ_START: GET http://chromium-review.git.corp.google.com/a/accounts/self/emails
BENCHMARK_REQ_END: GET http://chromium-review.git.corp.google.com/a/accounts/self/emails took 0.9099s
BENCHMARK_REQ_START: GET http://chromium-review.git.corp.google.com/a/projects/chromium%2Fsrc/code_owners.project_config
BENCHMARK_REQ_END: GET http://chromium-review.git.corp.google.com/a/projects/chromium%2Fsrc/code_owners.project_config took 0.6481s
Result: True
Total time: 1.6346s

--- Run 2 (Cache Enabled / Second Run) ---
Result: True
Total time: 0.0076s
```

Open in Gerrit

Related details

Attention is currently required from:
  • Yiwei Zhang
Submit Requirements:
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/tools/depot_tools
Gerrit-Branch: main
Gerrit-Change-Id: I1a3631074d1bcbb1a254caa6654fd8434f069aa2
Gerrit-Change-Number: 7227749
Gerrit-PatchSet: 5
Gerrit-Owner: Josiah Kiehl <ki...@google.com>
Gerrit-Reviewer: Josiah Kiehl <ki...@google.com>
Gerrit-Reviewer: Yiwei Zhang <yiwz...@google.com>
Gerrit-Attention: Yiwei Zhang <yiwz...@google.com>
Gerrit-Comment-Date: Sat, 06 Dec 2025 00:37:18 +0000
unsatisfied_requirement
open
diffy

Josiah Kiehl (Gerrit)

unread,
Dec 5, 2025, 9:14:59 PM (7 hours ago) Dec 5
to LUCI CQ, Yiwei Zhang, chromium...@chromium.org, chops-source-team...@google.com
Attention needed from Yiwei Zhang

Josiah Kiehl added 1 comment

File gerrit_util.py
Line 138, Patchset 8 (Latest):def _AtomicFileWriter(path, mode='w'):
Josiah Kiehl . unresolved

This writes to the config directory in favor of git config, per the other comment thread. I would use something like the atomicwrites lib for this, but idk how reasonable it is to add a dependency... and this code is not too involved to maintain, perhaps.

Open in Gerrit

Related details

Attention is currently required from:
  • Yiwei Zhang
Submit Requirements:
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/tools/depot_tools
Gerrit-Branch: main
Gerrit-Change-Id: I1a3631074d1bcbb1a254caa6654fd8434f069aa2
Gerrit-Change-Number: 7227749
Gerrit-PatchSet: 8
Gerrit-Owner: Josiah Kiehl <ki...@google.com>
Gerrit-Reviewer: Josiah Kiehl <ki...@google.com>
Gerrit-Reviewer: Yiwei Zhang <yiwz...@google.com>
Gerrit-Attention: Yiwei Zhang <yiwz...@google.com>
Gerrit-Comment-Date: Sat, 06 Dec 2025 02:14:56 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
unsatisfied_requirement
open
diffy
Reply all
Reply to author
Forward
0 new messages