Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ "delete" is slow. Where should I look first?

I have a C++ application where the "delete" function is slow to run. What might cause this and where should I begin my search for a solution?

Background:

This C++ code is in an ARX file running inside of AutoCAD, which is basically just a DLL.

The specific computer where delete is slow is running AutoCAD 2011, Windows 7, 64-bit. ARX's for AutoCAD 2011 have to be compiled using Visual Studio 2008 Service Pack 1.

The computer with the problem is a customer's computer. It does not have any version of Visual Studio installed on it.

On my development computer, the code does not have any problem in AutoCAD 2011.

To test, I have some code that deletes a linked list. On the computer with the problem, it takes 0.7 seconds to delete the list. On the computers and configurations without the problem, the same code takes 0.02 seconds. The specific times are not important--the large different between the two numbers is.

I made sure to be running the same version of the code on both computers, so it is not a release versus debug build problem.

like image 209
David Robison Avatar asked Jan 20 '11 21:01

David Robison


1 Answers

Roughly in the order I'd check them:

  • Other plugins: could that behavior caused by other ARX files? Can they be disabled on bad system?
  • PerfMon: Check if soft/hard page faults or cache misses peak during your delete (I hope you can set that up on the customers computer).
  • HeapQueryInformation: same values in good/bad environment?
  • Heap Lock: Could some other thread be highly active in the background, holding tight to the heap's lock? You could test by wrapping the loop in HeapLock / HeapUnlock (and time inside the lock, of course).
  • Hooks: Could the respective code be hooked? (e.g. a 3rd party app hooking into the C++/Win32 Heap functions to do whatever it wants to do)
  • Grasping at straws: Do the respective new's take unusually long? How are the individual delete times distributed?
like image 141
peterchen Avatar answered Oct 06 '22 00:10

peterchen