473,387 Members | 1,374 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Optimization of file reading...

Hi!

I'm trying to read a file, a very big file (few Gb at least, could be
hundreds too). I started using i/ostream, but found two problems: they
can't manage efficiently 64 bits offsets and don't perform well. Then
started using fread fwrite, with a 20 MB buffer. The question is: is
there an optimal buffer size? should I change the fread internal buffer
instead? Which are the parameters I must take into consideration for
optimizing read?

Thank you!

Dec 15 '06 #1
6 5597
Paolo wrote:
Hi!

I'm trying to read a file, a very big file (few Gb at least, could be
hundreds too). I started using i/ostream, but found two problems: they
can't manage efficiently 64 bits offsets and don't perform well. Then
started using fread fwrite, with a 20 MB buffer. The question is: is
there an optimal buffer size? should I change the fread internal buffer
instead? Which are the parameters I must take into consideration for
optimizing read?
If your platform supports it, memory map the file (mmap on UNIX like
systems).

--
Ian Collins.
Dec 15 '06 #2
Paolo wrote:
Hi!

I'm trying to read a file, a very big file (few Gb at least, could be
hundreds too). I started using i/ostream, but found two problems: they
can't manage efficiently 64 bits offsets and don't perform well. Then
started using fread fwrite, with a 20 MB buffer. The question is: is
there an optimal buffer size? should I change the fread internal buffer
instead? Which are the parameters I must take into consideration for
optimizing read?
I do not know the answer to your question, but of curiosity, did
you read your files in binary or in text mode at the time you had
noticed fstream's poor performance?

- J.
Dec 15 '06 #3

Jacek Dziedzic ha scritto:
Paolo wrote:
Hi!

I'm trying to read a file, a very big file (few Gb at least, could be
hundreds too). I started using i/ostream, but found two problems: they
can't manage efficiently 64 bits offsets and don't perform well. Then
started using fread fwrite, with a 20 MB buffer. The question is: is
there an optimal buffer size? should I change the fread internal buffer
instead? Which are the parameters I must take into consideration for
optimizing read?

I do not know the answer to your question, but of curiosity, did
you read your files in binary or in text mode at the time you had
noticed fstream's poor performance?

- J.
I used binary mode. I didn't directly notice poor performances, but I
read something about it in some discussions, maybe in this group too.

Dec 18 '06 #4

Paolo ha scritto:
Jacek Dziedzic ha scritto:
Paolo wrote:
Hi!
>
I'm trying to read a file, a very big file (few Gb at least, could be
hundreds too). I started using i/ostream, but found two problems: they
can't manage efficiently 64 bits offsets and don't perform well. Then
started using fread fwrite, with a 20 MB buffer. The question is: is
there an optimal buffer size? should I change the fread internal buffer
instead? Which are the parameters I must take into consideration for
optimizing read?
I do not know the answer to your question, but of curiosity, did
you read your files in binary or in text mode at the time you had
noticed fstream's poor performance?

- J.

I used binary mode. I didn't directly notice poor performances, but I
read something about it in some discussions, maybe in this group too.
Any idea????

Dec 21 '06 #5
Paolo wrote:
Paolo ha scritto:
>Jacek Dziedzic ha scritto:
>>Paolo wrote:
Hi!

I'm trying to read a file, a very big file (few Gb at least, could
be hundreds too). I started using i/ostream, but found two
problems: they can't manage efficiently 64 bits offsets and don't
perform well. Then started using fread fwrite, with a 20 MB
buffer. The question is: is there an optimal buffer size? should I
change the fread internal buffer instead? Which are the parameters
I must take into consideration for optimizing read?

I do not know the answer to your question, but of curiosity, did
you read your files in binary or in text mode at the time you had
noticed fstream's poor performance?

- J.

I used binary mode. I didn't directly notice poor performances, but I
read something about it in some discussions, maybe in this group too.

Any idea????
Try asking in a database newsgroup, they have plenty of tricks up their
sleeves. Also, the optimal buffer size for any I/O operation would be
very specific for your platform. Consider asking in the newsgroup for
your OS. Yet another idea: experiment on a smaller file with different
buffer sizes, find which one is better; although it can so happen that
it is different in different programs because of the surrounding
functionality. Any time you're concerned with performance, you should
measure and only then decide what (if anything) can or should be done.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Dec 21 '06 #6

Victor Bazarov ha scritto:
Paolo wrote:
Paolo ha scritto:
Jacek Dziedzic ha scritto:

Paolo wrote:
Hi!

I'm trying to read a file, a very big file (few Gb at least, could
be hundreds too). I started using i/ostream, but found two
problems: they can't manage efficiently 64 bits offsets and don't
perform well. Then started using fread fwrite, with a 20 MB
buffer. The question is: is there an optimal buffer size? should I
change the fread internal buffer instead? Which are the parameters
I must take into consideration for optimizing read?

I do not know the answer to your question, but of curiosity, did
you read your files in binary or in text mode at the time you had
noticed fstream's poor performance?

- J.

I used binary mode. I didn't directly notice poor performances, but I
read something about it in some discussions, maybe in this group too.
Any idea????

Try asking in a database newsgroup, they have plenty of tricks up their
sleeves. Also, the optimal buffer size for any I/O operation would be
very specific for your platform. Consider asking in the newsgroup for
your OS. Yet another idea: experiment on a smaller file with different
buffer sizes, find which one is better; although it can so happen that
it is different in different programs because of the surrounding
functionality. Any time you're concerned with performance, you should
measure and only then decide what (if anything) can or should be done.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Thank you very much for your answer! I made this post only to know if
there are "global" rules that may help me, but it seems there aren't so
I'll do some testing and chose the best size.

Dec 21 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Neil | last post by:
I just resolved a strange situation I was having with an ODBC linked SQL 7 view in an Access 2000 MDB file, and I'm trying to get some understanding as to what happened. The linked view was...
19
by: nospammmer | last post by:
Hello group, I have a rather general but interesting inquiry that is related to PHP and I hope this is the appropriate place to post it. I'm looking for a way to improve dramatically the...
3
by: John Welch | last post by:
I'm developing my first multi-user application, and have been reading a lot about the basics of multi-user optimization (ADH vol 2, this newsgroup's archives, etc.). I've decided to go with a file...
27
by: Ramesh | last post by:
Hi, I am currently maintaining a legacy code with a very very large code base. I am facing problems with C/C++ files having a lot of un-necessary #includes. On an average every C/C++ file has...
14
by: joshc | last post by:
I'm writing some C to be used in an embedded environment and the code needs to be optimized. I have a question about optimizing compilers in general. I'm using GCC for the workstation and Diab...
6
by: Rajorshi Biswas | last post by:
Hi folks, Suppose I have a large (1 GB) text file which I want to read in reverse. The number of characters I want to read at a time is insignificant. I'm confused as to how best to do it. Upon...
5
by: Tamir Khason | last post by:
I have a program will really big embedded text resources. Because of internationalization I have to save the embedded text in UTF-8, but it more then triple bigger then the original file. The last...
4
by: Bill Pierce | last post by:
Is it faster to read through a file, without checking for end of stream, and catch the EndOfStreamException or to do a check for position vs. length after reading each line of a file? This is...
2
by: Anthony2oo5 | last post by:
Image optimization Emergency lol Hey guys. I have a image hosting website that seems to have taken off over the past 2 days and jumped from 6GB per day, to 25 GB and rising. I was wondering if...
1
by: Rahul | last post by:
While reading "Efficient C++" by Dov Bulka I came across the follown statement "In addition, you must also define a copy constructor to "turn on" the Return Value Optimization(RVO). If the class...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.