Cache mechanism

Project:JNode Core
Component:Code
Category:task
Priority:normal
Assigned:Fabien D
Status:duplicate
Description

- Develop a cache system for devices (classes that are instanceof BlockDeviceAPI)
- Study the need to replace the byte[] parameters in BlockDeviceAPI by ByteBuffer or something else
- Study the impact on the classes BlockAlignmentSupport and FSBlockAlignmentSupport

The cache system :
- will be parameterizable (read strategy, write strategy, ...)
- won't be automatically installed on all devices (for example: RAM devices don't need a cache because they are fast enought)

byte[] vs. ByteBuffer

I would like very much to have the byte[] parameters in BlockDeviceAPI to be replaced by ByteBuffer's.

Ewout

ByteBuffer: direct or not ?

I am very new to java.nio (and so ByteBuffers) and I am not sure of what is better for performance : direct ByteBuffer or indirect ByteBuffer ?

If there is a difference, I think it can be at assembler/CPU level (CPU access to memory access through pointers).

Do you know if such a difference exists or if it is the same?

However, the ByteBuffer can handle the 2 cases, so there is just one line of code to modify (call to ByteBuffer.allocate(...) or to ByteBuffer.allocateDirect(...)).

Fabien

Re: direct or not

The difference is currently very limited. A direct buffer uses unmovable OS memory instead of java heap memory (for non-direct buffers), but in JNode this is the same.

Anyway for the implementation, there is only a difference on the lowest level, the way data is get out of or into the buffer.

Ewout

#1

Status:active» duplicate

This issue is the same as that other issue.