using metaspace::FreeChunkList; using metaspace::FreeChunkListVector; using metaspace::MemRangeCounter; using metaspace::MetachunkList; using metaspace::Settings;
TEST_VM(metaspace, metachunklist) {
ChunkGtestContext context;
MetachunkList lst;
Metachunk* chunks[10];
size_t total_size = 0;
for (int i = 0; i < 10; i++) {
Metachunk* c = NULL;
context.alloc_chunk_expect_success(&c, ChunkLevelRanges::all_chunks().random_value());
chunks[i] = c;
total_size += c->committed_words();
// Add random chunks to list and check the counter apis (word_size, commited_word_size, num_chunks) // Make every other chunk randomly uncommitted, and later we check that committed chunks are sorted in at the front // of the lists. for (int i = 0; i < 100; i++) {
Metachunk* c = NULL;
context.alloc_chunk_expect_success(&c, ChunkLevelRanges::all_chunks().random_value()); bool uncommitted_chunk = i % 3; if (uncommitted_chunk) {
context.uncommit_chunk_with_test(c);
c->set_in_use();
}
// Drain each list separately, front to back. While draining observe the order // in which the chunks come: since uncommitted chunks are added to the tail of // the list (see FreeChunkList::add_chunk()), no committed chunk should ever // follow an uncommitted chunk. for (chunklevel_t lvl = LOWEST_CHUNK_LEVEL; lvl <= HIGHEST_CHUNK_LEVEL; lvl++) {
Metachunk* c = lst.remove_first(lvl); bool found_uncommitted = false; while (c != NULL) {
// Test, for a list populated with a mixture of fully/partially/uncommitted chunks, // the retrieval-by-minimally-committed-words function.
TEST_VM(metaspace, freechunklist_retrieval) {
if (Settings::new_chunks_are_fully_committed()) { return;
}
ChunkGtestContext context;
FreeChunkList fcl;
Metachunk* c = NULL;
// For a chunk level which allows us to have partially committed chunks... const size_t chunk_word_size = Settings::commit_granule_words() * 4; const chunklevel_t lvl = level_fitting_word_size(chunk_word_size);
// Simple check 1. Empty list should yield nothing.
{
c = fcl.first_minimally_committed(0);
ASSERT_NULL(c);
}
// Simple check 2. Just a single uncommitted chunk.
{
fcl.add(c_0);
c = fcl.first_minimally_committed(0);
ASSERT_EQ(c_0, c);
c = fcl.first_minimally_committed(1);
ASSERT_NULL(c);
fcl.remove(c_0);
}
// Now a check with a fully populated list. // For different insert orders, try to retrieve different chunks by minimal commit level // and check the result. for (int insert_order = 0; insert_order < 4; insert_order ++) {
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.