Skip to content

Commit d008d49

Browse files
authored
Merge pull request #2034 from Idclip/win_delay_load
Removed delay loading last modified time warning logic
2 parents 5e1658e + 188b8ae commit d008d49

File tree

2 files changed

+10
-40
lines changed

2 files changed

+10
-40
lines changed

openvdb/openvdb/io/Archive.cc

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -465,8 +465,6 @@ class MappedFile::Impl
465465
, mRegion(mMap, boost::interprocess::read_only)
466466
, mAutoDelete(autoDelete)
467467
{
468-
mLastWriteTime = this->getLastWriteTime();
469-
470468
if (mAutoDelete) {
471469
#ifndef _WIN32
472470
// On Unix systems, unlink the file so that it gets deleted once it is closed.
@@ -493,37 +491,13 @@ class MappedFile::Impl
493491
}
494492
}
495493

496-
Index64 getLastWriteTime() const
497-
{
498-
Index64 result = 0;
499-
const char* filename = mMap.get_name();
500-
501-
#ifdef _WIN32
502-
// boost::interprocess::detail was renamed to boost::interprocess::ipcdetail in Boost 1.48.
503-
using namespace boost::interprocess::detail;
504-
using namespace boost::interprocess::ipcdetail;
505-
506-
if (void* fh = open_existing_file(filename, boost::interprocess::read_only)) {
507-
struct { unsigned long lo, hi; } mtime; // Windows FILETIME struct
508-
if (GetFileTime(fh, nullptr, nullptr, &mtime)) {
509-
result = (Index64(mtime.hi) << 32) | mtime.lo;
510-
}
511-
close_file(fh);
512-
}
513-
#else
514-
struct stat info;
515-
if (0 == ::stat(filename, &info)) {
516-
result = Index64(info.st_mtime);
517-
}
518-
#endif
519-
return result;
520-
}
521-
522494
boost::interprocess::file_mapping mMap;
523495
boost::interprocess::mapped_region mRegion;
524496
bool mAutoDelete;
525497
Notifier mNotifier;
498+
#if OPENVDB_ABI_VERSION_NUMBER <= 12
526499
mutable std::atomic<Index64> mLastWriteTime;
500+
#endif
527501

528502
private:
529503
Impl(const Impl&); // not copyable
@@ -554,18 +528,6 @@ MappedFile::filename() const
554528
SharedPtr<std::streambuf>
555529
MappedFile::createBuffer() const
556530
{
557-
#ifndef _WIN32
558-
if (!mImpl->mAutoDelete && mImpl->mLastWriteTime > 0) {
559-
// Warn if the file has been modified since it was opened
560-
// (but don't bother checking if it is a private, temporary file).
561-
if (mImpl->getLastWriteTime() > mImpl->mLastWriteTime) {
562-
OPENVDB_LOG_WARN("file " << this->filename() << " might have changed on disk"
563-
<< " since it was opened");
564-
mImpl->mLastWriteTime = 0; // suppress further warnings
565-
}
566-
}
567-
#endif
568-
569531
return SharedPtr<std::streambuf>{
570532
new boost::iostreams::stream_buffer<boost::iostreams::array_source>{
571533
static_cast<const char*>(mImpl->mRegion.get_address()), mImpl->mRegion.get_size()}};

pendingchanges/delayloadperf.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
OpenVDB:
2+
Improvements:
3+
Significant performance improvement to delay loaded files - the warning logic
4+
which checks the underlying mapped file for the last modified time has been
5+
removed, resulting in performance gains upwards of 10x when loading in node
6+
data buffers. Note that the check that was removed is entirely redundant on
7+
Windows and would only print a warning on other system.
8+
[Contributed by jjtParadox]

0 commit comments

Comments
 (0)