Skip to content
Snippets Groups Projects
Commit 5b63d613 authored by Daniel Salzman's avatar Daniel Salzman
Browse files

Merge branch 'journal_chunk_16k' into 'master'

journal: serialize to chunks usually smaller than 4 pages...

See merge request !1360
parents 1a49c679 0e36eb5a
No related branches found
No related tags found
1 merge request!1360journal: serialize to chunks usually smaller than 4 pages...
Pipeline #87868 passed
......@@ -27,7 +27,8 @@ typedef struct {
void *conf; // needed only for journal write operations
} zone_journal_t;
#define JOURNAL_CHUNK_MAX (70 * 1024)
#define JOURNAL_CHUNK_MAX (70 * 1024) // must be at least 64k + 6B
#define JOURNAL_CHUNK_THRESH (15 * 1024)
#define JOURNAL_HEADER_SIZE (32)
/*! \brief Convert journal_mode to LMDB environment flags. */
......
......@@ -27,7 +27,8 @@ static void journal_write_serialize(knot_lmdb_txn_t *txn, serialize_ctx_t *ser,
MDB_val chunk;
uint32_t i = 0;
while (serialize_unfinished(ser) && txn->ret == KNOT_EOK) {
serialize_prepare(ser, JOURNAL_CHUNK_MAX - JOURNAL_HEADER_SIZE, &chunk.mv_size);
serialize_prepare(ser, JOURNAL_CHUNK_THRESH - JOURNAL_HEADER_SIZE,
JOURNAL_CHUNK_MAX - JOURNAL_HEADER_SIZE, &chunk.mv_size);
if (chunk.mv_size == 0) {
break; // beware! If this is ommited, it creates empty chunk => EMALF when reading.
}
......
......@@ -143,7 +143,8 @@ static knot_rrset_t get_next_rrset(serialize_ctx_t *ctx)
}
}
void serialize_prepare(serialize_ctx_t *ctx, size_t max_size, size_t *realsize)
void serialize_prepare(serialize_ctx_t *ctx, size_t thresh_size,
size_t max_size, size_t *realsize)
{
*realsize = 0;
......@@ -185,6 +186,9 @@ void serialize_prepare(serialize_ctx_t *ctx, size_t max_size, size_t *realsize)
return;
}
*realsize = candidate;
if (candidate >= thresh_size) {
return;
}
tmp_phase++;
}
}
......
......@@ -46,11 +46,13 @@ serialize_ctx_t *serialize_zone_init(const zone_contents_t *z);
*
* \note This MUST be called before each serialize_chunk() !
*
* \param ctx Serializing context.
* \param max_size Maximum size of next chunk.
* \param realsize Output: real exact size of next chunk.
* \param ctx Serializing context.
* \param thresh_size Optimal size of next chunk.
* \param max_size Maximum size of next chunk.
* \param realsize Output: real exact size of next chunk.
*/
void serialize_prepare(serialize_ctx_t *ctx, size_t max_size, size_t *realsize);
void serialize_prepare(serialize_ctx_t *ctx, size_t thresh_size,
size_t max_size, size_t *realsize);
/*!
* \brief Perform one step of serializiation: fill one chunk.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment