-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Unify fingerprinting & Count64 #3904
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
Unify fingerprinting & Count64 #3904
Conversation
bc8647d
to
196742c
Compare
io::FileReader reader(config.geometries_path, io::FileReader::HasNoFingerprint); | ||
io::FileReader reader(config.geometries_path, io::FileReader::VerifyFingerprint); | ||
|
||
const auto number_of_geometries_indices = reader.ReadVectorSize<unsigned>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the logic behind ReadVectorSize
reading CountElement64
, then skipping T
(in this case unsigned
)? Naming doesn't cover what's actually happening here.
Ideally I'd also take this through a files
layer, any input as to how?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to extract the file size in order to pre-allocate the shared memory block. For this we need to extract the size of every block/vector.
I couldn't come up with a good abstraction for this yet. But yeah having a dedicated function in files::
would be good.
include/engine/engine.hpp
Outdated
auto mem = storage::makeSharedMemory(barrier.data().region); | ||
auto layout = reinterpret_cast<storage::DataLayout *>(mem->Ptr()); | ||
return layout->GetBlockSize(storage::DataLayout::CH_CORE_MARKER) > 4; | ||
return layout->GetBlockSize(storage::DataLayout::CH_CORE_MARKER) > 16; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This (and underlying sizeof(std::uint64_t) + sizeof(util::FingerPrint);
) can really bite... Any suggestions for a more understandable naming, to get rid of these magic numbers?
The least we should do is add some comments to both sections.
Would like to unify file names between |
@duizendnegen no objections - we have way too much repetition |
… function Fingerprint-aware
src/updater/updater.cpp
Outdated
using boost::interprocess::mapped_region; | ||
|
||
{ | ||
storage::io::FileReader file(filename, storage::io::FileReader::VerifyFingerprint); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opening this file with the FileReader
just for verifying the fingerprint seems a bit clumsy. On Windows this fails in a way since a subsequent call from file_mapping
results in Access denied
.
Is there a way to read just the Fingerprint from the mapped_region
? Should we implement an explicit Close
function for the FileReader
/FileWriter
, or do an implicit fclose
on the destructor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or do an implicit fclose on the destructor
Wait we don't close file handles? This is definitely a bug that should be fixed.
/cc @danpat I think these might be the reason we saw the file handle exhaustion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay just looked at the implementation: We just wrap ifstream
which closes on destruction, which still begs the question of why this fails here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it should be close-on-destroy. The errors on appveyor seem to be around mmap
calls though - perhaps we're not unmapping at some point? Multiple mappings should work though.....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wrong anyway, commented out the file reader fingerprint verification and errors still occur. I'll skip fingerprinting these mmap'ed files for now (just one file) to get this to land and open a ticket.
dd08505
to
e445ddc
Compare
Ready for review / feedback. I'm tackling config normalization in a separate PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, but travis is failing because the formatting is broken.
src/contractor/contractor.cpp
Outdated
const auto level_size = order_file.ReadElementCount32(); | ||
node_levels.resize(level_size); | ||
order_file.ReadInto(node_levels); | ||
files::readLevels(config.level_output_path, node_levels); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the refactor! I think we can remove Contractor::ReadNodeLevels
entirely now and directly call files::readLevels
.
src/contractor/contractor.cpp
Outdated
storage::io::FileWriter::HasNoFingerprint); | ||
|
||
storage::serialization::write(writer, node_levels); | ||
files::writeLevels(config.level_output_path, node_levels); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
io::FileReader reader(config.geometries_path, io::FileReader::HasNoFingerprint); | ||
io::FileReader reader(config.geometries_path, io::FileReader::VerifyFingerprint); | ||
|
||
const auto number_of_geometries_indices = reader.ReadVectorSize<unsigned>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to extract the file size in order to pre-allocate the shared memory block. For this we need to extract the size of every block/vector.
I couldn't come up with a good abstraction for this yet. But yeah having a dedicated function in files::
would be good.
src/updater/updater.cpp
Outdated
mapped_region region{mapping, mode}; | ||
|
||
// map region started at an offset of util::FingerPrint size | ||
mapped_region region{mapping, mode, 8}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of 8
what about using sizeof(Fingerprint)
?
Windows tests seem to fail during updating. I suspect the |
@TheMarex it's not about the 8 bytes part - see #3904 (comment) - it's opening and not explicitly closing the file, then re-opening (somehow). To get things to work I can leave out fingerprint checking .turn_penalties_index, or figure out a different way to read the fingerprint, or close the file explicitly somewhere. Open for suggestions. |
…teration because of Appveyor issues.
57afed6
to
c041afa
Compare
Skipped the problematic |
Issue
#3520
Tasklist
Requirements / Relations
This should go in after #3892 (the other way around is too much hassle)