Optimize macOS reflink copies in gclient-new-workdir [chromium/tools/depot_tools : main]

0 views
Skip to first unread message

Erik Staab (Gerrit)

unread,
Mar 23, 2026, 1:19:52 PM (24 hours ago) Mar 23
to Justin Cohen, chromium...@chromium.org, chops-source-team...@google.com
Attention needed from Justin Cohen

Erik Staab added 1 comment

File gclient-new-workdir.py
Line 101, Patchset 1 (Latest): return '-c' if sys.platform == 'darwin' else '--reflink'
Erik Staab . unresolved

Note that there is a darwin check here to control the reflink flag. If we won't hit the darwin path here anymore maybe `--reflink` can be hardcoded on line 276.

Open in Gerrit

Related details

Attention is currently required from:
  • Justin Cohen
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: I6058d19a5a9a73fff2e8cc2b0d926695bb418487
Gerrit-Change-Number: 7691305
Gerrit-PatchSet: 1
Gerrit-Owner: Justin Cohen <justi...@google.com>
Gerrit-CC: Erik Staab <est...@chromium.org>
Gerrit-Attention: Justin Cohen <justi...@google.com>
Gerrit-Comment-Date: Mon, 23 Mar 2026 17:19:50 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
unsatisfied_requirement
open
diffy

Kirubel Aklilu (Gerrit)

unread,
Mar 23, 2026, 1:21:29 PM (24 hours ago) Mar 23
to Justin Cohen, chromium...@chromium.org, chops-source-team...@google.com
Attention needed from Justin Cohen

Kirubel Aklilu added 2 comments

File gclient-new-workdir.py
Line 101, Patchset 1 (Latest): return '-c' if sys.platform == 'darwin' else '--reflink'
Kirubel Aklilu . unresolved

Should we replace this with an `assert not(sys.platform == 'darwin')` since this method isn't hit on Mac anymore?

Line 272, Patchset 1 (Latest): clonefile_darwin(root, workdir)
Kirubel Aklilu . unresolved

Should we catch the error and try to fallback to a regular copy? That's documented the behavior of `cp -c` on Mac.

Open in Gerrit

Related details

Attention is currently required from:
  • Justin Cohen
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: I6058d19a5a9a73fff2e8cc2b0d926695bb418487
Gerrit-Change-Number: 7691305
Gerrit-PatchSet: 1
Gerrit-Owner: Justin Cohen <justi...@google.com>
Gerrit-Reviewer: Kirubel Aklilu <kak...@chromium.org>
Gerrit-CC: Erik Staab <est...@chromium.org>
Gerrit-Attention: Justin Cohen <justi...@google.com>
Gerrit-Comment-Date: Mon, 23 Mar 2026 17:21:27 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
unsatisfied_requirement
open
diffy

Justin Cohen (Gerrit)

unread,
Mar 23, 2026, 2:20:36 PM (23 hours ago) Mar 23
to Kirubel Aklilu, Erik Staab, chromium...@chromium.org, chops-source-team...@google.com
Attention needed from Erik Staab and Kirubel Aklilu

Justin Cohen added 4 comments

Patchset-level comments
File-level comment, Patchset 2 (Latest):
Justin Cohen . resolved

ptal

File gclient-new-workdir.py
Line 101, Patchset 1: return '-c' if sys.platform == 'darwin' else '--reflink'
Erik Staab . resolved

Note that there is a darwin check here to control the reflink flag. If we won't hit the darwin path here anymore maybe `--reflink` can be hardcoded on line 276.

Justin Cohen

Done

Line 101, Patchset 1: return '-c' if sys.platform == 'darwin' else '--reflink'
Kirubel Aklilu . resolved

Should we replace this with an `assert not(sys.platform == 'darwin')` since this method isn't hit on Mac anymore?

Justin Cohen

Done

Line 272, Patchset 1: clonefile_darwin(root, workdir)
Kirubel Aklilu . unresolved

Should we catch the error and try to fallback to a regular copy? That's documented the behavior of `cp -c` on Mac.

Justin Cohen

Good idea. I fell back to cp -a -c, not just -c. Is that what you meant?

Open in Gerrit

Related details

Attention is currently required from:
  • Erik Staab
  • Kirubel Aklilu
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: I6058d19a5a9a73fff2e8cc2b0d926695bb418487
Gerrit-Change-Number: 7691305
Gerrit-PatchSet: 2
Gerrit-Owner: Justin Cohen <justi...@google.com>
Gerrit-Reviewer: Kirubel Aklilu <kak...@chromium.org>
Gerrit-CC: Erik Staab <est...@chromium.org>
Gerrit-Attention: Kirubel Aklilu <kak...@chromium.org>
Gerrit-Attention: Erik Staab <est...@chromium.org>
Gerrit-Comment-Date: Mon, 23 Mar 2026 18:20:34 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Kirubel Aklilu <kak...@chromium.org>
Comment-In-Reply-To: Erik Staab <est...@chromium.org>
unsatisfied_requirement
open
diffy

