Re: Re-read an image



IA,

Thanks for the tip. I'll have to try that and see if it will achieve
my goal of bogging down my programs! Just kidding, obviously I do not
want to slow my progs down. My interest in the matter is
benchmarking; I have several implementations of the exact same
function --- read an image, and downsample it --- and I want to have
a shoot out. I want to know who's fastest. And I can't do that if I
run one and then the other and then the other, because the first will
do all the legwork and will appear absurdly slow. Know what I mean?
Maybe I could get the same result by running several instances of
Matlab, but geez, that gets complicated. I just wanted an easy way to
run each prog say, 10 times, and then compare.

Thanks,
John

ImageAnalyst wrote:


John:
You can make MATLAB "forget" the variable it just read by using the
clear command. This is not the same as clearing the cache. MATLAB
is
not doing the caching - the drive adapter is. Perhaps there is
some
way of using some low level API command (not a MATLAB command) to
clear the disk cache, however I don't know how without digging into
it
and I don't know why you'd want to. Why on earth would you want to
make your program slower??!?!? I suppose you could read some
temporary, intermediate file that is located on a different part of
the disk. That would fill up the cache with a different set of
data.
Then when you went to read the part you want, the cache would not
be
valid (because it doesn't hold the sectors you're looking for) and
it
would have to retrieve it from disk (which also loads the cache
with
the new data).
Regards,
ImageAnalyst

==============================================
On Apr 3, 9:15 am, "John Marcovici"
<johnmarcov...@xxxxxxxxxxxxxxx>
wrote:
Thanks for explainer. I suspected something to do with caching
was at
play but honestly don't understand computers at that level. Now
how
can I clear out that cache <==> make Matlab forget about
the
image it just read?





ImageAnalyst wrote:

This is normal and happens all the time, even when loading
programs
and other data. Have you ever heard of disk caching? The
first
time
you read that image, it's most likely not in ram memory.
Then
it
must
go to the drive and read it off the disk - it actually
reads a
bunch
of sectors around your image, not just your exact image
bytes.
The
memory off the disk platter then gets sent to the CPU but
a
copy of
the sectors gets stored in ram (I'm not certain where this
ram
is.
I
think it's on the drive but maybe in your computer/cpu).
This
is
so
that the next time you want it, it will be pulled from ram
and
not
have to read the disk - this will make it faster. They do
this
because they noticed that often the next read a computer
wants
to
do
happens to come from the sectors of the disk right near
where
the
last
read was, so they might as well just store it in ram. If
they
were
right, it's faster, if they were wrong, well it's just the
same
as
it
would be with no caching.
Regards,
ImageAnalyst

On Apr 3, 2:22 am, "John Marcovici"

<johnmarcov...@xxxxxxxxxxxxxxx>



wrote:
Since we were talking about memory allocation using
malloc or
mxMalloc, I decided to run a few experiments using a
few DLL's
I
had
laying around. They essentially read in large images
and
downsample
them. No big deal. However, I noticed that if I read
an image,
then
read it again, the second read is drastically faster.
If
someone
can
explain why it is that subsequent reads are much
faster than
the
first, I would be interested to know. But, more
important to
me
at
the moment, how can I force subsequent reads to be
"clean",
that
is,
re-read from scratch? Doing a clear all does not help.
I want
to
force Matlab to forget that it just read the image and
apparently
knows how.

Thanks,
John- Hide quoted text -

- Show quoted text -- Hide quoted text -

- Show quoted text -



.



Relevant Pages

  • Re: [OT] Interview with Con Kolivas on Linux failures
    ... On one side there are people who point out that programs often allocate memory that goes unused most of the time, and this memory can be better used as disk cache. ... The ultimate result of this was the addition of a "swappiness" knob to 2.6 kernels to allow people to tune this to their taste. ... I haven't felt the need to tweak swappiness on my desktop machine from the default of 60, but it's also got 1 gigabyte of RAM. ...
    (Debian-User)
  • Re: Good settings for BlockRead
    ... > before each test to clear out the disk cache. ... with 512meg memory memory and a 2 gig file using blockread ... The interesting this is that if I force 300 mb of physical ram free ...
    (comp.lang.pascal.delphi.misc)
  • Re: 2.6 vm/elevator loading down disks where 2.4 does not
    ... disk more often, as they had less RAM for cache. ... send the line "unsubscribe linux-kernel" in ...
    (Linux-Kernel)
  • Re: Re-read an image
    ... This is not the same as clearing the cache. ... way of using some low level API command to ... clear the disk cache, however I don't know how without digging into it ... the sectors gets stored in ram (I'm not certain where this ram is. ...
    (comp.soft-sys.matlab)
  • Re: Ram Drive
    ... > its cache in between that and your program, ... If it is cacheing all these temporary files, ... rattling away as the temporary files are written out to disk, ...
    (microsoft.public.windowsxp.general)

Loading