Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 2 additions & 40 deletions openvdb/openvdb/io/Archive.cc
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,6 @@ class MappedFile::Impl
, mRegion(mMap, boost::interprocess::read_only)
, mAutoDelete(autoDelete)
{
mLastWriteTime = this->getLastWriteTime();

if (mAutoDelete) {
#ifndef _WIN32
// On Unix systems, unlink the file so that it gets deleted once it is closed.
Expand All @@ -493,37 +491,13 @@ class MappedFile::Impl
}
}

Index64 getLastWriteTime() const
{
Index64 result = 0;
const char* filename = mMap.get_name();

#ifdef _WIN32
// boost::interprocess::detail was renamed to boost::interprocess::ipcdetail in Boost 1.48.
using namespace boost::interprocess::detail;
using namespace boost::interprocess::ipcdetail;

if (void* fh = open_existing_file(filename, boost::interprocess::read_only)) {
struct { unsigned long lo, hi; } mtime; // Windows FILETIME struct
if (GetFileTime(fh, nullptr, nullptr, &mtime)) {
result = (Index64(mtime.hi) << 32) | mtime.lo;
}
close_file(fh);
}
#else
struct stat info;
if (0 == ::stat(filename, &info)) {
result = Index64(info.st_mtime);
}
#endif
return result;
}

boost::interprocess::file_mapping mMap;
boost::interprocess::mapped_region mRegion;
bool mAutoDelete;
Notifier mNotifier;
#if OPENVDB_ABI_VERSION_NUMBER <= 12
mutable std::atomic<Index64> mLastWriteTime;
#endif

private:
Impl(const Impl&); // not copyable
Expand Down Expand Up @@ -554,18 +528,6 @@ MappedFile::filename() const
SharedPtr<std::streambuf>
MappedFile::createBuffer() const
{
#ifndef _WIN32
if (!mImpl->mAutoDelete && mImpl->mLastWriteTime > 0) {
// Warn if the file has been modified since it was opened
// (but don't bother checking if it is a private, temporary file).
if (mImpl->getLastWriteTime() > mImpl->mLastWriteTime) {
OPENVDB_LOG_WARN("file " << this->filename() << " might have changed on disk"
<< " since it was opened");
mImpl->mLastWriteTime = 0; // suppress further warnings
}
}
#endif

return SharedPtr<std::streambuf>{
new boost::iostreams::stream_buffer<boost::iostreams::array_source>{
static_cast<const char*>(mImpl->mRegion.get_address()), mImpl->mRegion.get_size()}};
Expand Down
8 changes: 8 additions & 0 deletions pendingchanges/delayloadperf.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
OpenVDB:
Improvements:
Significant performance improvement to delay loaded files - the warning logic
which checks the underlying mapped file for the last modified time has been
removed, resulting in performance gains upwards of 10x when loading in node
data buffers. Note that the check that was removed is entirely redundant on
Windows and would only print a warning on other system.
[Contributed by jjtParadox]
Loading