Running GUI application in separate application domain

G

Guest

I'm trying to isolate "applications" into their own application domain within
a single process. I've quoted applications because it's a logical
representation of an application. Basically it consists of a bunch of
components supplied by some application group. I got this to work, somewhat.
The problem is that the application performs roughly (and this has not been
measured, but a guess based on the rendering of the application GUI) 10x
slower than a similar (almost identical) application in which all of the
components are created within the main (/default) application domain. Is
there some inherent performance problem with running GUI applications in
separate application domains?

By the way, I'm also posting this to the dotnet framework clr newsgroup.
 
G

Guest

I've got some additional information. Via configuration I was able to move
all these components into a single application domain, separate from the
default domain. The performance of this matches the performance of the
existing application where all the components are in the default domain. In
both of these scenarios I noticed the % Time in GC is around 7%. When these
components are spread across two application domains the % Time in GC is
around 20% and as I mentioned the performance appears to be about 10x worse.
I'm running the application from my laptop which is a single processor
machine. Why would separating the work of a single application to multiple
application domains have such a drastic change on the GC?
 
J

John Murray

I suspect that most of your problem is related to Marshalling the
objects across the app domains. The additional objects that are needed
to create this and the proxies could the additional GC work that needs
to occurs.
 
G

Guest

What marshaling? All the components are created in their appdomain. There
should be no marshaling going on.

Also, forget my last post. I ran it again with all the components in one
appdomain, other than the main appdomain, and the performance was very poor.
I guess the first time I tried that was just some sort of fluke. Though I
don't believe in flukes. My guess is that something is screwed up and most
of the time it's screwed up in the same way which causes the performance
problem.
 
G

Guest

By the way, I talk about performance but I guess some may be confused about
what I mean. The components are grid components (classes derived from the
SyncFusion grid) which are displaying real-time data updates over a TIB bus.
When these same components are all run in the default application domain the
application can keep up with the real-time updates. When I create two of the
grids in one appdomain and two in another the performance decreases
drastically.
 
D

David Levine

I'm not sure if this applies to your situation...there is a limitation in
the current BCL that prevents GUI components from being instantiated in
separate appdomains and that are all hosted in a GUI framework running in
its own appdomain. In other words, you cannot share GUI components across
appdomains. It's not that everything does not work, but some important
aspects don't work right. You can run a GUI framework in an appdomain other
then the default and have it host other GUI components, so long as all the
GUI pieces are all running in the same appdomain. You can share non-GUI
components across appdomain boundaries without apparent problems (otherwise
remoting would be completely useless). This may be related to the
performance problem you are seeing.
 
G

Guest

I'm hoping it's not related as I'm not attempting to share components across
appdomains.
 
G

Guest

I just ran some more tests and captured perfmon logs for the two different
scenarios. When I run the GUI components in the default app domain I get the
following results (I only lists the ones that are significantly different and
could potentially indicate the problem).

..NET CLR Security\Total Runtime Checks: Min=122,443 Max=358,890 Delta=~236,000
..NET CLR Memory\# Gen 0 Collections: Min=149 Max=9927 Delta=~9800
..NET CLR Memory\% Time in GC: Average=6
..NET CLR Memory\Allocated Bytes/sec: Average=12MB
..NET CLR Memory\Finalization Survivors: Average=344

The same counters for the scenario where the components are run in an
appdomain different from the default domain is:

..NET CLR Security\Total Runtime Checks: Min=124,677 Max=1,475,320 Delta=~1.3M
..NET CLR Memory\# Gen 0 Collections: Min=762 Max=69,766 Delta=~69,000
..NET CLR Memory\% Time in GC: Average=17
..NET CLR Memory\Allocated Bytes/sec: Average=32MB
..NET CLR Memory\Finalization Survivors: Average=38

For for some reason running these components in a different application
domain drastically increased the # of runtime security checks, # of gen 0
collections, % Time in GC, and the allocated bytes/sec. Note that the server
which generates the real time data feed is the same in both cases.

Any ideas?
 
G

Guest

I'm pretty certain is has to do with Security Runtime Checks. When I turn
Code Access Security off (caspol -s off) the performance is fine and of
course the runtime security checks perfmon counter is zero.

This is where some of the confusion comes in. When CAS is turned on
sometimes the performance is good and sometimes it isn't. However, ever
since I've started looking at the security runtime checks performance counter
I've noticed that every time the performance is slow I'm doing huge amounts
of runtime security checks. On the order of 3200/sec. When CAS is on and
the peformance is good the runtime security checks counter is much lower,
maybe 300/sec - 500/sec. I can't figure out why sometimes this counter will
be high and other times it will be low for the same assemblies. I've
literally ran the program once and noticed poor performance and then ran the
same program again (no changes) and noticed good performance. Again, the
poor performing run was generating loads of runtime security checks and the
good performing run was not.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top