# Patent

## Title
Fine grained adaptive throttling of background processes

## Abstract

Approaches for throttling backgrounds processes to a high degree of precision. The utilization of a shared resource that is used by one or more background processes is monitored. A frequency at which the one or more background processes are executed is dynamically adjusted based on the current utilization of the shared resource without adjusting the frequency in which one or more foreground processes are executed to ensure that the utilization of the shared resource does not exceed a threshold value. The monitoring of the utilization of the shared resource may be performed more often than the adjusted of the frequency at which the background processes are executed, and the utilization of the shared resources may be performed many times a second. Consequently, the utilization of the shared resource may be above a certain level (such as 65%) and less than another level, such as 90%, when background processes are executing.

## Background
FIELD OF THE INVENTION
The present invention generally relates to adjusting the throttling of background processes at a high degree of precision.
BACKGROUND
Processes executing on a computer system will often require access to shared resources of the computer system, such as memory and the CPU, to meet quality of service (QoS) requirements and expectations. A process that executes in the background (a “background process”) may be required to execute on a regular basis. Typical examples of a background process include an anti-virus program and a backup program. However, the execution of background processes may have a negative impact to the quality of service of other processes due to conflicts with shared resources. For example, a background process that is taking a relatively large portion of the CPU's availability will result in other processes having less access to the CPU. Shared resources can become saturated by background process. When a process accesses a saturated resource, their access is delayed and the average response time increase, thereby causing the execution of the process, and the computer system as a whole, to slow down.



BRIEF DESCRIPTION OF THE DRAWINGS
Embodiments of the invention are illustrated by way of example, and not by way of limitation, in the figures of the accompanying drawings and in which like reference numerals refer to similar elements and in which:
FIG. 1A is a graph illustrating under utilization of a shared resource using static throttling according to prior approaches;
FIG. 1B is a graph illustrating over utilization of a shared resource using static throttling according to prior approaches;
FIG. 2 is a flowchart illustrating the functional steps of fine grained dynamic throttling according to an embodiment of the invention;
FIG. 3 is a graph illustrating the utilization of a shared resource over time for an embodiment of the invention;
FIG. 4 is a graph illustrating a comparison of bandwidth versus block size according to an embodiment of the invention; and
FIG. 5 is a block diagram that illustrates a computer system upon which an embodiment of the invention may be implemented.



DETAILED DESCRIPTION OF THE INVENTION
Approaches for dynamically adjusting a frequency at which the one or more background processes are executed at a high degree of precision are described. In the following description, for the purposes of explanation, numerous specific details are set forth in order to provide a thorough understanding of the present invention. It will be apparent, however, that the present invention may be practiced without these specific details. In other instances, well-known structures and devices are shown in block diagram form in order to avoid unnecessarily obscuring the present invention.
Background Processes and Foreground Processes
Embodiments of the invention advantageously enable background processes to be dynamically throttled at a high degree of precision. As a result, the utilization of shared resources may be safely maintained at higher levels of utilization than by prior approaches. Before discussing how embodiments of the invention may be employed, it will be helpful to appreciate the differences between a background process and a foreground process. As used herein, a background process is a process designed to run in the background to perform a supportive function to a foreground process. A foreground process, as used herein, is a process that provides functionality central to the role of a device upon which the process executes. Foreground processes typically interact with a user and/or performs application level activity. Non-limiting, illustrative examples of functionality performed by a background process include making a backup copy of data and running an antivirus program. Non-limiting, illustrative examples of foreground processes include operating systems, database servers, text editors, and multimedia players.
Observed Limitations of the Prior Art
It is observed that prior approaches for managing the execution of background processes exhibit many limitations and disadvantages. One approach for managing the executing rate of a background process according to known techniques is the “noop” approach. In the “noop” approach, both background processes and foreground processes are dispatched in the order in which they are received. A disadvantage with this technique is that it provides no protection against over saturation of a shared resource. For example, if a set of foreground processes are highly utilizing a shared resource, executing a high load of background processes may over saturate the shared resource and subsequently degrade performance of the foreground processes.
According to another prior art approach termed “static throttling,” the frequency at which background processes are dispatched to the CPU is either static or changes infrequently. For example, in the static throttling approach, a background process may be configured to have 1000 IO operations per second. Static throttling is problematic in that it virtually always under utilizes or over utilizes shared resources, as it is difficult to accurately predict how much foreground processes will utilize a shared resource.
FIG. 1A is a graph illustrating the under utilization of a shared resource over time using static throttling according to the prior art. In FIG. 1A, the foreground process is assumed to be a database server, the background process is assumed to be a backup process, and the shared resource is the CPU. As depicted in FIG. 1A, much of the utilization of the shared resource is missed.
FIG. 1B is a graph illustrating the over utilization of a shared resource using static throttling according to the prior art. As shown in FIG. 1B, at around 160 seconds, the limit of the shared resource is reached. Hitting the limit of the shared resource in this manner will cause the foreground processes to slow down, as the background processes are competing directly against the foreground processes for access to the shared resource. This unfortunate situation will result in performance degradation of the foreground processes and will slow down the computer system in a meaningful and noticeable way.
Another approach for managing the execution rate of background processes is called “deadline.” In the “deadline” approach, an arbitrary deadline for when an IO is to occur is specified. For example, a process may be internally designated a one second deadline in which the IO operation requested by the process must occur. A scheduler may optimize the order in which IOs are issued as long as the performance of the IO operations still observers their assigned deadline. However, while the order in which IO operations are issued may change, the deadline approach is ineffective against addressing oversaturation of a shared resource, as the deadline approach does not consider how much or how little a shared resource is being used when reordering how IO operations are issued.
Another prior art approach for managing the execution rate of a background process is termed “CFQ,” which stands for Completely Fair Queue. In the CFQ approach, when either a background process or a foreground process desires access to the CPU, each process is assigned to one of a group of queues. Each queue is provided a certain amount of access to the CPU. When it is a particular's queue's turn to access the CPU, the process at the end of that queue is granted access to the CPU. In this way, all processes are provided access to the CPU, but certain higher-priority processes may be provided greater access to the CPU (by virtue of being assigned to a faster moving queue) than other lower-priority processes. However, the CFQ approach is also ineffective against addressing oversaturation of a shared resource, as the CFQ approach does not consider how much or how little a shared resource is being used when assigning processes to queues or determining how frequently IO operations should occur.
Fine Grained Dynamic Throttling
FIG. 2 is a flow chart illustrating the functional steps of fine grained dynamic throttling according to an embodiment of the invention. Advantageously, by performing the steps of FIG. 2, a shared resource may be safely utilized at a higher rate than by prior approaches. Additionally, the steps of FIG. 2 prevent oversaturation of a shared resource so that performance degradation, particularly to foreground processes, will not occur as a result of background processes. The process depicted in FIG. 2 involves frequently monitoring the utilization of a shared resource, and then frequently adjusting the execution rate of background processes to ensure the shared resource is appropriately utilized. For example, the utilization of the shared resource may be checked one hundred times per second, and the use of the shared resource by background processes may be adjusted every ten milliseconds to ensure that the shared resource is not over utilized or underutilized. In this way, the adjustment of the execution rate of the background processes may be performed frequently enough that the execution rate of the background processes will be made with enough time to correct for any overutilization to ensure the quality of service of the foreground processes, also using the shared resource, is not impacted or degraded.
In step 210 of FIG. 1, the utilization of a shared resource that is used by one or more background processes is monitored. The purpose of step 210 is to identify, with precision, how busy is a particular resource that is potentially used by both background and foreground processes.
Embodiments of the invention may be used to monitor a wide-variety of shared resources. Non-limiting, illustrative examples of shared resources which may be monitored in step 210 include one or more central processing units (CPUs), memory, persistent storage, and access to a network resource.
In an embodiment, step 210 may be performed by accessing a statistics information file implemented by an operating system. To illustrate a concrete example, the Linux operating system supports the file “/proc/diskstats,” which is a file that provides statistical information about resources of the computer system running the operating system. The “/proc/diskstats” file is updated with current statistical information about a wide variety of shared resources within a computer system each time the file is accessed. Internally, a function may be called to retrieve the statistical information when the file is read, and so this data is only retrieved as needed and is guaranteed to be current.
Step 210 may be performed frequently by embodiments to ensure that decisions regarding whether to increase or decrease the amount of IO operations issued by background processes are based on accurate data. For example, in one embodiment, step 210 may be performed at least five hundred times each second. In another embodiment, step 210 may be performed at least one thousand times each second. Other embodiments may perform step 210 in the range of one thousand to three thousand times per second. The particular frequency at which step 210 is performed will depend upon the characteristics of the computer system.
To provide a different perspective about how frequently step 210 may be performed by embodiments, in an embodiment, step 210 may be performed at least ten times as often as step 220 is performed. In another embodiment, step 210 may be performed at least one hundred times as often as step 220 is performed.
In step 220, the frequency at which one or more background processes are executed is adjusted without adjusting the frequency in which one or more foreground processes are executed. The purpose of step 220 is to ensure that the utilization of the shared resource is a great as possible without exceeding a threshold value. In certain embodiments, the threshold value may be less than 100% utilization, such as a value between 80-90% or 80-95% (e.g., 90% utilization), to provide some leeway room to ensure the load upon a shared resource is less than 100% of the capacity of the shared resource.
In an embodiment, step 220 is performed frequency to ensure that the utilization of the shared resources is optimized. In this way, the rate of which background resources access a shared resource may be quickly adjusted to ensure that any foreground process has priority to access the shared resource, but any excess capacity of the shared resource is used by background processes. As a result, step 220 may be performed many times each second. For example, to illustrate one example, step 220 may be performed at least eight times a second by one embodiment. Other embodiments may perform step 220 any number from eight to twenty times a second. Other embodiments may perform step 220 fifty or more times a second.
In an embodiment, the frequent adjustment to frequency at which one or more background processes are executed enables shared resources to be better utilized without causing the shared resources to be over utilized. To illustrate this point, consider FIG. 3, which is a graph illustrating the utilization of a shared resource over time for an embodiment of the invention. As shown in FIG. 3, the utilization of the shared resource remains around 90% while one or more background processes are executing. Other embodiments of the invention may be configured to ensure that the utilization of shared resources remains at least a certain level, such as any level between 65%-90% utilization, when one or more background processes are executing.
In an embodiment of the invention, an additional threshold (the “ceiling threshold”) may be established and used. When, in performing step 210, if the shared resource is being utilized greater than the ceiling threshold, then the threshold value used in step 210 may be automatically decreased, without human intervention, so that the shared resource does not exceed 100% utilization. The use of a ceiling threshold may be helpful in those embodiments where there is a lag time between when the threshold value is adjusted and when an impact upon the utilization of the shared resource is felt. If there is a delay in the impact upon the utilization of the shared resource when the threshold is updated, then using a ceiling threshold may be advantages to ensure the utilization of the shared resource stays below 100%.
For example, assume that the threshold value in step 210 is set at 88%. Further assume that the ceiling threshold is set at 95%. If the utilization of the shared resource is determined to exceed the ceiling threshold of 95%, then the threshold value of 88% may be dynamically lowered to ensure that the shared resource does not exceed 100% utilization, which would result in foreground processes having their quality of services diminished.
Computer system will employ many different shared resources and it is contemplated that embodiments may be used with many different numbers and types of shared resources. Further, each shared resource of an embodiment may have a different threshold. Consequently, the threshold associated with one shared resource may be completely independent from the threshold associated with a different resource. For example, persistent storage volume A may correspond to a hard-disk drive and have a threshold of 85% utilization, while persistent storage volume B may correspond to a different hard-disk drive or a solid state device and may have a threshold of 90%.
Note that certain embodiments may expose an interface wherein a user may update or configure the threshold value of a shared resource. In other embodiments, the threshold value of a shared resource may be programmatically determined or updated based upon heuristics and analysis. Such heuristics and analysis may be performed upon data about the shared resources retrieved in step 210.
To illustrate how an embodiment may be used with reference to a shared network resource, assume that two servers, denoted server A and server B, communicate with each over a one gigabyte network link. Further assume that server B becomes inoperable and, at a later point in time, comes back online. Sever A and server B each contained four databases, and the contents of the four databases on server B mirrored the contents of the four databases on server A. When server B comes back online, a recovery process will be initiated for each of the four databases on server B. Data will be copied from server A to server B to synchronize the contents of the four database on server B with the contents of the four databases on server A.
If only one instance of a database were undergoing recovery, then perhaps it could fully utilize the capacity of the communications link. However, traffic related to the recovery process is not the only type of communications carried over the communications link. Since server A and server B are in a cluster, membership communications or heartbeats are also exchanged over the communications link. If a member of the cluster fails to receive a heartbeat from a particular member of the cluster, the member may conclude that the particular member for whom a heartbeat message hasn't been received has gone down, which may be an erroneous conclusion. Thus, the recovery process for each instance needs to be aware that other processes wish to use the communications link. If each recovery process were to be allowed to fully utilize the communications link, the utilization of the communications link may effectively be over 100%, which would negatively impact foreground processes, such as heartbeat messages. Embodiments described herein present a solution by allowing background processes, such as a recovery process, to use only the excess utilization of a shared resource not used by foreground processes.
Embodiments of the invention may be implemented in a variety of different environments and programming entities. For example, embodiments may be implemented in an application or application operating environment.
Dynamic Adjustment of Block Size
Embodiments of the invention may be used to perform certain background processes, such as a backup process, more efficiently than prior approaches. In an embodiment of the invention wherein the background process is coping data, such as when a backup of a database or other data store is made, in addition to performing steps 210 and 220 of FIG. 2, the block size of data copied may be dynamically optimized.
FIG. 4 is a graph illustrating a comparison of bandwidth versus block size according to an embodiment of the invention. As shown in FIG. 4, theoretically, an increase in the bandwidth of a communications link should accommodate a larger block size. At some point, there will be an actual bandwidth limit associated with any physical communications link.
Utilization of persistent storage will increase with block size. However, as shown in FIG. 4, the observed behavior of an optimal block size will vary based on the available bandwidth of a communications link. Therefore, embodiments of the invention may dynamically determine a block size in which data should be copied or otherwise carried over a communications link based upon the available bandwidth in the communications link at that point in time.
Thus, in an embodiment, after performing step 210, alternatively or in addition to performing step 220, the block size of data copied by a background process is dynamically adjusted based upon the utilization for a shared resource, such as a communications link.
Implementing Mechanisms
In an embodiment, embodiments of the invention may be implemented on or using a computer system. FIG. 5 is a block diagram that illustrates a computer system 500 upon which an embodiment of the invention may be implemented. In an embodiment, computer system 400 includes processor 504, main memory 506, ROM 508, storage device 510, and communication interface 518. Computer system 500 includes at least one processor 504 for processing information. Computer system 500 also includes a main memory 506, such as a random access memory (RAM) or other dynamic storage device, for storing information and instructions to be executed by processor 504. Main memory 506 also may be used for storing temporary variables or other intermediate information during execution of instructions to be executed by processor 504. Computer system 500 further includes a read only memory (ROM) 508 or other static storage device for storing static information and instructions for processor 504. A storage device 510, such as a magnetic disk or optical disk, is provided for storing information and instructions.
Computer system 500 may be coupled to a display 512, such as a cathode ray tube (CRT), a LCD monitor, and a television set, for displaying information to a user. An input device 514, including alphanumeric and other keys, is coupled to computer system 500 for communicating information and command selections to processor 504. Other non-limiting, illustrative examples of input device 514 include a mouse, a trackball, or cursor direction keys for communicating direction information and command selections to processor 504 and for controlling cursor movement on display 512. While only one input device 514 is depicted in FIG. 5, embodiments of the invention may include any number of input devices 514 coupled to computer system 500.
Embodiments of the invention are related to the use of computer system 500 for implementing the techniques described herein. According to one embodiment of the invention, those techniques are performed by computer system 500 in response to processor 504 executing one or more sequences of one or more instructions contained in main memory 506. Such instructions may be read into main memory 506 from another machine-readable medium, such as storage device 510. Execution of the sequences of instructions contained in main memory 506 causes processor 504 to perform the process steps described herein. In alternative embodiments, hard-wired circuitry may be used in place of or in combination with software instructions to implement embodiments of the invention. Thus, embodiments of the invention are not limited to any specific combination of hardware circuitry and software.
The term “machine-readable storage medium” as used herein refers to any medium that participates in storing instructions which may be provided to processor 504 for execution. Such a medium may take many forms, including but not limited to, non-volatile media and volatile media. Non-volatile media includes, for example, optical or magnetic disks, such as storage device 510. Volatile media includes dynamic memory, such as main memory 506.
Non-limiting, illustrative examples of machine-readable media include, for example, a floppy disk, a flexible disk, hard disk, magnetic tape, or any other magnetic medium, a CD-ROM, any other optical medium, a RAM, a PROM, and EPROM, a FLASH-EPROM, any other memory chip or cartridge, or any other medium from which a computer can read.
Various forms of machine readable media may be involved in carrying one or more sequences of one or more instructions to processor 504 for execution. For example, the instructions may initially be carried on a magnetic disk of a remote computer. The remote computer can load the instructions into its dynamic memory and send the instructions over a network link 520 to computer system 500.
Communication interface 518 provides a two-way data communication coupling to a network link 520 that is connected to a local network. For example, communication interface 518 may be an integrated services digital network (ISDN) card or a modem to provide a data communication connection to a corresponding type of telephone line. As another example, communication interface 518 may be a local area network (LAN) card to provide a data communication connection to a compatible LAN. Wireless links may also be implemented. In any such implementation, communication interface 518 sends and receives electrical, electromagnetic or optical signals that carry digital data streams representing various types of information.
Network link 520 typically provides data communication through one or more networks to other data devices. For example, network link 520 may provide a connection through a local network to a host computer or to data equipment operated by an Internet Service Provider (ISP).
Computer system 500 can send messages and receive data, including program code, through the network(s), network link 520 and communication interface 518. For example, a server might transmit a requested code for an application program through the Internet, a local ISP, a local network, subsequently to communication interface 518. The received code may be executed by processor 504 as it is received, and/or stored in storage device 510, or other non-volatile storage for later execution.
In the foregoing specification, embodiments of the invention have been described with reference to numerous specific details that may vary from implementation to implementation. Thus, the sole and exclusive indicator of what is the invention, and is intended by the applicants to be the invention, is the set of claims that issue from this application, in the specific form in which such claims issue, including any subsequent correction. Any definitions expressly set forth herein for terms contained in such claims shall govern the meaning of such terms as used in the claims. Hence, no limitation, element, property, feature, advantage or attribute that is not expressly recited in a claim should limit the scope of such claim in any way. The specification and drawings are, accordingly, to be regarded in an illustrative rather than a restrictive sense.

## Claims

1. One or more computer readable non-transitory storage mediums storing one or more sequences of instructions, which when executed by one or more processors, cause:
monitoring utilization of a shared resource by one or more background processes and one or more foreground processes, wherein the one or more foreground processes and the one or more background process execute at respective frequencies of execution;
dynamically adjusting a frequency at which the one or more background processes are executed based on a comparison of a current utilization of the shared resource with a threshold value, without adjusting the frequency in which the one or more foreground processes are executed, the dynamically adjusting including decreasing the frequency of the one or more background processes in accordance with a determination that the current utilization is above the threshold value;
determining, without user input, whether the monitored utilization of the shared resource exceeds a ceiling threshold value which is greater than the threshold value, wherein the threshold value and the ceiling threshold value correspond to resource utilization levels;
in accordance with a determination that the monitored utilization of the shared resource exceeds the ceiling threshold value, updating, without user input, the threshold value; and
dynamically adjusting a frequency at which the one or more background processes are executed based on a comparison of the current utilization of the shared resource with the updated threshold value.

2. The one or more computer readable non-transitory storage mediums of claim 1, wherein monitoring is performed at least five hundred times each second.

3. The one or more computer readable non-transitory storage mediums of claim 1, wherein monitoring is performed at least one thousand times each second.

4. The one or more computer readable non-transitory storage mediums of claim 1, wherein monitoring is performed at least ten times as often as dynamically adjusting is performed.

