Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(#530) Add test cases to exercise print methods for mini-allocator metadata pages and for trunk verbose logging. #531

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,10 @@ $(BINDIR)/$(UNITDIR)/platform_apis_test: $(UTIL_SYS) \
$(COMMON_UNIT_TESTOBJ) \
$(PLATFORM_SYS)

$(BINDIR)/$(UNITDIR)/mini_allocator_test: $(COMMON_TESTOBJ) \
$(OBJDIR)/$(FUNCTIONAL_TESTSDIR)/test_async.o \
$(LIBDIR)/libsplinterdb.so

########################################
# Convenience mini unit-test targets
unit/util_test: $(BINDIR)/$(UNITDIR)/util_test
Expand Down
17 changes: 17 additions & 0 deletions src/allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,23 @@ allocator_print_allocated(allocator *al)
return al->ops->print_allocated(al);
}

// Return the address of the extent holding page at address 'addr'
static inline uint64
allocator_extent_base_addr(allocator *al, uint64 addr)
{
allocator_config *allocator_cfg = allocator_get_config(al);
return allocator_config_extent_base_addr(allocator_cfg, addr);
}

// Returns the address of the page next to input 'page_addr'
static inline uint64
allocator_next_page_addr(allocator *al, uint64 page_addr)
{
allocator_config *allocator_cfg = allocator_get_config(al);
return (page_addr + allocator_cfg->io_cfg->page_size);
}


static inline bool
allocator_page_valid(allocator *al, uint64 addr)
{
Expand Down
16 changes: 5 additions & 11 deletions src/btree.c
Original file line number Diff line number Diff line change
Expand Up @@ -1016,8 +1016,11 @@ btree_truncate_index(const btree_config *cfg, // IN
*-----------------------------------------------------------------------------
* btree_alloc --
*
* Allocates a node from the preallocator. Will refill it if there are no
* more nodes available for the given height.
* Allocates a new page from the mini-allocator for a new BTree node.
* from the (previously setup) mini-allocator. Will refill the mini-
* allocator's cache of pre-allocated extents if there are no more nodes
* (pages) available from the already-allocated extent for the given
* height.
*-----------------------------------------------------------------------------
*/
bool
Expand Down Expand Up @@ -1132,15 +1135,6 @@ btree_addrs_share_extent(cache *cc, uint64 left_addr, uint64 right_addr)
allocator_get_config(al), right_addr, left_addr);
}

static inline uint64
btree_root_to_meta_addr(const btree_config *cfg,
uint64 root_addr,
uint64 meta_page_no)
{
return root_addr + (meta_page_no + 1) * btree_page_size(cfg);
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Externalized in .h file so this can be called from unit test case in btree_stress_test.c:test_btree_print_diags().



/*----------------------------------------------------------
* Creating and destroying B-trees.
*----------------------------------------------------------
Expand Down
8 changes: 8 additions & 0 deletions src/btree_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,3 +305,11 @@ btree_get_child_addr(const btree_config *cfg,
{
return index_entry_child_addr(btree_get_index_entry(cfg, hdr, k));
}

static inline uint64
btree_root_to_meta_addr(const btree_config *cfg,
uint64 root_addr,
uint64 meta_page_no)
{
return root_addr + (meta_page_no + 1) * btree_page_size(cfg);
}
Loading