Re: Performance enhancement
The biggest performance wins come from replacing inefficient algorithms and data structures with more suitable ones.
Other approaches can give you incremental improvements, but the above is the only thing likely to "drastically" improve your speed.
Re: Performance enhancement
No way to tell without understanding the inner workings of the app.
I'd run a profiler and see which parts of the code were taking the most time, then look at them to see what can be improved.
Re: Performance enhancement
Sometimes, using a profiler indicates that the processing in the STL library implementation could be a problem. Can that truly be a problem on Windows ? Ofcouse, we have no control over the implementations inside that library (Dinkumware's problem right - on Windows)
Do you recommend using Windows APIs for reading files in place of using the STL file streams ?
Any other hints are most welcome !
Re: Performance enhancement
You may not have control over the STL implementation, but you do have control over how you use it. Nine times out of ten, perceived "STL slowness" is merely due to suboptimal usage.
Re: Performance enhancement
Quote:
Originally Posted by
humble_learner
Sometimes, using a profiler indicates that the processing in the STL library implementation could be a problem. Can that truly be a problem on Windows ? Ofcouse, we have no control over the implementations inside that library (Dinkumware's problem right - on Windows)
Do you recommend using Windows APIs for reading files in place of using the STL file streams ?
Any other hints are most welcome !
You're not there yet. If the profiler does point to the STL, you could then examine if you're using it correctly or not, or you may find that the program is already pretty well optimized and there isn't a whole lot you can do.
Find the bottlenecks before you go looking for solutions. No point speculating till you know for sure what's going on. Again, you can ask for hints or ideas all day long, but at this point nobody has anything to go on.
Re: Performance enhancement
Quote:
Originally Posted by
humble_learner
Sometimes, using a profiler indicates that the processing in the STL library implementation could be a problem. Can that truly be a problem on Windows ?
Windows is an operating system -- STL is C++ source code based on templates. You cannot associate one with the other. There are various C++ compilers available for Windows. Each one has their own version of the STL library, all having different internal implementations.
Quote:
Ofcouse, we have no control over the implementations inside that library (Dinkumware's problem right - on Windows)
Dimkumware is for Visual C++. Again, there are other compilers for Windows other than Visual C++.
Quote:
Do you recommend using Windows APIs for reading files in place of using the STL file streams ?
Again, whose STL? Also, file streams are not STL. Streams were around before STL came on the scene -- the very first C++ compilers for PC's (Turbo C++ for example) had streams way before STL was even developed.
Anyway, profile your code first before making assumptions on what needs to be improved.
Regards,
Paul McKenzie
Re: Performance enhancement
Quote:
Originally Posted by
humble_learner
The need is to enhance the performance of this application drastically.
How does the slowness of the application manifest itself?
Re: Performance enhancement
And let's also not forget the simple, "Whoops! I forgot to allocate enough memory to my application and now it's paging to the hard drive constantly."
Re: Performance enhancement
I would thread those file lookups, I'd eat my hat if file reads aren't taking 50% of the time of your app. File I/O is slow. Most hard drives have multiple disks and multiple read heads so it's possible to read multiple files at the same time. Multithread that part and you should see a dramatic boost in speed. A smart operating system will even separate files that are usually used together for this reason.
Processing is easy, cheap, and fast. To load a png, 99% of the time is loading, 1% is processing, and that's a million pixels that need to be analyzed.
Re: Performance enhancement
Quote:
Originally Posted by
jefranki
And let's also not forget the simple, "Whoops! I forgot to allocate enough memory to my application and now it's paging to the hard drive constantly."
:confused:
Re: Performance enhancement
I was curious about that too. Is there a way to specify how much memory that you want to allocate. I know how to do it in assembly and it can be done in Delphi, but I didn't C++ could do that.
Re: Performance enhancement
Most modern OSes should handle that automatically via virtual memory. If you're hitting a disk swap bottleneck, that means you truly are out of RAM, and no function call could change that.
Re: Performance enhancement
No, but optimizing when and how you store and load data can reduce the memory footprint.
Re: Performance enhancement
Quote:
Originally Posted by
Lindley
Most modern OSes should handle that automatically via virtual memory. If you're hitting a disk swap bottleneck, that means you truly are out of RAM, and no function call could change that.
I think this could be a possible reason for the performance overhead. I have two questions around this.
[1]
How would you handle a case where a large file needs to be parsed and data converted into memory (struture collections) for furthur processing ? Are there any standard algorithms that can be looked up which are performant ?
[2]
How would you handle a case where a file is large, needs to be processed where the first record might depend on data in the last record to create a valid data entity for furthur processing ?
Re: Performance enhancement
1) add more memory to your computer or use a database
2) Read the first record, move the file pointer to the end of the file and read the last record.
Re: Performance enhancement
Re: Performance enhancement
Quote:
Originally Posted by
Lindley
How big is "large" here?
And even more importantly, we still seem to be looking for solutions without first really knowing what the problem is. It's pretty freaking obvious when your computer is low on physical memory and starts caching. If that were really what was happening, I doubt we'd need a thread about it and hopefully a competent programmer would identify it right away.
Re: Performance enhancement
Quote:
Originally Posted by
Lindley
You may not have control over the STL implementation, but you do have control over how you use it. Nine times out of ten, perceived "STL slowness" is merely due to suboptimal usage.
Can you please provide some hints towards what could be sub-optimal usage of STL libraries ? Are there some tricks or points that need to be considered ?
One of the problems that we realizing was the choice of collection classes - we realized that using vectors instead of lists did enhance performance when accessing data because of it's random access capabilities.
Re: Performance enhancement
Yes, that's the sort of thing I'm talking about. Even though STL does a lot for you "behind the scenes", you still need to know in rough terms what it's doing, so that you can judge whether the capabilities of a particular container are ideal for you.
Stuff like, don't pass containers by value, should be pretty obvious but also qualifies.
Re: Performance enhancement
Quote:
Originally Posted by
GCDEF
No way to tell without understanding the inner workings of the app.
I'd run a profiler and see which parts of the code were taking the most time, then look at them to see what can be improved.
Is Rational Quantify a good tool to use as a profiler in case I want to profile C++ code for performance ?
Re: Performance enhancement
Quote:
Originally Posted by
humble_learner
Is Rational Quantify a good tool to use as a profiler in case I want to profile C++ code for performance ?
I don't know. I would assume so. I've always used the one that comes with Visual Studio.