Skip to content

Experiment with mmap in StaticRTree #1987

@danpat

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

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