https://github.com/pseitz/fastcpy
fastcpy
https://github.com/pseitz/fastcpy
Last synced: 14 days ago
JSON representation
fastcpy
- Host: GitHub
- URL: https://github.com/pseitz/fastcpy
- Owner: PSeitz
- License: mit
- Created: 2023-05-23T05:58:12.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-05-24T03:48:18.000Z (about 3 years ago)
- Last Synced: 2025-03-20T04:44:46.486Z (about 1 year ago)
- Language: Rust
- Size: 3.91 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# FastCpy
The Rust Compiler calls `memcpy` for slices of unknown length. There's considerable overhead for that in some cases.
If you know most of you copy operations are not too big you can use `fastcpy` to speed up your program.
`fastcpy` provides a faster implementation of `memcpy` for slices up to 32bytes (64bytes with `avx`).
It is designed to contain not too much assembly, so the overhead is low.
As fall back the standard `memcpy` is called
## Double Copy Trick
`fastcpy` employs a double copy trick to copy slices of length 4-32bytes (64bytes with `avx`).
E.g. Slice of length 6 can be copied with two uncoditional copy operations.
```
/// [1, 2, 3, 4, 5, 6]
/// [1, 2, 3, 4]
/// [3, 4, 5, 6]
```