Determine blocksize for fastcopying on Linux. Hopefully the whole file will be copied in a single call. The copying itself should be performed in a loop 'till EOF is reached (0 return) so a blocksize smaller or bigger than the actual file size should not make any difference, also in
(infd)
| 116 | raise err from None |
| 117 | |
| 118 | def _determine_linux_fastcopy_blocksize(infd): |
| 119 | """Determine blocksize for fastcopying on Linux. |
| 120 | |
| 121 | Hopefully the whole file will be copied in a single call. |
| 122 | The copying itself should be performed in a loop 'till EOF is |
| 123 | reached (0 return) so a blocksize smaller or bigger than the actual |
| 124 | file size should not make any difference, also in case the file |
| 125 | content changes while being copied. |
| 126 | """ |
| 127 | try: |
| 128 | blocksize = max(os.fstat(infd).st_size, 2 ** 23) # min 8 MiB |
| 129 | except OSError: |
| 130 | blocksize = 2 ** 27 # 128 MiB |
| 131 | # On 32-bit architectures truncate to 1 GiB to avoid OverflowError, |
| 132 | # see gh-82500. |
| 133 | if sys.maxsize < 2 ** 32: |
| 134 | blocksize = min(blocksize, 2 ** 30) |
| 135 | return blocksize |
| 136 | |
| 137 | def _fastcopy_copy_file_range(fsrc, fdst): |
| 138 | """Copy data from one regular mmap-like fd to another by using |
no outgoing calls
no test coverage detected
searching dependent graphs…