Justin Cohen (Gerrit)

unread,
Mar 23, 2026, 2:21:31 PM (23 hours ago) Mar 23
to Mark Mentovai, Erik Staab, Kirubel Aklilu, chromium...@chromium.org, chops-source-team...@google.com
Attention needed from Erik Staab, Kirubel Aklilu and Mark Mentovai

Justin Cohen added 1 comment

Patchset-level comments
Justin Cohen . resolved

mark@ on my m1 macbook gclient-new-workdir goes from taking over 10 minutes to less than 2 minutes. I'm curious if it's faster on newer macbooks. Can you ptal?

Open in Gerrit

Related details

Attention is currently required from:
  • Erik Staab
  • Kirubel Aklilu
  • Mark Mentovai
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: I6058d19a5a9a73fff2e8cc2b0d926695bb418487
Gerrit-Change-Number: 7691305
Gerrit-PatchSet: 2
Gerrit-Owner: Justin Cohen <justi...@google.com>
Gerrit-Reviewer: Erik Staab <est...@chromium.org>
Gerrit-Reviewer: Kirubel Aklilu <kak...@chromium.org>
Gerrit-Reviewer: Mark Mentovai <ma...@chromium.org>
Gerrit-Attention: Mark Mentovai <ma...@chromium.org>
Gerrit-Attention: Kirubel Aklilu <kak...@chromium.org>
Gerrit-Attention: Erik Staab <est...@chromium.org>
Gerrit-Comment-Date: Mon, 23 Mar 2026 18:21:29 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
unsatisfied_requirement
open
diffy

Kirubel Aklilu (Gerrit)

unread,
Mar 23, 2026, 2:24:42 PM (23 hours ago) Mar 23
to Justin Cohen, Mark Mentovai, Erik Staab, chromium...@chromium.org, chops-source-team...@google.com
Attention needed from Erik Staab, Justin Cohen and Mark Mentovai

Kirubel Aklilu voted and added 1 comment

Votes added by Kirubel Aklilu

Code-Review+1

1 comment

File gclient-new-workdir.py
Line 272, Patchset 1: clonefile_darwin(root, workdir)
Kirubel Aklilu . resolved

Should we catch the error and try to fallback to a regular copy? That's documented the behavior of `cp -c` on Mac.

Justin Cohen

Good idea. I fell back to cp -a -c, not just -c. Is that what you meant?

Kirubel Aklilu

Yes, that's right

Open in Gerrit

Related details

Attention is currently required from:
  • Erik Staab
  • Justin Cohen
  • Mark Mentovai
