Skip to content

Commit

Permalink
Inform the OS cache with madvise
Browse files Browse the repository at this point in the history
  • Loading branch information
drolbr committed Nov 4, 2022
1 parent 56f7e66 commit 2a9d964
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/template_db/file_blocks.h
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,7 @@ class Mmap
addr = mmap(0, length, PROT_READ, MAP_PRIVATE, fd, offset);
if (addr == (void*)(-1))
throw File_Error(errno, file_name, origin);
posix_madvise(addr, length, POSIX_MADV_WILLNEED);
}
~Mmap()
{
Expand Down
2 changes: 1 addition & 1 deletion src/template_db/file_blocks_index.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ struct Readonly_File_Blocks_Index : public File_Blocks_Index_Base
void increase_block_count(uint32 delta) { params.block_count += delta; }
virtual bool empty() const { return params.empty_; }
File_Blocks_Index_Iterator< Index > begin()
{ //std::cout<<"DEBUG File_Blocks_Idx "<<(void*)idx_file.begin()<<' '<<(void*)idx_file.end()<<' '<<data_file_name<<'\n';
{ posix_madvise((void*)idx_file.header(), idx_file.size(), POSIX_MADV_WILLNEED);
return File_Blocks_Index_Iterator< Index >(idx_file.begin(), idx_file.end()); }
File_Blocks_Index_Iterator< Index > end()
{ return File_Blocks_Index_Iterator< Index >(idx_file.end(), idx_file.end()); }
Expand Down

0 comments on commit 2a9d964

Please sign in to comment.