mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: fileModificationSkew: add polling. Fixes #1472.
This commit is contained in:
@ -82,6 +82,10 @@ OptimisationSwitches
|
|||||||
// updated. Set to 0 on distributed case.
|
// updated. Set to 0 on distributed case.
|
||||||
fileModificationSkew 10;
|
fileModificationSkew 10;
|
||||||
|
|
||||||
|
// How often retest (using above fileModificationSkew) before giving up.
|
||||||
|
// Default is 1.
|
||||||
|
//maxFileModificationPolls 100;
|
||||||
|
|
||||||
//- Modification checking:
|
//- Modification checking:
|
||||||
// - timeStamp : use modification time on file
|
// - timeStamp : use modification time on file
|
||||||
// - inotify : use inotify framework
|
// - inotify : use inotify framework
|
||||||
|
|||||||
@ -222,44 +222,77 @@ Foam::functionEntries::codeStream::getFunction
|
|||||||
off_t masterSize = mySize;
|
off_t masterSize = mySize;
|
||||||
Pstream::scatter(masterSize);
|
Pstream::scatter(masterSize);
|
||||||
|
|
||||||
DebugPout
|
for
|
||||||
<< nl << "on processor " << Pstream::myProcNo()
|
(
|
||||||
<< " have masterSize:" << masterSize
|
label iter = 0;
|
||||||
<< " and localSize:" << mySize << endl;
|
iter < regIOobject::maxFileModificationPolls;
|
||||||
|
iter++
|
||||||
if (mySize < masterSize)
|
)
|
||||||
{
|
{
|
||||||
DebugPout
|
DebugPout
|
||||||
<< "Local file " << libPath
|
<< "on processor " << Pstream::myProcNo()
|
||||||
<< " not of same size (" << mySize
|
<< "masterSize:" << masterSize
|
||||||
<< ") as master ("
|
<< " and localSize:" << mySize
|
||||||
<< masterSize << "). Waiting for "
|
<< endl;
|
||||||
<< regIOobject::fileModificationSkew
|
|
||||||
<< " seconds." << endl;
|
|
||||||
|
|
||||||
Foam::sleep(regIOobject::fileModificationSkew);
|
if (mySize == masterSize)
|
||||||
|
|
||||||
// Recheck local size
|
|
||||||
mySize = Foam::fileSize(libPath);
|
|
||||||
|
|
||||||
if (mySize < masterSize)
|
|
||||||
{
|
{
|
||||||
FatalIOErrorInFunction(parentDict)
|
break;
|
||||||
<< "Cannot read (NFS mounted) library " << nl
|
}
|
||||||
<< libPath << nl
|
else if (mySize > masterSize)
|
||||||
|
{
|
||||||
|
FatalIOErrorInFunction(context.dict())
|
||||||
|
<< "Excessive size when reading (NFS mounted) library "
|
||||||
|
<< nl << libPath << nl
|
||||||
<< "on processor " << Pstream::myProcNo()
|
<< "on processor " << Pstream::myProcNo()
|
||||||
<< " detected size " << mySize
|
<< " detected size " << mySize
|
||||||
<< " whereas master size is " << masterSize
|
<< " whereas master size is " << masterSize
|
||||||
<< " bytes." << nl
|
<< " bytes." << nl
|
||||||
<< "If your case is not NFS mounted"
|
<< "If your case is NFS mounted increase"
|
||||||
|
<< " fileModificationSkew or maxFileModificationPolls;"
|
||||||
|
<< nl << "If your case is not NFS mounted"
|
||||||
<< " (so distributed) set fileModificationSkew"
|
<< " (so distributed) set fileModificationSkew"
|
||||||
<< " to 0"
|
<< " to 0"
|
||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DebugPout
|
||||||
|
<< "Local file " << libPath
|
||||||
|
<< " not of same size (" << mySize
|
||||||
|
<< ") as master ("
|
||||||
|
<< masterSize << "). Waiting for "
|
||||||
|
<< regIOobject::fileModificationSkew
|
||||||
|
<< " seconds." << endl;
|
||||||
|
|
||||||
|
Foam::sleep(regIOobject::fileModificationSkew);
|
||||||
|
|
||||||
|
// Recheck local size
|
||||||
|
mySize = Foam::fileSize(libPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Finished doing iterations. Do final check
|
||||||
|
if (mySize != masterSize)
|
||||||
|
{
|
||||||
|
FatalIOErrorInFunction(context.dict())
|
||||||
|
<< "Cannot read (NFS mounted) library " << nl
|
||||||
|
<< libPath << nl
|
||||||
|
<< "on processor " << Pstream::myProcNo()
|
||||||
|
<< " detected size " << mySize
|
||||||
|
<< " whereas master size is " << masterSize
|
||||||
|
<< " bytes." << nl
|
||||||
|
<< "If your case is NFS mounted increase"
|
||||||
|
<< " fileModificationSkew or maxFileModificationPolls;"
|
||||||
|
<< nl << "If your case is not NFS mounted"
|
||||||
|
<< " (so distributed) set fileModificationSkew"
|
||||||
|
<< " to 0"
|
||||||
|
<< exit(FatalIOError);
|
||||||
}
|
}
|
||||||
|
|
||||||
DebugPout
|
DebugPout
|
||||||
<< nl << "on processor " << Pstream::myProcNo()
|
<< "on processor " << Pstream::myProcNo()
|
||||||
<< " after waiting: have masterSize:" << masterSize
|
<< " after waiting: have masterSize:" << masterSize
|
||||||
<< " and localSize:" << mySize << endl;
|
<< " and localSize:" << mySize << endl;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -250,54 +250,79 @@ void Foam::codedBase::createLibrary
|
|||||||
off_t masterSize = mySize;
|
off_t masterSize = mySize;
|
||||||
Pstream::scatter(masterSize);
|
Pstream::scatter(masterSize);
|
||||||
|
|
||||||
if (debug)
|
for
|
||||||
|
(
|
||||||
|
label iter = 0;
|
||||||
|
iter < regIOobject::maxFileModificationPolls;
|
||||||
|
iter++
|
||||||
|
)
|
||||||
{
|
{
|
||||||
Pout<< endl<< "on processor " << Pstream::myProcNo()
|
DebugPout
|
||||||
|
<< "on processor " << Pstream::myProcNo()
|
||||||
<< " have masterSize:" << masterSize
|
<< " have masterSize:" << masterSize
|
||||||
<< " and localSize:" << mySize
|
<< " and localSize:" << mySize
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
|
||||||
|
|
||||||
|
if (mySize == masterSize)
|
||||||
if (mySize < masterSize)
|
|
||||||
{
|
|
||||||
if (debug)
|
|
||||||
{
|
{
|
||||||
Pout<< "Local file " << libPath
|
break;
|
||||||
|
}
|
||||||
|
else if (mySize > masterSize)
|
||||||
|
{
|
||||||
|
FatalIOErrorInFunction(context.dict())
|
||||||
|
<< "Excessive size when reading (NFS mounted) library "
|
||||||
|
<< nl << libPath << nl
|
||||||
|
<< "on processor " << Pstream::myProcNo()
|
||||||
|
<< " detected size " << mySize
|
||||||
|
<< " whereas master size is " << masterSize
|
||||||
|
<< " bytes." << nl
|
||||||
|
<< "If your case is NFS mounted increase"
|
||||||
|
<< " fileModificationSkew or maxFileModificationPolls;"
|
||||||
|
<< nl << "If your case is not NFS mounted"
|
||||||
|
<< " (so distributed) set fileModificationSkew"
|
||||||
|
<< " to 0"
|
||||||
|
<< exit(FatalIOError);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DebugPout
|
||||||
|
<< "Local file " << libPath
|
||||||
<< " not of same size (" << mySize
|
<< " not of same size (" << mySize
|
||||||
<< ") as master ("
|
<< ") as master ("
|
||||||
<< masterSize << "). Waiting for "
|
<< masterSize << "). Waiting for "
|
||||||
<< regIOobject::fileModificationSkew
|
<< regIOobject::fileModificationSkew
|
||||||
<< " seconds." << endl;
|
<< " seconds." << endl;
|
||||||
}
|
|
||||||
Foam::sleep(regIOobject::fileModificationSkew);
|
|
||||||
|
|
||||||
// Recheck local size
|
Foam::sleep(regIOobject::fileModificationSkew);
|
||||||
mySize = Foam::fileSize(libPath);
|
|
||||||
|
|
||||||
if (mySize < masterSize)
|
// Recheck local size
|
||||||
{
|
mySize = Foam::fileSize(libPath);
|
||||||
FatalIOErrorInFunction(context.dict())
|
|
||||||
<< "Cannot read (NFS mounted) library " << nl
|
|
||||||
<< libPath << nl
|
|
||||||
<< "on processor " << Pstream::myProcNo()
|
|
||||||
<< " detected size " << mySize
|
|
||||||
<< " whereas master size is " << masterSize
|
|
||||||
<< " bytes." << nl
|
|
||||||
<< "If your case is not NFS mounted"
|
|
||||||
<< " (so distributed) set fileModificationSkew"
|
|
||||||
<< " to 0"
|
|
||||||
<< exit(FatalIOError);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debug)
|
|
||||||
|
// Finished doing iterations. Do final check
|
||||||
|
if (mySize != masterSize)
|
||||||
{
|
{
|
||||||
Pout<< endl<< "on processor " << Pstream::myProcNo()
|
FatalIOErrorInFunction(context.dict())
|
||||||
<< " after waiting: have masterSize:" << masterSize
|
<< "Cannot read (NFS mounted) library " << nl
|
||||||
<< " and localSize:" << mySize
|
<< libPath << nl
|
||||||
<< endl;
|
<< "on processor " << Pstream::myProcNo()
|
||||||
|
<< " detected size " << mySize
|
||||||
|
<< " whereas master size is " << masterSize
|
||||||
|
<< " bytes." << nl
|
||||||
|
<< "If your case is NFS mounted increase"
|
||||||
|
<< " fileModificationSkew or maxFileModificationPolls;"
|
||||||
|
<< nl << "If your case is not NFS mounted"
|
||||||
|
<< " (so distributed) set fileModificationSkew"
|
||||||
|
<< " to 0"
|
||||||
|
<< exit(FatalIOError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DebugPout
|
||||||
|
<< "on processor " << Pstream::myProcNo()
|
||||||
|
<< " after waiting: have masterSize:" << masterSize
|
||||||
|
<< " and localSize:" << mySize << endl;
|
||||||
}
|
}
|
||||||
reduce(create, orOp<bool>());
|
reduce(create, orOp<bool>());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -50,6 +50,17 @@ registerOptSwitch
|
|||||||
Foam::regIOobject::fileModificationSkew
|
Foam::regIOobject::fileModificationSkew
|
||||||
);
|
);
|
||||||
|
|
||||||
|
int Foam::regIOobject::maxFileModificationPolls
|
||||||
|
(
|
||||||
|
Foam::debug::optimisationSwitch("maxFileModificationPolls", 1)
|
||||||
|
);
|
||||||
|
registerOptSwitch
|
||||||
|
(
|
||||||
|
"maxFileModificationPolls",
|
||||||
|
int,
|
||||||
|
Foam::regIOobject::maxFileModificationPolls
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
bool Foam::regIOobject::masterOnlyReading = false;
|
bool Foam::regIOobject::masterOnlyReading = false;
|
||||||
|
|
||||||
|
|||||||
@ -131,6 +131,8 @@ public:
|
|||||||
|
|
||||||
static float fileModificationSkew;
|
static float fileModificationSkew;
|
||||||
|
|
||||||
|
static int maxFileModificationPolls;
|
||||||
|
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
|
|||||||
@ -1501,8 +1501,27 @@ void Foam::argList::parse
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
Info<< " (fileModificationSkew "
|
if (regIOobject::maxFileModificationPolls == 1)
|
||||||
<< regIOobject::fileModificationSkew << ")";
|
{
|
||||||
|
Info<< " (fileModificationSkew "
|
||||||
|
<< regIOobject::fileModificationSkew
|
||||||
|
<< ")";
|
||||||
|
}
|
||||||
|
else if (regIOobject::maxFileModificationPolls > 1)
|
||||||
|
{
|
||||||
|
Info<< " (fileModificationSkew "
|
||||||
|
<< regIOobject::fileModificationSkew
|
||||||
|
<< ", maxFileModificationPolls "
|
||||||
|
<< regIOobject::maxFileModificationPolls
|
||||||
|
<< ")";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "Invalid setting for maxFileModificationPolls "
|
||||||
|
<< regIOobject::maxFileModificationPolls
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Info<< nl;
|
Info<< nl;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user