Comparison: Kernel-Space vs User-Space Copying
Method | System Calls Used | User-Space Copying? | Zero-Copy? |
---|---|---|---|
Files.copy() | read() + write() | ✅ Yes | ❌ No |
ByteBuffer (NIO) | read() + write() | ✅ Yes | ❌ No |
Memory-Mapped File (mmap) | mmap() + memcpy() + msync() | 🚫 No (but may cause page faults) | ✅ Yes (after mapping) |
transferTo() (sendfile) | sendfile() | 🚫 No | ✅ Yes |
transferFrom() | sendfile() | 🚫 No | ✅ Yes |
Buffered Streams (I/O) | read() + write() | ✅ Yes | ❌ No |
Apache FileUtils.copyFile() | read()/write() OR sendfile() | ✅ Yes (if using streams) / 🚫 No (if using sendfile ) | ✅ Possible |
InputStream.transferTo() | read() + write() | ✅ Yes | ❌ No |
No comments:
Post a Comment