5. The one or more computer readable non-transitory storage mediums of claim 1, wherein monitoring is performed at least one hundred times as often as dynamically adjusting is performed.

6. The one or more computer readable non-transitory storage mediums of claim 1, wherein dynamically adjusting is performed at least eight times a second.

7. The one or more computer readable non-transitory storage mediums of claim 1, wherein the threshold value is a particular value in a range of 80% to 90% of the utilization capacity of the shared resource.

8. The one or more computer readable non-transitory storage mediums of claim 1, wherein each of the one or more background processes is a process designed to run in the background to perform a supportive function to a foreground process, and wherein each of the one or more foreground processes is a process that interacts with a user, performs application level activity, or provides functionality central to the role of a device upon which the process executes.

9. The one or more computer readable non-transitory mediums of claim 1, wherein the shared resource is one or more central processing units (CPUs).

10. The one or more computer readable non-transitory storage mediums of claim 1, wherein the shared resource is memory.

11. The one or more computer readable non-transitory storage mediums of claim 1, wherein the shared resource is persistent storage.

12. The one or more computer readable non-transitory storage mediums of claim 1, wherein the shared resource is a network resource.

13. The one or more computer readable non-transitory storage mediums of claim 1, further comprising dynamically adjusting a block size of data copied by a background process based upon the monitored utilization for a shared communications resource.

14. The one or more computer readable non-transitory storage mediums of claim 1, wherein monitoring the utilization of the shared resource comprises accessing a statistics information file implemented by an operating system.

15. The one or more computer readable non-transitory storage mediums of claim 1, wherein execution of the one or more sequences of instructions, which when executed, further cause the utilization of the shared resource to be at least 65% when the one or more background processes are executing.

16. A method for throttling backgrounds processes to a high degree of precision, comprising:
monitoring utilization of a shared resource by one or more background processes and one or more foreground processes, wherein the one or more foreground processes and the one or more background process execute at respective frequencies of execution;
dynamically adjusting a frequency at which the one or more background processes are executed based on a comparison of a current utilization of the shared resource with a threshold value, without adjusting the frequency in which the one or more foreground processes are executed, the dynamically adjusting including decreasing the frequency of the one or more background processes in accordance with a determination that the current utilization is above the threshold value;
determining, without user input, whether the monitored utilization of the shared resource exceeds a ceiling threshold value which is greater than the threshold value, wherein the threshold value and the ceiling threshold value correspond to resource utilization levels;
in accordance with a determination that the monitored utilization of the shared resource exceeds the ceiling threshold value, updating, without user input, the threshold value; and
dynamically adjusting a frequency at which the one or more background processes are executed based on a comparison of the current utilization of the shared resource with the updated threshold value.

