Tales from a Trading Desk

Noise from an Investment Bank

CLR Hosting

We have been running our three C# servers in production for a week now, with no defects and no performance issues.  Since we will be expected to process high volumns of messages per second in the next few weeks, we are going to move from the wks GC to the svr GC.  wks GC is the default GC used when you run a .NET application in anything other than ASP.NET on a 2+ CPU box - even on a multi CPU machine, and even when using Window services. To load the svr GC, we created a generic Windows service that loads the svr GC, creates an AppDomain, and runs our application: (error checked code not shown) .

 CComPtr spRuntimeHost;
 HRESULT hr = CorBindToRuntimeEx(NULL, //Retrieve latest version by default
         L"svr", //Request a Server (svr) or WorkStation (wks) build of the CLR
         STARTUP_LOADER_OPTIMIZATION_SINGLE_DOMAIN,
         CLSID_CorRuntimeHost,
         IID_ICorRuntimeHost,
         (void**)&spRuntimeHost);

 //Start the CLR
 hr = spRuntimeHost->Start();

 //Retrieve the IUnknown default AppDomain
 CComPtr pUnk;
 hr = spRuntimeHost->GetDefaultDomain(&pUnk);

 CComPtr<_AppDomain> spDefAppDomain;
 hr = pUnk->QueryInterface(&spDefAppDomain.p);

 // Create a domain setup
 CComPtr pUnkAppDomainSetup;
 hr = spRuntimeHost->CreateDomainSetup(&pUnkAppDomainSetup);

 CComPtr pAppDomainSetup;
 hr = pUnkAppDomainSetup->QueryInterface(__uuidof(IAppDomainSetup), (void**)&pAppDomainSetup);

 // Populate the domain setup
 hr = pAppDomainSetup->put_ApplicationBase(_bstr_t(appBase));

 hr = pAppDomainSetup->put_ConfigurationFile(_bstr_t(config));

 // Create a new domain based on the above setup
 CComPtr pNewAppDomain;
 LPWSTR pszTest = L"Test";
 spRuntimeHost->CreateDomainEx(pszTest, pAppDomainSetup, NULL, &pNewAppDomain);

 CComPtr<_AppDomain> spNewAppDomain;
 hr = pNewAppDomain->QueryInterface(&spNewAppDomain.p);

 CComPtr<_ObjectHandle> objectHandle;
 hr = spNewAppDomain->CreateInstance(_bstr_t(assemblyName), _bstr_t(assemblyType), &objectHandle);

/* IAppLoader is from an internal C# assemble generated via tlbexp*/

 VARIANT v;
 VariantInit(&v);
 hr = objectHandle->Unwrap(&v);

 _ASSERT(v.pdispVal);
 CComPtr pPR;
 hr = v.pdispVal->QueryInterface(__uuidof(IAppLoader), (void**) &pPR);
 _ASSERT(pPR);
 pPR->Run();

Hopefully by the middle of next week we should have a basic comparison of the servers running with wks vs. svr GC.

Posted: Feb 24 2004, 05:47 PM by mdavey | with 14 comment(s)
Filed under:

Comments

TrackBack said:

# February 27, 2004 8:05 AM

Missing IAppLoader said:

How can I Get IAppLoader??
# April 23, 2004 10:00 PM

Matt said:

Try adding this to the .cpp file:

#import <mscorlib.tlb> raw_interfaces_only high_property_prefixes("_get","_put","_putref")
using namespace mscorlib;

That should then explose the IAppLoader interface
# April 26, 2004 11:24 AM

Steve said:

That's good stuff, thanks for posting the code.

There is some additional background info on this in the Microsoft newsgroups.

For example :
http://groups.google.com/groups?hl=en&lr=&th=d8bb51c5517b9182&seekm=eMhnjkUIDHA.588%40TK2MSFTNGP10.phx.gbl#link11


Hopefully this will be easier in 2.0...

# May 12, 2004 1:01 PM

TrackBack said:

Using the server garbage collector
# May 17, 2004 4:21 AM

TrackBack said:

Not sure who really to attribute this first part too. I came across it in some googling and wrote it down at the time.<br /><ol><li>Create the system environment variable COMPLUS_BUILDFLAVOR</li><li>SET
COMPLUS_BUILDFLAVOR = SVR</li><li>Generate this ke
# May 17, 2004 6:05 PM

TrackBack said:

# July 9, 2004 10:37 AM

lai suat said:

I found your website perfect for my needs. It contains wonderful and helpful posts. I have read most of them and got a lot from them.

# May 23, 2011 10:33 PM

Buy oem software said:

fpi7wC Informative, but not convincing. Something is missing but what I can not understand. But I will say frankly: bright and benevolent thoughts!...

# September 24, 2011 10:32 AM

Buy oem software online said:

2qccL6 Comrade kill yourself.

# October 26, 2011 6:36 PM

Cheap software online said:

OuPuFJ Author, keep doing  in the same way..!!

# November 5, 2011 5:22 PM

cheap Microsoft Office download said:

nACHO4 Sometimes I also see something like this, but earlier I didn`t pay much attention to this!....

# December 27, 2011 7:46 PM

social said:

Muchos Gracias for your post.Thanks Again. Fantastic.

# May 8, 2012 11:54 AM

bookmarking said:

CgHrnO Really enjoyed this article post. Want more.

# May 11, 2012 5:31 PM
Leave a Comment

(required) 

(required) 

(optional)

(required)