Submit Requirements:
    • requirement is not satisfiedCode-Owners
    • requirement satisfiedCode-Review
    • requirement 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: I6058d19a5a9a73fff2e8cc2b0d926695bb418487
    Gerrit-Change-Number: 7691305
    Gerrit-PatchSet: 2
    Gerrit-Owner: Justin Cohen <justi...@google.com>
    Gerrit-Reviewer: Erik Staab <est...@chromium.org>
    Gerrit-Reviewer: Kirubel Aklilu <kak...@chromium.org>
    Gerrit-Reviewer: Mark Mentovai <ma...@chromium.org>
    Gerrit-Attention: Mark Mentovai <ma...@chromium.org>
    Gerrit-Attention: Justin Cohen <justi...@google.com>
    Gerrit-Attention: Erik Staab <est...@chromium.org>
    Gerrit-Comment-Date: Mon, 23 Mar 2026 18:24:39 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    Comment-In-Reply-To: Justin Cohen <justi...@google.com>
    Comment-In-Reply-To: Kirubel Aklilu <kak...@chromium.org>
    unsatisfied_requirement
    satisfied_requirement
    open
    diffy

    Mark Mentovai (Gerrit)

    unread,
    Mar 23, 2026, 2:38:11 PM (22 hours ago) Mar 23
    to Justin Cohen, Kirubel Aklilu, Erik Staab, chromium...@chromium.org, chops-source-team...@google.com
    Attention needed from Erik Staab and Justin Cohen

    Mark Mentovai added 5 comments

    Patchset-level comments
    Mark Mentovai . resolved

    Does this ever need to copy things across filesystems?

    File gclient-new-workdir.py
    Line 120, Patchset 2 (Latest): ['cp', '-a', cp_copy_on_write_flag(), src, dest],
    Mark Mentovai . unresolved

    Can’t the `--reflink` be here now, in-line?

    Line 122, Patchset 2 (Latest): except (subprocess.CalledProcessError, OSError):
    Mark Mentovai . unresolved

    I’d prefer to be explicit: the Apple one might raise an OSError, the subprocess one might raise a CalledProcessError, and there’s no overlap.

    Line 157, Patchset 2 (Latest): src_index = os.path.join(src_git_dir, 'index')
    dest_index = os.path.join(dest_git_dir, 'index')
    if sys.platform == 'darwin':
    clonefile_darwin(src_index, dest_index)
    else:
    subprocess.check_call([
    'cp',
    '-a',
    cp_copy_on_write_flag(),
    src_index,
    dest_index,
    ])
    Mark Mentovai . unresolved

    Now that I see this happening a second time: you should really refactor this into common logic. There should be a function that knows how to copy(src, dest), and let it figure out whether to dispatch to the Apple function or start a cp subprocess.

    I see a third and fourth follow, so, an even stronger justification.

    Line 291, Patchset 2 (Latest): except OSError:
    subprocess.check_call(
    ['cp', '-a', '-c', root, workdir])
    Mark Mentovai . unresolved

    ?

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Erik Staab
    • Justin Cohen
    Submit Requirements:
      • requirement is not satisfiedCode-Owners
      • requirement satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      • requirement 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: I6058d19a5a9a73fff2e8cc2b0d926695bb418487
      Gerrit-Change-Number: 7691305
      Gerrit-PatchSet: 2
      Gerrit-Owner: Justin Cohen <justi...@google.com>
      Gerrit-Reviewer: Erik Staab <est...@chromium.org>
      Gerrit-Reviewer: Kirubel Aklilu <kak...@chromium.org>
      Gerrit-Reviewer: Mark Mentovai <ma...@chromium.org>
      Gerrit-Attention: Justin Cohen <justi...@google.com>
      Gerrit-Attention: Erik Staab <est...@chromium.org>
      Gerrit-Comment-Date: Mon, 23 Mar 2026 18:38:01 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      unsatisfied_requirement
      satisfied_requirement
      open
      diffy

      Mark Mentovai (Gerrit)

      unread,
      Mar 23, 2026, 3:09:16 PM (22 hours ago) Mar 23
      to Justin Cohen, Kirubel Aklilu, Erik Staab, chromium...@chromium.org, chops-source-team...@google.com
      Attention needed from Erik Staab and Justin Cohen

      Mark Mentovai added 1 comment

      Patchset-level comments
      Justin Cohen . unresolved

      mark@ on my m1 macbook gclient-new-workdir goes from taking over 10 minutes to less than 2 minutes. I'm curious if it's faster on newer macbooks. Can you ptal?

      Mark Mentovai

      mark@ on my m1 macbook gclient-new-workdir goes from taking over 10 minutes to less than 2 minutes. I'm curious if it's faster on newer macbooks. Can you ptal?

      Original:

      ```
      % time PYTHONPATH=/chrome/depot_tools python3 /tmp/gclient-new-workdir_old-649c49853f28cbaec21bd80cf7df9cec.py /slash/chrome/chrome /slash/chrome/chrome.justin
      […]
      PYTHONPATH=/chrome/depot_tools python3 /slash/chrome/chrome 1.52s user 140.87s system 89% cpu 2:39.60 total
      ```

      This is actually worse than using `--no-reflink`:

      ```
      % time PYTHONPATH=/chrome/depot_tools python3 /tmp/gclient-new-workdir_old-649c49853f28cbaec21bd80cf7df9cec.py --no-reflink /slash/chrome/chrome /slash/chrome/chrome.justin
      […]
      37.77s user 57.30s system 81% cpu 1:56.20 total

      ```

      Yours:

      ```
      % time PYTHONPATH=/chrome/depot_tools python3 /tmp/gclient-new-workdir_new-a199c80e238c2ef2fa9df7d7f54c31d3.py /slash/chrome/chrome /slash/chrome/chrome.justin
      […]
      0.07s user 6.95s system 32% cpu 21.772 total
      ```

      It then takes 1m14s to `rm -r`.

      Additional thoughts:

      I usually refer to /chrome, which is a symbolic link to /slash/chrome, but when I use /chrome/chrome.justin as the new_workdir, it totally messes up this script (both original and your modification): it detects copy-on write support, makes an empty directory at new_workdir, sticks a .gclient symbolic link in it, and then exits successfully with a cheerful message that it used copy-on-write. Total time 0.120s, but new_workdir doesn’t have anything other than .gclient in it.

      Gerrit-Comment-Date: Mon, 23 Mar 2026 19:09:14 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Justin Cohen <justi...@google.com>
      unsatisfied_requirement
      satisfied_requirement
      open
      diffy

      Mark Mentovai (Gerrit)

      unread,
      Mar 23, 2026, 5:01:07 PM (20 hours ago) Mar 23
      to Justin Cohen, Kirubel Aklilu, Erik Staab, chromium...@chromium.org, chops-source-team...@google.com
      Attention needed from Erik Staab and Justin Cohen

      Mark Mentovai added 1 comment

      Patchset-level comments
      Justin Cohen . unresolved

      mark@ on my m1 macbook gclient-new-workdir goes from taking over 10 minutes to less than 2 minutes. I'm curious if it's faster on newer macbooks. Can you ptal?

      Mark Mentovai

      mark@ on my m1 macbook gclient-new-workdir goes from taking over 10 minutes to less than 2 minutes. I'm curious if it's faster on newer macbooks. Can you ptal?

      Original:

      ```
      % time PYTHONPATH=/chrome/depot_tools python3 /tmp/gclient-new-workdir_old-649c49853f28cbaec21bd80cf7df9cec.py /slash/chrome/chrome /slash/chrome/chrome.justin
      […]
      PYTHONPATH=/chrome/depot_tools python3 /slash/chrome/chrome 1.52s user 140.87s system 89% cpu 2:39.60 total
      ```

      This is actually worse than using `--no-reflink`:

      ```
      % time PYTHONPATH=/chrome/depot_tools python3 /tmp/gclient-new-workdir_old-649c49853f28cbaec21bd80cf7df9cec.py --no-reflink /slash/chrome/chrome /slash/chrome/chrome.justin
      […]
      37.77s user 57.30s system 81% cpu 1:56.20 total

      ```

      Yours:

      ```
      % time PYTHONPATH=/chrome/depot_tools python3 /tmp/gclient-new-workdir_new-a199c80e238c2ef2fa9df7d7f54c31d3.py /slash/chrome/chrome /slash/chrome/chrome.justin
      […]
      0.07s user 6.95s system 32% cpu 21.772 total
      ```

      It then takes 1m14s to `rm -r`.

      Additional thoughts:

      I usually refer to /chrome, which is a symbolic link to /slash/chrome, but when I use /chrome/chrome.justin as the new_workdir, it totally messes up this script (both original and your modification): it detects copy-on write support, makes an empty directory at new_workdir, sticks a .gclient symbolic link in it, and then exits successfully with a cheerful message that it used copy-on-write. Total time 0.120s, but new_workdir doesn’t have anything other than .gclient in it.

      Mark Mentovai

      I usually refer to /chrome, which is a symbolic link to /slash/chrome, but when I use /chrome/chrome.justin as the new_workdir, it totally messes up this script (both original and your modification): it detects copy-on write support, makes an empty directory at new_workdir, sticks a .gclient symbolic link in it, and then exits successfully with a cheerful message that it used copy-on-write. Total time 0.120s, but new_workdir doesn’t have anything other than .gclient in it.

      Probably due to the inconsistent application of `os.path.realpath` (ugh).

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Erik Staab
      • Justin Cohen
      Submit Requirements:
      • requirement is not satisfiedCode-Owners
      • requirement satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      • requirement 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: I6058d19a5a9a73fff2e8cc2b0d926695bb418487
      Gerrit-Change-Number: 7691305
      Gerrit-PatchSet: 3
      Gerrit-Owner: Justin Cohen <justi...@google.com>
      Gerrit-Reviewer: Erik Staab <est...@chromium.org>
      Gerrit-Reviewer: Kirubel Aklilu <kak...@chromium.org>
      Gerrit-Reviewer: Mark Mentovai <ma...@chromium.org>
      Gerrit-Attention: Justin Cohen <justi...@google.com>
      Gerrit-Attention: Erik Staab <est...@chromium.org>
      Gerrit-Comment-Date: Mon, 23 Mar 2026 21:01:05 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Mark Mentovai <ma...@chromium.org>
      Comment-In-Reply-To: Justin Cohen <justi...@google.com>
      unsatisfied_requirement
      satisfied_requirement
      open
      diffy

      Justin Cohen (Gerrit)

      unread,
      Mar 23, 2026, 5:27:08 PM (20 hours ago) Mar 23
      to Kirubel Aklilu, Mark Mentovai, Erik Staab, chromium...@chromium.org, chops-source-team...@google.com
      Attention needed from Erik Staab and Mark Mentovai

      Justin Cohen added 4 comments

      File gclient-new-workdir.py
      Line 120, Patchset 2: ['cp', '-a', cp_copy_on_write_flag(), src, dest],
      Mark Mentovai . resolved

      Can’t the `--reflink` be here now, in-line?

      Justin Cohen

      Done

      Line 122, Patchset 2: except (subprocess.CalledProcessError, OSError):
      Mark Mentovai . resolved

      I’d prefer to be explicit: the Apple one might raise an OSError, the subprocess one might raise a CalledProcessError, and there’s no overlap.

      Justin Cohen

      Done

      Line 157, Patchset 2: src_index = os.path.join(src_git_dir, 'index')

      dest_index = os.path.join(dest_git_dir, 'index')
      if sys.platform == 'darwin':
      clonefile_darwin(src_index, dest_index)
      else:
      subprocess.check_call([
      'cp',
      '-a',
      cp_copy_on_write_flag(),
      src_index,
      dest_index,
      ])
      Mark Mentovai . resolved

      Now that I see this happening a second time: you should really refactor this into common logic. There should be a function that knows how to copy(src, dest), and let it figure out whether to dispatch to the Apple function or start a cp subprocess.

      I see a third and fourth follow, so, an even stronger justification.

      Justin Cohen

      Done

      Line 291, Patchset 2: except OSError:

      subprocess.check_call(
      ['cp', '-a', '-c', root, workdir])
      Mark Mentovai . resolved

      ?

      Justin Cohen

      Kirubel requested we fall back to this if it fails.

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Erik Staab
      • Mark Mentovai
      Submit Requirements:
      • requirement is not satisfiedCode-Owners
      • requirement satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      • requirement 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: I6058d19a5a9a73fff2e8cc2b0d926695bb418487
      Gerrit-Change-Number: 7691305
      Gerrit-PatchSet: 5
      Gerrit-Owner: Justin Cohen <justi...@google.com>
      Gerrit-Reviewer: Erik Staab <est...@chromium.org>
      Gerrit-Reviewer: Kirubel Aklilu <kak...@chromium.org>
      Gerrit-Reviewer: Mark Mentovai <ma...@chromium.org>
      Gerrit-Attention: Mark Mentovai <ma...@chromium.org>
      Gerrit-Attention: Erik Staab <est...@chromium.org>
      Gerrit-Comment-Date: Mon, 23 Mar 2026 21:27:06 +0000
      unsatisfied_requirement
      satisfied_requirement
      open
      diffy

      Justin Cohen (Gerrit)

      unread,
      Mar 23, 2026, 5:27:27 PM (20 hours ago) Mar 23
      to Kirubel Aklilu, Mark Mentovai, Erik Staab, chromium...@chromium.org, chops-source-team...@google.com
      Attention needed from Erik Staab and Mark Mentovai

      Justin Cohen added 1 comment

      Patchset-level comments
      Mark Mentovai . resolved

      Does this ever need to copy things across filesystems?

      Justin Cohen

      I don't know. I'm sure someone will try to do that.

      Gerrit-Comment-Date: Mon, 23 Mar 2026 21:27:25 +0000
      unsatisfied_requirement
      satisfied_requirement
      open
      diffy

      Justin Cohen (Gerrit)

      unread,
      Mar 23, 2026, 5:37:54 PM (19 hours ago) Mar 23
      to Kirubel Aklilu, Mark Mentovai, Erik Staab, chromium...@chromium.org, chops-source-team...@google.com
      Attention needed from Erik Staab and Mark Mentovai

      Justin Cohen added 1 comment

      Patchset-level comments
      File-level comment, Patchset 2:
      Justin Cohen . resolved

      mark@ on my m1 macbook gclient-new-workdir goes from taking over 10 minutes to less than 2 minutes. I'm curious if it's faster on newer macbooks. Can you ptal?

      Mark Mentovai

      mark@ on my m1 macbook gclient-new-workdir goes from taking over 10 minutes to less than 2 minutes. I'm curious if it's faster on newer macbooks. Can you ptal?

      Original:

      ```
      % time PYTHONPATH=/chrome/depot_tools python3 /tmp/gclient-new-workdir_old-649c49853f28cbaec21bd80cf7df9cec.py /slash/chrome/chrome /slash/chrome/chrome.justin
      […]
      PYTHONPATH=/chrome/depot_tools python3 /slash/chrome/chrome 1.52s user 140.87s system 89% cpu 2:39.60 total
      ```

      This is actually worse than using `--no-reflink`:

      ```
      % time PYTHONPATH=/chrome/depot_tools python3 /tmp/gclient-new-workdir_old-649c49853f28cbaec21bd80cf7df9cec.py --no-reflink /slash/chrome/chrome /slash/chrome/chrome.justin
      […]
      37.77s user 57.30s system 81% cpu 1:56.20 total

      ```

      Yours:

      ```
      % time PYTHONPATH=/chrome/depot_tools python3 /tmp/gclient-new-workdir_new-a199c80e238c2ef2fa9df7d7f54c31d3.py /slash/chrome/chrome /slash/chrome/chrome.justin
      […]
      0.07s user 6.95s system 32% cpu 21.772 total
      ```

      It then takes 1m14s to `rm -r`.

      Additional thoughts:

      I usually refer to /chrome, which is a symbolic link to /slash/chrome, but when I use /chrome/chrome.justin as the new_workdir, it totally messes up this script (both original and your modification): it detects copy-on write support, makes an empty directory at new_workdir, sticks a .gclient symbolic link in it, and then exits successfully with a cheerful message that it used copy-on-write. Total time 0.120s, but new_workdir doesn’t have anything other than .gclient in it.

      Mark Mentovai

      I usually refer to /chrome, which is a symbolic link to /slash/chrome, but when I use /chrome/chrome.justin as the new_workdir, it totally messes up this script (both original and your modification): it detects copy-on write support, makes an empty directory at new_workdir, sticks a .gclient symbolic link in it, and then exits successfully with a cheerful message that it used copy-on-write. Total time 0.120s, but new_workdir doesn’t have anything other than .gclient in it.

      Probably due to the inconsistent application of `os.path.realpath` (ugh).

      Justin Cohen

      I think patchset 6 will fix this. Can you try again?

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Erik Staab
      • Mark Mentovai
      Submit Requirements:
        • requirement is not satisfiedCode-Owners
        • requirement satisfiedCode-Review
        • requirement 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: I6058d19a5a9a73fff2e8cc2b0d926695bb418487
        Gerrit-Change-Number: 7691305
        Gerrit-PatchSet: 6
        Gerrit-Owner: Justin Cohen <justi...@google.com>
        Gerrit-Reviewer: Erik Staab <est...@chromium.org>
        Gerrit-Reviewer: Kirubel Aklilu <kak...@chromium.org>
        Gerrit-Reviewer: Mark Mentovai <ma...@chromium.org>
        Gerrit-Attention: Mark Mentovai <ma...@chromium.org>
        Gerrit-Attention: Erik Staab <est...@chromium.org>
        Gerrit-Comment-Date: Mon, 23 Mar 2026 21:37:52 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        Comment-In-Reply-To: Mark Mentovai <ma...@chromium.org>
        Comment-In-Reply-To: Justin Cohen <justi...@google.com>
        unsatisfied_requirement
        satisfied_requirement
        open
        diffy

        Mark Mentovai (Gerrit)

        unread,
        10:02 AM (3 hours ago) 10:02 AM
        to Justin Cohen, Kirubel Aklilu, Erik Staab, chromium...@chromium.org, chops-source-team...@google.com
        Attention needed from Erik Staab and Justin Cohen

        Mark Mentovai added 7 comments

        File gclient-new-workdir.py
        Line 95, Patchset 6 (Latest): libc_path = ctypes.util.find_library("c")
        Mark Mentovai . unresolved

        This file seems to `'single-quote'` string literals. Stick with that for consistency.

        Line 101, Patchset 6 (Latest): res = _libc.clonefile(os.fsencode(src), os.fsencode(dst), 0)
        Mark Mentovai . unresolved

        For precise equivalence with `cp -a`, you would use `CLONE_NOFOLLOW | CLONE_ACL` here.

        Line 104, Patchset 6 (Latest): raise OSError(err, os.strerror(err), src)
        Mark Mentovai . unresolved

        You probably want `, None, dst` too (sets the `filename2` attribute). The `None` is `winerror`, but it’s safely ignored on non-Windows.

        Line 112, Patchset 6 (Latest): except OSError:
        subprocess.check_call(['cp', '-a', '-c', src, dest])
        Mark Mentovai . unresolved

        I disagree with this fallback.

        `cp -ac` is so much worse than the direct `clonefile` call*, and probably doesn’t actually do anything different than the direct `clonefile` call is intended to**. All the fallback does is silently paper over problems calling `clonefile`.

        \* why is `cp -c` so bad? does it clone each file individually, rather than cloning the entire directory hierarchy in a single call?

        \** `cp -c` can fall back to a non-clone copy if the filesystem doesn’t support clones, but you shouldn’t care because you detect whether clones are supported before trying it. Also, my experience has been that `cp -c` still doesn’t work across filesystems.

        Line 215, Patchset 6 (Latest): args.repository = os.path.realpath(args.repository)
        Mark Mentovai . resolved

        I didn’t re-test, but this will probably work.

        Line 229, Patchset 6 (Latest): gclient = os.path.realpath(os.path.join(args.repository, '.gclient'))
        Mark Mentovai . unresolved

        You probably don’t need any other `realpath` now that you’re doing the big one above. Look elsewhere, too.

        Line 282, Patchset 6 (Latest): if args.reflink:
        Mark Mentovai . unresolved

        This name is btrfs-specific. The name would ideally be made more generic, something about copy-on-write. You can hang on to `--reflink`/`--no-reflink` as deprecated options for compatibility, though.

        (If you want to take this up, save it for a follow-up change.)

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Erik Staab
        • Justin Cohen
        Submit Requirements:
          • requirement is not satisfiedCode-Owners
          • requirement satisfiedCode-Review
          • requirement is not satisfiedNo-Unresolved-Comments
          • requirement 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: I6058d19a5a9a73fff2e8cc2b0d926695bb418487
          Gerrit-Change-Number: 7691305
          Gerrit-PatchSet: 6
          Gerrit-Owner: Justin Cohen <justi...@google.com>
          Gerrit-Reviewer: Erik Staab <est...@chromium.org>
          Gerrit-Reviewer: Kirubel Aklilu <kak...@chromium.org>
          Gerrit-Reviewer: Mark Mentovai <ma...@chromium.org>
          Gerrit-Attention: Justin Cohen <justi...@google.com>
          Gerrit-Attention: Erik Staab <est...@chromium.org>
          Gerrit-Comment-Date: Tue, 24 Mar 2026 14:02:24 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          unsatisfied_requirement
          satisfied_requirement
          open
          diffy

          Justin Cohen (Gerrit)

          unread,
          10:29 AM (3 hours ago) 10:29 AM
          to LUCI CQ, Kirubel Aklilu, Mark Mentovai, Erik Staab, chromium...@chromium.org, chops-source-team...@google.com
          Attention needed from Erik Staab and Mark Mentovai

          Justin Cohen added 7 comments

          Patchset-level comments
          File-level comment, Patchset 7 (Latest):
          Justin Cohen . resolved

          ptal!

          File gclient-new-workdir.py
          Line 95, Patchset 6: libc_path = ctypes.util.find_library("c")
          Mark Mentovai . resolved

          This file seems to `'single-quote'` string literals. Stick with that for consistency.

          Justin Cohen

          Done

          Line 101, Patchset 6: res = _libc.clonefile(os.fsencode(src), os.fsencode(dst), 0)
          Mark Mentovai . resolved

          For precise equivalence with `cp -a`, you would use `CLONE_NOFOLLOW | CLONE_ACL` here.

          Justin Cohen

          Done

          Line 104, Patchset 6: raise OSError(err, os.strerror(err), src)
          Mark Mentovai . resolved

          You probably want `, None, dst` too (sets the `filename2` attribute). The `None` is `winerror`, but it’s safely ignored on non-Windows.

          Justin Cohen

          Done

          Line 112, Patchset 6: except OSError:

          subprocess.check_call(['cp', '-a', '-c', src, dest])
          Mark Mentovai . resolved

          I disagree with this fallback.

          `cp -ac` is so much worse than the direct `clonefile` call*, and probably doesn’t actually do anything different than the direct `clonefile` call is intended to**. All the fallback does is silently paper over problems calling `clonefile`.

          \* why is `cp -c` so bad? does it clone each file individually, rather than cloning the entire directory hierarchy in a single call?

          \** `cp -c` can fall back to a non-clone copy if the filesystem doesn’t support clones, but you shouldn’t care because you detect whether clones are supported before trying it. Also, my experience has been that `cp -c` still doesn’t work across filesystems.

          Justin Cohen

          Done

          Line 229, Patchset 6: gclient = os.path.realpath(os.path.join(args.repository, '.gclient'))
          Mark Mentovai . resolved

          You probably don’t need any other `realpath` now that you’re doing the big one above. Look elsewhere, too.

          Justin Cohen

          Done

          Line 282, Patchset 6: if args.reflink:
          Mark Mentovai . resolved

          This name is btrfs-specific. The name would ideally be made more generic, something about copy-on-write. You can hang on to `--reflink`/`--no-reflink` as deprecated options for compatibility, though.

          (If you want to take this up, save it for a follow-up change.)

          Justin Cohen

          Will do in a followup!

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Erik Staab
          • Mark Mentovai
          Submit Requirements:
            • requirement is not satisfiedCode-Owners
            • requirement satisfiedCode-Review
            • requirement 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: I6058d19a5a9a73fff2e8cc2b0d926695bb418487
            Gerrit-Change-Number: 7691305
            Gerrit-PatchSet: 7
            Gerrit-Owner: Justin Cohen <justi...@google.com>
            Gerrit-Reviewer: Erik Staab <est...@chromium.org>
            Gerrit-Reviewer: Justin Cohen <justi...@google.com>
            Gerrit-Reviewer: Kirubel Aklilu <kak...@chromium.org>
            Gerrit-Reviewer: Mark Mentovai <ma...@chromium.org>
            Gerrit-Attention: Mark Mentovai <ma...@chromium.org>
            Gerrit-Attention: Erik Staab <est...@chromium.org>
            Gerrit-Comment-Date: Tue, 24 Mar 2026 14:28:57 +0000
            Gerrit-HasComments: Yes
            Gerrit-Has-Labels: No
            Comment-In-Reply-To: Mark Mentovai <ma...@chromium.org>
            unsatisfied_requirement
            satisfied_requirement
            open
            diffy

            Mark Mentovai (Gerrit)

            unread,
            11:22 AM (2 hours ago) 11:22 AM
            to Justin Cohen, LUCI CQ, Kirubel Aklilu, Erik Staab, chromium...@chromium.org, chops-source-team...@google.com
            Attention needed from Erik Staab and Justin Cohen

            Mark Mentovai added 2 comments

            Patchset-level comments
            Mark Mentovai . resolved

            LGTM

            File gclient-new-workdir.py
            Line 176, Patchset 7 (Latest):def adopt_git_worktree(src, dest):
            Mark Mentovai . unresolved

            This function only works in “reflink” mode now. You want to document that at least.

            Open in Gerrit

            Related details

            Attention is currently required from:
            • Erik Staab
            • Justin Cohen
            Submit Requirements:
              • requirement is not satisfiedCode-Owners
              • requirement satisfiedCode-Review
              • requirement is not satisfiedNo-Unresolved-Comments
              • requirement 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: I6058d19a5a9a73fff2e8cc2b0d926695bb418487
              Gerrit-Change-Number: 7691305
              Gerrit-PatchSet: 7
              Gerrit-Owner: Justin Cohen <justi...@google.com>
              Gerrit-Reviewer: Erik Staab <est...@chromium.org>
              Gerrit-Reviewer: Justin Cohen <justi...@google.com>
              Gerrit-Reviewer: Kirubel Aklilu <kak...@chromium.org>
              Gerrit-Reviewer: Mark Mentovai <ma...@chromium.org>
              Gerrit-Attention: Justin Cohen <justi...@google.com>
              Gerrit-Attention: Erik Staab <est...@chromium.org>
              Gerrit-Comment-Date: Tue, 24 Mar 2026 15:22:23 +0000
              Gerrit-HasComments: Yes
              Gerrit-Has-Labels: No
              unsatisfied_requirement
              satisfied_requirement
              open
              diffy

              Justin Cohen (Gerrit)

              unread,
              11:31 AM (1 hour ago) 11:31 AM
              to LUCI CQ, Kirubel Aklilu, Mark Mentovai, Erik Staab, chromium...@chromium.org, chops-source-team...@google.com
              Attention needed from Erik Staab and Mark Mentovai

              Justin Cohen added 1 comment

              File gclient-new-workdir.py
              Line 176, Patchset 7:def adopt_git_worktree(src, dest):
              Mark Mentovai . resolved

              This function only works in “reflink” mode now. You want to document that at least.

              Justin Cohen

              Done

              Open in Gerrit

              Related details

              Attention is currently required from:
              • Erik Staab
              • Mark Mentovai
              Submit Requirements:
                • requirement is not satisfiedCode-Owners
                • requirement satisfiedCode-Review
                • requirement 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: I6058d19a5a9a73fff2e8cc2b0d926695bb418487
                Gerrit-Change-Number: 7691305
                Gerrit-PatchSet: 8
                Gerrit-Owner: Justin Cohen <justi...@google.com>
                Gerrit-Reviewer: Erik Staab <est...@chromium.org>
                Gerrit-Reviewer: Justin Cohen <justi...@google.com>
                Gerrit-Reviewer: Kirubel Aklilu <kak...@chromium.org>
                Gerrit-Reviewer: Mark Mentovai <ma...@chromium.org>
                Gerrit-Attention: Mark Mentovai <ma...@chromium.org>
                Gerrit-Attention: Erik Staab <est...@chromium.org>
                Gerrit-Comment-Date: Tue, 24 Mar 2026 15:31:08 +0000
                Gerrit-HasComments: Yes
                Gerrit-Has-Labels: No
                Comment-In-Reply-To: Mark Mentovai <ma...@chromium.org>
                unsatisfied_requirement
                satisfied_requirement
                open
                diffy

                Mark Mentovai (Gerrit)

                unread,
                11:31 AM (1 hour ago) 11:31 AM
                to Justin Cohen, LUCI CQ, Kirubel Aklilu, Erik Staab, chromium...@chromium.org, chops-source-team...@google.com
                Attention needed from Erik Staab and Justin Cohen

                Mark Mentovai added 1 comment

                Mark Mentovai . resolved

                LGTM

                Open in Gerrit

                Related details

                Attention is currently required from:
                • Erik Staab
                • Justin Cohen
                Submit Requirements:
                • requirement is not satisfiedCode-Owners
                • requirement satisfiedCode-Review
                • requirement 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: I6058d19a5a9a73fff2e8cc2b0d926695bb418487
                Gerrit-Change-Number: 7691305
                Gerrit-PatchSet: 8
                Gerrit-Owner: Justin Cohen <justi...@google.com>
                Gerrit-Reviewer: Erik Staab <est...@chromium.org>
                Gerrit-Reviewer: Justin Cohen <justi...@google.com>
                Gerrit-Reviewer: Kirubel Aklilu <kak...@chromium.org>
                Gerrit-Reviewer: Mark Mentovai <ma...@chromium.org>
                Gerrit-Attention: Justin Cohen <justi...@google.com>
                Gerrit-Attention: Erik Staab <est...@chromium.org>
                Gerrit-Comment-Date: Tue, 24 Mar 2026 15:31:45 +0000
                Gerrit-HasComments: Yes
                Gerrit-Has-Labels: No
                unsatisfied_requirement
                satisfied_requirement
                open
                diffy
                Reply all
                Reply to author
                Forward
                0 new messages