Performance enhancement
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 22

Thread: Performance enhancement

  1. #1
    Join Date
    Jan 2006
    Posts
    384

    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 ?

  2. #2
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Fairfax, VA
    Posts
    10,888

    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.

  3. #3
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Posts
    12,057

    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.

  4. #4
    Join Date
    Jan 2006
    Posts
    384

    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 !

  5. #5
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Fairfax, VA
    Posts
    10,888

    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.

  6. #6
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Posts
    12,057

    Re: Performance enhancement

    Quote Originally Posted by humble_learner View Post
    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.

  7. #7
    Join Date
    Apr 1999
    Posts
    27,423

    Re: Performance enhancement

    Quote Originally Posted by humble_learner View Post
    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

  8. #8
    Join Date
    May 2009
    Posts
    2,413

    Re: Performance enhancement

    Quote Originally Posted by humble_learner View Post
    The need is to enhance the performance of this application drastically.
    How does the slowness of the application manifest itself?

  9. #9
    Join Date
    Apr 2004
    Posts
    102

    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."

  10. #10
    Join Date
    Jan 2009
    Posts
    1,689

    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.

  11. #11
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Posts
    12,057

    Re: Performance enhancement

    Quote Originally Posted by jefranki View Post
    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."

  12. #12
    Join Date
    Jan 2009
    Posts
    1,689

    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.

  13. #13
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Fairfax, VA
    Posts
    10,888

    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.

  14. #14
    Join Date
    Jan 2009
    Posts
    1,689

    Re: Performance enhancement

    No, but optimizing when and how you store and load data can reduce the memory footprint.

  15. #15
    Join Date
    Jan 2006
    Posts
    384

    Re: Performance enhancement

    Quote Originally Posted by Lindley View Post
    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 ?

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center