Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

use huge pages via mmap() instead of hugetlbfs #9577

Merged
merged 3 commits into from
Oct 28, 2020
Merged

Conversation

spoonincode
Copy link
Contributor

Change Description

Previously, huge page usage in nodeos required specifying hugetlbfs mount points via the database-hugepage-path option. To make huge page usage easier to use, as it can be quite a performance boost, this PR completely removes the database-hugepage-path option and tries to allocate huge pages directly via mmap() when database-map-mode is either heap or locked. This is easier for operators as there is no need to fuss with hugetlbfs which is doubly a headache inside a container.

The general logic when operating on Linux with the database-map-mode set to either heap or locked is now,

  • try to use 1GB pages; if that fails then,
  • try to use 2MB pages; if that fails then,
  • use standard 4KB pages

When running on macOS there is a new attempt to use 2MB pages. This is new functionality. However, in my testing, the chance of successfully using 2MB pages is exceedingly slim for any database size nodeos is likely to use.

It’s important to note there are some additional subtle differences in behavior now:

  • No longer is locked mode required to use huge pages, both heap and locked will attempt to use huge pages
  • Databases that are not a multiple of the huge page size will still be able to use huge pages. That is, if reversible-blocks-db-size-mb=340, and there is a 1GB page available for use, the database will still be placed in a 1GB page despite the DB only being 340MB. This is different behavior than before which required the DB size to be a multiple of the huge page size to even attempt huge page usage.

Example

Say you have nodeos configured with a chain DB of 16GB, and a reversible DB of 340MB, i.e.

chain-state-db-size-mb = 16384
reversible-blocks-db-size-mb = 340

To have these databases placed in 1GB pages at runtime, reserve 17 1GB pages:

echo 17 > /sys/kernel/mm/hugepages/hugepages-1048576kB/nr_hugepages

and start nodeos with database-map-mode=heap (or locked). There will be a message at start up such as

CHAINBASE: Database "state" using 1GB pages

indicating that 1GB pages are in use.

Be aware that reserving large numbers of 1GB pages post-boot is increasingly unlikely the longer the platform is running. You would likely want to reserve these pages very quickly (right after boot) or even modify the kernel command line (via GRUB, UEFI, etc) to reserve them automatically ASAP.

Needs EOSIO/chainbase#69

Change Type

Select ONE

  • Documentation
  • Stability bug fix
  • Other
  • Other - special case

Consensus Changes

  • Consensus Changes

API Changes

  • API Changes

Documentation Additions

  • Documentation Additions

@spoonincode spoonincode merged commit fee6367 into develop Oct 28, 2020
@spoonincode spoonincode deleted the new_hugepages branch October 28, 2020 23:16
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants