apple / apple/swift-async-algorithms
Consumption of multiple bytes at once from `AsyncBufferedByteIterator`?
- Dominant language
- Swift
- Stars
- 3.7k
- Forks
- 226
- Avg merge
- 10d 3h
- Merged PRs (30d)
- 1
Description
Would the team take any exception to a proposal to add a method to `AsyncBufferedByteIterator` that could copy more than one byte at a time to an `UnsafeMutableRawBufferPointer` or similar? It seems that if you were, say, chewing through 1 GB of data, copying chunks at a time using `copyBytes(from:)`, `copyMemory(from:)`, or one of the other fancy versions of `memcpy` in the standard library could have the potential to be a lot more efficient than calling `next()` literally one billion times...
Yes, I know the compiler can do a lot of inlining and other optimizations here, but c'mon, you can't beat `memcpy` in a speed contest.
Contributor guide
Research direction
Start by reading AsyncBufferedByteIterator and its existing next() API, then compare the proposed copyBytes(from:) and copyMemory(from:) approaches. Done would require an agreed bulk-copy API and a clear way to validate its behavior and efficiency.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- api
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100