Next: , Previous: , Up: SCM Interface   [Contents][Index]

6.2 SCM Segments

The block-size of a segment (given in call to make-seg) is a parameter crucial for performance; balancing CPU time traversing blocks with file-system latency. block-size should be an integer multiple of the file-system block size.

In the 1990s our nominal block-size was 2.kiB; now it should probably be 4.kiB, 8.kiB, or 16.kiB.

Scheme Procedure: init-wb max-num-ents max-num-buks max-blk-size

Initializes the WB system. Max-blk-size determines the size of the disk cache buffers. max-num-ents is the number of disk cache buffers to be allocated. (* max-num-ents Max-blk-size) should be less than the size of RAM on your computer. If not all max-num-ents cannot be allocated (by malloc) then WB can still run properly. max-num-buks is the number of hash buckets for the disk cache. It should be of approximately the same size as or larger than max-num-ents. The number of buffers actually allocated is returned if successful; a status code is returned otherwise.

If init-wb is called with the same arguments after it has already been called, NOTPRES (-1) is returned.

Scheme Procedure: final-wb

Frees all memory used by the WB system. All segments will be closed.

Scheme Procedure: open-seg filename mutable?

Opens the database file filename and returns a segment if successful, and false otherwise. The database will be read-only if the mutable? argument is false. It will be read-write if the mutable? argument is true.

Scheme Procedure: close-seg seg hammer

Closes database segment seg and the file containing it. If hammer is #f then if there are any problems freeing buffers then the close is aborted. A status code is returned.

Scheme Procedure: make-seg filename block-size

The integer block-size specifies the size of B-tree blocks. block-size should be an integer multiple of the file-system block size. Nominal value is 4096.

make-seg creates a new open empty mutable database seg of name filename. If successful, seg is returned; otherwise a status code is returned.

Next: , Previous: , Up: SCM Interface   [Contents][Index]