From 4dbb7cec61449f5595f24f30c27259953e264918 Mon Sep 17 00:00:00 2001 From: Greg Burd Date: Mon, 20 May 2024 20:28:45 -0400 Subject: [PATCH] WIP --- tests/soak.c | 56 +++++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/tests/soak.c b/tests/soak.c index 3edb522..c5fbddc 100644 --- a/tests/soak.c +++ b/tests/soak.c @@ -552,7 +552,7 @@ __sm_count(void *handle) /* midl ------------------------------------------------------------------ */ -static bool __midl_validate(void *handle); +//static bool __midl_validate(void *handle); static void * __midl_alloc(size_t capacity) @@ -572,7 +572,7 @@ __midl_free(void *handle) static pgno_t __midl_set(void **handle, pgno_t pg) { - assert(__midl_validate(*handle)); + // assert(__midl_validate(*handle)); MDB_IDL *_list = (MDB_IDL *)handle, list = *_list; if (list[0] + 1 == list[-1]) { assert(mdb_midl_need(_list, list[-1] + 1) == 0); @@ -581,7 +581,7 @@ __midl_set(void **handle, pgno_t pg) mdb_midl_xappend(list, pg); mdb_midl_sort(list); // assert(mdb_midl_insert(list, pg) == 0); - assert(__midl_validate(*handle)); + // assert(__midl_validate(*handle)); return pg; } @@ -596,7 +596,7 @@ __midl_is_set(void *handle, pgno_t pg) static pgno_t __midl_clear(void **handle, pgno_t pg) { - assert(__midl_validate(*handle)); + // assert(__midl_validate(*handle)); MDB_IDL list = *(MDB_IDL *)handle; unsigned len = list[0]; list[0] = len -= 1; @@ -606,7 +606,7 @@ __midl_clear(void **handle, pgno_t pg) for (unsigned j = len + 1; j <= list[-1]; j++) list[j] = 0; #endif - assert(__midl_validate(*handle)); + // assert(__midl_validate(*handle)); return pg; } @@ -642,7 +642,7 @@ search_done:; static bool __midl_take_span(void **handle, pgno_t pg, unsigned len) { - assert(__midl_validate(*handle)); + // assert(__midl_validate(*handle)); MDB_IDL list = *(MDB_IDL *)handle; int i = list[list[0]] == pg ? list[0] : mdb_midl_search(list, pg); unsigned j, num = len; @@ -657,14 +657,14 @@ __midl_take_span(void **handle, pgno_t pg, unsigned len) for (j = mop_len + 1; j <= mop[-1]; j++) mop[j] = 0; #endif - assert(__midl_validate(*handle)); + // assert(__midl_validate(*handle)); return true; } static bool __midl_release_span(void **handle, pgno_t pg, unsigned len) { - assert(__midl_validate(*handle)); + // assert(__midl_validate(*handle)); MDB_IDL *_list = (MDB_IDL *)handle, list = *_list; if (list[0] + len >= list[-1]) { assert(mdb_midl_need(_list, list[-1] + len) == 0); @@ -675,7 +675,7 @@ __midl_release_span(void **handle, pgno_t pg, unsigned len) // assert(mdb_midl_insert(list, i) == 0); } mdb_midl_sort(list); - assert(__midl_validate(*handle)); + // assert(__midl_validate(*handle)); return true; } @@ -689,7 +689,7 @@ __midl_is_span(void *handle, pgno_t pg, unsigned len) return false; if (len == 1) return true; - if (list[len] + 1 != list[len - 1]) + if (list[idx] + len - 1 != list[idx - len + 1]) return false; return true; } @@ -710,7 +710,7 @@ __midl_is_empty(void *handle, pgno_t pg, unsigned len) static bool __midl_merge(void **handle, void *other_handle) { - assert(__midl_validate(*handle)); + // assert(__midl_validate(*handle)); MDB_IDL *_list = (MDB_IDL *)handle, list = *_list, other = (MDB_IDL)other_handle; if (list[0] + other[0] >= list[-1]) { assert(mdb_midl_need(_list, list[-1] + other[0]) == 0); @@ -718,7 +718,7 @@ __midl_merge(void **handle, void *other_handle) } mdb_midl_xmerge(list, other_handle); mdb_midl_sort(*_list); - assert(__midl_validate(*handle)); + // assert(__midl_validate(*handle)); return true; } @@ -907,7 +907,7 @@ elapsed(struct timespec *s, struct timespec *e) static pgno_t __stats_set(td_histogram_t *stats, void *fn, void **handle, pgno_t pg) { - if (stats) { + if (statistics && stats) { struct timespec s, e; ts(&s); pgno_t retval = ((pgno_t(*)(void **, pgno_t))fn)(handle, pg); @@ -921,7 +921,7 @@ __stats_set(td_histogram_t *stats, void *fn, void **handle, pgno_t pg) static bool __stats_is_set(td_histogram_t *stats, void *fn, void *handle, pgno_t pg) { - if (stats) { + if (statistics && stats) { struct timespec s, e; ts(&s); bool retval = ((bool (*)(void *, pgno_t))fn)(handle, pg); @@ -935,7 +935,7 @@ __stats_is_set(td_histogram_t *stats, void *fn, void *handle, pgno_t pg) static pgno_t __stats_clear(td_histogram_t *stats, void *fn, void **handle, pgno_t pg) { - if (stats) { + if (statistics && stats) { struct timespec s, e; ts(&s); pgno_t retval = ((pgno_t(*)(void **, pgno_t))fn)(handle, pg); @@ -949,7 +949,7 @@ __stats_clear(td_histogram_t *stats, void *fn, void **handle, pgno_t pg) static pgno_t __stats_find_span(td_histogram_t *stats, void *fn, void *handle, unsigned len) { - if (stats) { + if (statistics && stats) { struct timespec s, e; ts(&s); pgno_t retval = ((pgno_t(*)(void *, unsigned))fn)(handle, len); @@ -963,7 +963,7 @@ __stats_find_span(td_histogram_t *stats, void *fn, void *handle, unsigned len) static bool __stats_take_span(td_histogram_t *stats, void *fn, void **handle, pgno_t pg, unsigned len) { - if (stats) { + if (statistics && stats) { struct timespec s, e; ts(&s); bool retval = ((bool (*)(void *, pgno_t, unsigned))fn)(handle, pg, len); @@ -977,7 +977,7 @@ __stats_take_span(td_histogram_t *stats, void *fn, void **handle, pgno_t pg, uns static bool __stats_release_span(td_histogram_t *stats, void *fn, void **handle, pgno_t pg, unsigned len) { - if (stats) { + if (statistics && stats) { struct timespec s, e; ts(&s); bool retval = ((bool (*)(void *, pgno_t, unsigned))fn)(handle, pg, len); @@ -991,7 +991,7 @@ __stats_release_span(td_histogram_t *stats, void *fn, void **handle, pgno_t pg, static bool __stats_is_span(td_histogram_t *stats, void *fn, void *handle, pgno_t pg, unsigned len) { - if (stats) { + if (statistics && stats) { struct timespec s, e; ts(&s); bool retval = ((bool (*)(void *, pgno_t, unsigned))fn)(handle, pg, len); @@ -1005,7 +1005,7 @@ __stats_is_span(td_histogram_t *stats, void *fn, void *handle, pgno_t pg, unsign static bool __stats_is_empty(td_histogram_t *stats, void *fn, void *handle, pgno_t pg, unsigned len) { - if (stats) { + if (statistics && stats) { struct timespec s, e; ts(&s); bool retval = ((bool (*)(void *, pgno_t, unsigned))fn)(handle, pg, len); @@ -1019,7 +1019,7 @@ __stats_is_empty(td_histogram_t *stats, void *fn, void *handle, pgno_t pg, unsig static bool __stats_is_first(td_histogram_t *stats, void *fn, void *handle, pgno_t pg, unsigned len) { - if (stats) { + if (statistics && stats) { struct timespec s, e; ts(&s); bool retval = ((bool (*)(void *, pgno_t, unsigned))fn)(handle, pg, len); @@ -1033,7 +1033,7 @@ __stats_is_first(td_histogram_t *stats, void *fn, void *handle, pgno_t pg, unsig static bool __stats_merge(td_histogram_t *stats, void *fn, void **handle, void *other_handle) { - if (stats) { + if (statistics && stats) { struct timespec s, e; ts(&s); bool retval = ((bool (*)(void **, void *))fn)(handle, other_handle); @@ -1427,7 +1427,7 @@ main(int argc, char *argv[]) checkpoint(types); left -= len; - if (toss(15) > 13) { + if (toss(7) == 6) { do { pgno_t pgno; size_t len, retries = amt / 10; @@ -1447,18 +1447,19 @@ main(int argc, char *argv[]) checkpoint(types); foreach(types) { - assert(invoke(type, is_span, pgno, len) == false); + assert(invoke(type, is_empty, pgno, len)); assert(mutate(type, release_span, pgno, len)); - assert(invoke(type, is_span, pgno, len) == true); + assert(invoke(type, is_span, pgno, len)); cast(type, validate); } checkpoint(types); left += len; } - } while (amt - left > amt / 100); + } while (toss(4) < 3); } - if (toss(10) > 8) { + // if (toss(10) > 8) { + if (0) { size_t new_offset, new_amt; pgno_t max; larger_please: @@ -1491,6 +1492,7 @@ main(int argc, char *argv[]) containers[type].free(new_handles[type]); } } + if (statistics) { const float dists[] = { 0.5, 0.75, 0.90, 0.99, 0.999 }; fprintf(stats_fp, "%f,%zu,", nsts(), iteration);