Search

CN-121996573-A - Resource allocation method and related equipment

CN121996573ACN 121996573 ACN121996573 ACN 121996573ACN-121996573-A

Abstract

The application provides a resource allocation method and related equipment, and relates to the technical field of computers. The resource allocation method comprises the steps of responding to a first operation of a user, starting a first application, obtaining a buffer partition strategy corresponding to a preset type if the first application is the application of the preset type, partitioning a buffer based on the buffer partition strategy, dividing the buffer into a plurality of buffer partitions, obtaining buffer information of threads of the first application, wherein the buffer information comprises buffer utilization rate and/or buffer bandwidth, and adjusting the capacity of the buffer partition corresponding to the first application under the condition that the buffer information of the threads of the first application meets preset conditions. By using the method, the capacity of the cache partition corresponding to the application of the preset type can be adaptively adjusted, the cache requirement of the thread of the application of the preset type is preferentially ensured, and the maximum utilization of the cache resource is achieved.

Inventors

  • ZHAO SHIPENG

Assignees

  • 荣耀终端股份有限公司

Dates

Publication Date
20260508
Application Date
20241106

Claims (16)

  1. 1. A resource allocation method applied to an electronic device, the method comprising: in response to a first operation of a user, starting a first application; if the first application is an application of a preset type, acquiring a cache partition strategy corresponding to the preset type; Partitioning a cache based on the cache partition strategy, and dividing the cache into a plurality of cache partitions; Obtaining cache information of threads of the first application, wherein the cache information comprises a cache utilization rate and/or a cache bandwidth; And under the condition that the cache information of the thread of the first application meets the preset condition, adjusting the capacity of the cache partition corresponding to the first application.
  2. 2. The resource allocation method of claim 1, wherein the cache partitioning policy comprises a plurality of cache partitioning sub-policies, the partitioning of the cache based on the cache partitioning policy comprising: acquiring type information corresponding to an application running in the electronic equipment; Determining a cache partition sub-strategy corresponding to the type information from the cache partition strategy; partitioning the cache based on the determined cache partition sub-policy.
  3. 3. The method for allocating resources according to claim 1 or 2, wherein the preset condition includes that a cache utilization rate of a thread of the first application is smaller than a first threshold value, or a cache bandwidth of the thread of the first application is larger than a second threshold value, and adjusting a capacity of a cache partition corresponding to the first application includes: and increasing the capacity of the cache partition corresponding to the first application.
  4. 4. The method of claim 1 or 2, wherein the preset condition includes that a cache utilization of a thread of the first application gradually decreases until the cache utilization is smaller than a first threshold value in a first preset duration, or that a cache bandwidth of the thread of the first application gradually increases until the cache bandwidth is larger than a second threshold value in a second preset duration, and the adjusting the capacity of a cache partition corresponding to the first application includes: and increasing the capacity of the cache partition corresponding to the first application.
  5. 5. The method for allocating resources as defined in claim 3 or 4, wherein the preset types include a first type and a second type, and the increasing the capacity of the cache partition corresponding to the first application includes: If the first application is the first type of application, increasing the capacity of the cache partition corresponding to the first application by a first preset percentage; If the first application is the second type of application, increasing the capacity of the cache partition corresponding to the first application by a second preset percentage, wherein the first preset percentage is larger than the second preset percentage.
  6. 6. The method for allocating resources according to claim 3 or 4, wherein said increasing the capacity of the cache partition corresponding to the first application includes: And under the condition that capacity reduction space exists in other cache partitions except the cache partition corresponding to the first application, increasing the capacity of the cache partition corresponding to the first application.
  7. 7. The method for allocating resources as defined in claim 3 or 4, wherein the applications run by the electronic device include a plurality of types, each type of application corresponds to a cache partition, and each cache partition corresponds to a cache supply priority, and the increasing the capacity of the cache partition corresponding to the first application includes: Under the condition that other cache partitions except the cache partition corresponding to the first application correspond to a plurality of cache supply priorities, determining a first target cache partition from the other cache partitions, wherein the first target cache partition is the cache partition with the lowest cache supply priority among the cache partitions with capacity reduction spaces; and reducing the capacity of the first target cache partition and increasing the capacity of the cache partition corresponding to the first application.
  8. 8. The method for allocating resources according to claim 1 or 2, wherein the preset condition includes that a cache utilization rate of a thread of the first application is greater than or equal to a third threshold value, and a cache bandwidth of the thread of the first application is less than or equal to a fourth threshold value, and the adjusting the capacity of the cache partition corresponding to the first application when the cache information of the thread of the first application satisfies the preset condition includes: and under the condition that the cache information of the thread of the first application meets the preset condition and lasts for a third preset duration, reducing the capacity of the cache partition corresponding to the first application.
  9. 9. The method of allocating resources according to claim 8, wherein the reducing the capacity of the cache partition corresponding to the first application includes: And reducing the capacity of the cache partition corresponding to the first application by a third preset percentage, wherein the third preset percentage is smaller than the percentage adopted by the cache partition corresponding to the first application when the capacity is increased.
  10. 10. The method of claim 8, wherein the application executed by the electronic device includes a plurality of types, each type of application corresponds to a cache partition, each cache partition corresponds to a cache provisioning priority, and the reducing the capacity of the cache partition corresponding to the first application includes: under the condition that other cache partitions except the cache partition corresponding to the first application correspond to a plurality of cache supply priorities, determining a second target cache partition from the other cache partitions, wherein the second target cache partition is the cache partition with the highest cache supply priority among the cache partitions with capacity increasing space; and reducing the capacity of the cache partition corresponding to the first application, and increasing the capacity of the second target cache partition.
  11. 11. The method of allocating resources according to claim 8, wherein the reducing the capacity of the cache partition corresponding to the first application includes: And reducing the capacity of the buffer partition corresponding to the first application under the condition that the capacity of the buffer partition corresponding to the first application is larger than a preset capacity, wherein the preset capacity is the capacity of the buffer partition strategy configured for the buffer partition corresponding to the first application.
  12. 12. A resource allocation method applied to an electronic device, the method comprising: Acquiring type information of a plurality of threads running in the electronic equipment; Determining a cache partition strategy based on the type information of the threads; Partitioning a cache based on the cache partition strategy, and dividing the cache into a plurality of cache partitions; Obtaining cache information of a target thread in the plurality of threads, wherein the cache information comprises a cache utilization rate and/or a cache bandwidth; And under the condition that the cache information of the target thread meets the preset condition, adjusting the capacity of the cache partition corresponding to the target thread.
  13. 13. The method for allocating resources according to claim 12, wherein the target thread is a thread of a preset type of application, and the adjusting the capacity of the cache partition corresponding to the target thread if the cache information of the target thread meets a preset condition includes: Increasing the capacity of a cache partition corresponding to the target thread under the condition that the cache information of the target thread meets a first preset condition, wherein the first preset condition comprises that the cache utilization rate of the target thread is smaller than a first threshold value or the cache bandwidth of the target thread is larger than a second threshold value; And under the condition that the cache information of the target thread meets a second preset condition, reducing the capacity of a cache partition corresponding to the target thread, wherein the second preset condition comprises that the cache utilization rate of the target thread is greater than or equal to a third threshold value and the cache bandwidth of the target thread is less than or equal to a fourth threshold value.
  14. 14. The cache chip is characterized by comprising a cache memory, a cache controller, a cache utilization monitor and a cache bandwidth monitor: The cache memory is used for storing data; The cache utilization rate monitor is used for monitoring the cache utilization rate of the target thread; the buffer bandwidth monitor is used for monitoring the buffer bandwidth of the target thread; The cache controller is used for partitioning the cache memory based on a pre-configured cache partition strategy, and dividing the cache memory into a plurality of cache partitions; the cache controller is further configured to adjust a capacity of a cache partition corresponding to the target thread based on a monitoring result of the cache utilization monitor and/or the cache bandwidth monitor.
  15. 15. An electronic device comprising a memory and a processor; the memory is coupled to the processor; the memory is used for storing program instructions; The processor is configured to read the program instructions stored in the memory to implement the resource allocation method according to any one of claims 1 to 11 or to implement the resource allocation method according to any one of claims 12 to 13.
  16. 16. A computer readable storage medium, characterized in that the computer readable storage medium has stored therein computer readable instructions, which when executed by a processor, implement the resource allocation method according to any one of claims 1 to 11 or the resource allocation method according to any one of claims 12 to 13.

