LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 08-05-2004, 03:51 AM   #1
Not now, John!
Member
 
Registered: Jul 2004
Distribution: LFS 5.1
Posts: 161

Rep: Reputation: 30
File opening/reading speed differs first time and after that


Why is there a speed difference when opening/reading files first time and after that?
Here's an example.
Code:
$ time md5sum song.mp3
290abe89444add77b02815c55311e452  song.mp3

real    0m2.472s
user    0m0.940s
sys     0m0.360s
$ time md5sum song.mp3
290abe89444add77b02815c55311e452  song.mp3

real    0m0.065s
user    0m0.030s
sys     0m0.030s
Differences are larger with big files:
Code:
$ time md5sum file.tar.bz2
3c6cfd9fcd180481063b4058cf6faff2  file.tar.bz2

real    0m7.072s
user    0m1.230s
sys     0m0.960s
$ time md5sum file.tar.bz2
3c6cfd9fcd180481063b4058cf6faff2  file.tar.bz2

real    0m0.165s
user    0m0.110s
sys     0m0.040s
I thought it was Journal on ext3 file system, but same happens on ext2 systems too.
I think that on my previous system (RedHat 8.0, 2.4.20) this didn't happen.

Linux 2.4.26, ext3, HDD Seagate ST340014A.

Thanks in advance.

Last edited by Not now, John!; 08-05-2004 at 09:38 AM.
 
Old 08-05-2004, 09:08 AM   #2
r0b0
Member
 
Registered: Aug 2004
Location: Europe
Posts: 608

Rep: Reputation: 50
Everytime a file is read, its contents are stored in memory to speed-up possible future reads of the same file. This concept is known as caching, file-cache.
So the first time, the file is read from the disk (takes a long time), next times it is read from the cache, which is part of RAM and it is very fast.
R.
 
Old 08-05-2004, 09:37 AM   #3
Not now, John!
Member
 
Registered: Jul 2004
Distribution: LFS 5.1
Posts: 161

Original Poster
Rep: Reputation: 30
Thanks for your reply.
On other forum I got same answer. It's nice feature.
I was confused with long time needed for first time accessing file.
Trying to solve this problem I activated VIA chipset support in my kernel. After that DMA was activated on boot, and all file accesses are 3 times faster then before.

Thanks again.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to limit the bouncy icon time when opening a program blastradius Ubuntu 4 11-02-2005 01:07 AM
Hard time reading man pages waelaltaqi Linux - General 5 10-10-2005 09:54 AM
Perl - Reading Real Time streams vitoal18t Programming 10 05-18-2005 06:59 AM
reading a line at a time in a file topcat Programming 2 12-14-2004 05:49 AM
reading a time warner dvr disk aort527 Linux - Hardware 0 07-06-2004 07:28 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:18 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration