Dynamically enhancing the performance of a foreground application

A performance enhancing solution can be executed on a computing device to detect changes in the foreground application. When the foreground application changes, the performance enhancing solution can adjust the allocation of system resources to running applications to thereby enhance the performance of the foreground application.

CROSS-REFERENCE TO RELATED APPLICATIONS

BACKGROUND

The performance and responsiveness of an application is largely dependent on the availability of system resources. For example, when multiple applications are concurrently executing, the applications will necessarily share the system resources. Some technologies exist for enhancing how system resources are allocated to running applications. For example, the operating system may provide a scheduler (e.g., the Windows Scheduler or the Linux Scheduler) that is configured to control when an application (or more particularly, an application's process or thread) is run based on a priority setting or other considerations. However, the functionality that such schedulers perform does not directly manage the availability of system resources for a particular application. Instead, this functionality is largely limited to performing time slot allocation and enforcing static priority settings or allocating all system resources equally while always prioritizing the foreground application over background applications.

BRIEF SUMMARY

The present invention extends to methods, systems, and computer program products for dynamically enhancing the performance of a foreground application. More particularly, embodiments of the present invention may be implemented to ensure that an application that is currently running in the foreground can be allocated sufficient system resources to enhance its performance even when other applications are running in the background. A performance enhancing solution can be executed on a computing device to detect changes in the foreground application. When the foreground application changes, the performance enhancing solution can adjust the allocation of system resources to running applications to thereby enhance the performance of the foreground application.

In some embodiments, the present invention may be implemented as a method for dynamically enhancing the performance of a foreground application. It can be detected that a first application of a plurality of running applications has become the foreground application and that the first application is a target application. In response to determining that the first application is a target application, an allocation of system resources to the plurality of running applications can be adjusted to enhance the performance of the first application while the first application is the foreground application.

In some embodiments, the present invention can be implemented as computer storage media storing computer executable instructions which when executed on a computing device implement a method for dynamically enhancing the performance of a foreground application. This method can include: monitoring for changes in the foreground application; upon detecting that the foreground application has changed, determining that the foreground application is a target application; and in response to determining that the foreground application is a target application, adjusting an allocation of system resources to a plurality of running applications to enhance the performance of the foreground application.

In some embodiments, the present invention may be implemented as a computing device that includes system resources, an operating system, a performance enhancing solution and a plurality of applications. The performance enhancing solution is configured to dynamically enhance the performance of at least one target application of the plurality of applications by adjusting an allocation of the system resources to the plurality of applications.

DETAILED DESCRIPTION

FIG. 1illustrates a computing device100and provides an example of components that may exist on computing device100when embodiments of the present invention are implemented. Computing device100can represent a desktop, laptop, server, thin client, smart phone or any other type of computing device that is capable of running applications. For example, computing device100is shown as having system resources110and an operating system120that controls how system resources110will be made available to any application that is executed on computing device100.FIG. 1further shows that a number of applications140-1through140-n(where n could represent any integer greater than 1) may be running on computing device at any given time, one of which could be the foreground application. Although embodiments of the present invention could be implemented when any number of applications are running concurrently, benefits of implementing the present invention will be enhanced when many applications are running concurrently. The term “foreground application” and its variants should be construed in accordance with its typical meaning. As an example, the foreground application may be viewed as the application that owns (or is associated with) the window that has focus.

System resources110can generally represent the various types of hardware and/or software resources that may be required to execute an application or that an application may employ during execution. For example, system resources110may include the central processing unit, memory, input/output (I/O) resources (including physical and virtual storage and network I/O stacks), etc. Although embodiments of the present invention will be described primarily using various Windows-specific examples, operating system120can represent any available operating system including Windows, Linux, Unix, iOS, Android, etc.

FIG. 1also illustrates that a performance enhancing solution130can be employed on computing device100to implement embodiments of the present invention. Performance enhancing solution130can represent any suitable form of software that may be executed on computing device100to perform the functionality described herein. As examples only, performance enhancing solution130could be or could include a process, service, driver, etc. that may run in user mode, kernel mode or both. As an overview, performance enhancing solution130may be configured to interface with system resources110, operating system120and/or applications140-1through140-nto monitor which of applications140-1through140-nmay be running in the foreground and to dynamically adjust how operating system120allocates system resources110to at least some of applications140-1through140-nin a manner that enhances the performance of the foreground application.

FIG. 2provides a flow diagram representing an example of how performance enhancing solution130may dynamically enhance the performance of a foreground application. As shown, when performance enhancing solution130is loaded, it may identify one or more applicable policies. This step is shown in dashed lines to represent that it is an optional step that may not be performed in all implementations of the present invention. For example, performance enhancing solution130may not rely on a policy in embodiments where it adjusts the allocation of system resources110in a similar manner regardless of which application is the foreground application. However, the use of policy may enable a wide range of customizations and dynamic adjustments. Various examples of how performance enhancing solution130may employ a policy are provided below.

While performance enhancing solution130executes concurrently with applications140-1through140-n, it can monitor for changes in the foreground application. In other words, performance enhancing solution130can be configured to detect which application is running in the foreground at any particular time. Performance enhancing solution130could employ any suitable technique for determining the foreground application. For example, performance enhancing solution130could install a hook that causes operating system120to notify it whenever the foreground application changes (e.g. using the SetWindowsHookExA function to install a WH_CBT hook procedure that watches for HCBT_SETFOCUS notifications in a Windows-based implementation). As another example, performance enhancing solution130could periodically call a function provided by operating system120to obtain the foreground application (e.g., by calling the GetForegroundWindow function in Windows or by reading the _NET_ACTIVE_WINDOW property in Linux).

Regardless of the technique that performance enhancing solution130may employ to enable it to detect when the foreground application has changed, when it detects a change in the foreground application, performance enhancing solution130may determine whether the current foreground application is a “target application.” This step is shown in dashed lines to represent that performance enhancing solution130need not always make this determination. In particular and as further described below, in some embodiments, performance enhancing solution130may always enhance the performance of the foreground application (i.e., it may always treat the foreground application as if it were a “target application”) as opposed to enhancing the foreground application only when it is a target application.

In embodiments where performance enhancing solution130determines whether the foreground application is a target application, performance enhancing solution130may make the determination based on policy. For example, the user may be enabled to define a policy that lists each application that should be considered a target application. Alternatively or additionally, the user may be enabled to define a policy that causes performance enhancing solution130to select the most frequently used applications as target applications. In such cases, some of applications140-1through140-nmay be target applications while others may not be target applications (or “non-target applications”).

If the foreground application is a target application (or if the performance of the foreground application is always enhanced), performance enhancing solution130may interface with operating system120to adjust the allocation of system resources110to one or more of applications140-1through140-nto thereby enhance the performance of the foreground application. Performance enhancing solution130may employ a policy to determine how to adjust the allocation of system resources110.

In addition to adjusting the allocation of system resources110when the current foreground application is a target application, in some instances, performance enhancing solution130may also adjust the allocation of system resources110when the current foreground application is not a target application. For example, if the previous foreground application was a target application but the current foreground application is not a target application, performance enhancing solution130may adjust (or revert) a previous allocation of system resources110that was intended to enhance the performance of the previous foreground application. In some embodiments, performance enhancing solution130may also be configured to dynamically enhance the performance of a target application even when the target application is not the foreground application.

In short, performance enhancing solution130can dynamically adjust the allocation of system resources110in response to a change in the foreground application and/or in response to identifying that a target application is running. The primary purpose of such adjustments is to ensure that the performance of the target application, particularly when the target application is the foreground application, will be enhanced. When and how performance enhancing solution130will make such adjustments can be controlled by one or more policies.

Performance enhancing solution130may identify an applicable policy in various different ways. For example, a policy may be specific to a current user of computing device100, to a particular position or role of the current user, to the particular type of computing device100, to a particular hardware and/or software configuration of computing device100, to a particular time of day, day of the week or other time-based criteria, etc. The content of a policy may also vary or may be defined in various different ways. For example, the policy may identify specific applications that should be treated as target applications (e.g., a list of applications selected by the user, an administrator or other individual), may specify criteria by which performance enhancing solution130should identify applications that should be treated as target applications (e.g., the ten most used applications which could be determined at one particular time or repeatedly), may specify whether the foreground application should always be treated as a target application, etc. As another example, the policy may define specific types and/or amounts of adjustments that should be made to system resources110when a target application is the foreground application, how adjustments, whether or not specifically defined in the policy, should be made to running applications (e.g., whether to apply adjustments to background applications, the foreground application or both, and/or whether to apply adjustments selectively to target and/or non-target applications), whether and/or how adjustments should be made when the foreground application is a target application as opposed to a non-target application, etc.

FIGS. 3A-3Cprovide an example of how performance enhancing solution130may dynamically enhance the performance of a foreground application. This example is intended to represent one of many different implementations that could be accomplished in accordance with embodiments of the present invention.

Turning toFIG. 3A, it is assumed that applications140-1through140-3are running concurrently and that, in step1a, application140-1becomes the foreground application (as represented by the solid lines) while applications140-2and140-3are running in the background (as represented by the dashed lines). How application140-1becomes the foreground application is not essential to the present invention. For example, application140-1could become the foreground application in response to the user launching the application, attempting to open a document associated with the application, clicking on or otherwise selecting the application's window to give it focus, etc. It is also assumed that performance enhancing solution130has identified a policy300that is currently applicable.

In step1b, performance enhancing solution130detects that application140-1has become the foreground application. As one Windows-specific example only,FIG. 3Arepresents that performance enhancing solution130could perform this detection by periodically calling the GetForegroundWindow( ) function which returns a handle to the window in the foreground. Although not shown, performance enhancing solution130could employ this handle to retrieve a process ID or some other identifier associated with the foreground window that could be used to identify application140-1as the owner of the window. Alternatively, as mentioned above, performance enhancing solution130could call one or more functions to directly obtain the process ID, thread ID or other identifier associated with the window in the foreground.

Using the process ID, thread ID or some other identifier (e.g., the process name), and possibly other information that performance enhancing solution130has maintained to identify the previously current foreground application (e.g., a process name or process ID of the application that had been the foreground application up until this point), performance enhancing solution130could then determine that application140-1has become the foreground application (i.e., that the foreground application has changed and that application140-1is the current foreground application). In short, there are many techniques that performance enhancing solution130could employ to determine which application owns the window that is in the foreground and to determine when the application that owns the window in the foreground has changed.

Turning toFIG. 3B, after determining that the foreground application has changed and identifying the current foreground application as application140-1(e.g., based on its process ID, process name or any other suitable identifier), in step2, performance enhancing solution130can determine whether the current foreground application is a target application. For example, it is assumed that policy300provides a list of target applications that includes application140-1. As described above, this list could have been specified by a user, created by performance enhancing solution130based on some criteria or otherwise populated. Accordingly, in this example, performance enhancing solution130could determine that application140-1, the current foreground application, is a target application by determining that an identifier of target application140-1is included in the list of target applications in policy300. As suggested above, a primary purpose for step2is to determine when the performance of the current foreground application should be enhanced (i.e., to selectively enhance the performance of the foreground application only when it is a target application). Therefore, in embodiments where performance enhancing solution130always enhances the performance of the foreground application, step2may not be necessary. A number of variations of step2could equally be performed. For example, policy300may provide a list of non-target applications, in which case step2may entail determining that application140-1is not included in the list of non-target applications.

Turning toFIG. 3C, in step3, and based on the determination that application140-1is a target application (or that the performance of application140-1should otherwise be enhanced), performance enhancing solution130can interface with operating system120to adjust the allocation of system resources110to applications140-1through140-3. Notably, to accomplish this adjustment, performance enhancing solution130need not necessarily adjust the allocation of system resources110for each of applications140-1through140-3, but may adjust the allocation of system resources110in a manner that will enhance the performance of the foreground application.

FIG. 3Cprovides a Windows-specific example in which performance enhancing solution130adjusts the allocation of system resources110to enhance the performance of application140-1, the current foreground application, by only increasing the allocation of system resources110to application140-1. In particular, performance enhancing solution130is shown as employing the SetPriorityClass function to set the priority class for application140-1to a higher level (e.g., ABOVE_NORMAL_PRIORITY_CLASS). The Windows operating system employs the priority class of each process (or thread) to determine which process will obtain the next slice of the CPU time. Accordingly, by setting the priority class of application140-1's process to a high level, application140-1will likely obtain more frequent slices of CPU time.

Performance enhancing solution130is also shown as employing the SetProcessAffinityMask function to set the processor affinity mask for the threads of application140-1's process to a higher level. Setting the processor affinity mask to a higher level may allow application140-1's threads to run on each available processor or at least a greater number of the available processors on computing device100.

Performance enhancing solution130is also shown as employing the NtSetInformationProcess function to set the ProcessIoPriority class to a higher level. Setting the ProcessIoPriority class to a higher level may allow application140-1's I/O to be handled at a higher priority. Performance enhancing solution130is also shown as employing the QOSSetFlow function to prioritize application140-1's network packets such as, for example, to meet a required service level agreement of application140-1.

AlthoughFIG. 3Cuses four Windows-specific functions as examples, it is reiterated that performance enhancing solution130could employ similar or equivalent functions available within the Windows operating system or any other operating system to accomplish the same or similar type of adjustments to the allocation of system resources110. Accordingly, step3may encompass any functionality that performance enhancing solution130may perform to increase the availability of system resources110for the current foreground application including, but not limited to, increasing the priority class, the process affinity, the I/O priority and QoS of the current foreground application.

In some embodiments, in addition to or in place of increasing the allocation of system resources110to the current foreground application, performance enhancing solution130may also reduce the allocation of system resources110to one or more background applications. For example, in step3, performance enhancing solution130may also employ the SetPriorityClass function, the SetProcessAffinityMask function, the ProcessIoPriority class and the QOSSetFlow function to reduce the priority class, process affinity, I/O priority and QoS respectively of applications140-2and140-3. In such cases, the reduction in the allocation of system resources110to applications140-2and140-3may ensure that the increase in the allocation of system resources110to application140-1results in a performance enhancement. Alternatively, performance enhancing solution130may only reduce the allocation of system resources110to background applications to cause the performance of the current foreground application to be increased. In short, the increase in performance can be accomplished by any adjustment in the allocation of system resources110that causes the allocation of system resources110to the current foreground application to be increased relative to the allocation of system resources110to one or more concurrently running applications.

In some embodiments, performance enhancing solution130may base its adjustments in the allocation of system resources110on current consumption of system resources110. For example, if consumption of system resources110is high at the time when performance enhancing solution130performs step3, it may choose to decrease the allocation of system resources110to each background application in addition to increasing the allocation of system resources110to the current foreground application. In contrast, if the consumption of system resources110is low, performance enhancing solution130may choose only to increase the allocation of system resources110to the current foreground application. In some embodiments, such decisions may be based on policy300.

In some embodiments, performance enhancing solution130may employ policy300to determine which background applications should have their allocation of system resources110reduced. For example, policy300may dictate that the allocation of system resources110to a target application that is running in the background should not be reduced while the allocation of system resources110to a non-target application that is running in the background should be reduced. Similarly, policy300may dictate that the allocation of system resources110to a target application that is running in the background should be reduced to a lesser extent relative to the reduction in the allocation of system resources110to a non-target application that is running in the background.

Returning to the example inFIGS. 3A-3C, at some point, application140-1will no longer be the foreground application, and performance enhancing solution130can repeat the above-described process. For example, if application140-2becomes the foreground application, performance enhancing solution130may again perform step2and step3as appropriate. In such a case, and assuming application140-2is a target application, performance enhancing solution130may perform step3in a similar manner as described above. However, if application140-2is not a target application, performance enhancing solution130may not adjust the allocation of system resources110to increase the performance of application140-2, but may rather undo the previous adjustments it had made to increase the performance of application140-1. In other words, when a non-target application is the foreground application, performance enhancing solution130may cause the allocation of system resources110to return to a default state.

However, in some embodiments, performance enhancing solution130may retain previous adjustments in the allocation of system resources110that were made to enhance the performance of an application that is no longer the foreground application. For example, after application140-1is no longer the foreground application, performance enhancing solution130may retain the adjustments it made in step3until a target application becomes the foreground application. Similarly, if a non-target application becomes the foreground application and that non-target application previously had its allocation of system resources110reduced, performance enhancing solution130may retain the reduction even though the non-target application is the foreground application. In some embodiments, all such variations could be controlled using policy.

By using the above-described techniques, performance enhancing solution130can increase the performance of a foreground application in a dynamic/real-time manner. For example, in some embodiments, performance enhancing solution130could repeatedly monitor for the ten most used applications and treat those ten most used applications as target applications. In this way, performance enhancing solution130may always increase the performance of the applications with which the user most frequently interacts.

The above-described techniques may also provide performance enhancements without sacrificing battery life or otherwise unduly increasing power consumption. For example, in comparison to changing the power mode for the entire system which would quickly drain a battery, performance enhancing solution130can target the increase in performance to only the target applications while they are the foreground application. Additionally, in some cases, the increased power utilization that may result from a temporary increase in the allocation of system resources to the foreground application may be offset by the decreased power utilization that results from the temporary (or permanent) decrease in the allocation of system resources to the background applications.

In summary, a performance enhancing solution can be employed on a wide variety of computing devices to dynamically enhance the performance of an application while it is the foreground application. Such enhancements can be obtained by either or both increasing system resources available to the foreground application or limiting system resources available to background applications. Such enhancements may also be provided to a select set of target applications which may be manually defined or dynamically selected.