* How to clear UBC (unified buffer cache)?
@ 1999-07-26 4:00 Karl
1999-08-02 4:00 ` Eric Werme - replace nospam with werme
0 siblings, 1 reply; 2+ messages in thread
From: Karl @ 1999-07-26 4:00 UTC (permalink / raw)
This is regarding Digital Unix OSF1 v4.0 on an alpha
I am trying to prevent caching from causing a bias in the timing of
different functions that read from disk. I need to time how long two
different methods take to read the same data from the same files.
Unfortunately, once I've run the first function, so much of the data is
cached that the
second function appears dramatically faster. This behavior persists even if
I swap the order of the functions.
Is there a way to programmatically (or *any* way) clear the UBC (Unified
Buffer Cache)? Is there a way to clear the metadata buffer cache?
Rebooting the system or re-mounting the filesystem are not practical
options.
Karl
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: How to clear UBC (unified buffer cache)?
1999-07-26 4:00 How to clear UBC (unified buffer cache)? Karl
@ 1999-08-02 4:00 ` Eric Werme - replace nospam with werme
0 siblings, 0 replies; 2+ messages in thread
From: Eric Werme - replace nospam with werme @ 1999-08-02 4:00 UTC (permalink / raw)
"Karl" <kbarkei@cs.umass.edu> writes:
>Is there a way to programmatically (or *any* way) clear the UBC (Unified
>Buffer Cache)? Is there a way to clear the metadata buffer cache?
>Rebooting the system or re-mounting the filesystem are not practical
>options.
Try this snippet from the Connectathon testsuite (www.connectathon.org):
#define MMAP
#ifdef MMAP
#include <sys/mman.h>
#endif
#ifdef MMAP
caddr_t maddr;
#endif
#ifdef MMAP
maddr = mmap((caddr_t)0, (size_t)size, PROT_READ,
MAP_PRIVATE, fd, (off_t)0);
if (maddr == NULL) {
error("can't mmap '%s'", bigfile);
exit(1);
}
if (msync(maddr, (size_t)size, MS_INVALIDATE) < 0) {
error("can't invalidate pages for '%s'", bigfile);
exit(1);
}
if (munmap(maddr, (size_t)size) < 0) {
error("can't munmap '%s'", bigfile);
exit(1);
}
#endif
No guarantees that it works on all past or future releases or all file
systems. It does work on NFS. (But no guaranteess it will continue to do
so.)
It invalidates the cache for the file descriptor fd, not for the whole
FS.
-Ric Werme
--
<> Eric (Ric) Werme <> The above is unlikely to contain <>
<> ROT-13 addresses: <> official claims or policies of <>
<> <jrezr@mx3.qrp.pbz> <> Compaq Computer Corp. <>
<> <jrezr@plorecbegny.arg> <> http://www.cyberportal.net/werme <>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1999-08-02 4:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1999-07-26 4:00 How to clear UBC (unified buffer cache)? Karl
1999-08-02 4:00 ` Eric Werme - replace nospam with werme
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox