问题
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.
回答1:
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.
回答2:
When a user is logged in, most of the services in your system that are required are up and running. For example whatever you see in taskmanager and system tray.
However, when you run it from the System acc, it has to actually start some of the services that are needed in your case I am guessing it you can solve it by identifying those services and use a different thread altogether which might reduce your turn-around time.
But, the performance and CPU usage will definitely be impacted. I hope this makes sense. Thanks
来源:https://stackoverflow.com/questions/20906195/wpf-low-performance-when-process-is-executed-under-system-account