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

More robust memory mapping #370

Merged
merged 23 commits into from
Jun 22, 2020
Merged

More robust memory mapping #370

merged 23 commits into from
Jun 22, 2020

Conversation

elshize
Copy link
Member

@elshize elshize commented Apr 25, 2020

Addresses, in part, #357.

Fixes #367

@elshize elshize requested review from JMMackenzie and amallia April 25, 2020 23:27
@elshize elshize self-assigned this Apr 25, 2020
private:
explicit MemorySource(std::unique_ptr<mio::mmap_source> source) : m_source(std::move(source)) {}

std::unique_ptr<mio::mmap_source> m_source;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why a pointer? We could use mio::mmap_source.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mistakenly thought I couldn't use value but I can, thanks.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kept the pointer to separate implementation from the header.

namespace pisa {

/// This is an owning memory source for any byte-based structures.
class MemorySource {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not against this class. Just for the sake of discussion, what is the additional value when compared to a mio::mmap_source?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good question. This is a very light wrapper but has the following advantages:

  1. Initial motivation was to have something less error-prone, in particular, something that gives a clear error when trying to map a non-existent file, but also something that fails quickly if the memory is empty.
  2. It's implementation agnostic, if we ever decide to use another backend or even provide alternative to loading everything in memory, we can easily do that.
  3. Now that I made some changes, I actually separated implementation and only a small header from mio is necessary to use it, the rest is in a binary. Same could be done for binary_collection later on.

Copy link
Member

@JMMackenzie JMMackenzie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aside from Antonio's comments it's nice! Good work.

@JMMackenzie
Copy link
Member

Worth mentioning that this closes #367 right?

@elshize
Copy link
Member Author

elshize commented Apr 28, 2020

As mentioned before, I think there's more to be done, I think index/wand data need to be decoupled from the way we handle memory. It's not as much about the mapper as it is about mappable_vector. Imo it needs to go. Regardless, I'll write down what I mean in more detail separately, and we can discuss.

@elshize
Copy link
Member Author

elshize commented May 3, 2020

@amallia any updates on this?

@amallia
Copy link
Member

amallia commented May 3, 2020

@amallia any updates on this?

I will follow up soon

@elshize
Copy link
Member Author

elshize commented May 5, 2020

@amallia still waiting for comments to the latest push.

@codecov
Copy link

codecov bot commented Jun 11, 2020

Codecov Report

Merging #370 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #370   +/-   ##
=======================================
  Coverage   92.41%   92.41%           
=======================================
  Files          90       91    +1     
  Lines        4915     4918    +3     
=======================================
+ Hits         4542     4545    +3     
  Misses        373      373           
Impacted Files Coverage Δ
include/pisa/block_freq_index.hpp 96.49% <ø> (ø)
include/pisa/io.hpp 95.65% <ø> (ø)
include/pisa/sharding.hpp 93.28% <ø> (ø)
include/pisa/wand_data.hpp 62.50% <ø> (ø)
include/pisa/freq_index.hpp 98.33% <100.00%> (ø)
include/pisa/invert.hpp 96.05% <100.00%> (ø)
include/pisa/memory_source.hpp 100.00% <100.00%> (ø)
include/pisa/query/term_processor.hpp 97.72% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e2dab63...fd6fd29. Read the comment docs.

@amallia amallia merged commit 0468d9a into master Jun 22, 2020
@amallia amallia deleted the memory-source branch June 22, 2020 12:15
@amallia
Copy link
Member

amallia commented Jun 22, 2020

Sorry. It took a while but I was finally able to check it again and merge it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove pessimizing move
3 participants