Linux: Access time of mapped data


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Linux: Access time of mapped data
# 1  
Old 06-02-2009
Linux: Access time of mapped data

Before I forget, I'm running on a RedHat 5 box with the following uname -a output:
Linux gnc141c 2.6.18-53.el5 #1 SMP Wed Oct 10 16:34:19 EDT 2007 x86_64 x86_64 x86_64 GNU/Linux

Now on to my question.

I'm using a tool that maps a Matlab .mat file using the Linux mmap functionality and then provides access to the saved variables (this is all done at the Matlab command prompt). I've found that using a variable in a calculation, such as
Code:
a = foo*1;

(where foo was a variable saved in the .mat file) forces the variable into active memory. I'm finding, however, that the time to execute the line of code above in Matlab depends on where the variable was saved in the .mat file.

If "foo" was the 1st variable saved in the .mat file, I can execute that line in microseconds. If "foo" was the 20th variable in the .mat file, the time-to-execute jumps up 1000 times to the millisecond region. And then, to make it more confusing, the last handful of variables at the end of the .mat file drop back down to the microsecond region. For the sake of example, all of the variables are the same size. In general, the first couple of variables in the .mat file are accessible in microseconds, the middle 80% or so of the variables take milliseconds, and the last couple go back to microseconds.

I can understand it taking a little longer to find a variable further down in the file, but by a factor of 1000? And what about the variables at the end that are accessible quickly again? From my very limited understanding of what goes on behind-the scenes, I think this has something to do with Linux's memory management.

Another little tidbit I noticed is that once I've accessed one of the variables (and taken the millisecond time penalty), many of the other millisecond variables now take microseconds. This stays true until I reboot (a cache thing, I think).

In case you're wondering about a Matlab .mat file, all the variables are stored as double-precision arrays, one at a time, top to bottom. So the first variable is listed at the top of the file, followed by all of its data, followed by the next variable and all of its data, etc.

Any thoughts? This problem is significant to me because I'm working with thousands of .mat files. The difference between a microsecond and a millisecond can be the difference of hours of processing time.

Thanks,
Dan
# 2  
Old 06-03-2009
I just got some advice from a Linux guru. He suggested that all of the variables take milliseconds to access, even the ones in the beginning of the file that appear to take microseconds. The difference is the mapper defaults to loading the first page of data into memory when the mapper is first called. So all those variables at the beginning of the .mat file enjoy being defaulted into memory right off the bat.

Still doesn't explain why the last couple of variables also appear to be defaulted into memory as well... but that could just be a oddity of the mapper.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Proxy Server

How to use Squid on Linux to control certain IP to access Web Server and certain IP cannot access?

Dear all experts here, :) I would like to install a proxy server on Linux server to perform solely to control the access of Web server. In this case, some of my vendor asked me to try Squid and I have installed it onto my Linux server. I would like know how can I set the configuration to... (1 Reply)
Discussion started by: kwliew999
1 Replies

2. Programming

Find gaps in time data and replace missing time value and column 2 value by interpolation in awk

Dear all, I am kindly seeking assistance on the following issue. I am working with data that is sampled every 0.05 hours (that is 3 minutes intervals) here is a sample data from the file 5.00000 15.5030 5.05000 15.6680 5.10000 16.0100 5.15000 16.3450 5.20000 16.7120 5.25000... (4 Replies)
Discussion started by: malandisa
4 Replies

3. Shell Programming and Scripting

need the last access time for a .gz file

i have file named aaaa. The file aaaa was zipped on one particular time. Need to know the command to find out when the file "aaaa" was actually zipped. (1 Reply)
Discussion started by: expert
1 Replies

4. Programming

time access in C

I've a problem with time functions in C. I get current time and convert it to local time and gmt time. But their value seems to be same.I think I'm missing something.. #include <stdio.h> #include <memory.h> #include <time.h> int main() { time_t now_local, now_gmt; ... (2 Replies)
Discussion started by: xyzt
2 Replies

5. Linux

Is my data lost? Installed Linux, no longer can I access my hard drives.

Here's the story - I installed Linux on my Y drive, and all went well until I tried to boot into XP again. I can't access or install an operating system to my other three hard drives, C, X, and Z. I think that during the install my hard drives were changed to something other then NTFS, but... (4 Replies)
Discussion started by: Ironkey
4 Replies

6. Shell Programming and Scripting

How to get data between the start time and end time?

Hi, Can anyone help me how can I get the line that between the start time and end time. file1.txt 15/03/2009 20:45:03 Request: - Data of this line 15/03/2009 20:45:12 Response: - Data of this line 15/03/2009 22:10:40 Request: - Data of this line 15/03/2009 22:10:42 Response: - Data of... (1 Reply)
Discussion started by: tanit
1 Replies

7. UNIX for Dummies Questions & Answers

Access time of a file

I thought that access time of a file is time when the file was run last time (or I read somewhere that it's time when system lookup the file -> but I'm not sure when it really is) How is it exactly? Thank you for help! (11 Replies)
Discussion started by: MartyIX
11 Replies

8. Linux

How to access mapped dirve in Linux

i want to access mounted/mapped drive in linux using C code is it possible to access the mapped drive in linux using C code ? waiting for replay NIrav (0 Replies)
Discussion started by: niravuchat
0 Replies

9. UNIX for Dummies Questions & Answers

Need help to access/mount so to access folder/files on a Remote System using Linux OS

Hi I need to access files from a specific folder of a Linux system from an another Linux System Remotely. I know how to, Export a folder on One SCO System & can access the same by using Import via., NFS in the Sco Unix SVR4 System using the scoadmin utility. Also, I know to use mount -t ... (2 Replies)
Discussion started by: S.Vishwanath
2 Replies
Login or Register to Ask a Question