Why the odd performance curve differential between ByteBuffer.allocate() and ByteBuffer.allocateDirect()

前端 未结 4 1224
醉酒成梦
醉酒成梦 2020-12-07 10:16

I\'m working on some SocketChannel-to-SocketChannel code which will do best with a direct byte buffer--long lived and large (tens to hundreds of me

4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-07 10:46

    I suspect that these knees are due to tripping across a CPU cache boundary. The "non-direct" buffer read()/write() implementation "cache misses" earlier due to the additional memory buffer copy compared to the "direct" buffer read()/write() implementation.

提交回复
热议问题