rewrite soak with more flexibility and ability to record/playback events to reproduce bugs #10

Merged
greg merged 11 commits from gburd/soak-rec into main 2024-05-21 00:29:26 +00:00
Showing only changes of commit 5bd3872153 - Show all commits

View file

@ -128,7 +128,9 @@ _sparsemap_set(sparsemap_t **map, sparsemap_idx_t idx, bool value)
static void *
__sm_alloc(size_t capacity)
{
return (void *)sparsemap(capacity);
sparsemap_t *map = sparsemap(capacity);
assert(map != NULL);
return map;
}
static void
@ -271,6 +273,7 @@ static void *
__midl_alloc(size_t capacity)
{
MDB_IDL list = mdb_midl_alloc(capacity);
assert(list != NULL);
return (void *)list;
}
@ -287,6 +290,7 @@ __midl_set(void **handle, pgno_t pg)
MDB_IDL *_list = (MDB_IDL *)handle, list = *_list;
if (list[0] + 1 == list[-1]) {
mdb_midl_need(_list, list[-1] + 1);
list = *_list;
}
mdb_midl_insert(list, pg);
return pg;
@ -303,7 +307,7 @@ __midl_is_set(void *handle, pgno_t pg)
static pgno_t
__midl_clear(void **handle, pgno_t pg)
{
MDB_IDL *_list = (MDB_IDL *)handle, list = *_list;
MDB_IDL list = (MDB_IDL *)*handle;
unsigned len = list[0];
list[0] = len -= 1;
for (unsigned j = pg - 1; j < len;)
@ -344,7 +348,7 @@ search_done:;
static bool
__midl_take_span(void **handle, pgno_t pg, unsigned len)
{
MDB_IDL *_list = (MDB_IDL *)handle, list = *_list;
MDB_IDL list = (MDB_IDL *)*handle;
int i = list[list[0]] == pg ? list[0] : mdb_midl_search(list, pg) + len;
unsigned j, num = len;
pgno_t *mop = list;
@ -366,6 +370,7 @@ __midl_release_span(void **handle, pgno_t pg, unsigned len)
MDB_IDL *_list = (MDB_IDL *)handle, list = *_list;
if (list[0] + len >= list[-1]) {
mdb_midl_need(_list, list[-1] + len);
list = *_list;
}
for (size_t i = pg; i < pg + len; i++) {
mdb_midl_insert(list, i);
@ -407,7 +412,12 @@ __midl_merge(void **handle, void *other_handle)
{
MDB_IDL *_list = (MDB_IDL *)handle, list = *_list;
MDB_IDL other = (MDB_IDL)other_handle;
if (list[0] + other[0] >= list[-1]) {
mdb_midl_need(_list, list[-1] + other[0]);
list = *_list;
}
mdb_midl_append_list(_list, other);
list = *_list;
mdb_midl_sort(list);
return true;
}
@ -444,7 +454,9 @@ __midl_validate(void *handle)
static void *
__roar_alloc(size_t capacity)
{
return roaring_bitmap_create();
roaring_bitmap_t *map = roaring_bitmap_create();
assert(map != NULL);
return map;
}
static void
@ -497,7 +509,6 @@ __roar_take_span(void **handle, pgno_t pg, unsigned len)
{
roaring_bitmap_t **_rbm = (roaring_bitmap_t **)handle, *rbm = *_rbm;
roaring_bitmap_remove_range(rbm, pg, pg + len);
roaring_bitmap_run_optimize(rbm);
return true;
}