Database Open Parameters (mco_db_params_t) in eXtremeDB/rt

The runtime settings for a database opened by mco_db_open_dev() in eXtremeDB/rt are defined in the mco_db_params_t structure.

The mco_db_params_t structure is defined in mco.h as follows:

    typedef struct mco_db_params_t_ {
        mco_uint2        mark;                    /* Initialized by mco_db_params_init() */
        mco_uint2        mem_page_size;           /* Memory page size */
        mco_uint4        disk_page_size;          /* Disk page size (0 for in-memory DB) */
        mco_uint4        db_max_connections;      /* Maximum number of connections */
        mco_offs_t       disk_max_database_size;  /* Max size of persistent database */
        mco_offs_t       disk_max_file_size;      /* max size of database file */
        mco_offs_t       file_extension_quantum;  /* File extension quantum to reduce fragmentation */
        mco_uint2        connection_context_size; /* Recovery connection context size */
        mco_uint2        hash_load_factor;        /* Hash table load factor (%) */
        unsigned int     mode_mask;               /* Open mode mask */
        unsigned int     min_conn_local_pages;    /* Min pages in per-connection allocator */
        unsigned int     max_conn_local_pages;    /* Max pages in per-connection allocator */
        int              allocation_bitmap_caching_priority; /* Priority for allocator bitmap pages */
        int              index_caching_priority;  /* Priority for index pages */
        int              object_caching_priority; /* Priority for object pages */
        char*            cipher_key;              /* Database encryption key */
        mco_bool         dynamic_hash;            /* Enable dynamic hash table extension */
        unsigned int     max_classes;             /* Space reserved for classes (for dynamic schema) */
        unsigned int     max_indexes;             /* Space reserved for indexes (for dynamic schema) */
        mco_size_t       autocompact_threshold;   /* Object size threshold for auto-compaction */
        MCO_TRANS_SCHED_POLICY trans_sched_policy; /* Transaction scheduling policy */
        mco_uint8        max_trans_time;          /* Max transaction time (0 to disable) */
        unsigned int     max_active_pages;        /* Max pages accessed by a connection */
        unsigned int     page_hash_bundles;       /* Bundles in page hash for encryption/compression */
        unsigned int     expected_compression_ratio; /* Expected compression ratio for page map allocation */
        mco_uint1        btree_cursor_read_ahead_size; /* B-Tree cursor read-ahead size */
        unsigned int     additional_heap_size;    /* Heap for internal DB operations (e.g., save/load) */
        mco_size_t       backup_map_size;         /* Size of backup counters array (bytes, power of two) */
        unsigned int     backup_min_pages;        /* Pages for last exclusive backup pass */
        unsigned int     backup_max_passes;       /* Max passes before exclusive backup pass */
        mco_uint4        file_backup_delay;       /* Delay between backup block writes (ms) */
        unsigned int     max_pi_readers;          /* Max parallel read-only transactions (PI TM) */
        mco_offs_t       sync_threshold;          /* Data amount to trigger fsync (avoid write storms) */
        mco_offs_t       flush_range;             /* Range for sync_file_range (0 disables) */
        mco_size_t       tlb_cache_lines;         /* TLB cache lines (for mcoxfile, if no MCO_DB_INMEM_PAGE_MAP) */
        mco_size_t       tlb_cache_ways;          /* TLB cache ways */
        mco_size_t       meta_cache_lines;        /* Metadata cache lines (for mcoxflash) */
        mco_size_t       meta_cache_ways;         /* Metadata cache ways */
        int              flash_gc_ratio;          /* Flash garbage collection aggressiveness */
        mco_size_t       rollback_buf_size;       /* Size of copy-on-write rollback buffer */
    } mco_db_params_t;

The fields of this structure are described below:

mark
Internal marker set by mco_db_params_init(). Applications must not modify this field.
mem_page_size
Size of a memory page for conventional or shared memory devices. For persistent and mixed-mode databases, this value must be a power of two.
disk_page_size
Size of a persistent storage page. Set to zero for all-in-memory databases. Must be a power of two.
db_max_connections
Maximum number of concurrent connections to the database.
disk_max_database_size
Maximum size of the persistent database on disk.
disk_max_file_size
Maximum size of the database file. The default is MCO_INFINITE_DATABASE_SIZE. This value should be larger than disk_max_database_size plus the minimum size of a transaction.
file_extension_quantum
Allocation block size used when extending the database file. This can help reduce file fragmentation.
connection_context_size
Size of the application-specific context attached to each connection, used during recovery to verify that the connection's owner task is still alive.
hash_load_factor
Threshold (as a percentage) for hash index table reallocation. When the number of items exceeds this percentage of the table size, the table is extended.
mode_mask
Bitmask of database open mode flags. Defined in mco.h.
min_conn_local_pages
Minimum number of pages held by the per-connection allocator.
max_conn_local_pages
Maximum number of pages held by the per-connection allocator.
allocation_bitmap_caching_priority
Cache priority for allocation bitmap pages. Higher values keep these pages in the LRU cache longer.
index_caching_priority
Cache priority for index pages. Higher values keep these pages in the LRU cache longer.
object_caching_priority
Cache priority for object (non-BLOB) pages. Higher values keep these pages in the LRU cache longer.
cipher_key
Encryption key for the database.
dynamic_hash
Enables dynamic extension of hash tables when the number of items exceeds the hash_load_factor.
max_classes
Number of class slots to reserve in the database header to support dynamic schema creation (e.g., via SQL CREATE TABLE). Irrelevant for non-SQL applications.
max_indexes
Number of index slots to reserve in the database header to support dynamic schema modification (e.g., via SQL ALTER TABLE). Irrelevant for non-SQL applications.
autocompact_threshold
Object size threshold (in bytes) that triggers automatic compaction (mco_autocompact()) during transaction commit.
trans_sched_policy
Scheduling policy for transactions with the same priority (e.g., Fifo, ReaderFavor).
max_trans_time
Maximum allowed transaction duration (in milliseconds). A value of 0 disables the limit. Note: This setting has no effect except in special debug builds of the eXtremeDB/rt runtime.
max_active_pages
Maximum number of pages a single connection can access. The default is 32. Relevant when encryption, protection, or compression is enabled.
page_hash_bundles
Number of bundles in the internal page hash used for encryption, protection, or compression.
expected_compression_ratio
Expected compression ratio used to allocate the virtual page map. The default value is 10. It is not recommended to change this value.
btree_cursor_read_ahead_size
Number of keys pre-fetched from a B-Tree leaf page on each access. Cannot exceed MCO_CFG_CURSOR_BUF_SIZE.
additional_heap_size
Additional heap memory allocated for internal database operations, primarily for buffering during XML export/import and database save/load operations.
backup_map_size
Size of the backup counters array, in bytes (must be a power of two). Ignored if disk_max_database_size is not set. Set to zero to disable the incremental backup feature.
backup_min_pages
Number of pages processed in the final exclusive pass of the backup procedure. Set to zero to disable this threshold.
backup_max_passes
Maximum number of non-exclusive passes performed before the final exclusive backup pass.
file_backup_delay
Delay in milliseconds between writing backup blocks to minimize performance impact. The default is 0 (no delay).
max_pi_readers
Maximum number of parallel read-only transactions supported by the Priority Inheritance (PI) transaction manager, which is the default in eXtremeDB/rt.
sync_threshold
Amount of data written (in bytes) that triggers an fsync() call to avoid a "write storm" and long delays during transaction commit.
flush_range
Range (in bytes) for the sync_file_range() system call to prevent long blocking in fsync(). A value of 0 disables this feature.
tlb_cache_lines
Number of lines in the TLB (Translation Lookaside Buffer) cache for the mcoxfile driver. Used only when the MCO_DB_INMEM_PAGE_MAP mode is not set.
tlb_cache_ways
Number of ways (associativity) in the TLB cache for the mcoxfile driver.
meta_cache_lines
Number of lines in the metadata cache for the mcoxflash driver.
meta_cache_ways
Number of ways (associativity) in the metadata cache for the mcoxflash driver.
flash_gc_ratio
Aggressiveness of the flash garbage collection process. Controls how much free space is maintained to ensure wear leveling and performance.
rollback_buf_size
Size of the buffer used by the copy-on-write (COW) implementation for transaction rollbacks.

disk_max_file_size Parameter Specifics

The disk_max_file_size parameter is used exclusively with the xfile library. It defines the maximum physical size of the database file on disk, which includes the file header, page maps, allocation ring buffer (if present), and physical data pages. By default, this parameter is set to MCO_INFINITE_DATABASE_SIZE. When configured this way, the physical file size can scale to approximately twice the logical database size specified by the disk_max_database_size parameter, roughly equating to header_size + page_map_size * 2 + alloc_buffer_size + disk_max_database_size * 2. This parameter is validated during initialization to ensure that the allocated file size is sufficient to execute transactions of minimum size.