IO Buffers

ODB IO operations use a special multi-buffer to increase performance.

Buffer and Multi-buffer implementation can be found on the org.neodatis.odb.core.io package

IBufferedIO.png

The default implementation used by ODB is the MultiBufferedFileIO.

Buffer parameters can be configured by the following methods of the class org.neodatis.odb.core.Configuration:

Method Description Default value
get/setDefaultBufferSizeForData Sets the default buffer size when writing data in database file 4096 bytes
get/setDefaultBufferSizeForTransaction Sets the default buffer size when writing data in transaction file 2*4096 bytes
get/setNbBuffers Sets the number of buffers when using Multi-buffer buffering 5
get/setUseMultiBuffer Tells ODB if multi buffer buffernig strategy must be used true

The buffer is used to decrease the number of real IO operations. When reading or writing, ODB works in memory (using an array of byte) and try to do a single IO operation.

The array of byte is the buffer.

Single buffer

For example, when reading an object at position x. ODB first reads a whole block of the size of the buffer and puts the bytes in an array of bytes. Reads will then be done on the array of bytes instead of doing IO operations. When a read or write is requested on a position that is not in the buffer, ODB flushes the buffer (doing a write operation) and reloads the buffer at the right position.

Multi Buffer

Multi buffer is a strategy that uses more than one buffer to increase performance. Most IO operations need to write things in different places in the file: because creating a new object need to create o new OID, may need to update the metamodel, … So using a single buffer may be costly sometimes because for writing a single object may imply in loading and flushing the same buffer more that once. Multi-buffer allows to work with a buffer for each region of the file that needs to be updated. This strategy (and a good configuration) guarantees an optimization for IO operations.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License