Click here to Skip to main content
Click here to Skip to main content

Improving the performance of ISAPI Applications – Profiling the ISAPI DLL’s

, 15 Jun 2003
Rate this:
Please Sign up or sign in to vote.
ISPAI Applications are meant to be run on Web-Servers and ISAPI developers like me often face ISAPI related performance issues . Here is the brief discussion on how to profile an ISAPI DLL and determine and solve the performance related issues.

Introduction

ISPAI Applications are meant to be run on Web-Servers and ISAPI developers like me often face ISAPI related performance issues. Here is the brief discussion on how to profile an ISAPI DLL and determine and solve the performance related issues.

ISAPI Applications are meant to run on High-load environment and the IIS Server has to respond to several hundred (ideally more than that) requests per second. To improve the performance of the ISAPI Applications first of all it is very important to understand how ISAPI works on IIS.

Understanding ISAPI Execution

There are two types of ISAPI programs for the web-servers – extensions and filters. These are DLL’s that run in IIS process address space thus interacting with IIS and other ISAPI DLL’s also. One thing has to be kept into mind that since web-servers (yes, ISAPI is not only for IIS but for lots of many servers-almost all server vendors provide the API’s to extend the functionality of the web servers) can handle more that one request at a time the ISAPI DLL can be called upon by more than one thread concurrently.

During the server startup (web-publishing service-w3svc) all the initialization takes place-it checks and load the ISAPI filters from the registry. Then the worker pool threads of IIS initializes. All these worker-threads accept the incoming HTTP requests and process them. If the ISAPI filters are configured to run than it loads the ISAPI Dll. ISAPI DLL is like any other regular DLL. The ISAPI Dll is then registered by calling GetExtensionVersion (which is called only once and contains registration data as name and version etc.)Then the HttpExtensionProc is called.The DLL remains in process address space until the execution is going on. During IIS Shutdown procedures all the loaded DLL are unloaded and all worker threads are stopped and IIS stopped.

Now, since ISAPI runs in the IIS process address space the chance of corrupting the memory space of IIS are high (although the thing worth noting is that IIS allows you to debug and test ISAPI Dll’s in isolation mode but that will reduce the server performance and will be an over-head). Most importantly the multithreading issues have to be taken into consideration. Since ISAPI DLLs are called upon by number of threads at a time thus our code needs to be “thread-safe”(also keep in mind not to lock resources in threads), avoid global data structures in your DLL’s unless absolutely needed otherwise use critical sections.

To determine the bottlenecks in your ISAPI application we need to do profiling the ISAPI DLL. Well, by profiling we mean examining the run-time behavior of the application to determine the performance of the various sections of the application and knowing which sections are taking how much time and thus detecting the bottlenecks of the application. Profiling an ISAPI DLL is very important part of determining and improving the performance of the DLL.

Profiling the ISAPI DLL

The steps to profile your DLL are:

  1. Build the DLL enabling the profiling and generation of map files in linker options see fig below

    SetOptions

  2. Run this command at the command line on your ISAPI DLL. Prep /om /ft yourISAPI.dll This command will create a self-profiling DLL with _LL extension. This self-profiling file would keep the record for function-timing, function-counting, function-coverage. This would generate a file named yourISAPI._LL.

  3. Rename the original DLL to something else and name this DLL (with _LL extension as .DLL)

  4. Copy this profiled DLL and profile.dll to the web-server where you want the ISAPI to run.

  5. Copy the following file from yourDriveLetter:\ProgramFiles\Microsoft Visual Studion\VC98\Bin directory to the same place where you copied the DLL’s.

    The files to be copied and put are – Profile.EXE , Profile.DLL, Profile.ini.

  6. Set the __ProfileBPI and __ProfileBPO system environment variables to the path of your PBI and PBO file that will be generated when you run the prep command.

  7. Stop and restart IIS so the profiled DLL is loaded.

  8. run the application , i.e send the request to your ISAPI so that ISAPI is executed and then stop the IIS after execution.

  9. run the following commands in the directory where PBI and PBO files are located.

Prep /m yourISAPI Plist yourISAPI

Note: DO NOT PUT IN EXTENSION-ONLY NAME OF THE DLL HAS TO BE GIVEN

Prep /m will merge the statistics gathered and generate .PBT file, and plist will format the .PBT file into text file. Now you can have the input of the PBT file to the text file you want.

For e.g plist yourISAPi > Profile1.txt On command line. You can easily see which section of your code is taking how much time.

And now that you have an analysis of the section based upon time(which crtical for web-applications) you can remove and take rectifications for the bottlenecks.

Hope this will help you all. 
 

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Tarundeep Singh Kalra
Web Developer
United States United States
Tarun started programming with BASIC,FORTRAN while in school and then gradually became intrested in c,c++ He is now a professional programmer. He is mechanical engineer by qualifications but loves to code and work on latest technologies.
He has worked on various technologies and platforms - Wi-Fi, ISA Servers,Sendmail,VOIP,NDIS Drivers,VLANs etc.He likes to help and mentor people.So if you need any sort of technical help just mail him.
 
visit him at : www.tarunsadhana.com

Comments and Discussions

 
Questionprofiling a "dll" Pinmemberchittem18-Oct-06 4:20 
GeneralProfiler Error PinmemberNir Levy23-Jan-05 3:21 
GeneralIs profiling supported in Visual Studio .NET 2003 PinmemberSuresh Narayan13-Apr-04 3:53 
GeneralRe: Is profiling supported in Visual Studio .NET 2003 PinmemberTarundeep Singh Kalra13-Apr-04 21:25 
GeneralRe: Is profiling supported in Visual Studio .NET 2003 PinsussVT_Student25-Nov-04 17:18 
GeneralRe: Is profiling supported in Visual Studio .NET 2003 PinmemberTarundeep Singh Kalra25-Nov-04 17:43 
GeneralSome ISAPI related query Pinmembercoolvcguy21-Jan-04 12:29 
GeneralRe: Some ISAPI related query Pinmembertarundeep singh21-Jan-04 18:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.1411019.1 | Last Updated 16 Jun 2003
Article Copyright 2003 by Tarundeep Singh Kalra
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid