Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Will C++0x RValue references or other features will have an impact on streams performance?

Lot of profiling shows that C++ streams are not the best way to performe file or text string manipulation when performance (speed) is required. Still, the standard streams are a good way to keep things type-safe.

From what I've read, most of the problem is because streams implementations have to 1) create/copy a lot of little objects 2) arnt fully generic (don't manage char and wchar the same way?) etc.

Anyway, I was thinking that maybe some C++0x would allow implementers to limit at least object creation/copy and maybe there are other features that would allow other performance improvements, maybe allowing to reach the printf() performance?

Is there an immediate impact? Or will we have to wait for new implementations? Or do we still need a new (STL-like) stream library?

like image 303
Klaim Avatar asked Dec 10 '10 13:12

Klaim


1 Answers

You might be interested in some of the performance comparisons in my question here. Even the lowest level functions in the C++ standard library streams API are incredibly slow under common implementations, and looking through the source code of e.g. Visual C++'s stringbuf class, I don't see copying of small temporary objects. So rvalue-references are not likely to help much.

AFAICT, the main reason for slowness of C++ iostreams is that library developers are stuck with a mindset that I/O is the bottleneck, so there's no point in worrying about performance of the I/O library. But I/O is decidedly not the bottleneck.

like image 69
Ben Voigt Avatar answered Oct 08 '22 12:10

Ben Voigt