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

Improve / refactor anonymous mmap capabilities #10810

Closed
wants to merge 9 commits into from

Conversation

pdillinger
Copy link
Contributor

Summary: The motivation for this change is a planned feature (related to HyperClockCache) that will depend on a large array that can essentially grow automatically, up to some bound, without the pointer address changing and with guaranteed zero-initialization of the data. Anonymous mmaps provide such functionality, and this change provides an internal API for that.

The other existing use of anonymous mmap in RocksDB is for allocating in huge pages. That code and other related Arena code used some awkward non-RAII and pre-C++11 idioms, so I cleaned up much of that as well, with RAII, move semantics, constexpr, etc.

More specifcs:

  • Minimize conditional compilation
  • Add Windows support for anonymous mmaps
  • Use std::deque instead of std::vector for more efficient bag

Test Plan: unit test added for new functionality

Summary: The motivation for this change is a planned feature (related to
HyperClockCache) that will depend on a large array that can essentially
grow automatically, up to some bound, without the pointer address
changing and with guaranteed zero-initialization of the data. Anonymous
mmaps provide such functionality, and this change provides an internal
API for that.

The other existing use of anonymous mmap in RocksDB is for allocating in
huge pages. That code and other related Arena code used some awkward
non-RAII and pre-C++11 idioms, so I cleaned up much of that as well,
with RAII, move semantics, constexpr, etc.

More specifcs:
* Minimize conditional compilation
* Add Windows support for anonymous mmaps
* Use std::deque instead of std::vector for more efficient bag

Test Plan: unit test added for new functionality
@facebook-github-bot
Copy link
Contributor

@pdillinger has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

port/mmap.cc Outdated Show resolved Hide resolved
@facebook-github-bot
Copy link
Contributor

@pdillinger has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@pdillinger has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

pdillinger added a commit to pdillinger/rocksdb that referenced this pull request Nov 28, 2022
Summary: Because of unexpected / unvalidated changes in memory usage
associated with facebook#10810

Test Plan: CI

Reviewers:

Subscribers:

Tasks:

Tags:
pdillinger added a commit that referenced this pull request Nov 28, 2022
pdillinger added a commit to pdillinger/rocksdb that referenced this pull request Nov 29, 2022
Summary: Partial revert of facebook#10810 to go back to using new char[]
directly and track raw pointers.

Test Plan:
pdillinger added a commit that referenced this pull request Dec 1, 2022
pdillinger added a commit to pdillinger/rocksdb that referenced this pull request Dec 1, 2022
Summary: The change to `make_unique<char[]>` in facebook#10810 inadvertently
started initializing data in Arena blocks, which could lead to increased
memory use due to (at least on our implementation) force-mapping pages
as a result. This goes back to `new char[]` while keeping all the
other good parts of facebook#10810.

Test Plan: unit test added (fails on Linux before fix)
facebook-github-bot pushed a commit that referenced this pull request Dec 1, 2022
Summary:
The change to `make_unique<char[]>` in #10810 inadvertently started initializing data in Arena blocks, which could lead to increased memory use due to (at least on our implementation) force-mapping pages as a result. This change goes back to `new char[]` while keeping all the other good parts of #10810.

Pull Request resolved: #11012

Test Plan: unit test added (fails on Linux before fix)

Reviewed By: anand1976

Differential Revision: D41658893

Pulled By: pdillinger

fbshipit-source-id: 267b7dccfadaeeb1be767d43c602a6abb0e71cd0
seckcoder added a commit to rockset/rocksdb-cloud that referenced this pull request Jul 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants