feat: add -f/--sendfile for zero-copy file transfer

- Add file_send_sendfile() using sendfile() syscall to send file
  content directly from fd to socket, bypassing userspace memory
- Add use_sendfile field to Config struct (default false)
- Add -f / --sendfile flag parsing in client.c
- sendfile path in send_chunk() used when -f is set without -c or -s
- send_files_multithreaded() falls back to single-threaded when
  sendfile is enabled (loader pipeline becomes unnecessary)
- Add Sendfile (-f) test case to test.py
This commit is contained in:
2026-07-05 16:25:20 +02:00
parent e7c23c135b
commit 01045d7d14
7 changed files with 53 additions and 2 deletions
+4
View File
@@ -49,6 +49,7 @@ The client-server communication uses the following status codes:
| `-m` | Enable multithreading mode |
| `-c [level]` | Enable compression with optional level (1-22, default: 5) |
| `-s` | Enable chunk serialization (batch-transfer all files per chunk) |
| `-f` | Enable sendfile (zero-copy file transfer, bypasses userspace memory) |
| `--source-dir <path>` | Source directory to sync (overrides `FASTSYNC_SOURCE_DIR`) |
| `--dest-dir <path>` | Server-side destination directory (overrides `FASTSYNC_DEST_DIR`) |
| `--save-to-disk` | Persist received files to disk |
@@ -118,6 +119,9 @@ make
# Multithreaded with compressed chunk serialization
./build/client -m -s -c 3
# Sendfile (zero-copy, bypasses userspace for large files)
./build/client -f
```
## Testing