GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Documenting that the new (3.14) `pathlib` copy functionality uses Copy-on-Write · Issue #124985 · python/cpython

Documenting that the new (3.14) pathlib copy functionality uses Copy-on-Write #124985

New issue
Copy link
New issue
Copy link
Closed
Closed
Documenting that the new (3.14) pathlib copy functionality uses Copy-on-Write#124985
Copy link
Labels
docsDocumentation in the Doc dirDocumentation in the Doc dirtopic-pathlib

Description

@opk12
opk12
opened on Oct 4, 2024
Issue body actions

Documentation

(edited)

The PR 119058 and 122369 added pathlib.Path.copy(), with Copy-on-Write support. CoW should be documented, because it has distinctive, user-requested properties on huge files.

  • Copying is instantaneous, does negligible I/O, requires no disk space for the data and negligible disk space for the metadata.
  • Reading the original and the copy does half the I/O and requires half the RAM (page cache) than a traditional copy (think booting VM images)

In the context of a Linux VM manager, CoW is an explicit desired property. Disk image copying is the slowest part of snapshotting a VM. Users expect CoW snapshots nowadays, and intentionally set up a CoW filesystem for the disk image directory.

For clarity, I'm not asking to mention FICLONE specifically. I'm not asking to mention copy_file_range, a micro-optimization on the traditional copy algorithm. Instead, my point is that switching from O(file size) to zero is a user-visible feature.

Keywords: reflink copy

Linked PRs

  • GH-124985: Document that pathlib.Path.copy() uses copy-on-write. #125861

Activity

  1. opk12
    added
    docsDocumentation in the Doc dirDocumentation in the Doc dir
    on Oct 4, 2024
  2. picnixz commented on Oct 4, 2024

    @picnixz
    picnixz
    on Oct 4, 2024
    Member
    More actions

    I'm not sure to follow what you want to do. What I understood is that you want us to document how we support CoW filesystems (by the way, the project you linked only support Python 3.7 according to pypi and I don't know why it would be a "keyword").

    cc @barneygale as the PR's author

  3. picnixz
    added
    pendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is provided
    topic-pathlib
    on Oct 4, 2024
  4. opk12
    changed the title [-]Reflink mention in the `pathlib` doc[/-] [+]Documenting that the new (3.14) `pathlib` copy functionality uses Copy-on-Write[/+] on Oct 5, 2024
  5. opk12 commented on Oct 5, 2024

    @opk12
    opk12
    on Oct 5, 2024
    Author
    More actions

    Please document that copies are CoW if the filesystem is CoW and list the supported filesystems, so that one is certain to provide CoW to the end user. Please leave out the implementation details (the exact syscalls).

    Sorry for the confusion. reflink copy / shallow copy is jargon for CoW, and the library was named after that. I now reworked the ticket title.

    Reacted by Bénédikt Tran
  6. picnixz
    removed
    pendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is provided
    on Oct 5, 2024
  7. barneygale commented on Oct 5, 2024

    @barneygale
    barneygale
    on Oct 5, 2024
    Contributor
    More actions

    I'm cautious about touting the speed benefits of copy(), because the implementation of PathBase.copy() makes too many system calls when walking directories. We ought to add an implementation of Path.copy() that uses os.DirEntry.is_symlink() and is_dir(), rather than calling these methods on path objects. Or we could open a large can of worms, and consider whether PathBase.iterdir() might be allowed generate path objects with a special dir_entry attribute that grants public access to a os.DirEntry-like object, and then implement this in Path.iterdir(), and consult the attribute from PathBase.copy().

  8. opk12 commented on Oct 6, 2024

    @opk12
    opk12
    on Oct 6, 2024
    Author
    More actions

    Very good point. Without touching on copy()'s performance, how about only saying that it does CoW and on which filesystems? As said above, CoW is an explicit user request, has much better free space requirement and future read performance.

    Reacted by Barney Gale
  9. opk12 commented on Oct 6, 2024

    @opk12
    opk12
    on Oct 6, 2024
    Author
    More actions

    (Off-topic: there even was an actual proposal at btrfs, the most used CoW fs on Linux, to CoW-copy an arbitrary directory with a single syscall. The proposal stalled, but showed that this is doable.)

  10. barneygale commented on Oct 14, 2024

    @barneygale
    barneygale
    on Oct 14, 2024
    Contributor
    More actions

    #125419 will solve the known copy() performance problems. When it lands I'll start working on this issue.

    Reacted by opk12
  11. barneygale
    added a commit that references this issue on Oct 22, 2024

    pythonGH-124985: Document that `pathlib.Path.copy()` uses copy-on-write.

    d92267a
  12. willingc
    added this to docs issueson Oct 31, 2024
  13. github-project-automation
    moved this to Todo in docs issueson Oct 31, 2024
  14. barneygale
    added a commit that references this issue on Nov 5, 2024

    GH-124985: Document that `pathlib.Path.copy()` uses copy-on-write. (#…

    ff83499
  15. barneygale commented on Nov 5, 2024

    @barneygale
    barneygale
    on Nov 5, 2024
    Contributor
    More actions

    This is now documented! Turns out I didn't need to wait for #125419. Thanks for the report, @opk12

  16. barneygale
    closed this as completedon Nov 5, 2024
  17. picnixz
    added a commit that references this issue on Dec 8, 2024

    pythonGH-124985: Document that `pathlib.Path.copy()` uses copy-on-wri…

    4b214a0
  18. ebonnal
    added a commit that references this issue on Jan 12, 2025

    pythonGH-124985: Document that `pathlib.Path.copy()` uses copy-on-wri…

    41925df
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

    docsDocumentation in the Doc dirDocumentation in the Doc dirtopic-pathlib

    Projects

    • docs issues
      Status
      Todo
      Show more project fields

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402520 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.