1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

ProcessPluginFramework in the form of windows system service

Discussion in 'Operating Systems' started by mbk1969, May 19, 2013.

  1. mbk1969

    mbk1969 Ancient Guru

    Messages:
    7,924
    Likes Received:
    4,557
    GPU:
    GeForce GTX 1070
    Process Plugin Framework is utility in form of the system service. It provides possibility to run PowerShell scripts on start (and on exit) of any process.
    PPF service consists of:
    - ProcessPluginFrameworkService.exe - service executable;
    - System.Management.Automation.dll - PowerShell library;
    - ProcessPluginFrameworkService.exe.ini - ini-file with settings;
    - Plugins - folder with PowerShell scripts (aka plugins).

    Ini-file format follows classic ini-file section style:
    Code:
    [processname]
    plugin1
    plugin2(param1, param2, ..., paramN)
    ...
    
    where processname - name of process without '.exe' part;
    "pluginN" - name of PowerShell script-file inside "Plugins" folder;
    "paramN" - any parameter to pass to the given script (see later for $user_params).

    PPF supports syntax in ini-file for pipelining plugins so that they would start strictly each after previous. Place plugins in one line and separate them with '|'. Example:
    Code:
    [notepad]
    PriorityHigh | MemPriority(A) | IOPriority(B)
    Sleep(500) | ReplaceThreadsPriority(0, 2)
    so the plugins in fisrt line will be invoked - MemPriority after PriorityHigh, IOPriority after MemPriority, and plugins at second line - ReplaceThreadsPriority after Sleep. (But whole first line and whole second line will be invoked independently from each other.)

    PPF service parses ini-file once at start. Plugin sript-files must be placed in "Plugins" or its subfolders (at any nesting level), and must have unique names.

    Each specified plugin script is executed asynchronously in its own instance of PowerShell.
    Each plugin script recieves following parameters:
    - $user_params - array of parameters specified for plugin in ini-file; in example above script "plugin2" will have $user_params = @('param1', 'param2', ..., 'paramN');
    $user_params is empty array if no parameters is specified;
    - $trace_location - string with full path of a "Traces" subfolder (which created at service`s start in case it doesn`t exist);
    - $process_helper - instance of ProcessAPIHelper class which impersonates started process.

    Bundle with source file - http://www.mediafire.com/file/dsjir5g74a11vvk/PPF_source_v4.zip

    Bundle with PowerShell V3 library - http://www.mediafire.com/file/d4b479cxh6mdlml/System.Management.Automation-PSv3.zip
    Extract it into folder with PPF service binary. If you are at Win10 then you can search for a newer version of library (System.Management.Automation.dll) and paste it instead.

    Bundle with installation script - http://www.mediafire.com/file/c4t695g791kbvbo/Install-PPFService.zip
    Download and extract it into the folder with source file. Then either execute it from PowerShell session or from Explorer. Script should build service binary from source code and register it in system. By default service is registered with local system account.

    But to be able to execute PowerShell scripts you first should permit them - run PowerShell and execute there
    Code:
    Set-ExecutionPolicy RemoteSigned
    https://msdn.microsoft.com/powershe...osoft.powershell.security/Set-ExecutionPolicy

    You can choose the process start detection mechanism - either WMI or ETW events.
    By default WMI events are used to catch the process starts. To switch to ETW events you must specify the following section in ProcessPluginFrameworkService.exe.ini:
    [PollingInterval=ETW]


    PPF comes with following gentlemen set of plugins:

    PowerPlanPlugins.zip:
    PowerBalanced.ps1
    PowerPerformance.ps1
    PowerSaver.ps1
    Sets specified in name power plan when process is started.​
    PowerPerformanceUntilExit.ps1
    Sets performance power plan while process is running.​
    DisableSystemSleepUntilExit.ps1
    Prevents Windows from sleep state while process is running.​
    PowerSaverWhileDisplayOff.ps1
    Switches Windows from current power plan to power saver plan while monitor is off (idle).​
    ProcessorIdleOffUntilExit.ps1
    Disables processor idle states while process is running.​
    PriorityClassPlugins.zip:
    PriorityAboveNormal.ps1
    PriorityBelowNormal.ps1
    PriorityHigh.ps1
    PriorityIdle.ps1
    PriorityNormal.ps1
    Sets specified in plugin`s name priority class for a process.​
    IOPriority.ps1
    Adjusts IO priority of process; syntax in ini-file:
    IOPriority(N)
    where N is number:
    0 - Very Low IO priority;
    1 - Low IO priority;
    2 - Normal IO priority;
    3- High IO priority.
    Most probably this plugin should be used after any priority class plugin, because Windows adjusts IO priority each time process priority class is adjusted.
    MemPriority.ps1
    Adjusts memory priority of process; syntax in ini-file:
    MemPriority(N)
    where N is number in range between 1 (Low) and 5 (Default).
    Most probably this plugin should be used after any priority class plugin, because Windows adjusts memory priority each time process priority class is adjusted.​
    PriorityLowerProcessesUntilExit.ps1
    Lowers the priority class of specified processes for the duration of the process.
    Parameter for plugin - comma-separated list of process names (with or without '.exe').
    On process`s exit all of the changed priority classes will revert to original levels.​
    DisableProcessPriorityBoost.ps1
    Disables process priority boost.​
    EnableProcessPriorityBoost.ps1
    Enables process priority boost.
    See http://msdn.microsoft.com/en-us/library/windows/desktop/ms684828(v=vs.85).aspx for details about priority boost.
    ProcessorAffinityPlugins.zip:
    AffinityAdd.ps1
    Plugin for adding CPUs to process` affinity.
    Parameter for plugin - comma-separated list of logical processors (1-based).
    Meaning is 'add specified CPUs to CPUs available to process'.​
    AffinityDel.ps1
    Deletes logical CPUs from the CPUs configured currently into the process (aka CPU affinity mask).
    Parameter for plugin - comma-separated list of logical processors (1-based).
    Meaning is 'do not run process on specified CPUs'.​
    AffinitySet.ps1
    Sets logical CPUs configured currently into the process (aka CPU affinity mask).
    Parameter for plugin - either comma-separated list of logical processors (1-based) or '*' (for 'all processors').
    Meaning is 'run process only on specified CPUs'.
    With the help of AffinitySet and AffinityDel you can (kinda) isolate processes from each other. For example, you specify AffinitySet(1,2) for a helper software like MSI AfterBurner, EVGA Precision, chat clients, browsers etc, and - AffinityDel(1,2) for the games.
    Another usage scenario for AffinitySet is single-threaded application which should benefit by avoiding the CPU switching.​
    AffinityAwayProcessesUntilExit.ps1
    If you have set CPU affinity for process with the help of AffinitySet, AffinityAdd or AffinityDel then you can use AffinityAwayProcessesUntilExit to force specified processes to CPU not affiliated to the process.
    Parameter for plugin - comma-separated list of process names (with or without '.exe').
    On process`s exit all of the changed CPU affinites will revert to original values.​
    AffinityPinThreadsUntilExit.ps1
    Syntax in ini-file: AffinityPinThreadsUntilExit
    or AffinityPinThreadsUntilExit(first_wait)
    or AffinityPinThreadsUntilExit(first_wait, cycle_wait)
    or AffinityPinThreadsUntilExit(first_wait, cycle_wait, trace)
    where 'first_wait' - number of seconds to wait before starting the main plugin`s cycle (default=10s);
    'cycle_wait' - number of seconds to wait between each plugin`s cycle iterations (default=1s);
    'trace' - any non empty sequence of characters to switch on the plugin`s trace events written to 'Applications' event log (by default it is off).

    Algorithm of plugin cycle iteration:
    1 - enumerate all threads of process
    1.a - calculate the delta (difference) in total CPU times of thread - current and previous
    1.b - ignore the threads with zero delta
    1.c - group the threads by the delta in sorted dictionary, where key is delta and value is array of threads
    2 - enumerate threads with maximum delta
    2.a - ignore the threads which are pinned to CPU already
    2.b - select the CPU in round-robin manner and pin the thread to it

    The purpose of plugin is to avoid the CPU switching for the most active threads of process. Ideal processor feature is used to pin the thread to CPU.
    ThreadPriorityPlugins.zip:
    ReplaceThreadsPriority.ps1
    Enumerates all threads in process and for each one with specified current thread priority level sets specified new thread priority level. Syntax in ini-file:
    ReplaceThreadsPriority(cur1 new1/cur2 new2/...)
    where 'curN newN' - pair of current and replacement priority thread levels
    - one of following integer numbers:
    '1' - means 'THREAD_PRIORITY_ABOVE_NORMAL',
    '-1' - means 'THREAD_PRIORITY_BELOW_NORMAL',
    '2' - means 'THREAD_PRIORITY_HIGHEST',
    '-2' - means 'THREAD_PRIORITY_LOWEST',
    '0' - means 'THREAD_PRIORITY_NORMAL',
    '-15' - means 'THREAD_PRIORITY_IDLE',
    '15' - means 'THREAD_PRIORITY_TIME_CRITICAL'.
    Example - for all threads with priority level 0 (THREAD_PRIORITY_NORMAL) replaces priority level to -2 (THREAD_PRIORITY_LOWEST):
    Code:
    [notepad]
    ReplaceThreadsPriority(0 -2)
    See http://msdn.microsoft.com/en-us/library/windows/desktop/ms685100(v=vs.85).aspx for details about priorities.​
    ReplaceThreadsPriorityUntilExit.ps1
    Applies specified thread priority replacements at its start and then applies specified thread priority replacements at each creation of thread.
    Syntax:
    Code:
    ReplaceThreadsPriorityUntilExit(cur1 new1/cur2 new2/...)
    where 'curN newN' - pair of current and replacement thread priority levels.
    VariousPlugins.zip:
    InvokeOnExit.ps1
    Invokes a list of file system items (through PowerShell`s cmdlet Invoke-Item) at the process exit.
    Parameter for plugin - comma-separated list of items.
    Invoking file item is the same as clicking 'Open' in item`s context menu in explorer.
    InvokeOnStart.ps1
    Invokes a list of file system items (through PowerShell`s cmdlet Invoke-Item) at the process start.
    Parameter for plugin - comma-separated list of items.
    Invoking file item is the same as clicking 'Open' in item`s context menu in explorer.
    LogEtwTrace.ps1
    Logs ETW trace of specified ETW providers into file while target process is running.
    Syntax:
    Code:
    LogEtwTrace(ETW_provider1_guid[, ETW_provider2_guid, ...])
    Example which logs Microsoft-Windows-Kernel-Power provider trace while notepad is running:
    Code:
    [notepad]
    LogEtwTrace({331c3b3a-2005-44c2-ac5e-77220c37d6b4})
    To view all registered ETW providers execute (in elevated command prompt):
    Code:
    logman query providers
    https://technet.microsoft.com/en-us/library/cc788030.aspx
    LongQuantumUntilExit.ps1
    Sets long thread quantum (globally for OS) for the duration of the process.
    It might make sense to use long thread quantum if the machine is about to run a background/server-style workload. For example, if a long-running computation, encoding or modeling simulation needs to run.​
    MaximumTimerResolutionUntilExit.ps1
    Sets maximum timer resolution for a lifespan of specified process.​
    Sleep.ps1
    Plugin for configurable pause span - Sleep(N), where N - number of milliseconds.​
    PauseMonitoringUntilExit.ps1
    Stops monitoring of processes by PPF service for the duration of the process.​
    StopServicesUntilExit.ps1
    Stops services for the duration of the process.
    Parameter for plugin - comma-separated list of services names.
    On process`s exit all of the services that were stopped by plugin will restart.
    TraceSystem.ps1
    Traces several system performance counters to help troubleshoot possible stuttering and freezes. Counters are:
    '\System\Processor Queue Length' - is the number of ready threads in the processor queue. There is a single queue for processor time even on computers with multiple processors. Therefore, if a computer has multiple processors, you need to divide this value by the number of processors servicing the workload. A sustained processor queue of less than 10 threads per processor is normally acceptable.
    '\PhysicalDisk(_Total)\Current Disk Queue Length' - is the number of requests outstanding on the disk at the time the performance data is collected. It also includes requests in service at the time of the collection. This is a instantaneous snapshot, not an average over the time interval. This counter might reflect a transitory high or low queue length, but if there is a sustained load on the disk drive, it is likely that this will be consistently high. Requests experience delays proportional to the length of this queue.
    '\Memory\Available MBytes' - is the amount of physical memory, in Megabytes, immediately available for allocation to a process or for system use. It is equal to the sum of memory assigned to the standby (cached), free and zero page lists.
    '\Memory\Pages/sec' - is the rate at which pages are read from or written to disk to resolve hard page faults. This counter is a primary indicator of the kinds of faults that cause system-wide delays. It is the sum of 'Memory\\Pages Input/sec' and 'Memory\\Pages Output/sec'. It is counted in numbers of pages.
    '\Processor(_Total)\% DPC Time' - is the percentage of time that the processor spent receiving and servicing deferred procedure calls (DPCs) during the sample interval. This counter displays the average busy time as a percentage of the sample time.
    '\Processor(_Total)\DPCs Queued/sec' - is the average rate, in incidents per second, at which deferred procedure calls (DPCs) were added to the processor's DPC queue. This counter measures the rate that DPCs are added to the queue, not the number of DPCs in the queue. This counter displays the difference between the values observed in the last two samples, divided by the duration of the sample interval.
    '\Processor(_Total)\% Interrupt Time' - is the time the processor spends receiving and servicing hardware interrupts during sample intervals. This value is an indirect indicator of the activity of devices that generate interrupts. Normal thread execution is suspended during interrupts. This counter displays the average busy time as a percentage of the sample time.
    '\Processor(_Total)\Interrupts/sec' - is the average rate, in incidents per second, at which the processor received and serviced hardware interrupts. This counter displays the difference between the values observed in the last two samples, divided by the duration of the sample interval.
    '\Processor(_Total)\% Idle Time' - is the percentage of time the processor is idle during the sample interval.
    '\Processor(_Total)\% C1 Time' - is the percentage of time the processor spends in the C1 low-power idle state. C1 low-power idle state enables the processor to maintain its entire context and quickly return to the running state.
    '\Processor(_Total)\% C2 Time' - is the percentage of time the processor spends in the C2 low-power idle state. C2 low-power idle state enables the processor to maintain the context of the system caches. The C2 power state is a lower power and higher exit latency state than C1.
    '\Processor(_Total)\% C3 Time' - is the percentage of time the processor spends in the C3 low-power idle state. When the processor is in the C3 low-power idle state it is unable to maintain the coherency of its caches. The C3 power state is a lower power and higher exit latency state than C2.

    TraceSystem has optional single input parameter - interval of sampling in milliseconds. By default interval is 500ms. List of counters is placed into the plugin`s body so user can manipulate it himself. Only restriction is - use english (non-localized) paths for counters.
    File name pattern for trace log is 'SystemTrace_<ProcessName>_<DateTime>.txt'. Trace log file has textual Tab-Separated-Values (TSV) format. MS Excel recognizes this format.​

    To use these plugins create folder Plugins in the folder with service binary, download plugin bundle and extract it to that Plugins folder (or to its subfolder).
     
    Last edited: Sep 21, 2019
  2. mbk1969

    mbk1969 Ancient Guru

    Messages:
    7,924
    Likes Received:
    4,557
    GPU:
    GeForce GTX 1070
    Source file was updated. See Edit2 for details.
     
  3. tappingbowl

    tappingbowl Master Guru

    Messages:
    209
    Likes Received:
    1
    GPU:
    Nvidia
    Hello, mbk1969. Thanks for the great utility.
    Yet, a minor problem has been encountered, regarding file names in "ProcessPluginFramework.exe.ini".
    Application, seems does not recognize some symbols in a names of processes (e.g. "@", "-").
    Tried to do something with "mpc-hc.exe" - did not work.

    Would be grateful, if you could look into it.
     
  4. mbk1969

    mbk1969 Ancient Guru

    Messages:
    7,924
    Likes Received:
    4,557
    GPU:
    GeForce GTX 1070
    I will dig it.
     

  5. mbk1969

    mbk1969 Ancient Guru

    Messages:
    7,924
    Likes Received:
    4,557
    GPU:
    GeForce GTX 1070
    Bug fixing: Source file was updated. It can be downloaded here - http://www.mediafire.com/download/37..._source_v2.zip - and service binary can be rebuild (by renaming or removing and starting the Install-PPFService.ps1).
    Change log:
    - fixed bug with process names containing non-alphanumeric symbols.


    Bug was in Regex patterns. Replaced them with simple string parsing.
     
    Last edited: Feb 24, 2014
  6. tappingbowl

    tappingbowl Master Guru

    Messages:
    209
    Likes Received:
    1
    GPU:
    Nvidia
    Worked well. Thank you again.
    Silly me, "pausemonitoringuntilexit" for "mpc-hc.exe" - totallly forgot about that. Moving this setting to "madHcCtrl.exe" - solved it.

    Just remembered one more issue, but it is more complicated, i guess.
    Following error, appearing in logs:
    Event 0, ProcessPluginFramework.
    Code:
    System.ComponentModel.Win32Exception (0x80004005): The parameter is incorrect 
       at WindowsService.ProcessAPIHelper..ctor(CancellationToken cancellationTkn, UInt32 processId, String processName) 
       at WindowsService.WindowsService.MonitorProcess()
    I think it is occurred during start of the service, but not sure. And it does not happen all the time. Last time this error appeared - five days ago. I will observe for it, and will let you know, if it is still actual.

    Affinity and priority management is pretty tricky for me. People could get some help in managing their systems. There are questions, like:
    -Is it better to manage manually (with this service), all the possible processes in the system, or leave it to operating system?
    -If manual management decided, what processes to what groups / cores / cpus, better to set?
    -How do you determine, that a certain process benefits from multi-thread or single? I know there is an utility "ProcessExplorer", it has a feature to watch process' threads, but still, personally for me, it is hard to understand, where to look.
    Is it thread priority? Not process priority? Then, is it recommended or not, to set this service for low process priority, as well?

    Also, great find, about MSI. Applied this mode to most of devices.
    Hard fails are - Marvell Storage Controller and build-in creative audio.
    Intel USBs - probably too, keyboard did not work after tweaking.
    Ignores - Realtek network adapter and Intel SMbus controller.

    I did observe, that devices which had one of the following lines in their .inf driver file - succeeded with converting to MSI-mode.
    This is the lines, from "nvdd.inf"
    Exception is Intel's IOH devices. I did not find any evidence of MSI in .inf. Intel's .inf - referring to machine.inf's, "Pci.sys" driver.
     
    Last edited: Feb 25, 2014
  7. mbk1969

    mbk1969 Ancient Guru

    Messages:
    7,924
    Likes Received:
    4,557
    GPU:
    GeForce GTX 1070
    There are no universal/generic rules. I think Windows controls processes pretty much efficiently. I wrote this utility to give gurus a free toy. I have read about ProcessLasso in this forum quite frequently, so I decided to implement similar utility but with extensibility in mind - hence PowerShell and .Net. It was fun for me.
    PPF is not used on my rigs, because home rig is powerful enough for all games, and work rig - for development. I did extensive optimization by switching off all unnecessary services and apps because the more threads to schedule the less performance.

    It is what you should research. If you interested or have trouble with any app you can try to play with affinity. I thought about affinity plugin in terms of isolation of not-important/secondary/helper processes.

    You phrased it wrong. No external utility can switch process between multi- and single-thread because it is internal process design/implementation. With PPF we can only assign all threads of process to any CPU.

    You quoted my note about thread and task, but it was about internal design detail.

    Yeah, USB1, USB2, Marvell stor, Ceative audio, SMBus controller - all were reluctant to work in MSI mode.

    Edit: I think that overall such utility as PPF is more interesting/promising for users with professional tasks - video/photo/audio editing, calculations, - where you can gain by increasing task process priority, or by dedicating CPU cores.
     
    Last edited: Feb 25, 2014
  8. drbaltazar

    drbaltazar Banned

    Messages:
    416
    Likes Received:
    0
    GPU:
    amd 7950 3gb
    Polling ? Is this what control USB 1 and usb2 stupid polling (arrrg)
     
  9. tappingbowl

    tappingbowl Master Guru

    Messages:
    209
    Likes Received:
    1
    GPU:
    Nvidia
    As i supposed. Windows does a good job, noticed it too.
    Well, my rig is pretty powerful as well, but i experience some sudden fps-drops in certain games. Turning off core parking, setting your cpu power settings values of p-states and c-states, turning off multimedia scheduler service, using your Set Timer Resolution service and PPF service - made some improve for me. Also, HPET thing. After i turn it off in the bios, dpc latency became about 5-10, but actual visual experience in the game is worse.

    I agree here. Is there a list of optimizations you did?

    Understood. Maybe it will be helpful, if there would be a list for default system processes.
    Rank 1 processes (default priority, 1-2 cores):
    conhost
    csrss
    lsass
    lsm
    services
    smss
    svchost

    Rank 2 processes (default priority, 1-2 cores):
    dllhost
    dwm
    explorer
    wininit
    winlogon
    wmiprvse

    Rank 3 processes (games, high priority, using most cores)

    Rank 4 processes (temporary utilities, browser, priority below normal / normal, 1-2 cores):
    browser

    Rank 5 processes (idle processes, low priority, 1-2 cores):
    alg
    ProcessPluginFrameworkService
    taskhost
    trustedinstaller

    Rank 6 processes (specific, critical processes, all cores required):
    winsat
    Any recommendations?

    Mm.. i understand that part, but i meant is it possible to determine which design is used in a specific application, multi- or single-thread?
    Here is your quote:
    "single-threaded" application - how do i know, which application is single-threaded?
    I use HT, then there is a point to set such application to core+logical core, despite it's design?
    And one more interesting observation. When i watched cpu cores usage through "ProcessExplorer", application set to two specific cores, was using, just a little bit, other cores. I guess it is windows' thread schedule design or whatever. Yet still, i believe it would be better if interruptions between cores are smaller.

    So, i suppose, it is okay to set priority of "ProcessPluginFramework" to low priority. Also, about priorities. Found out, through "ProcessExplorer" - there is one more priority, except "Realtime", called "Background 4 (Low I/O and Memory Priority)". Is "Idle" priority lower than that, or not? If it is not lower, could we have such plugin in PPF service?

    In my case, my "sensetive rig" seems does like such tweaks. And hell, it is slightly better, when most of devices use independent virtual irq, instead of forced one. Also, there is such thing as MSI-X.
    Google: "18946/eng/readme.txt"
    So i wonder, what is better? MSI-X or MSI? I know the device and driver must support MSI-X so, when you set "MSISupported" to 1 and not adding "MessageNumberLimit" is it MSI-X?
    Also, some information about "MessageNumberLimit" here: Google: site:msdn.microsoft.com "ff544246(v=vs.85)"
    Any thoughts?
     
    Last edited: Mar 2, 2014
  10. mbk1969

    mbk1969 Ancient Guru

    Messages:
    7,924
    Likes Received:
    4,557
    GPU:
    GeForce GTX 1070
    I assume that USB polling is internal USB implementation aspect and as such it has nothing to do neither with PCIE implementation nor with IRQs. Interrupt is mean of OS <=> device communication. That is more higher level than USB polling.
     

  11. mbk1969

    mbk1969 Ancient Guru

    Messages:
    7,924
    Likes Received:
    4,557
    GPU:
    GeForce GTX 1070
    I did not switch HPET off in BIOS. I just did disable its usage for QPC function.


    Since I use xDSL for internet, I switched to a manual start services:
    Computer browser (aka Browser), Workstation (aka LanmanWorkstation), Server (aka LanmanServer), SSDP discovery (aka SSDPSRV), Interactive Services Detection (aka UI0Detect), PnP-X IP Bus Enumerator (aka IPBusEnum), and some others. Algorithm is - you switch service to manual start mode and try to perform usual activity such as internet, games, multimedia.


    I wouldn`t touch system processes. There is though performance counter which can tell how much CPU time process eats. I mean high priority of process doesn`t mean that it actually occupies CPUs much. Also you should count number of threads within process. The more threads the less performance.

    If process has only one thread it is single-threaded.

    Its ok.


    These priorities are not about threads, but about I/O and memory operations.

    I believe MSI-X is just new version of MSI. And modern motherboards implement namely MSI-X. When you restrict MSI-X to some quantity of IRQs (say 1) the mode is still MSI-X. It is kinda same as PCI devices in modern motherboards - they work in PCIE bus, but bus is still PCIE. It doesn`t switch to PCI mode.

    It doesn`t say that if you specify MessageNumberLimit it will switch PCI 3.0 to PCi 2.2. Just limiting the number of MSIs per device.

    Intel`s text though phrases namely switching MSI-X off, but whole document is for some 3 Intel devices. So what that means in effect I don`t know.
     
    Last edited: Feb 25, 2014
  12. tappingbowl

    tappingbowl Master Guru

    Messages:
    209
    Likes Received:
    1
    GPU:
    Nvidia
    This? "bcdedit /set useplatformclock false".

    Mine are pretty same, except i use ICS.

    Hm.. i don't touch priority of most system processes, just separate them by cores. More important going for first cpus, less important go after and etc. And amount of threads in processes, means the more threads process has - the less performance it will show on a single core?

    How to determine that? That is what i meant from the start. Where to look?

    I mean PPF service uses "PriorityClass" plugins, and one level of priority is missing, between "PriorityIdle" and "PriorityBelowNormal". "PriorityBackground" if it was present. And what will be lower, in actual performance, "Idle" or "Background"? They seem to have same number 4.

    Just tried turning off my "Renesas USB 3.0 Host Controller", added "MessageNumberLimit" 1. Looked into msinfo32.exe - "Renesas USB 3.0 Host Controller" has only one virutal irq. But before applying this tweak it had 8 virtual irqs. That's how it works, i suppose.
     
  13. mbk1969

    mbk1969 Ancient Guru

    Messages:
    7,924
    Likes Received:
    4,557
    GPU:
    GeForce GTX 1070
    Yes


    I mean the more threads OS should schedule the more lower overall performance of OS is. Regardless of number of cores. And when process has a bunch of threads and it is sitting there while you play game it is no good. And sometimes you can`t stop process - for example Battlelog browser plugin failed to work in IE, so I installed it in Opera (new one). Have you idea how many resources (threads among them) swallowed by chromium powered browser?


    In the same Process Explorer. You can add column in main window. And you can start process properties dialog and see Threads tab. And you can start PowerShell, then get process:
    Code:
    $p = get-process -name notepad
    $p.threads.count
    and even look each thread - $p.threads
    and even look for a thread`s processor time - $p.threads[0].TotalProcessorTime


    http://msdn.microsoft.com/en-us/library/windows/desktop/ms685100(v=vs.85).aspx

    Do you see priority 'Background' ? PPF use Win32 API for setting process priority, so...

    Yeah, I stumbled upon two devices which behaved exactly the same. And after using MessageNumberLimit they started to work correctly.
     
    Last edited: Feb 26, 2014
  14. drbaltazar

    drbaltazar Banned

    Messages:
    416
    Likes Received:
    0
    GPU:
    amd 7950 3gb
    MessageNumberLimit is set at 1 by ms by default .if you meet a corp that does set this it would be nice to name them because so far I haven't met one .Asus does set it ,but its powder to the eyes since it is exactly set the same way ms set it by default if inf component address to an address of IRQ not already used.
     
  15. tappingbowl

    tappingbowl Master Guru

    Messages:
    209
    Likes Received:
    1
    GPU:
    Nvidia
    Oh, yes i understood that part. More threads = less available resources. But when i asked for recommendations about configuring PPF service for processes i did not understand well your response.
    - Do not touch system processes.
    You mean do not touch high priority system processes? Like winlogon, dwm? Or do not touch priority of any system processes? Or do not touch them in any way?

    Yeah, but even in active processes, like game not all of the threads are highly used. It is seen in "ProcessExplorer" "Threads" tab, column "CPU" or "Cycles Delta" or "Context Switches" and "Cycles" lower. For example, "ProcessPluginFramework" - has only one instance of itself. But the most active thread is "clr.dll!GetMetaDataInternalInterface+address". Command $p.threads.count - returns 23. But the most using thread is 1. Should it be considered as 23-threaded application or 1-threaded?
    As compared, STR service - does not use constantly a thread, like PPF service does.
    And the most active thread there, is it's instance "SetTimerResolution.exe". Total threads - 6. I mean, if a process uses multiple threads (not it's instances, but helper dlls) does it mean it is actually using multiple threads? For example, uTorrent has 12 instances of itself, as threads, and a lot of additional libraries. I believe it is really multi-threaded. And applications with only 1 instance, but multiple threads - pseudo multi-threaded or not fully single-threaded. Applications with only one instance of itself - single-threaded. Is that right?
    And i wonder, why PPF service use one thread constantly, even when no processes from the list being launched and STR service - does not. It is acting like STR service only with empty "ProcessPluginFramework.exe.ini". "pausemonitoringuntilexit" - reduces number of cycles per second, but that thread is still active. Is it not possible to make it like STR service?

    Seems i get it. Difference is only in "Low I/O and Memory Priority". You can set it, through "ProcessExplorer", and then "I/O priority", for every thread in a process is "very low". I guess, this switch cannot be accessed through powershell, to include in the list of PPF service plugins?

    Though, i am not sure what is more correct. Because my motherboard has 8 usb 3.0 ports, and so there was 8 virtual irqs. 1 for each device, i believe. Could a possible irq conflict happen, when more than 1 device is used in usb 3.0, simultaneously?

    STR service works great. Reduces dpc latency, almost by half. And it is more stable, judging by DPC Latency Checker's outputs. DPC Latency Checker's times - acting very interesting, when you change timer resolution to 0.5, during measuring. It's times are as low as without HPET enabled in bios, but only sometimes, not all the time.
    i.imgur.com/lXP33hN.png - timer interval: 15.600 ms
    i.imgur.com/YlPCW6q.png - timer interval: 0.500 ms (timer interval changed during measuring)
     
    Last edited: Mar 2, 2014

  16. mbk1969

    mbk1969 Ancient Guru

    Messages:
    7,924
    Likes Received:
    4,557
    GPU:
    GeForce GTX 1070
    In case of system processes we don`t know their intrinsic details, their duties. Affinity is no big change, but priority change can lead to unexpected results.

    You should be aware that not only priority but affinity as well are inherited by child processes. I.e. when you launch some exe in explorer.exe it inherits explorer`s settings.

    There are apps with only one thread. For example cmd.exe. Such apps I call single-threaded. Some apps have multiple threads not in main path of code but in used libraries, OS APIs. From internal source code point of view they are single-threaded, but from external point of view they are multi-threaded (OS, CPU don`t care how those threads created within app).
    Regarding the thread`s used processor time, of course threads that perform actual work consume CPU the most. But OS scheduler has to check every thread regardless of thread`s activity. Hence - the less threads in OS the better performance.


    PPF constantly polls OS for a list of running processes. But only if ini-file is not empty. STR service of first version only calls two Win32 API functions and then does nothing except usual interaction with service controller.
    It is possible to avoid such polling but I wanted to avoid WMI usage, because WMI can be turned off.


    If you will tell me which Win32 API call can set that I/O priority...


    IRQ conflict is the same IRQ lines for a different devices. If IRQ lines are all different - there is no conflict. IRQ is assinged for device. Do you see devices "USB port"? I see only USB controllers, hubs. I mentioned two devices with multiple IRQs - they didn`t work correctly until I limited IRQs to 1. If your USB controller works fine with multiple IRQs then I guess you can leave all IRQs.


    Edit: Btw if you use Win8 you should not use DPCLat and use only LatencyMon.

    Edit2: I can blend STR to PPF for you. It will make sense for your rig.
     
    Last edited: Feb 26, 2014
  17. tappingbowl

    tappingbowl Master Guru

    Messages:
    209
    Likes Received:
    1
    GPU:
    Nvidia
    Yes, i do change priorities only if these processes are secondary.

    Noticed it. Yet, it is just a fast-paced list, which must be improved, for more precise and evident results.

    Understood. For applications with multiple threads in OS APIs - it is better to give them 2 or more cores. So, for example, if i need to isolate application, like "cmd.exe" - is it better to put it in one core or one+next nearest? Since i use HT.

    The most curious part - i use second version of STR service, with not empty .ini file. That is why i find it very interesting. My personal guess, PPF service needs such polls for plugin's like "pausemonitoringuntilexit" - it will not know when application did shutdown, without polls. So, i thought it will be more intelligent to activate such polling, when this kind of plugin is in active state. But if currently there are no processes, with this function, in active state - it will not use polls. I am not familiar with internals of this, just my guess.

    I am not sure if it will help, there what i have found in the google: site:superuser.com "136021/h"
    Hope this helps.

    I rarely use it, so probably it won't make much harm. I left it with "MessageNumberLimit" at 1, just because it is less IRQs - probably, less threads. Will observe, anyway.

    I am aware of that behavior in Win8. My OS is Win7. That is why it is very interesting.

    Well, if it would make less threads - why not? I will be thankful.
     
  18. drbaltazar

    drbaltazar Banned

    Messages:
    416
    Likes Received:
    0
    GPU:
    amd 7950 3gb
    There are range of affinity ,if you change it to suit your need but stay within that defined range you should be fine !but don't change it from its range . you have leeway . if I recall it is ranged in tree section (1 to 10 ,11 to 20 , 21 to 30 )don't use the number I write its just a random example to get the point!
     
  19. drbaltazar

    drbaltazar Banned

    Messages:
    416
    Likes Received:
    0
    GPU:
    amd 7950 3gb
    Also IRQ can have conflict even within one device even if it has its own address ! Why !some computer part can read and write at the same time , so in some circumstance all hell break loose .imagine if you have 4 GPU and all of them can read and write simultaneously ?(ya you get the idea.
    Ps:most GPU can read and write simultaneously,and I suspect a lot of other computer part also probably do or can that most don't know !
     
    Last edited: Feb 26, 2014
  20. mbk1969

    mbk1969 Ancient Guru

    Messages:
    7,924
    Likes Received:
    4,557
    GPU:
    GeForce GTX 1070
    Source file was updated. It can be downloaded here - http://www.mediafire.com/download/37xfk8xl8f94dax/PPF_source_v2.zip - and service binary can be rebuild (by renaming or removing and starting the Install-PPFService.ps1).
    Change log:
    - added plugin MaximumTimerResolutionUntilExit, which sets maximum timer resolution for a lifespan of specified process.

    With that plugin PPF can be used as STR v.2 .

    tappingbowl, according to Microsoft PROCESS_MODE_BACKGROUND_BEGIN can be set only by process itself. I`ve tried it in PPF and no luck.
     
    Last edited: Feb 26, 2014

Share This Page