Skip to content

Commit

Permalink
Adds guards for hugepages
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco Previtali committed Nov 11, 2019
1 parent c5c57c4 commit a62c145
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions bloomfilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,13 @@ class BF {
_mode(0),
_bf(size, 0)
{
#ifdef MADV_HUGEPAGE
char* const sptr = reinterpret_cast<char*>(_bf.data());
const size_t soffset = SHARK_HUGEPAGESIZE - (reinterpret_cast<size_t>(sptr) % SHARK_HUGEPAGESIZE);
char* const eptr = sptr + (((size + 63) >> 6) << 3);
const size_t eoffset = (reinterpret_cast<size_t>(eptr) % SHARK_HUGEPAGESIZE);
madvise(sptr + soffset, (eptr - sptr) - eoffset - soffset, MADV_HUGEPAGE);
#endif
}

~BF() {}
Expand Down

0 comments on commit a62c145

Please sign in to comment.