Skip to content

Experiment with mmap in StaticRTree #1987

Closed

Description

@danpat

We can possibly save the cost of a syscall in our StaticRtree here:

inline void LoadLeafFromDisk(const uint32_t leaf_id, LeafNode &result_node)
{
if (!leaves_stream.is_open())
{
leaves_stream.open(m_leaf_node_filename, std::ios::in | std::ios::binary);
}
if (!leaves_stream.good())
{
throw exception("Could not read from leaf file.");
}
const uint64_t seek_pos = sizeof(uint64_t) + leaf_id * sizeof(LeafNode);
leaves_stream.seekg(seek_pos);
BOOST_ASSERT_MSG(leaves_stream.good(), "Seeking to position in leaf file failed.");
leaves_stream.read((char *)&result_node, sizeof(LeafNode));
BOOST_ASSERT_MSG(leaves_stream.good(), "Reading from leaf file failed.");
}

by using mmap to access the leaf node data.

This StackOverflow ticket: http://stackoverflow.com/a/5589622
talks about some of the tradeoffs. Because we do quite a lot of IO on each nearest-neighbor search, it's not clear to me whether we're a good candidate for mmap. We should measure this.

/cc @daniel-j-h

Activity

  1. daniel-j-h commented on Feb 18, 2016

    @daniel-j-h
    Member
  2. TheMarex commented on May 7, 2016

    @TheMarex
    Member

    This is implemented as part of #2385

  3. TheMarex commented on May 7, 2016

    @TheMarex
    Member

    Landed.

  4. daniel-j-h commented on May 8, 2016

    @daniel-j-h
    Member

    Did you try setting hints such as madvise or pre-faulting pages? I think the Boost.IOStream's mmap features are very basic only and do not support this. Boost.Interprocess' mapped_region is more advanced in this regard. (Otherwise ifdef and syscalls)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions