FAQ - What are pristine blocks?

FAQ - What are pristine blocks?

Detail

In Aerospike log files the following line is displayed at start up:

Jul 29 2021 09:21:08 GMT: INFO (drv_ssd): (drv_ssd.c:1035) /opt/aerospike/data/common06.data init wblocks: pristine-id 8 pristine 2 free-q 0, defrag-q 0

What are pristine blocks?

(The log lines used are only for illustration and would not represent real production setup where more than a handful of blocks would be available. This example is from a basic configuration on a single node running on a laptop with a 10MiB configured storage space.)

Answer

Pristine blocks are blocks that have never been written to by the Aerospike server before. In effect, they are perfectly empty blocks. The Aerospike server contains an optimization whereby it will prioritize writing to blocks that have already been through the defragmentation process. When the Aerospike log lists pristine blocks it is giving a measure of blocks on the disks that have never been written and subsequently freed via defragmentation. Pristine blocks do not correspond to free blocks.

The amount of blocks freed by defragmentation is given in the free-q metric listed within the same line. Thus the total space available for writing is free-q + pristine. This is shown in the logs as free-wblocks.

Aug 02 2021 13:23:10 GMT: INFO (drv_ssd): (drv_ssd.c:1829) {bar} /opt/aerospike/data/bar.dat: used-bytes 960000 free-wblocks 1 write-q 0 write (0,0.0) defrag-q 0 defrag-read (0,0.0) defrag-write (0,0.0)

The optimization around using free blocks before pristine blocks is to speed up cold start. Aerospike uses blocks sequentially along the disk (Aerospike maps blocks logically and the underlying storage has its own block management subsystem). During a cold start, the disk is scanned to rebuild the primary index. By concentrating active write blocks near the start of the disk, the time to cold start is minimized (a cold start stops when it hits pristine blocks on the disk).

Notes

  • The first 8 MiB of any disk is used for header information. This is measured as a function of the configured write-block-size. With the default 1 MiB block size, 8 blocks are reserved. With a 2 MiB block size, 4 blocks would be reserved and so on.

  • There is a subsequent optimization for frequently written records. When an update is done and the record being updated exists in the currently in-use write block, the record is replaced in situ, rather than in sequence after the last written record on the block.

  • The pristine metric, which refers to the number of unwritten pristine blocks should not be confused with pristine-id which simply defines the block-id after which blocks are pristine.

Keywords

BLOCK DISK SSD PRISTINE FREE PRISTINE-ID

Timestamp

August 2021

© 2021 Copyright Aerospike, Inc. | All rights reserved. Creators of the Aerospike Database.