[SR-9604] Array initialisation from UnsafeRawBufferPointer takes 10x longer than from UnsafeBufferPointer<UInt8> #52050
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
compiler
The Swift compiler itself
performance
standard library
Area: Standard library umbrella
Additional Detail from JIRA
md5: 93fe6fdccf1fe595e6c2a712aacb4092
Issue Description:
John Connolly noticed a 4x slowdown of his NIO Redis driver (repro in https://github.com/John-Connolly/nio-performance) when switching from NIO 1.8.0 to NIO 1.9.0.
Turns out that
ByteBuffer.getBytes
is a lot slower in NIO 1.9.0 which caused all the slowdown.The only change in
getBytes
however was from switchingto
as part of this PR: apple/swift-nio#524
This can also be reproduced super easily without NIO just standalone with this program:
running this gives:
Swift 4.2.1
Swift 5 dev
Essentially, there seems to be a fast path missing that allows us to use
memcpy
instead of byte-by-byte copy when usingUnsafeRawBufferPointer
. Slices perform even worse...CC @moiseev/@atrick/@airspeedswift/@milseman
The text was updated successfully, but these errors were encountered: