Resource allocation method and related equipment

By monitoring cache utilization and bandwidth, and adaptively adjusting the cache partition capacity, the problem of insufficient cache resource utilization is solved, achieving efficient utilization of cache resources and improving user experience.

CN121996573APending Publication Date: 2026-05-08HONOR DEVICE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
HONOR DEVICE CO LTD
Filing Date
2024-11-06
Publication Date
2026-05-08

AI Technical Summary

Technical Problem

In existing technologies, offline pre-configured cache partitioning strategies cannot maximize the utilization of cache resources, resulting in poor cache performance.

Method used

By monitoring the cache utilization and cache bandwidth of threads, the capacity of the cache partition is adaptively adjusted to prioritize the caching needs of preset application types, thereby maximizing the utilization of cache resources.

Benefits of technology

Effectively avoid cache contention, improve user experience, and ensure efficient use of cache resources, especially prioritizing the smooth operation of critical applications in high-demand scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121996573A_ABST
    Figure CN121996573A_ABST
Patent Text Reader

Abstract

The invention provides a resource allocation method and related equipment, and relates to the technical field of computers. The resource allocation method comprises the steps of starting a first application in response to a first operation of a user; if the first application is the application of the preset type, obtaining a cache partitioning strategy corresponding to the preset type, partitioning a cache based on the cache partitioning strategy, and dividing the cache into a plurality of cache partitions; obtaining cache information of a thread 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 a preset condition, adjusting the capacity of a cache partition corresponding to the first application. By means of the method, the capacity of the cache partition corresponding to the application of the preset type can be adjusted in a self-adaptive mode, the cache requirement of the thread of the application of the preset type is guaranteed preferentially, and maximum utilization of cache resources is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a resource allocation method and related equipment. Background Technology

[0002] Cache partitioning is a technique that divides cache space into multiple independent parts, each of which can be managed independently. Cache partitioning can isolate threads from each other or limit the cache capacity used by a thread.

[0003] In related technologies, offline pre-configured cache partitioning strategies are used to set corresponding cache partitions for different types of threads. However, due to the complex and variable operating conditions of electronic devices, offline pre-configuration cannot maximize the utilization of cache resources. Summary of the Invention

[0004] In view of the above, it is necessary to provide a resource allocation method and related equipment to maximize the utilization of cache resources.

[0005] In a first aspect, this application provides a resource allocation method applied to an electronic device. The resource allocation method includes: responding to a first operation by a user, launching a first application; if the first application is an application of a preset type, obtaining a cache partitioning strategy corresponding to the preset type, partitioning the cache based on the cache partitioning strategy, and dividing the cache into multiple cache partitions; obtaining cache information of the threads of the first application, the cache information including cache utilization and / or cache bandwidth; and adjusting the capacity of the cache partition corresponding to the first application when the cache information of the threads of the first application meets preset conditions.

[0006] By employing the above technical solution, corresponding cache partitioning strategies are configured offline for electronic devices running preset types of applications. This allows for automatic cache partitioning according to the preset strategy upon detecting the application's runtime, minimizing cache contention between different threads during application execution. Furthermore, by monitoring the cache utilization and / or bandwidth of the application's threads, the system adaptively adjusts the capacity of the corresponding cache partitions, prioritizing the caching needs of the application's threads and maximizing cache resource utilization. The preset application types can be defined based on actual cache protection requirements. For example, for game scenarios with cache protection requirements, the preset application type could include game applications.

[0007] In one possible implementation, the cache partitioning strategy includes multiple cache partitioning sub-strategies. Partitioning the cache based on the cache partitioning strategy includes: obtaining type information corresponding to the application running on the electronic device; determining the cache partitioning sub-strategy corresponding to the type information from the cache partitioning strategy; and partitioning the cache based on the determined cache partitioning sub-strategy.

[0008] By adopting the above technical solution, when the application being launched is a certain preset type of application, different cache partitioning sub-strategies can be set to meet the cache partitioning requirements of fine-grained division of application types, and cache contention between different types of threads can be avoided to the greatest extent.

[0009] In one possible implementation, the preset conditions include that the cache utilization of the first application's thread is less than a first threshold, or the cache bandwidth of the first application's thread is greater than a second threshold, and the capacity of the cache partition corresponding to the first application is adjusted: the capacity of the cache partition corresponding to the first application is increased.

[0010] Using the above technical solution, if the cache utilization rate of the first application's thread is less than the first threshold, or the cache bandwidth is greater than the second threshold, it indicates that the data hit rate of the first application's thread in the cache is not high. By configuring more cache capacity for the cache partition corresponding to the first application's thread, the cache bandwidth of the first application's thread can be reduced, or the cache utilization rate of the first application's thread can be improved, thereby maximizing the release of cache capacity and improving the user experience when using the first application.

[0011] In one possible implementation, the preset conditions include the cache utilization rate of the first application's thread gradually decreasing within a first preset time period until it is less than a first threshold, or the cache bandwidth of the first application's thread gradually increasing within a second preset time period until it is greater than a second threshold, and adjusting the capacity of the cache partition corresponding to the first application, including: increasing the capacity of the cache partition corresponding to the first application.

[0012] By adopting the above technical solution, not only can the maximum capacity of the cache be released, improving the user experience of using the first application, but it can also avoid the problem of erroneously adjusting the capacity of the corresponding cache partition due to the instantaneous fluctuations in the cache utilization rate / cache bandwidth of the first application's threads.

[0013] In one possible implementation, the preset types include a first type and a second type. Increasing the capacity of the cache partition corresponding to the first application includes: if the first application is a first type application, increasing the capacity of the cache partition corresponding to the first application by a first preset percentage; if the first application is a second type application, increasing the capacity of the cache partition corresponding to the first application by a second preset percentage, wherein the first preset percentage is greater than the second preset percentage.

[0014] By adopting the above technical solution, since different types of applications have different data fluctuation levels, or different types of applications have different smoothness or latency requirements, by setting different percentages for capacity adjustment for different types of applications, it is possible to increase the capacity of the corresponding cache partition by different percentages in different scenarios. This avoids the problem of increasing the capacity of the cache partition too much and affecting the operation of other threads, or increasing it too little and requiring multiple adjustments.

[0015] In one possible implementation, increasing the capacity of the cache partition corresponding to the first application includes: increasing the capacity of the cache partition corresponding to the first application when there is room for capacity reduction in other cache partitions besides the cache partition corresponding to the first application.

[0016] Using the above technical solution, since the total capacity of the cache is fixed, if there is room for capacity reduction in other cache partitions besides the cache partition corresponding to the first application, it means that the capacity of the cache partition corresponding to the first application can be increased by reducing the capacity of other cache partitions, thus avoiding the problem of failure to increase the capacity of the cache partition corresponding to the first application.

[0017] In one possible implementation, the applications running on the electronic device include multiple types, each type of application corresponds to a cache partition, and each cache partition corresponds to a cache supply priority. Increasing the capacity of the cache partition corresponding to the first application includes: in the case where other cache partitions besides the cache partition corresponding to the first application correspond to multiple cache supply priorities, determining a first target cache partition from the other cache partitions, the first target cache partition being the cache partition with the lowest cache supply priority among the cache partitions with capacity reduction space; reducing the capacity of the first target cache partition and increasing the capacity of the cache partition corresponding to the first application.

[0018] By adopting the above technical solution, the capacity of the cache partition with low cache supply priority can be reduced first, so as to increase the capacity of the cache partition corresponding to the first application, thereby prioritizing the caching needs of the first application's thread and other threads with higher priority.

[0019] In one possible implementation, the preset conditions include that the cache utilization rate of the first application's thread is greater than or equal to a first threshold, and the cache bandwidth of the first application's thread is less than or equal to a second threshold. When the cache information of the first application's thread meets the preset conditions, adjusting the capacity of the cache partition corresponding to the first application includes: reducing the capacity of the cache partition corresponding to the first application when the cache information of the first application's thread meets the preset conditions and continues for a third preset duration.

[0020] Using the above technical solution, if the cache information of the first application's thread meets the preset conditions and continues for a third preset duration, it can be indicated that the first application's thread has exited the high cache requirement. By reducing the cache capacity of the cache partition corresponding to the first application's thread, the cache capacity of the cache partition corresponding to other threads can be increased, which can improve the running smoothness of other threads and avoid the problem of erroneously adjusting the capacity of the corresponding cache partition due to the instantaneous fluctuation of the cache utilization / cache bandwidth of the first application's thread.

[0021] In one possible implementation, reducing the capacity of the cache partition corresponding to the first application includes: reducing the capacity of the cache partition corresponding to the first application by a third preset percentage, wherein the third preset percentage is less than the percentage used when increasing the capacity of the cache partition corresponding to the first application.

[0022] By adopting the above technical solution, by setting the decrease rate of the cache capacity of the cache partition corresponding to the thread of the first application to be lower than the increase rate, the situation of the cache capacity being immediately triggered to increase after the cache capacity is reduced can be avoided to the greatest extent.

[0023] In one possible implementation, the electronic device runs multiple types of applications, each type of application corresponds to a cache partition, and each cache partition corresponds to a cache supply priority. Reducing the capacity of the cache partition corresponding to the first application includes: in the case where other cache partitions besides the cache partition corresponding to the first application correspond to multiple cache supply priorities, determining a second target cache partition from the other cache partitions, the second target cache partition being the cache partition with the highest cache supply priority among the cache partitions with room for capacity increase; reducing the capacity of the cache partition corresponding to the first application, and increasing the capacity of the second target cache partition.

[0024] By adopting the above technical solution, when reducing the capacity of the cache partition corresponding to the first application, the capacity of other cache partitions with higher cache supply priority can be increased first, so as to prioritize the cache needs of the first application's threads and other threads with higher priority.

[0025] In one possible implementation, reducing the capacity of the cache partition corresponding to the first application includes: reducing the capacity of the cache partition corresponding to the first application when the capacity of the cache partition corresponding to the first application is greater than a preset capacity, wherein the preset capacity is the capacity configured for the cache partition corresponding to the first application according to the cache partition strategy.

[0026] By adopting the above technical solution, the capacity of the cache partition corresponding to the first application can be reduced to below the initially configured cache capacity, thus avoiding affecting the operation of the threads of the first application.

[0027] Secondly, this application provides a resource allocation method applied to an electronic device. The resource allocation method includes: obtaining type information of multiple threads running in the electronic device; determining a cache partitioning strategy based on the type information of the multiple threads; partitioning the cache based on the cache partitioning strategy to divide the cache into multiple cache partitions; obtaining cache information of a target thread among the multiple threads, the cache information including cache utilization and / or cache bandwidth; and adjusting the capacity of the cache partition corresponding to the target thread when the cache information of the target thread meets preset conditions.

[0028] By adopting the above technical solution, the corresponding cache partitioning strategy is configured for the currently running thread through offline pre-configuration. This allows the electronic device to automatically partition the cache according to the type information of all currently running threads using the corresponding cache partitioning strategy. This can minimize cache contention between threads. Furthermore, by monitoring the cache utilization and / or cache bandwidth of the target thread, the capacity of the cache partition corresponding to the target thread can be adaptively adjusted to prioritize the cache needs of the target thread and maximize the utilization of cache resources.

[0029] In one possible implementation, the target thread is a thread of a predefined application. When the cached information of the target thread meets predefined conditions, the capacity of the cache partition corresponding to the target thread is adjusted, including: increasing the capacity of the cache partition corresponding to the target thread when the cached information of the target thread meets a first predefined condition, the first predefined condition including the cache utilization rate of the target thread being less than a first threshold, or the cache bandwidth of the target thread being greater than a second threshold; and decreasing the capacity of the cache partition corresponding to the target thread when the cached information of the target thread meets a second predefined condition, the second predefined condition including the cache utilization rate of the target thread being greater than or equal to a third threshold, and the cache bandwidth of the target thread being less than or equal to a fourth threshold.

[0030] By adopting the above technical solution, the capacity of the cache partition corresponding to the thread of the preset type application can be adaptively adjusted. When the thread of the preset type application is in a high cache demand situation, the cache demand of the thread of the preset type application is prioritized to maximize the utilization of cache resources. When the thread of the preset type application exits the high cache demand situation, the cache capacity of the cache partition corresponding to the thread of the preset type application is reduced, so as to increase the cache capacity of the cache partition corresponding to other threads, thereby improving the running smoothness of other threads.

[0031] Thirdly, this application provides a cache chip, which includes a cache memory, a cache controller, a cache utilization monitor, and a cache bandwidth monitor. The cache memory is used to store data, the cache utilization monitor is used to monitor the cache utilization of a target thread, the cache bandwidth monitor is used to monitor the cache bandwidth of the target thread, the cache controller is used to partition the cache memory based on a pre-configured cache partitioning strategy, dividing the cache memory into multiple cache partitions, and the cache controller is also used to adjust the capacity of the cache partition corresponding to the target thread based on the monitoring results of the cache utilization monitor and / or the cache bandwidth monitor.

[0032] By adopting the above technical solution, the cache memory is partitioned through an offline pre-configured cache partitioning strategy, which can minimize cache contention between threads. Furthermore, by configuring a cache utilization monitor and a cache bandwidth monitor, the cache utilization and / or cache bandwidth of the target thread can be monitored. This allows the cache chip to adaptively adjust the capacity of the cache partition corresponding to the target thread, thereby prioritizing the cache needs of the target thread and maximizing the utilization of cache resources.

[0033] Fourthly, this application provides an electronic device, which includes a memory and a processor; the memory and the processor are coupled; the memory is used to store program instructions; the processor is used to read the program instructions stored in the memory to implement the resource allocation method of the first aspect and its possible implementations, or to implement the resource allocation method of the second aspect and its possible implementations.

[0034] Fifthly, this application provides a computer-readable storage medium storing computer-readable instructions, which, when executed by a processor, implement the resource allocation method of the first aspect and its possible implementations described above, or the resource allocation method of the second aspect and its possible implementations described above.

[0035] Sixthly, this application provides a computer program product containing computer-readable instructions that, when executed by a processor, implement the resource allocation method of the first aspect and its possible implementations described above, or the resource allocation method of the second aspect and its possible implementations described above.

[0036] Furthermore, the technical effects brought about by aspects four through six can be found in the descriptions of the methods in the above-mentioned method section, and will not be repeated here. Attached Figure Description

[0037] Figure 1 A schematic diagram illustrating a possible application scenario provided by an embodiment of this application;

[0038] Figure 2This is a schematic diagram of the architecture of a cache chip provided in one embodiment of this application;

[0039] Figure 3 This is a schematic diagram illustrating cache partitioning and cache partition capacity adjustment of a cache chip according to an embodiment of this application;

[0040] Figure 4 This is a hardware and software architecture diagram of an electronic device provided in an embodiment of this application;

[0041] Figure 5 This is a flowchart illustrating the steps of a resource allocation method provided in an embodiment of this application;

[0042] Figure 6 This is a flowchart illustrating the steps of a resource allocation method according to another embodiment of this application;

[0043] Figure 7 This is a hardware architecture diagram of an electronic device provided in one embodiment of this application. Detailed Implementation

[0044] The technical solutions of the embodiments of this application will now be described with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative effort are within the scope of protection of this application.

[0045] In the following description, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of the embodiments of this application, words such as "exemplary," "or," and "for example" are used to indicate examples, illustrations, or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or design solutions. Specifically, the use of words such as "exemplary," "or," and "for example" is intended to present the relevant concepts in a concrete manner.

[0046] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains. The terminology used in this application's specification is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. It should be understood that, unless otherwise stated, " / " in this application means "or". For example, A / B can mean A or B. "And / or" in this application is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, and B alone. "At least one" means one or more. "More than one" means two or more. For example, at least one of a, b, or c can represent: a, b, c, a and b, a and c, b and c, and a, b, and c. It should be understood that the order of steps shown in the flowcharts herein can be changed, and some can be omitted.

[0047] To facilitate understanding of the embodiments of this application, the technical terms involved in this application will first be introduced:

[0048] Memory partition and monitor (MPAM) is an extended feature for partitioning and monitoring memory system resources to improve resource fairness and performance in shared memory systems.

[0049] Cache: When the computing speed of a computing unit is mismatched with the memory access speed of the storage unit, the computing unit will experience a significant amount of idle time while waiting to access data in the storage unit. Caching technology was developed to address this problem. A cache refers to a storage device capable of high-speed data exchange. Generally, the cache is located between the storage unit (such as external storage, or secondary storage) and the computing unit (such as the CPU). External storage can be, for example, the hard drive of a device, which can be a solid-state disk (SSD) or a hard disk drive (HDD). On the one hand, by pre-loading high-value data from the storage unit into the cache, the computing unit can directly read this high-value data from the cache, which enables high-speed data exchange. This improves the efficiency of the computing unit's access to memory, thereby reducing the idle time of the computing unit and increasing the execution speed of the application (APP). High-value data includes, for example, data recently accessed by the computing unit, data accessed frequently by the computing unit, or working set data, and so on. Here, the working set can be understood as a dataset consisting of all the data required by an application. On the other hand, when an entity writes data to the storage unit, the data to be written can first be written to a cache, and then the cached data can be periodically written to external storage (called disk flushing). The entity can be, for example, an application, a compute node, a client device, or a CPU core, etc., and is not limited to these. In this way, for the entity, writing data to the cache is considered as the completion of the input / output (IO) operation for writing data, which can improve the response speed of the entity.

[0050] Read Hit: Since the size of the cache is generally limited and much smaller than that of external storage, the amount of data that can be stored in the cache is very limited. In a data reading scenario, the I / O request initiated by an entity carries the logical address of the data to be read. That is, the logical address carried in the I / O request is the logical address that the I / O request wants to access. When the cache contains data corresponding to the logical address carried by the I / O request, the I / O request has a read hit in the cache. When the cache does not contain data corresponding to the logical address carried by the I / O request, it means that the I / O request for reading data has not found the data to be read in the cache, i.e., a cache miss occurs. Furthermore, a cache miss can trigger the reading of the data requested by the I / O request from the backend of the cache (such as external storage), and the data read from the backend is cached in the cache. It can be seen that when the I / O request has a read hit in the cache, there is no need to read the data to be read from the backend, thereby improving the response speed of the entity.

[0051] Write Hit: In a write data scenario, the I / O request initiated by an entity carries the data to be written and the logical address for storing the data. That is, the logical address carried in the I / O request is the logical address that the I / O request wants to access. When the physical address corresponding to the logical address carried in the I / O request exists in the cache, it means that data has been written to that logical address before this I / O request and is cached, but has not yet been flushed from the cache to external storage. In this case, the I / O request for writing data is said to have hit the logical address storing the data to be written in the cache, or simply an I / O request write hit in the cache. Furthermore, the cache can update the data already written to that logical address in the cache based on the data to be written carried in this I / O request, and subsequently flush the updated data to external storage. When the physical address corresponding to the logical address carried in the I / O request does not exist in the cache, it means that data has not been written to that logical address before this I / O request, or that data has been written to that logical address before this I / O request and the written data has been flushed from the cache to external storage. In this scenario, an I / O request for writing data misses the logical address in the cache where the data to be written is stored; this is simply referred to as an I / O request write miss in the cache. Subsequently, the cache allocates a corresponding physical address to the logical address carried in the received I / O request and writes the data to be written, carrying the data from the I / O request, to that physical address, thus achieving caching of the data to be written. It is evident that when an I / O request achieves a write hit in the cache, the data already written to the logical address can be updated in the cache, thereby reducing the number of times the cache is flushed to external storage, and thus saving bandwidth between the cache and external storage.

[0052] Caching performance: Caching performance is generally evaluated using hit rates. Read hit rate: The ratio of the number of times an IO request successfully reads from the cache within a given period to the total number of IO read requests within that period. Write hit rate: The ratio of the number of times an IO request successfully writes to the cache within a given period to the total number of IO write requests within that period.

[0053] To avoid cache contention, the cache is typically partitioned, allowing data requested by different types of I / O requests to be cached in different partitions. These different types of I / O requests may be initiated by different threads or threads of different types; this embodiment does not limit this. The thread type can refer to the type of application to which the thread belongs; that is, one type of application corresponds to one type of thread. Due to the complex and varied operating scenarios of electronic devices, setting corresponding cache partitions for different types of threads using offline pre-configured cache partitioning strategies cannot maximize the utilization of cache resources, resulting in poor cache performance.

[0054] In view of this, embodiments of this application provide a resource allocation method that partitions and monitors the cache based on MPAM, and adjusts the cache partitions using the monitoring results of the cache utilization rate and / or cache bandwidth of the target thread, so as to maximize the utilization of cache resources and improve cache performance.

[0055] like Figure 1 The illustration shows a possible application scenario provided by an embodiment of this application, which includes an electronic device 100. The electronic device can be a terminal device such as a mobile phone, tablet computer, laptop computer, or smart wearable device, or a computing device such as an in-vehicle system or server. This application embodiment does not limit the device type of the electronic device 100. For example, Figure 1 The following explanation uses a smartphone as an example of electronic device 100.

[0056] The electronic device 100 has various types of applications installed. The types of applications can be categorized based on the scenarios they correspond to, and this embodiment does not limit this. For example, application types according to scenarios may include: smart office applications (office software, email applications, etc.), chat and communication applications (instant messaging, social applications, etc.), music and video applications (video playback, music playback, live streaming applications, etc.), games, shopping applications (e-commerce, food delivery, group buying applications, etc.), financial applications (payment, banking applications, etc.), news and reading applications (news, novel applications, etc.), travel applications (maps, public transportation, ride-hailing applications, etc.), and system operation applications (applications / processes that maintain the normal operation of the electronic device's operating system), etc.

[0057] In some embodiments, corresponding cache partitioning strategies can be pre-configured for different types of applications running on an electronic device at different times. For example, the pre-configured cache partitioning strategy may include a cache partitioning strategy for running only one type of application, or a cache partitioning strategy for running multiple types of applications simultaneously (the cache capacity for each type of application can be defined).

[0058] For different types of applications, cache provisioning priorities can be further divided based on the immediacy of application data or the user's tolerance for latency / responsiveness. This allows electronic devices to adjust cache partitions based on cache monitoring results, prioritizing cache provisioning for currently active applications or applications currently running in the foreground. In other words, it prioritizes providing cache to threads currently active or those currently running in the foreground.

[0059] For example, different types of applications can be divided into four cache provisioning priorities: first cache provisioning priority, second cache provisioning priority, third cache provisioning priority, and fourth cache provisioning priority. The first cache provisioning priority is high priority, the second cache provisioning priority is middle priority, the third cache provisioning priority is normal priority, and the fourth cache provisioning priority is low priority. Each cache provisioning priority can correspond to one or more types of applications, and the types of applications corresponding to each cache provisioning priority can be set and adjusted according to actual needs. This application embodiment does not limit this.

[0060] Suppose that electronic device 100 responds to the first user's operation and launches a first game application. The display screen currently shows the game interface 101 of the first game application. While the first user is playing the game, a call request prompt box for a second chat application pops up. The first user clicks the answer control in the call request prompt box to make a call with the second user. That is, the first user can play the game using the first game application while simultaneously using the second chat application to talk to the second user. For example, as... Figure 1 As shown, after the first user clicks the answer control in the call request prompt box, the call box 102 is displayed floating on the game interface 101.

[0061] Assume that the electronic device 100 is currently running system applications, a first game application, and a second chat application, and the current corresponding cache partitioning strategy is the first cache partitioning strategy. The game application's threads are pre-configured to have a first cache allocation priority, the chat application's threads have a second cache allocation priority, and the system application's threads have a fourth cache allocation priority. While the first user is playing a game using the first game application and simultaneously communicating with the second user using the second chat application, the cache utilization and / or cache bandwidth of the first game application's threads can be monitored. Based on the monitoring results, the pre-configured first cache partitioning strategy can be adjusted to prioritize cache allocation for the first game application's threads, thereby minimizing stuttering and frame drops in the first game application.

[0062] In some embodiments, the cache utilization rate of a first game application's thread can refer to the cache hit rate of the first game application's data. A decrease in the cache utilization rate of a first game application's thread indicates a lower cache hit rate, requiring more data to be read from external storage. In this case, the cache utilization rate of the first game application's thread can be improved by configuring more cache capacity for the cache partition corresponding to that thread. The cache bandwidth of a first game application's thread can refer to the bandwidth for writing data from external storage to the cache. An increase in the cache bandwidth indicates that more data is being written from external storage to the cache, increasing the amount of data and indirectly reflecting a low cache hit rate. In this case, the cache bandwidth of the first game application's thread can be reduced by configuring more cache capacity for the cache partition corresponding to that thread.

[0063] For example, if the cache utilization rate of the first game application's thread is detected to be less than a first threshold, or the cache bandwidth of the first game application's thread is detected to be greater than a second threshold, the pre-configured first cache partitioning strategy can be adjusted to prioritize cache allocation for the first game application's thread. The first and second thresholds can be set according to actual needs, and this application embodiment does not limit them.

[0064] In some embodiments, after the first user ends the call with the second user, if the applications currently running on the electronic device include system applications and the first game application, the corresponding cache partitioning strategy is changed to the second cache partitioning strategy. In this case, while the first user is playing the game using the first game application, the cache utilization rate and / or cache bandwidth of the first game application's threads can also be monitored. Based on the monitoring results, the pre-configured second cache partitioning strategy is adjusted to prioritize caching for the threads of the first game application, thereby minimizing the occurrence of stuttering, frame drops, and other issues in the first game application.

[0065] In some embodiments, the electronic device 100 may also trigger the execution of a cache partitioning strategy or a cache partitioning adjustment strategy when a preset scenario is detected. Other non-preset scenarios may not require pre-configuration of a cache partitioning strategy or may not require cache partitioning adjustment (i.e., the pre-configured cache partitioning strategy remains unchanged). For example, the electronic device 100 may partition the cache based on a preset cache partitioning strategy in a preset scenario, configuring different cache partitions for threads in different groups. Threads in the same group may refer to applications belonging to the same application or applications of the same type. Preset scenarios can be set according to actual needs, and this application embodiment does not limit this. For example, a preset scenario may refer to a scenario where the application has high requirements for smoothness or latency. Preset scenarios may include game scenarios, video playback scenarios, etc., where high requirements for smoothness or latency are present. A game scenario may refer to the electronic device 100 opening a game application or running a game application in the foreground. A video playback scenario may refer to the electronic device 100 opening a video playback application or running a video playback application in the foreground. Video playback applications include, but are not limited to, video applications, short video applications, live streaming applications, and other applications that play audio and video.

[0066] To enable real-time monitoring of cache utilization and / or cache bandwidth, a cache utilization monitor and a cache bandwidth monitor can be configured in the cache chip.

[0067] like Figure 2 As shown, the cache chip 200 may include a cache memory 201, a cache controller 202, a cache utilization monitor 203, and a cache bandwidth monitor 204. The cache chip 200 may be integrated on a central processing unit (CPU) or on a system-on-chip (SoC), and this embodiment of the application does not limit this. The cache memory 201 may be a storage area composed of static random-access memory (SRAM). The cache controller 202 can be used to adjust cache partitions; for example, the cache controller 202 may dynamically adjust cache partitions based on the monitoring results of the cache utilization monitor 203 and / or the cache bandwidth monitor 204. The cache utilization monitor 203 can be used to monitor the cache utilization of a target thread. The cache bandwidth monitor 204 can be used to monitor the cache bandwidth of a target thread.

[0068] In some embodiments, the target thread may be a thread with a high cache provisioning priority, such as a thread with a first cache provisioning priority. The target thread may also be a thread associated with a preset scenario; for example, the target thread may be a thread of a game application or a video playback application. The target thread may also be a thread of an application running in the foreground.

[0069] In some embodiments, the cache controller 202 can also be used to control the cache utilization monitor 203 and the cache bandwidth monitor 204 to perform corresponding monitoring functions, or to pause the execution of corresponding monitoring functions. For example, the cache controller 202 can control the cache utilization monitor 203 and the cache bandwidth monitor 204 to perform corresponding monitoring functions based on instructions from upper-layer chips (e.g., CPUs) or upper-layer software. The monitoring results of the cache utilization monitor 203 and the cache bandwidth monitor 204 can be reported to the cache controller 202, which then reports the monitoring results to the upper-layer chips or upper-layer software.

[0070] In some embodiments, the cache chip 200 may further include performance counters, such as a byte counter and a cache line counter. The cache utilization monitor 203 can determine cache utilization based on a first sampling window of cache lines and the count value of the cache line counter within the first sampling window. For example, the cache line counter can start and stop counting based on instructions from the cache utilization monitor 203, with the first sampling window being the time window between the start and end of the count. The cache bandwidth monitor 204 can determine cache bandwidth based on a second sampling window of bytes and the count value of the byte counter within the second sampling window. For example, the byte counter can start and stop counting based on instructions from the cache bandwidth monitor 204, with the second sampling window being the time window between the start and end of the count.

[0071] like Figure 3 As shown, the example is a cache partitioning strategy configured for a preset scenario.

[0072] The cache controller 202 can partition the cache memory 201 into multiple independent cache partitions based on the cache partitioning strategy sent by the upper-layer chip or upper-layer software. The cache controller 202 can also control the cache utilization monitor 203 and cache bandwidth monitor 204 to perform corresponding monitoring functions based on instructions from the upper-layer chip or upper-layer software. The cache utilization monitor 203 and cache bandwidth monitor 204 can report the monitoring results to the cache controller 202, allowing the cache controller 202 to adjust the capacity of the corresponding cache partitions based on the monitoring results.

[0073] For example, consider a game scenario. In this scenario, a pre-configured cache partitioning strategy can be used to set cache partitions for each type of thread. Assume there are four thread types, corresponding to a first cache supply priority, a second cache supply priority, a third cache supply priority, and a fourth cache supply priority. The cache partitioning strategy for the game scenario can include multiple cache partitioning sub-strategies, each corresponding to a specific runtime scenario. For instance, in a game scenario, if the currently running threads include two types, corresponding to the first cache supply priority and the second cache supply priority, the first cache partitioning sub-strategy is used, and cache partitions are set for these two thread types based on it. Similarly, in a game scenario, if the currently running threads include two types, corresponding to the first cache supply priority and the third cache supply priority, the second cache partitioning sub-strategy is used, and cache partitions are set for these two thread types based on it. For example, in a game scenario, the currently running threads include three types, corresponding to the first cache supply priority, the second cache supply priority, and the fourth cache supply priority, respectively. In this case, the third cache partitioning sub-policy is used to set cache partitions for these three types of threads.

[0074] In some embodiments, the cache controller 202 can find the corresponding cache partition sub-policy based on the type information of the thread currently running on the electronic device, and set the partition of the cache memory 201 based on the corresponding cache partition sub-policy, so as to set cache partitions for one or more types of threads currently running on the electronic device in the game scene.

[0075] In a game scenario, the target thread is the thread of the game application. Cache utilization monitor 203 monitors the cache utilization of the target thread, and cache bandwidth monitor 204 monitors the cache bandwidth of the target thread. For example, if the electronic device is currently running a first game application, and the target thread is the thread of that first game application, the amount of game data is not constant during the first user's gameplay. The amount of game data changes with game screen transitions, game scene transitions, and competitive mode transitions. An increase in the amount of game data may lead to a decrease in the cache utilization of the target thread.

[0076] When the cache utilization monitor 203 detects that the cache utilization of the target thread is lower than a first threshold, the cache controller 202 can adjust the currently used cache partitioning sub-strategy to increase the cache capacity of the cache partition corresponding to the target thread, thereby improving the cache utilization of the target thread. For example, adjusting the currently used cache partitioning sub-strategy could be to increase the cache capacity of the cache partition corresponding to the target thread by a first preset percentage, where the first preset percentage can be a percentage of the total cache capacity. For instance, if the total capacity of the cache memory 201 is 10MB and the first preset percentage is 10%, then 1MB of cache capacity would be added to the cache partition corresponding to the target thread.

[0077] In some embodiments, the first preset percentage can be set to different values ​​based on different scenarios, such as the latency tolerance of the target application in the scenario, the degree of data fluctuation, etc. For example, the latency tolerance of a game scenario is lower than that of a video playback scenario, so the first preset percentage value for the game scenario can be set relatively higher, such as 10%, while the first preset percentage value for the video playback scenario can be set relatively lower, such as 5%.

[0078] In some embodiments, the first preset percentage can also be adjusted based on the rate of decrease of the cache utilization of the target thread. That is, in the case of a rapid decrease in cache utilization, more cache capacity can be added to the cache partition corresponding to the target thread at one time to reduce the probability of multiple adjustments to the cache partition corresponding to the target thread in a short period of time.

[0079] In some embodiments, the cache controller 202 may adjust the currently adopted cache partitioning sub-strategy to increase the cache capacity for the cache partition corresponding to the target thread when the application corresponding to the target thread is running in the foreground and the cache utilization monitor 203 detects that the cache utilization of the target thread is lower than a first threshold.

[0080] In some embodiments, after adjusting the cache capacity of the target thread once, if the cache utilization of the target thread is still lower than the first threshold, the capacity of the cache partition corresponding to the target thread can be adjusted again, for example, by adding 1MB of cache capacity to the cache partition corresponding to the target thread again.

[0081] In some embodiments, since the total cache capacity is fixed, increasing the cache capacity for the target thread will reduce the cache capacity for other non-target threads. That is, adjusting the currently adopted cache partitioning sub-strategy may include increasing the capacity of the cache partition for the target thread and decreasing the capacity of the cache partition for non-target threads. Specifically, when the cache capacity of the cache partition corresponding to the target thread is increased by 1MB, the cache capacity of the cache partition corresponding to the non-target thread needs to be reduced by 1MB accordingly. Non-target threads can refer to threads other than the threads of the game application currently running in a game scenario.

[0082] In some embodiments, threads other than those in game applications may correspond to different cache supply priorities. Non-target threads that undergo cache capacity reduction are prioritized for threads with lower cache supply priorities. That is, if multiple non-target threads have different cache supply priorities, the capacity of the cache partition corresponding to the non-target thread with the lower cache supply priority is reduced first. Only when the cache partition corresponding to the non-target thread with the lower cache supply priority has no room for adjustment is the capacity of the cache partition corresponding to the non-target thread with the higher cache supply priority adjusted.

[0083] In some embodiments, if all cache partitions corresponding to non-target threads have no adjustable capacity, indicating that no additional cache capacity can be squeezed from the cache partitions corresponding to non-target threads, then even if the cache utilization of the target thread is still lower than the first threshold, the cache controller 202 may stop adjusting the capacity of the cache partitions corresponding to the target thread. The fact that the cache partitions corresponding to non-target threads have no adjustable capacity may mean that the capacity of the cache partitions corresponding to non-target threads is already a preset capacity. The preset capacity can be set according to actual adjustment needs; for example, the preset capacity can be set to 0MB or other values. This embodiment does not limit this.

[0084] By configuring the cache controller 202 to adjust the currently used cache partitioning sub-strategy when the cache utilization monitor 203 detects that the cache utilization of the target thread is lower than a first threshold, the capacity adjustment of the cache partition for the target thread can be achieved instantly. However, this adjustment method may also be erroneous due to instantaneous fluctuations in the cache utilization of the target thread. To solve this problem, in some embodiments, the cache controller 202 may also adjust the currently used cache partitioning sub-strategy to increase the cache capacity of the cache partition corresponding to the target thread when the cache utilization monitor 203 detects that the cache utilization of the target thread gradually decreases within a first preset time period and decreases to below the first threshold. The first preset time period can be set according to actual adjustment needs, and this application embodiment does not limit it.

[0085] The cache controller 202 can also adjust the currently adopted cache partitioning sub-strategy to increase the cache capacity of the cache partition corresponding to the target thread when the cache utilization monitor 203 detects that the cache utilization of the target thread is lower than the first threshold and continues for a second preset duration. The second preset duration can be set according to actual adjustment needs, and this embodiment does not limit it.

[0086] It is understood that, in a game scenario, the cache controller 202 can trigger an adjustment to the currently adopted cache partitioning sub-policy based on the monitoring results of either the cache utilization monitor 203 or the cache bandwidth monitor 204. The way the cache controller 202 adjusts the currently adopted cache partitioning sub-policy based on the monitoring results of the cache bandwidth monitor 204 is similar to the way it adjusts the currently adopted cache partitioning sub-policy based on the monitoring results of the cache utilization monitor 203, and to avoid repetition, this embodiment will not elaborate further.

[0087] In some embodiments, the first threshold and the second threshold corresponding to the target thread in different preset scenarios may be different. For example, the first threshold and the second threshold corresponding to the target thread in a game scenario may be different from the first threshold and the second threshold corresponding to the target thread in a video playback scenario.

[0088] Taking a video playback scenario as an example, cache partitions can be set for each type of thread based on a pre-configured cache partitioning strategy. Assume there are four thread types, corresponding to the first cache supply priority, second cache supply priority, third cache supply priority, and fourth cache supply priority, respectively. The cache partitioning strategy corresponding to the video playback scenario can include multiple cache partitioning sub-strategies, each corresponding to a specific running scenario. For example, in a video playback scenario, if the currently running threads include two types, corresponding to the first cache supply priority and the second cache supply priority, this corresponds to one cache partitioning sub-strategy, and cache partitions are set for these two types of threads based on this sub-strategy. As another example, in a video playback scenario, if the currently running threads include three types, corresponding to the first cache supply priority, the second cache supply priority, and the fourth cache supply priority, this corresponds to another cache partitioning sub-strategy, and cache partitions are set for these three types of threads based on this sub-strategy.

[0089] In some embodiments, the cache controller 202 can find the corresponding cache partition sub-policy based on the type information of the thread currently running on the electronic device, and set the partition of the cache memory 201 based on the corresponding cache partition sub-policy, so as to set cache partitions for one or more types of threads currently running on the electronic device in the video playback scenario.

[0090] In a video playback scenario, the target thread is the thread of a video playback application. Cache utilization monitor 203 monitors the cache utilization of the target thread, and cache bandwidth monitor 204 monitors the cache bandwidth of the target thread. For example, if the electronic device is currently running a first video playback application, and the target thread is the thread of that application, the amount of video data is not constant during the user's viewing of the video. The amount of video data changes with video frame changes, the on / off state of subtitles / effects, and the change in image clarity. As the amount of video data increases, the cache bandwidth of the target thread also increases.

[0091] When the cache bandwidth monitor 204 detects that the cache bandwidth of the target thread exceeds a second threshold, the cache controller 202 can adjust the currently used cache partitioning sub-strategy to increase the cache capacity of the cache partition corresponding to the target thread, thereby reducing the cache bandwidth of the target thread. For example, adjusting the currently used cache partitioning sub-strategy could involve increasing the cache capacity of the cache partition corresponding to the target thread by a first preset percentage.

[0092] In some embodiments, the first preset percentage can also be adjusted based on the rate of increase of the cache bandwidth of the target thread. That is, in the case of a rapid increase in cache bandwidth, more cache capacity can be added to the cache partition corresponding to the target thread at one time to reduce the probability of multiple adjustments to the cache partition corresponding to the target thread in a short period of time.

[0093] In some embodiments, the cache controller 202 may adjust the currently adopted cache partitioning sub-strategy to increase the cache capacity for the cache partition corresponding to the target thread when the application corresponding to the target thread is running in the foreground and the cache bandwidth monitor 204 detects that the cache bandwidth of the target thread is greater than the second threshold.

[0094] In some embodiments, after adjusting the cache capacity of the target thread once, if the cache bandwidth of the target thread is still greater than the second threshold, the capacity of the cache partition corresponding to the target thread can be adjusted again, for example, by increasing the cache capacity of the cache partition corresponding to the target thread by a first preset percentage.

[0095] In some embodiments, since the total cache capacity is fixed, increasing the cache capacity for the target thread will reduce the cache capacity for other non-target threads. That is, adjusting the currently adopted cache partitioning sub-strategy may include increasing the capacity of the cache partition for the target thread and decreasing the capacity of the cache partition for non-target threads. Specifically, when the cache capacity of the cache partition corresponding to the target thread is increased by a first preset percentage, the cache capacity of the cache partition corresponding to the non-target thread needs to be reduced by the first preset percentage accordingly. Non-target threads can refer to threads other than those of the video playback application currently running in a video playback scenario.

[0096] In some embodiments, threads other than those in video playback applications may correspond to different cache supply priorities. Non-target threads that undergo cache capacity reduction are prioritized for threads with lower cache supply priorities. That is, if multiple non-target threads have different cache supply priorities, the capacity of the cache partition corresponding to the non-target thread with the lower cache supply priority is reduced first. Only when the cache partition corresponding to the non-target thread with the lower cache supply priority has no room for adjustment is the capacity of the cache partition corresponding to the non-target thread with the higher cache supply priority adjusted.

[0097] In some embodiments, if all cache partitions corresponding to non-target threads have no adjustable capacity, indicating that no additional cache capacity can be squeezed from the cache partitions corresponding to non-target threads, then even if the cache bandwidth of the target thread is still greater than the second threshold, the cache controller 202 may stop adjusting the capacity of the cache partitions corresponding to the target thread. The statement that the cache partitions corresponding to non-target threads have no adjustable capacity may mean that the capacity of the cache partitions corresponding to non-target threads is already at a preset capacity. The preset capacity can be set according to actual adjustment needs, and this embodiment does not limit this.

[0098] By configuring the cache controller 202 to adjust the currently used cache partitioning sub-strategy when the cache bandwidth monitor 204 detects that the cache bandwidth of the target thread is greater than the second threshold, the capacity adjustment of the cache partition of the target thread can be achieved instantly. However, this adjustment method may also be erroneous due to instantaneous fluctuations in the cache bandwidth of the target thread. To solve this problem, in some embodiments, the cache controller 202 can also adjust the currently used cache partitioning sub-strategy when the cache bandwidth monitor 204 detects that the cache bandwidth of the target thread gradually increases within a third preset time period and increases to a level greater than the second threshold, thereby increasing the cache capacity of the cache partition corresponding to the target thread. The third preset time period can be set according to actual adjustment needs, and this application embodiment does not limit it.

[0099] The cache controller 202 can also adjust the currently adopted cache partitioning sub-strategy to increase the cache capacity of the cache partition corresponding to the target thread if the cache bandwidth monitor 204 detects that the cache bandwidth of the target thread is greater than the second threshold and continues for a fourth preset duration. The fourth preset duration can be set according to actual adjustment needs, and this embodiment does not limit it.

[0100] It is understood that, in a video playback scenario, the cache controller 202 can trigger an adjustment of the currently adopted cache partitioning sub-strategy based on the monitoring results of either the cache utilization monitor 203 or the cache bandwidth monitor 204. The method by which the cache controller 202 adjusts the currently adopted cache partitioning sub-strategy based on the monitoring results of the cache utilization monitor 203 is similar to the method described above for adjusting the currently adopted cache partitioning sub-strategy based on the monitoring results of the cache bandwidth monitor 204. To avoid repetition, this embodiment will not elaborate further.

[0101] In some embodiments, electronic devices may face extreme operating scenarios where multiple preset scenarios are triggered simultaneously during operation. For example, the applications launched by the electronic device may include game applications and video playback applications. In this case, the application running in the foreground of the electronic device is generally an application within a preset scenario, and the target thread is the thread of the application currently running in the foreground and belonging to the preset scenario.

[0102] For example, the application running in the foreground is a game application, while the video playback application runs in the background. The target thread is the game application's thread. The cache controller 202 can, based on the monitoring results of the cache information (cache utilization / cache bandwidth) of the game application's thread by either the cache utilization monitor 203 or the cache bandwidth monitor 204, trigger an adjustment to the currently used cache partitioning sub-strategy. This adjustment increases the cache capacity of the cache partition corresponding to the target thread, thereby reducing the target thread's cache bandwidth or increasing its cache utilization. Alternatively, if the cache information meets a first preset condition, the adjustment to the currently used cache partitioning sub-strategy is triggered to increase the cache capacity of the cache partition corresponding to the target thread. The first preset condition could be that the cache utilization is less than a first threshold, or the cache bandwidth is greater than a second threshold. If the cache information does not meet the first preset condition, the capacity of the cache partition corresponding to the target thread may not be increased.

[0103] For example, the application running in the foreground is a video playback application, while the game application runs in the background. The target thread is the video playback application's thread. The cache controller 202 can, based on the monitoring results of the cache information of the video playback application's thread by either the cache utilization monitor 203 or the cache bandwidth monitor 204, trigger an adjustment to the currently used cache partitioning sub-strategy. This increases the cache capacity of the cache partition corresponding to the target thread, thereby reducing the target thread's cache bandwidth or increasing its cache utilization.

[0104] In some embodiments, after increasing the cache capacity of the cache partition corresponding to the target thread, the cache controller 202 may also reduce the cache capacity of the cache partition corresponding to the target thread based on the monitoring results of the cache information of the target thread by the cache utilization monitor 203 and the cache bandwidth monitor 204, so as to increase the cache capacity of the cache partition corresponding to the non-target thread after the target thread exits the high cache requirement, thereby ensuring the smooth operation of the non-target thread.

[0105] For example, if the cache information of the target thread meets the second preset condition, the cache controller 202 reduces the cache capacity of the cache partition corresponding to the target thread by a second preset percentage. Correspondingly, the cache controller 202 increases the cache capacity of the cache partition not corresponding to the target thread by a second preset percentage. The second preset percentage can be less than the first preset percentage, meaning the reduction in cache capacity of the cache partition corresponding to the target thread is lower than the increase, to avoid triggering an immediate increase in cache capacity after a reduction. For example, in a game scenario, if the cache capacity of the cache partition corresponding to the target thread is increased by 10%, and the cache information of the target thread meets the second preset condition, the cache capacity of the cache partition corresponding to the target thread can be reduced by 2% or less. As another example, in a video playback scenario, if the cache capacity of the cache partition corresponding to the target thread is increased by 5%, and the cache information of the target thread meets the second preset condition, the cache capacity of the cache partition corresponding to the target thread can be reduced by 1% or less.

[0106] In some embodiments, if the cache information of the target thread does not meet the second preset condition, the capacity of the cache partition corresponding to the target thread may not be reduced. The second preset condition can be set according to the actual scenario's operational needs, and this application embodiment does not limit it. For example, the second preset condition is that the cache utilization monitor 203 detects that the cache utilization of the target thread is greater than or equal to a third threshold, and the cache bandwidth monitor 204 detects that the cache bandwidth of the target thread is less than or equal to a fourth threshold, and this lasts for a fifth preset duration. The fifth preset duration can be set according to actual needs, and this application embodiment does not limit it. The third threshold and the fourth threshold can be set according to actual cache adjustment needs, and this application embodiment does not limit them. For example, the third threshold can be set to be equal to or unequal to the first threshold, and the fourth threshold can be set to be equal to or unequal to the second threshold.

[0107] In some embodiments, after reducing the cache capacity of the target thread once, if the cache information of the target thread still meets the second preset condition, the capacity of the cache partition corresponding to the target thread can be reduced again. If the capacity of the cache partition corresponding to the target thread recovers to the preset capacity or the capacity configured for the target thread by the cache partition sub-policy, the reduction of the cache partition capacity corresponding to the target thread is stopped. The preset capacity can be set to be slightly larger than the capacity configured for the target thread by the cache partition sub-policy.

[0108] For example, the total cache capacity is 10MB, and the currently running threads include two types: Type 1 threads and Type 2 threads. The Type 1 thread is the target thread. The current cache partitioning sub-strategy is as follows: Type 1 threads correspond to the first cache partition with a capacity of 8MB, and Type 2 threads correspond to the second cache partition with a capacity of 2MB. When triggering an increase in cache capacity for the target thread's corresponding cache partition, the maximum capacity of the first cache partition can be increased to 10MB. When triggering a decrease in cache capacity for the target thread's corresponding cache partition, the maximum capacity of the first cache partition can be decreased to 8MB.

[0109] In some embodiments, non-target threads may correspond to different cache provisioning priorities. When increasing cache capacity, the non-target thread with the highest cache provisioning priority is prioritized. That is, if there are multiple non-target threads with different cache provisioning priorities, the capacity of the cache partition corresponding to the non-target thread with the highest cache provisioning priority is increased first, so as to restore the cache partition corresponding to the non-target thread with the highest cache provisioning priority to the capacity configured by the cache partition sub-policy. Only after the cache partition corresponding to the non-target thread with the highest cache provisioning priority has been restored to the capacity configured by the cache partition sub-policy is the capacity of the cache partition corresponding to the non-target thread with the next lower cache provisioning priority adjusted.

[0110] To better understand the implementation details of the above resource allocation method on electronic devices, the following section will combine... Figure 4 This section describes the process by which various software and hardware components in an electronic device work together to implement the aforementioned resource allocation method. Details are as follows:

[0111] The operating system of an electronic device can adopt a layered architecture, event-driven architecture, microkernel architecture, microservice architecture, or cloud architecture. This application uses the layered architecture Android system as an example to illustrate the software structure of the electronic device. Figure 4 As shown, a layered architecture divides software into several layers, each with a clear role and function. Layers communicate with each other through software interfaces. Taking the Android system as an example, in some implementations, the Android system is divided into four layers, from top to bottom: the application layer (Apk), the application framework layer (Framework), the hardware abstraction layer (HAL), and the kernel layer (Kernel).

[0112] The kernel layer may contain hardware-associated drivers that are linked to the hardware layer. It may also include hardware-intensive programs, such as interrupt handlers, and basic, common, frequently used modules, such as clock management modules and process scheduling modules.

[0113] For example, the hardware layer includes a display screen, which can be used to display game interfaces, video playback interfaces, etc. The kernel layer may contain display drivers and touch drivers. The display driver is used to drive the display panel in the display screen to display content, which may include game interfaces, video playback interfaces, etc. The touch driver is used to obtain user touch operations on the display screen from the touch layer in the display screen, such as touch operations on the game interface, to control game character movement, skill casting, etc.

[0114] The hardware abstraction layer may include a cache partitioning and adjustment module. This module can be used to execute the resource allocation method provided in the embodiments of this application, enabling the partitioning of the cache based on a pre-configured cache partitioning strategy, and the adjustment of the capacity of the cache partitions, for example, dynamically adjusting the capacity of the cache partitions corresponding to the target thread and non-target threads.

[0115] The application framework layer provides application programming interfaces (APIs) and programming frameworks for applications in the application layer. For example, the application framework layer may include window managers, content providers, view systems, resource managers, etc.

[0116] The window manager manages window programs. It can obtain the screen size, determine the presence of a status bar, lock the screen, and capture screenshots. The content provider stores and retrieves data, making this data accessible to applications. This data can include videos, images, audio, made and received phone calls, browsing history and bookmarks, phone books, etc. The view system includes visual controls, such as controls for displaying text and controls for displaying images. The view system can be used to build applications. A display interface can consist of one or more views. For example, a display interface including a text notification icon can include a view for displaying text and a view for displaying images. The resource manager provides applications with various resources, such as localized strings, icons, images, layout files, video files, etc.

[0117] The application layer can include a series of application packages. For example, application packages can include video playback applications, game applications, etc.

[0118] Please see Figure 5 This illustrates the process by which an electronic device partitions and adjusts the cache capacity under a preset scenario, based on a cache resource allocation method. This embodiment uses an offline preset method to configure different cache partitions for different types of threads according to different preset scenarios. This allows the electronic device to partition the cache according to the offline preset cache partitioning strategy when a preset scenario is detected, with each type of thread corresponding to a separate cache partition.

[0119] 501: When the threads running on the electronic device include threads of a preset scenario, obtain the cache partitioning policy corresponding to the preset scenario. The cache partitioning policy includes one or more cache partitioning sub-policies.

[0120] In some embodiments, an electronic device may create an application process in response to a user's action to launch the corresponding application. An application process may contain one or more threads to meet the different concurrent processing needs of the application.

[0121] The preset scenarios can be set according to actual needs, and this application embodiment does not limit this. For example, preset scenarios include, but are not limited to, game scenarios and video playback scenarios. The thread of the preset scenario can refer to the thread of the application corresponding to the preset scenario, such as the thread of a game application or the thread of a video playback application. That is, the thread of the preset scenario can be understood as the thread of an application of a preset type. This application embodiment obtains the cache partitioning strategy corresponding to the preset scenario, so that when the electronic device is in the preset scenario, the cache can be partitioned based on the cache partitioning strategy, avoiding cache contention between different types of threads in the preset scenario, which would affect the flow of thread operation.

[0122] In some embodiments, the cache partitioning strategy corresponding to each preset scenario may include one or more cache partitioning sub-strategies. The cache partitioning sub-strategies can be used to divide the cache into multiple cache partitions. The multiple cache partitions referred to in this application embodiment may refer to two or more cache partitions. Each cache partitioning sub-strategy may correspond to a running scenario. For example, in a game scenario, if the currently running threads include a first type and a second type, it corresponds to the first cache partitioning sub-strategy; if the currently running threads include a first type and a third type, it corresponds to the second cache partitioning sub-strategy; and if the currently running threads include a first type, a second type, and a third type, it corresponds to the third cache partitioning sub-strategy.

[0123] In some embodiments, threads can be categorized into two or more types. If threads are categorized into two types, the cache partitioning strategy may include only one cache partitioning sub-strategy. In this case, step 502 below can be omitted, and the cache can be directly partitioned based on the cache partitioning strategy to obtain cache partitions corresponding to each type of thread. For example, if the thread types include threads in a preset scenario and threads in a non-preset scenario, the cache can be divided into two cache partitions. The capacity of the two cache partitions can be set according to actual needs, with one cache partition corresponding to threads in the preset scenario and the other cache partition corresponding to threads in the non-preset scenario.

[0124] 502: Obtain the type information of the thread running on the electronic device, and determine the target cache partitioning sub-policy corresponding to the thread type information from the cache partitioning policy.

[0125] In some embodiments, thread types can be categorized according to actual needs. For example, thread types can be divided into threads for preset scenarios and threads for non-preset scenarios. Another example is that the thread type categorization can correspond to cache supply priorities; that is, the number of thread types can be set according to a pre-defined number of cache supply priorities, with different types of threads corresponding to different cache supply priorities.

[0126] If a cache partitioning policy contains multiple cache partitioning sub-policies, the cache partitioning sub-policy corresponding to the thread type information can be determined from the cache partitioning policy based on the type information of the currently running thread on the electronic device. For example, if the currently running thread includes types 1, 2, and 3, the corresponding cache partitioning sub-policy can be determined to be the third cache partitioning sub-policy.

[0127] In the same scenario, different cache partitioning sub-strategies can be set in this application embodiment to meet the cache partitioning requirements of fine-grained division of thread types and avoid cache contention between different types of threads.

[0128] 503: The cache is partitioned based on the target cache partitioning sub-strategy to obtain cache partitions corresponding to each type of thread.

[0129] After determining the cache partitioning sub-strategy corresponding to the thread type information, the cache can be partitioned based on the cache partitioning sub-strategy to obtain the cache partition corresponding to each type of thread.

[0130] In some embodiments, the cache partitioning sub-policy can define information such as how many cache partitions the cache will be divided into and the capacity information of each cache partition. Partitioning the cache based on the target cache partitioning sub-policy ensures that each type of thread can correspond to a cache partition, avoiding cache contention between different types of threads.

[0131] 504: Retrieve cache information for threads in a preset scenario. The cache information includes cache utilization and / or cache bandwidth.

[0132] In some embodiments, cache information of threads in a preset scenario can be monitored by cache utilization monitor 203 and cache bandwidth monitor 204.

[0133] The threads in the preset scenario can be characterized with a high probability that the user currently expects to prioritize the allocation of resources to the threads in the preset scenario, so as to ensure the smooth operation of the threads in the preset scenario. In this embodiment, the cache utilization rate and / or cache bandwidth of the threads in the preset scenario are obtained to realize real-time monitoring of the cache usage of the threads in the preset scenario, so as to facilitate the adaptive adjustment of the cache partition in the future, so as to prioritize the allocation of cache resources to the threads in the preset scenario.

[0134] 505: If the cache information of the thread in the preset scenario meets the first preset condition, adjust the target cache partition sub-policy to increase the cache capacity of the cache partition corresponding to the thread in the preset scenario.

[0135] In some embodiments, the first preset condition may be that the cache utilization rate of the thread in the preset scenario is less than a first threshold, or the cache bandwidth of the thread in the preset scenario is greater than a second threshold. If the cache information of the thread in the preset scenario meets the first preset condition, it indicates that the data hit rate of the thread in the preset scenario in the cache is not high. In this case, the cache bandwidth of the thread in the preset scenario can be reduced or the cache utilization rate of the thread in the preset scenario can be increased by configuring more cache capacity for the cache partition corresponding to the thread in the preset scenario, thereby achieving the maximum release of cache capacity and improving the user's device experience in the preset scenario.

[0136] For example, the target cache partition sub-policy can be adjusted and sent to the cache controller 202 so that the cache controller 202 can increase the cache capacity of the cache partition corresponding to the thread in the preset scenario.

[0137] In some embodiments, if the cached information of the thread in the preset scenario does not meet the first preset condition, the process can jump to step 504.

[0138] 506: If the cache information of the thread in the preset scenario meets the second preset condition, adjust the target cache partition sub-policy to reduce the cache capacity of the cache partition corresponding to the thread in the preset scenario.

[0139] In some embodiments, the second preset condition may be that the cache utilization rate of the thread in the preset scenario is greater than or equal to a third threshold, and the cache bandwidth is less than or equal to a fourth threshold, and the current cache capacity of the cache partition corresponding to the thread in the preset scenario is greater than the cache capacity configured for that cache partition by the pre-configured cache partition sub-policy. If the cache information of the thread in the preset scenario meets the second preset condition, it indicates that the thread in the preset scenario has exited the high cache requirement. In this case, the cache capacity of the cache partition corresponding to the thread in the preset scenario can be reduced to increase the cache capacity of the cache partition corresponding to the thread in the non-preset scenario, thereby improving the running smoothness of the thread in the non-preset scenario.

[0140] For example, in step 503, after partitioning the cache based on the cache partitioning sub-strategy, the capacity of the cache partition corresponding to the thread in the preset scenario is the first cache capacity. The second preset condition includes that the current cache capacity of the cache partition corresponding to the thread in the preset scenario is greater than the first cache capacity.

[0141] In some embodiments, when increasing the cache capacity of the cache partition corresponding to the thread of the preset scenario, the capacity of the cache partition corresponding to the thread of the preset scenario may be increased to a maximum of equal to the total cache capacity. When decreasing the cache capacity of the cache partition corresponding to the thread of the preset scenario, the capacity of the cache partition corresponding to the thread of the preset scenario may be decreased to a maximum of equal to the first cache capacity.

[0142] In some embodiments, increasing or decreasing the cache capacity of the cache partition corresponding to the thread in the preset scenario can be achieved without adjusting the target cache partition sub-policy. For example, while keeping the target cache partition sub-policy unchanged, the cache controller 202 can directly increase or decrease the cache capacity of the cache partition corresponding to the thread in the preset scenario, and decrease or increase the cache capacity of the cache partition corresponding to the thread in a non-preset scenario.

[0143] In some embodiments, if the cache information of the thread in the preset scenario does not meet the second preset condition, the process can jump to step 504.

[0144] Please see Figure 6 This illustrates the process of an electronic device partitioning and adjusting the capacity of its cache based on a resource allocation method. The embodiments in this application use an example where the electronic device currently has multiple threads running.

[0145] 601: Get type information for multiple threads.

[0146] In some embodiments, thread types can be categorized according to actual needs. For example, thread types can be divided into threads for preset scenarios and threads for non-preset scenarios. Another example is that thread type categorization can correspond to cache provisioning priority. Yet another example is that thread type categorization can also refer to the application type categorization method described above.

[0147] 602: Determine the cache partitioning strategy based on the type information of multiple threads.

[0148] In some embodiments, a corresponding cache partitioning strategy can be configured offline for various combinations of thread types that an electronic device may run. This allows the electronic device to automatically partition the cache according to the currently running thread type using the corresponding cache partitioning strategy. Each type of thread can correspond to a separate cache partition to achieve cache isolation between different types of threads.

[0149] 603: The cache is partitioned based on a cache partitioning strategy, dividing the cache into multiple cache partitions.

[0150] In some embodiments, electronic devices partition the cache based on a cache partitioning strategy to minimize cache contention between different types of threads.

[0151] 604: Retrieves cache information for the target thread among multiple threads. The target thread corresponds to the first cache partition among multiple cache partitions. The cache information includes cache utilization and / or cache bandwidth.

[0152] In some embodiments, the target thread can refer to the thread that is currently expected to receive priority cache provisioning. For example, the target thread can be a thread of an application in a preset scenario, or a thread of an application running in the foreground. By monitoring the cache utilization and / or cache bandwidth of the target thread, it is easier to adaptively adjust the capacity of the cache partition corresponding to the target thread to prioritize the cache needs of the target thread.

[0153] 605: Adjust the capacity of the first cache partition if the cached information of the target thread meets the preset conditions.

[0154] In some embodiments, the preset conditions may include conditions that require increasing the capacity of the first cache partition, or conditions that require decreasing the capacity of the first cache partition. For example, the preset conditions may include a first preset condition and a second preset condition.

[0155] The first preset condition can be that the cache utilization of the target thread is less than a first threshold, or the cache bandwidth of the target thread is greater than a second threshold. If the cache information of the target thread meets the first preset condition, it indicates that the hit rate of the target thread's data in the cache is not high. In this case, the cache bandwidth of the target thread can be reduced or the cache utilization of the target thread can be increased by configuring more cache capacity for the cache partition corresponding to the target thread, thereby achieving the maximum release of cache capacity.

[0156] The second preset condition can be that the cache utilization of the target thread is greater than or equal to the third threshold, and the cache bandwidth is less than or equal to the fourth threshold, and the current cache capacity of the cache partition corresponding to the target thread is greater than the cache capacity configured for that cache partition by the pre-configured cache partitioning strategy. If the cache information of the target thread meets the second preset condition, it indicates that the target thread has exited the high cache requirement. In this case, the cache capacity of the cache partition corresponding to the target thread can be reduced to increase the cache capacity of the cache partition corresponding to non-target threads, thereby improving the smoothness of non-target thread operation.

[0157] See Figure 7 As shown, the electronic device 100 involved in the embodiments of this application will be described below. The electronic device 100 in the embodiments of this application can be a mobile phone, tablet computer, desktop computer, laptop computer, handheld computer, notebook computer, ultra-mobile personal computer (UMPC), large screen, smart TV, netbook, as well as cellular phone, personal digital assistant (PDA), augmented reality (AR) / virtual reality (VR) devices, and other terminal devices. It can also be a vehicle-mounted system, server, or other computing device. The embodiments of this application do not impose special limitations on the specific form of the electronic device. Please refer to... Figure 7 , Figure 7 This is a possible structural schematic diagram of the electronic device 100 provided in the embodiments of this application.

[0158] Electronic device 100 may include processor 110, external memory interface 120, internal memory 121, universal serial bus (USB) interface 130, charging management module 140, power management module 141, battery 142, antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, audio module 170, speaker 170A, receiver 170B, microphone 170C, headphone jack 170D, sensor module 180, button 190, motor 191, indicator 192, camera 193, display screen 194, and subscriber identification module (SIM) card interface 195, etc.

[0159] It is understood that the structures illustrated in the embodiments of the present invention do not constitute a specific limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.

[0160] In addition, an operating system runs on top of the aforementioned components. Examples include Apple's iOS operating system, Google's Android open-source operating system, and Microsoft's Windows operating system.

[0161] Processor 110 may include one or more processing units, such as application processors (APs), modem processors, graphics processing units (GPUs), image signal processors (ISPs), controllers, video codecs, digital signal processors (DSPs), baseband processors, and / or neural network processing units (NPUs). These different processing units may be independent devices or integrated into one or more processors.

[0162] For example, processor 110 can be used to execute the resource allocation method described above, adjusting the pre-configured cache partitioning strategy to dynamically adjust the capacity of the cache partitions corresponding to the target thread and non-target threads. As another example, processor 110 can communicate with the cache controller 202 to control the cache controller 202 to dynamically adjust the capacity of the cache partitions corresponding to the target thread and non-target threads. The monitoring results of cache utilization monitor 203 and cache bandwidth monitor 204 can be reported to processor 110 through cache controller 202, allowing processor 110 to control cache controller 202 to dynamically adjust the capacity of the cache partitions corresponding to the target thread and non-target threads based on the monitoring results of cache utilization monitor 203 and cache bandwidth monitor 204.

[0163] The processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory can store instructions or data that the processor 110 has just used or that are being used repeatedly. If the processor 110 needs to use the instructions or data again, it can retrieve them directly from the memory. This avoids repeated accesses, reduces the waiting time of the processor 110, and thus improves system efficiency.

[0164] In some embodiments, the processor 110 may include one or more interfaces. Interfaces may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.

[0165] The wireless communication function of electronic device 100 can be realized through antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, modem processor and baseband processor, etc.

[0166] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 can be used to cover one or more communication frequency bands. Different antennas can also be multiplexed to improve antenna utilization. For example, antenna 1 can be multiplexed as a diversity antenna for a wireless local area network. In some other embodiments, the antennas can be used in conjunction with tuning switches.

[0167] The mobile communication module 150 can provide solutions for wireless communication, including 2G / 3G / 4G / 5G, applied to the electronic device 100. The mobile communication module 150 may include at least one filter, switch, power amplifier, low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves via antenna 1, and perform filtering, amplification, and other processing on the received electromagnetic waves before transmitting them to a modem processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modem processor and convert it into electromagnetic waves for radiation via antenna 1. In some embodiments, at least some functional modules of the mobile communication module 150 may be housed in the processor 110. In some embodiments, at least some functional modules of the mobile communication module 150 and at least some modules of the processor 110 may be housed in the same device.

[0168] The wireless communication module 160 can provide solutions for wireless communication applications on the electronic device 100, including wireless local area networks (WLANs) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), and infrared (IR) technologies. The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via antenna 2, performs frequency modulation and filtering of the electromagnetic wave signals, and sends the processed signal to processor 110. The wireless communication module 160 can also receive signals to be transmitted from processor 110, perform frequency modulation and amplification, and convert them into electromagnetic waves for radiation via antenna 2.

[0169] In some embodiments, antenna 1 of electronic device 100 is coupled to mobile communication module 150, and antenna 2 is coupled to wireless communication module 160, enabling electronic device 100 to communicate with networks and other devices via wireless communication technology. The wireless communication technology may include Global System for Mobile Communications (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Time-Division Code Division Multiple Access (TD-SCDMA), Long Term Evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technologies, etc. The GNSS may include the Global Positioning System (GPS), the Global Navigation Satellite System (GLONASS), the BeiDou Navigation Satellite System (BDS), the Quasi-Zenith Satellite System (QZSS), and / or satellite-based augmentation systems (SBAS).

[0170] The sensor module 180 may include various types of sensors, such as fingerprint sensors, ambient light sensors, pressure sensors, gyroscope sensors, accelerometer sensors, etc.

[0171] Electronic device 100 implements display functions through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, connected to the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations and for graphics rendering. Processor 110 may include one or more GPUs, which execute program instructions to generate or modify display information.

[0172] The display screen 194 can be used to display images, videos, etc. For example, the display screen 194 can be used to display video playback interfaces, game interfaces, etc. The display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a minimized display, a microLED, a micro-OLED, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 100 may include one or N display screens 194, where N is a positive integer greater than 1. In this embodiment, the display screen 194 can be a touch screen, meaning that a touch sensor is integrated into the display screen 194.

[0173] Internal memory 121 may include one or more random access memory (RAM) and one or more non-volatile memory (NVM). The RAM may include static random-access memory (SRAM), dynamic random-access memory (DRAM), synchronous dynamic random-access memory (SDRAM), double data rate synchronous dynamic random-access memory (DDR SDRAM, such as fifth-generation DDR SDRAM, generally referred to as DDR5 SDRAM), etc.; the NVM may include disk storage devices and flash memory.

[0174] Flash memory can be classified according to its operating principle, including NOR FLASH, NAND FLASH, 3D NAND FLASH, etc.; according to the level of the storage cell, including single-level cell (SLC), multi-level cell (MLC), triple-level cell (TLC), quad-level cell (QLC), etc.; and according to the storage specification, including universal flash storage (UFS) and embedded multimedia card (eMMC), etc.

[0175] The random access memory can be directly read and written by the processor 110. It can be used to store executable programs (such as machine instructions) of the operating system or other running programs, as well as user and application data.

[0176] Non-volatile memory can also store executable programs and user and application data, and can be pre-loaded into random access memory for direct reading and writing by the processor 110.

[0177] The external memory interface 120 can be used to connect to external non-volatile memory, thereby expanding the storage capacity of the electronic device 100. The external non-volatile memory communicates with the processor 110 through the external memory interface 120 to perform data storage functions.

[0178] The resource allocation methods described in the above embodiments can all be implemented in the electronic device 100 having the above hardware structure.

[0179] This embodiment also provides a computer-readable storage medium storing computer instructions. When the computer instructions are executed on the electronic device 100, the electronic device 100 performs the aforementioned related method steps to implement the resource allocation method in the above embodiment.

[0180] This embodiment also provides a computer program product that, when run on a computer, causes the computer to perform the aforementioned steps to implement the resource allocation method described in the above embodiment.

[0181] This embodiment also provides a chip system coupled to a memory. The chip system is used to read and execute computer programs stored in the memory to implement the resource allocation method in the above embodiments.

[0182] Through the above description of the implementation methods, those skilled in the art can clearly understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.

[0183] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another device, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.

[0184] The unit described as a separate component may or may not be physically separate. The component shown as a unit can be one physical unit or multiple physical units, that is, it can be located in one place or distributed in multiple different places. Some or all of the units can be selected to achieve the purpose of the solution in this embodiment according to actual needs.

[0185] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0186] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solutions of the embodiments of this application, essentially or in other words, the parts that contribute to the prior art, or all or part of the technical solutions, can be embodied in the form of a software product. This software product is stored in a storage medium and includes several instructions to cause a device (which may be a microcontroller, chip, etc.) or processor to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0187] The above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit it. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.

Claims

1. A resource allocation method applied to electronic devices, characterized in that, The method includes: Launch the first application in response to the user's first action; If the first application is an application of a preset type, obtain the cache partitioning strategy corresponding to the preset type; The cache is partitioned based on the aforementioned cache partitioning strategy, and the cache is divided into multiple cache partitions; Obtain the cache information of the thread of the first application, the cache information including cache utilization and / or cache bandwidth; If the cache information of the thread of the first application meets the preset conditions, adjust the capacity of the cache partition corresponding to the first application.

2. The resource allocation method as described in claim 1, characterized in that, The cache partitioning strategy includes multiple cache partitioning sub-strategies, and the partitioning of the cache based on the cache partitioning strategy includes: Obtain the type information corresponding to the application running in the electronic device; Determine the cache partitioning sub-policy corresponding to the type information from the cache partitioning policy; The cache is partitioned based on a determined cache partitioning sub-strategy.

3. The resource allocation method as described in claim 1 or 2, characterized in that, The preset conditions include the cache utilization rate of the first application's thread being less than a first threshold, or the cache bandwidth of the first application's thread being greater than a second threshold, adjusting the capacity of the cache partition corresponding to the first application, including: Increase the capacity of the cache partition corresponding to the first application.

4. The resource allocation method as described in claim 1 or 2, characterized in that, The preset conditions include the cache utilization rate of the first application's thread gradually decreasing until it is less than a first threshold within a first preset time period, or the cache bandwidth of the first application's thread gradually increasing until it is greater than a second threshold within a second preset time period. Adjusting the capacity of the cache partition corresponding to the first application includes: Increase the capacity of the cache partition corresponding to the first application.

5. The resource allocation method as described in claim 3 or 4, characterized in that, The preset type includes a first type and a second type, and increasing the capacity of the cache partition corresponding to the first application includes: If the first application is an application of the first type, the capacity of the cache partition corresponding to the first application is increased by a first preset percentage; If the first application is the second type of application, the capacity of the cache partition corresponding to the first application is increased by a second preset percentage, wherein the first preset percentage is greater than the second preset percentage.

6. The resource allocation method as described in claim 3 or 4, characterized in that, Increasing the capacity of the cache partition corresponding to the first application includes: If there is room for capacity reduction in other cache partitions besides the cache partition corresponding to the first application, increase the capacity of the cache partition corresponding to the first application.

7. The resource allocation method as described in claim 3 or 4, characterized in that, The electronic device runs multiple types of applications, each type of application corresponds to a cache partition, and each cache partition corresponds to a cache provisioning priority. Increasing the capacity of the cache partition corresponding to the first application includes: In the case where other cache partitions besides the cache partition corresponding to the first application correspond to multiple cache supply priorities, a first target cache partition is determined from the other cache partitions. The first target cache partition is the cache partition with the lowest cache supply priority among the cache partitions with capacity reduction space. Reduce the capacity of the first target cache partition and increase the capacity of the cache partition corresponding to the first application.

8. The resource allocation method as described in claim 1 or 2, characterized in that, The preset conditions include that the cache utilization rate of the first application's thread is greater than or equal to a third threshold, and the cache bandwidth of the first application's thread is less than or equal to a fourth threshold. Adjusting the capacity of the cache partition corresponding to the first application when the cache information of the first application's thread meets the preset conditions includes: If the cache information of the thread of the first application meets the preset conditions and continues for a third preset duration, the capacity of the cache partition corresponding to the first application is reduced.

9. The resource allocation method as described in claim 8, characterized in that, Reducing the capacity of the cache partition corresponding to the first application includes: The capacity of the cache partition corresponding to the first application is reduced by a third preset percentage, which is less than the percentage used when increasing the capacity of the cache partition corresponding to the first application.

10. The resource allocation method as described in claim 8, characterized in that, The electronic device runs multiple types of applications, each type of application corresponds to a cache partition, and each cache partition corresponds to a cache provisioning priority. Reducing the capacity of the cache partition corresponding to the first application includes: In the case where other cache partitions besides the cache partition corresponding to the first application correspond to multiple cache supply priorities, a second target cache partition is determined from the other cache partitions. The second target cache partition is the cache partition with the highest cache supply priority among the cache partitions with room for capacity increase. Reduce the capacity of the cache partition corresponding to the first application and increase the capacity of the second target cache partition.

11. The resource allocation method as described in claim 8, characterized in that, Reducing the capacity of the cache partition corresponding to the first application includes: If the capacity of the cache partition corresponding to the first application is greater than the preset capacity, the capacity of the cache partition corresponding to the first application is reduced. The preset capacity is the capacity configured for the cache partition corresponding to the first application by the cache partitioning strategy.

12. A resource allocation method applied to electronic devices, characterized in that, The method includes: Obtain the type information of multiple threads running in the electronic device; Based on the type information of the multiple threads, a cache partitioning strategy is determined; The cache is partitioned based on the aforementioned cache partitioning strategy, and the cache is divided into multiple cache partitions; Obtain cache information of the target thread among the plurality of threads, the cache information including cache utilization and / or cache bandwidth; If the cache information of the target thread meets the preset conditions, adjust the capacity of the cache partition corresponding to the target thread.

13. The resource allocation method as described in claim 12, characterized in that, The target thread is a thread of a preset type of application. Adjusting the capacity of the cache partition corresponding to the target thread, when the cache information of the target thread meets preset conditions, includes: If the cache information of the target thread meets the first preset condition, the capacity of the cache partition corresponding to the target thread is increased. The first preset condition includes the cache utilization rate of the target thread being less than a first threshold, or the cache bandwidth of the target thread being greater than a second threshold. If the cache information of the target thread meets the second preset condition, the capacity of the cache partition corresponding to the target thread is reduced. The second preset condition includes that the cache utilization rate of the target thread is greater than or equal to a third threshold and the cache bandwidth of the target thread is less than or equal to a fourth threshold.

14. A cache chip, characterized in that, The cache chip includes a cache memory, a cache controller, a cache utilization monitor, and a cache bandwidth monitor. The cache memory is used to store data; The cache utilization monitor is used to monitor the cache utilization of the target thread; The cache bandwidth monitor is used to monitor the cache bandwidth of the target thread; The cache controller is used to partition the cache memory based on a pre-configured cache partitioning strategy, dividing the cache memory into multiple cache partitions; The cache controller is also used to adjust the capacity of the cache partition corresponding to the target thread based on the monitoring results of the cache utilization monitor and / or the cache bandwidth monitor.

15. An electronic device, characterized in that, The electronic device includes a memory and a processor; The memory and the processor are coupled; The memory is used to store program instructions; The processor is configured to read the program instructions stored in the memory to implement the resource allocation method as described in any one of claims 1 to 11, or to implement the resource allocation method as described in any one of claims 12 to 13.

16. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-readable instructions, which, when executed by a processor, implement the resource allocation method as described in any one of claims 1 to 11, or implement the resource allocation method as described in any one of claims 12 to 13.