Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF - Low performance when process is executed under SYSTEM account

Problem Description

I have a WPF Application that is usually running under a local user account with Administrator rights. However, in certain scenarios, the process is started by a service or script that is running under SYSTEM account and the process is therefore also running under the SYSTEM account.

The issue is that when the process is running under SYSTEM account, there are some noticeable lags (the UI is not very responsive).

I did some digging using perfmon and didn't see anything suspicious (CPU is not overloaded, no unusual exceptions are thrown, no memory leaks, etc ...). I also checked the Event log and didn't find anything usefull (no Warnings / Errors, only unrelated information about the system).

I first thought it was due to the process being executed in an Impersonated context, but even without impersonation (I used PsExec.exe -i -s to start it under SYSTEM account), the lags still persists.

Any idea where this would come from ?
Do not hesitate to ask if you need more information, I'm mostly looking for some ideas that would help find the root cause (the obvious workaround for this is to not start the process under SYSTEM account but it is not really a fix).

Also, note that the application is running under a customized version of Windows Embedded Standard (XP SP3) and on a device with a capacitive touch screen.

My Question

My question is not "how can I solve this problem ?" but "why is the application running with low performance when under SYSTEM account.

Update 1

I tried to change Windows's performance optimization settings as @Sander suggested, nothing changed (http://support.microsoft.com/kb/308417).

Update 2

I also did a test using this application: http://www.kynosarges.org/WpfPerformance.html#Application
When running the app under each account, I consistently get running time about twice longer under SYSTEM account for the first GDI+ test (it basically draws a bunch of triangles), which leads me to think this is not strictly WPF limited. Again, I didn't change anything except the account under which the process is executed.

like image 662
Superzadeh Avatar asked Jan 03 '14 14:01

Superzadeh


1 Answers

I think you should bypass the issue altogether. Don't give a system service UI, instead divide your application into two parts - one part that will perform the actual actions will run as a service (under whatever account makes sense) and the other - the UI - will run as an ordinary user process.

Use WCF to communicate between the two relatively easily.

It will solve your performance issue, as well as many potential security issues that your solution exposes.

like image 67
zmbq Avatar answered Nov 16 '22 00:11

zmbq