-
September 10th, 2009, 08:10 AM
#1
Performance enhancement
The target application is a pure C++ based application executing on Windows. The application is single threaded and involves business logic and lots of file parsing and interpretation of data.
The need is to enhance the performance of this application drastically.
This is a standalone single threaded command line based application which has no IPC communication at all.
What would the areas that you Gurus would ask us to look at in detail, which could limit performance of executing applications ?
-
September 10th, 2009, 08:12 AM
#2
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.
-
September 10th, 2009, 08:14 AM
#3
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.
-
September 10th, 2009, 09:17 AM
#4
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 !
-
September 10th, 2009, 09:20 AM
#5
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.
-
September 10th, 2009, 09:24 AM
#6
Re: Performance enhancement
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.
-
September 10th, 2009, 09:41 AM
#7
Re: Performance enhancement
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.
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++.
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
-
September 10th, 2009, 10:24 AM
#8
Re: Performance enhancement
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?
-
September 10th, 2009, 11:44 PM
#9
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."
-
September 11th, 2009, 06:51 AM
#10
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.
Last edited by ninja9578; September 11th, 2009 at 06:54 AM.
-
September 11th, 2009, 07:19 AM
#11
Re: Performance enhancement
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."
-
September 11th, 2009, 08:58 AM
#12
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.
-
September 11th, 2009, 10:29 AM
#13
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.
-
September 11th, 2009, 12:10 PM
#14
Re: Performance enhancement
No, but optimizing when and how you store and load data can reduce the memory footprint.
-
September 14th, 2009, 09:20 AM
#15
Re: Performance enhancement
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 ?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|