17. An apparatus, comprising:
one or more processors; and
one or more computer readable storage medium storing one or more sequences, which when executed by the one or more processors, cause:
monitoring utilization of a shared resource by one or more background processes and one or more foreground processes, wherein the one or more foreground processes and the one or more background process execute at respective frequencies of execution;
dynamically adjusting a frequency at which the one or more background processes are executed based on a comparison of a current utilization of the shared resource with a threshold value, without adjusting the frequency in which the one or more foreground processes are executed, the dynamically adjusting including decreasing the frequency of the one or more background processes in accordance with a determination that the current utilization is above the threshold value;
determining, without user input, whether the monitored utilization of the shared resource exceeds a ceiling threshold value which is greater than the threshold value, wherein the threshold value and the ceiling threshold value correspond to resource utilization levels;
in accordance with a determination that the monitored utilization of the shared resource exceeds the ceiling threshold value, updating, without user input, the threshold value; and
dynamically adjusting a frequency at which the one or more background processes are executed based on a comparison of the current utilization of the shared resource with the updated threshold value.

18. The apparatus of claim 17, wherein the shared resource is one or more central processing units (CPUs).

19. The apparatus of claim 17, wherein the shared resource is memory.

20. The apparatus of claim 17, wherein the monitoring is performed at least ten times as often as the dynamically adjusting is performed.