Remove slow sync() call for NFS flushing.

This commit is contained in:
Wilson Snyder 2013-02-04 21:21:55 -05:00
parent 936855c81c
commit 238fc24684
3 changed files with 15 additions and 3 deletions

View File

@ -162,13 +162,11 @@ inline void V3FileDependImp::writeTimes(const string& filename, const string& cm
*ofp<<"# DESCR"<<"IPTION: Verilator output: Timestamp data for --skip-identical. Delete at will."<<endl; *ofp<<"# DESCR"<<"IPTION: Verilator output: Timestamp data for --skip-identical. Delete at will."<<endl;
*ofp<<"C \""<<cmdline<<"\""<<endl; *ofp<<"C \""<<cmdline<<"\""<<endl;
#ifndef _WIN32
sync(); // Push files so sizes look correct
#endif
for (set<DependFile>::iterator iter=m_filenameList.begin(); for (set<DependFile>::iterator iter=m_filenameList.begin();
iter!=m_filenameList.end(); ++iter) { iter!=m_filenameList.end(); ++iter) {
// Read stats of files we create after we're done making them (execpt for this file, of course) // Read stats of files we create after we're done making them (execpt for this file, of course)
DependFile* dfp = (DependFile*)&(*iter); DependFile* dfp = (DependFile*)&(*iter);
V3Options::fileNfsFlush(dfp->filename());
dfp->loadStats(); dfp->loadStats();
off_t showSize = iter->size(); off_t showSize = iter->size();
if (dfp->filename() == filename) showSize=0; // We're writing it, so need to ignore it if (dfp->filename() == filename) showSize=0; // We're writing it, so need to ignore it

View File

@ -28,6 +28,7 @@
#include <cctype> #include <cctype>
#include <dirent.h> #include <dirent.h>
#include <unistd.h> #include <unistd.h>
#include <fcntl.h>
#include <set> #include <set>
#include <list> #include <list>
#include <map> #include <map>
@ -277,6 +278,17 @@ bool V3Options::fileStatNormal(const string& filename) {
return true; return true;
} }
void V3Options::fileNfsFlush(const string& filename) {
// NFS caches stat() calls so to get up-to-date information must
// do a open or opendir on the filename.
// Faster to just try both rather than check if a file is a dir.
if (DIR* dirp = opendir(filename.c_str())) {
closedir(dirp);
} else if (int fd = ::open(filename.c_str(), O_RDONLY)) {
if (fd>0) ::close(fd);
}
}
string V3Options::fileExists (const string& filename) { string V3Options::fileExists (const string& filename) {
// Surprisingly, for VCS and other simulators, this process // Surprisingly, for VCS and other simulators, this process
// is quite slow; presumably because of re-reading each directory // is quite slow; presumably because of re-reading each directory

View File

@ -36,6 +36,7 @@
class V3OptionsImp; class V3OptionsImp;
class FileLine; class FileLine;
struct stat;
typedef vector<string> V3StringList; typedef vector<string> V3StringList;
typedef set<string> V3StringSet; typedef set<string> V3StringSet;
@ -321,6 +322,7 @@ class V3Options {
V3LangCode fileLanguage(const string &filename); V3LangCode fileLanguage(const string &filename);
static bool fileStatDir (const string& filename); static bool fileStatDir (const string& filename);
static bool fileStatNormal (const string& filename); static bool fileStatNormal (const string& filename);
static void fileNfsFlush(const string& filename);
// METHODS (other OS) // METHODS (other OS)
static void throwSigsegv(); static void throwSigsegv();