In here , Anoop Sam John pointed out an crtial problem , I pasted here:
So if we read from HDFS into a pooled BB and then give to LRU cache for caching (ya mostly cache on read might be true) we will cache the block which is backed by this pooled DBB? Unless the block is evicted , this BB wont go back to pool. I think this is some thing we can not livw with !! For LRU cache the sizing itself is based on what % of heap size we can grow. But here in effect we are occupying the off heap space for the cached blocks. All the sizing assumptions and calc going out of control !
It's indeed an big problem here. so we can only make the block ref to an heap area if we use LRUCache (both LruBlockCache and CombinedBlockCache case). Or we can also make the lru cache offheap ?
I think we can introduce an switch indicate that whether the lru block cache offheap or not, if heap, then coping those bytes from ByteBuff to heap.