Description

Resource allocation method and related equipment Technical Field The present application relates to the field of computer technologies, and in particular, to a resource allocation method and related devices. Background Cache (Cache) partitioning mechanism is a technique that divides the Cache space into multiple independent portions, each of which can be managed independently. The threads can be isolated from each other or the buffer capacity used by the threads can be limited by a buffer partition mechanism. In the related art, corresponding cache partitions are set for different types of threads through offline preset cache partition strategies. Because the running conditions of the electronic equipment are complex and changeable, the maximum utilization of the cache resources cannot be realized by an off-line preset mode. Disclosure of Invention In view of the foregoing, it is desirable to provide a resource allocation method and related devices to maximize the utilization of cache resources. The application provides a resource allocation method which is applied to electronic equipment and comprises the steps of starting a first application in response to first operation of a user, obtaining a cache partition strategy corresponding to a preset type if the first application is the application of the preset type, partitioning a cache based on the cache partition strategy, dividing the cache into a plurality of cache partitions, obtaining cache information of threads of the first application, wherein the cache information comprises cache utilization rate and/or cache bandwidth, and adjusting the capacity of the cache partition corresponding to the first application under the condition that the cache information of the threads of the first application meets preset conditions. By adopting the technical scheme, when the electronic equipment runs the application of the preset type in an off-line preset mode, the corresponding cache partition strategy is configured, so that when the application of the preset type is identified to run, the cache can be automatically partitioned according to the preset cache partition strategy, cache competition among different threads during the running of the application of the preset type can be avoided to the greatest extent, and the cache requirement of the threads of the application of the preset type is preferentially ensured by monitoring the cache utilization rate and/or the cache bandwidth of the threads of the application of the preset type, so that the cache resource is maximally utilized. The preset type of application may be defined according to an actual scene cache guarantee requirement, for example, the preset type of application may include a game type application. In one possible implementation, the cache partition strategy comprises a plurality of cache partition sub-strategies, and the cache is partitioned based on the cache partition strategy, and the method comprises the steps of obtaining type information corresponding to an application running in the electronic equipment, determining the cache partition sub-strategy corresponding to the type information from the cache partition strategy, and partitioning the cache based on the determined cache partition sub-strategy. By adopting the technical scheme, under the condition that the started application is of a certain preset type, different cache partition sub-strategies can be set, the cache partition requirement of the fine partition of the application type is met, and the cache competition among threads of different types can be avoided to the greatest extent. In one possible implementation manner, the preset condition includes that the cache utilization rate of the thread of the first application is smaller than a first threshold value, or the cache bandwidth of the thread of the first application is larger than a second threshold value, and the capacity of the cache partition corresponding to the first application is adjusted, namely the capacity of the cache partition corresponding to the first application is increased. By adopting the technical scheme, if the cache utilization rate of the thread of the first application is smaller than the first threshold value or the cache bandwidth is larger than the second threshold value, the hit rate of the data of the thread of the first application in the cache is low, the cache bandwidth of the thread of the first application is reduced or the cache utilization rate of the thread of the first application is improved by configuring more cache capacity for the cache partition corresponding to the thread of the first application, the maximum capacity release of the cache is achieved, and the experience of a user in using the first application is improved. In one possible implementation manner, the preset condition includes that the cache utilization rate of the thread of the first application is gradually reduced within a first preset duration until the cache utili