473,396 Members | 2,011 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,396 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 5598
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.