Dynamic allocation method and device of cache area, computer device and medium

By dynamically allocating the cache area, the cache size is adjusted dynamically according to the total memory space and the amount of data, which solves the problem of low memory management efficiency caused by fixed cache area, achieves a balance between data migration and data computing power, and improves the efficiency and accuracy of memory management.

CN116010302BActive Publication Date: 2026-06-23SHENZHEN INTELLIFUSION TECHNOLOGIES CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
SHENZHEN INTELLIFUSION TECHNOLOGIES CO LTD
Filing Date
2022-12-29
Publication Date
2026-06-23

AI Technical Summary

Technical Problem

In existing memory management methods, the cache size of data blocks is usually a fixed value, which may result in too few or too many data blocks, making it impossible to guarantee data movement and concurrent data computing power, thus leading to low memory management efficiency.

Method used

By obtaining the ratio of the number of cache areas to the total memory space, the maximum subspace is determined, a grading table is established, the target grading level and the range of available grading levels are dynamically updated, and cache space is dynamically allocated based on the actual data volume and the minimum cache space, thus balancing data migration and data computing power.

Benefits of technology

It improves the efficiency and accuracy of memory management, ensures parallel data processing and data migration, avoids waste of memory resources, and improves overall processing efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116010302B_ABST
    Figure CN116010302B_ABST
Patent Text Reader

Abstract

The application relates to the technical field of storage management, in particular to a dynamic allocation method and device of a cache area, computer equipment and a medium. The method obtains the number of cache areas and the total memory space, calculates the ratio of the total memory space and the number as a maximum subspace, obtains a level table, determines a preset level meeting a preset condition as a target level, updates a reference subspace corresponding to the target level, obtains an actual data amount and a minimum cache space, reads an updated subspace of an adjacent level of any preset level, when the actual data amount is smaller than a reference data amount of the preset level and the minimum cache space is smaller than the updated subspace, uses the updated subspace as the allocation cache space of target data, and the level table is updated in real time through the total memory space, the number of cache areas, the actual data amount and the minimum cache space of the target data obtained in real time, the allocation cache space of the target data is dynamically determined, and the efficiency and accuracy of memory allocation are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of storage management technology, and in particular to a method, apparatus, computer device, and medium for dynamic allocation of cache areas. Background Technology

[0002] Currently, with the increasing demand for high-performance operators and the growing volume of data being processed, embedded programming typically employs data block processing to handle the current data. Furthermore, to ensure parallel processing of data transfer and computing power, and to improve the effective utilization of tightly coupled memory space on the embedded platform, ping-pong buffers or circular buffers are commonly used to manage and allocate tightly coupled memory. This provides computing power for processing the current data block while simultaneously enabling the transfer of the next data block.

[0003] However, in existing memory management methods, the cache size of data blocks is usually a fixed value. This can result in the number of data blocks being too small, making it impossible to guarantee data movement and concurrent data computing power through multiple data blocks, or the number of data blocks being too large, which increases the scheduling time for data movement and thus leads to low memory management efficiency. Therefore, how to improve the efficiency of memory management has become an urgent problem to be solved. Summary of the Invention

[0004] In view of this, embodiments of the present invention provide a method, apparatus, computer device, and medium for dynamic allocation of cache areas to solve the problem of low memory management efficiency.

[0005] In a first aspect, embodiments of the present invention provide a method for dynamically allocating a cache, the method comprising:

[0006] Obtain the number of cache areas and the total remaining memory space, calculate the ratio of the total memory space to the number of cache areas, and determine the ratio calculation result as the maximum subspace;

[0007] Obtain a preset level table, which includes N preset levels and their corresponding reference subspaces and reference data volumes, where N is an integer greater than zero;

[0008] The minimum preset level among all preset levels corresponding to reference subspaces larger than the maximum subspace is determined as the target level. The reference subspaces corresponding to the target level are updated in the level table with the maximum subspace to obtain the updated level table.

[0009] Obtain the actual data volume and minimum cache space of the target data, and determine the available level range based on the preset value and the target level. For any preset level within the available level range, determine the adjacent levels of the preset level, and read the updated subspace of the adjacent level from the updated level table.

[0010] If the actual data volume is less than the reference data volume of the preset level and the minimum cache space is less than the update subspace, then the update subspace is used as the allocation cache space for the target data.

[0011] Secondly, embodiments of the present invention provide a dynamic allocation device for a cache area, the dynamic allocation device comprising:

[0012] The space acquisition module is used to acquire the number of cache areas and the total remaining memory space, calculate the ratio of the total memory space to the number of cache areas, and determine the ratio calculation result as the maximum subspace.

[0013] The table acquisition module is used to acquire a preset level table, which includes N preset levels and their corresponding reference subspaces and reference data volumes, where N is an integer greater than zero.

[0014] The table update module is used to determine the minimum preset level among all preset levels corresponding to reference subspaces that are greater than the maximum subspace as the target level, and update the reference subspace corresponding to the target level in the level table with the maximum subspace to obtain the updated level table.

[0015] The space reading module is used to obtain the actual data volume and minimum cache space of the target data, and determine the available level range according to the preset value and the target level. For any preset level within the available level range, it determines the adjacent levels of the preset level and reads the updated subspace of the adjacent level from the updated level table.

[0016] The space allocation module is used to use the updated subspace as the allocation cache space for the target data if the actual data volume is less than the reference data volume of the preset level and the minimum cache space is less than the updated subspace.

[0017] Thirdly, embodiments of the present invention provide a computer device, the computer device including a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the dynamic allocation method as described in the first aspect.

[0018] Fourthly, embodiments of the present invention provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the dynamic allocation method as described in the first aspect.

[0019] The beneficial effects of the embodiments of the present invention compared with the prior art are as follows:

[0020] Obtain the number of cache areas and the total remaining memory space. Calculate the ratio of total memory space to number of cache areas, and determine the result of this ratio as the maximum subspace. Obtain a preset level table, which includes N preset levels, their corresponding reference subspaces, and reference data volumes. Determine the minimum preset level among all preset levels corresponding to reference subspaces greater than the maximum subspace as the target level. Update the reference subspaces corresponding to the target level in the level table using the maximum subspace, resulting in an updated level table. Obtain the actual data volume and minimum cache space of the target data. Based on the preset values ​​and the target level, determine the range of available levels. For any preset level within the level range, determine the adjacent levels of the preset level, read the updated subspace of the adjacent level from the updated level table, and if the actual data volume is less than the reference data volume of the preset level and the minimum cache space is less than the updated subspace, then the updated subspace is used as the allocation cache space for the target data. By obtaining the total memory space, the number of cache areas, the actual data volume of the target data, and the minimum cache space in real time, the level table is updated in real time, and the allocation cache space for the target data is dynamically determined according to the updated level table. This balances the cache space allocation for data migration and data computing power, thereby improving the efficiency and accuracy of memory allocation. Attached Figure Description

[0021] To more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0022] Figure 1 This is a schematic diagram of an application environment for a dynamic allocation method for a cache area provided in Embodiment 1 of the present invention;

[0023] Figure 2 This is a flowchart illustrating a dynamic allocation method for a cache area provided in Embodiment 1 of the present invention;

[0024] Figure 3 This is a schematic diagram of the structure of a dynamic allocation device for a cache area provided in Embodiment 2 of the present invention;

[0025] Figure 4 This is a schematic diagram of the structure of a computer device provided in Embodiment 3 of the present invention. Detailed Implementation

[0026] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of the invention. However, those skilled in the art will understand that the invention can be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods are omitted so as not to obscure the description of the invention with unnecessary detail.

[0027] It should be understood that, when used in this specification and the appended claims, the term "comprising" indicates the presence of the described features, integrals, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or collections thereof.

[0028] It should also be understood that the term “and / or” as used in this specification and the appended claims refers to any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.

[0029] As used in this specification and the appended claims, the term "if" may be interpreted, depending on the context, as "when," "once," "in response to determination," or "in response to detection." Similarly, the phrase "if determined" or "if [described condition or event] is detected" may be interpreted, depending on the context, as meaning "once determined," "in response to determination," "once [described condition or event] is detected," or "in response to detection of [described condition or event]."

[0030] Furthermore, in the description of this invention and the appended claims, the terms "first," "second," "third," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.

[0031] References to "one embodiment" or "some embodiments" as described in this specification mean that one or more embodiments of the invention include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.

[0032] It should be understood that the sequence number of each step in the following embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.

[0033] To illustrate the technical solution of the present invention, specific embodiments are described below.

[0034] The dynamic allocation method for a buffer provided in Embodiment 1 of this invention can be applied to applications such as... Figure 1 In this application environment, the client communicates with the server. The client includes, but is not limited to, handheld computers, desktop computers, laptops, ultra-mobile personal computers (UMPCs), netbooks, cloud terminal devices, and personal digital assistants (PDAs). The server can be a standalone server or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms.

[0035] The client can target the data to be processed. When the amount of data to be processed is large, the data to be processed is divided into blocks to obtain multiple target data. The client is used to allocate memory space for the cache corresponding to each target data. The memory space can be a tightly coupled memory space within the server.

[0036] Tightly coupled memory can be applied to applications such as predictable real-time interrupt handling, encryption algorithms that avoid cache analysis, and processor-side encoding / decoding with improved performance. Tightly coupled memory can be used as a cache or as local memory. Both clients and servers can be deployed in cache memory allocation scenarios on embedded platforms. The server can communicate with at least one client to allocate cache memory space for data to be processed by multiple clients.

[0037] See Figure 2 This is a flowchart illustrating a dynamic allocation method for a buffer provided in Embodiment 1 of the present invention. The aforementioned dynamic allocation method for a buffer can be applied to... Figure 1The client, whose corresponding computer device connects to the server, obtains information from the server regarding the total remaining memory space, the number of cache areas, and a preset tier table. The number of cache areas can refer to the number of cache areas set in the memory management method. The total remaining memory space can refer to the amount of space available for memory allocation within the server. The preset tier table can be used for real-time adjustment of cache space allocation. The client's computer device obtains the target data, its actual data volume, and the minimum cache space from the user terminal. The actual data volume can be the total amount of target data, and the minimum cache space can be used to determine the minimum allocated space size for the target data. For example... Figure 2 As shown, the dynamic allocation method for this cache area may include the following steps:

[0038] Step S201: Obtain the number of cache areas and the total remaining memory space, calculate the ratio of the total memory space to the number of cache areas, and determine the ratio calculation result as the maximum subspace.

[0039] The number of cache areas can refer to the number of cache areas of the film crew in the memory management scheme configured in the embedded platform. The remaining total memory space can refer to the total amount of memory space that can be used for cache allocation in the embedded platform. The ratio calculation result can represent the maximum memory space size that a single cache area can theoretically be allocated, that is, the maximum subspace.

[0040] Specifically, when the amount of data to be processed is large, the embedded platform usually cannot provide a corresponding amount of memory space for the data to be processed to perform calculations. The memory that the embedded platform can provide can refer to tightly coupled memory (TCM). Therefore, it is necessary to perform data segmentation on the data to be processed to obtain multiple data blocks with smaller data volumes, and then provide memory space for the data blocks to realize the management and planning of the total memory space.

[0041] In embedded programming, memory management schemes for tightly coupled memory can be implemented using ping-pong buffers or circular buffers. A ping-pong buffer, also known as a dual buffer, uses at least two buffers for memory management. One buffer is used for data processing, while the other buffers are used for data movement, i.e., data read and write operations. Taking the ping-pong buffer as an example, at the current moment, one buffer is used for data processing, and the other buffer is used for data read and write. The data processing and data read / write steps are completed in parallel. In the next moment, the read data can be processed, and the processed data can be written out and new data can be read in. This cycle ensures that data processing and data read / write are parallel at each moment, so that processed data can be written out at each moment. Thus, at the cost of increasing the buffer space, the data processing efficiency is improved.

[0042] The number of cache areas in the ping-pong buffer is two. The number of cache areas in the circular buffer can be obtained statistically, and is usually an integer greater than 2. Let the number of cache areas be 'a', and the remaining total memory space, i.e., the available tightly coupled memory, be 'b'. Then the maximum subspace (max) can be expressed as:

[0043]

[0044] The steps described above—obtaining the number of cache areas and the remaining total memory space, calculating the ratio of the total memory space to the number of cache areas, and determining the result of the ratio calculation as the maximum subspace—can determine the maximum allocatable space of a single cache area. This allows for subsequent use of the maximum allocatable space as a reference upper limit to restrict the cache space allocation of each cache area, thus avoiding situations where the total memory space cannot meet the cache space requirements of the cache areas, which would lead to low memory management accuracy. This effectively improves the accuracy of memory management.

[0045] Step S202: Obtain a preset level table, which includes N preset levels and their corresponding reference subspaces and reference data volumes.

[0046] The preset level table can be 3*N in size, that is, three rows and N columns. Each row corresponds to one attribute information, which can be the preset level, reference subspace, and reference data volume. Each column corresponds to all parameter information of a preset level. The parameter information includes the reference subspace and the reference data volume corresponding to the preset level. The preset level can refer to the management level of the cache, which is used to instruct the cache to perform memory management and allocation. The reference subspace can refer to the amount of memory allocated under normal circumstances for the corresponding preset level. The reference data volume can refer to the amount of data corresponding to the processing requirements that the reference subspace provided by the corresponding preset level can meet. N is an integer greater than zero.

[0047] Optionally, obtaining a preset level table includes:

[0048] Establish N preset levels and their corresponding reference subspaces to obtain N first mapping relationships;

[0049] For any reference subspace, multiply the reference subspace with a preset coefficient, and determine the multiplication result as the reference data volume corresponding to the reference subspace. Traverse each reference subspace to obtain the reference data volume of the corresponding reference subspace, and establish a second mapping relationship between N preset levels and their corresponding reference data volumes.

[0050] The N preset levels, reference subspaces, and reference data volumes are concatenated in ascending order to obtain a level table.

[0051] The first mapping relationship may include the mapping relationship between the preset level and the reference subspace. The preset coefficient may refer to the minimum number of blocks, that is, the minimum number of blocks when the data to be processed is divided into blocks. The second mapping relationship may include the mapping relationship between the preset level and the reference data volume.

[0052] Specifically, in this embodiment, the preset levels are represented by level0, level1, ..., leveln, ... levelN, etc. For example, if the reference data volume q is 128k and the preset coefficient is 4, that is, the minimum number of blocks is 4, then the amount of data to be processed for each data block is... That is, 32k.

[0053] The amount of data that a single data block needs to process is also the size of the reference subspace. When the size of the reference subspace is greater than the amount of data that a single data block needs to process, it means that the reference subspace can meet the memory requirements for processing the data in a single data block. Let the preset level at this time be level 4. Then the concatenation result of the fifth preset level, reference subspace, and reference data amount is [level4, 32k, 128k]. T Accordingly, the reference data size and reference subspace corresponding to preset levels lower than level 4 can be halved sequentially. For example, the concatenation result of the fourth set of preset levels, reference subspaces, and reference data size is [level 3, 16k, 64k]. T The concatenation result of the third set of preset levels, reference subspaces, and reference data sizes is [level2, 8k, 32k]. T The concatenation result of the second set of preset levels, reference subspaces, and reference data sizes is [level1, 4k, 16k]. T The first set of preset levels, reference subspaces, and reference data sizes is concatenated as [level0, 2k, 8k]. TBy concatenating the five preset levels, reference subspaces, and reference data volumes in ascending order of the five preset levels, a level table can be obtained.

[0054] For cases with a small amount of data to be processed, such as less than 2k, the preset level can be set to level 0. In this case, the data corresponding to the amount of data to be processed only needs to occupy a single reference subspace to meet its data processing requirements, that is, the number of data blocks is only 1. It should be noted that the implementer can adjust the value of the preset coefficient according to the actual situation.

[0055] In this embodiment, a reference subspace is determined based on the reference data volume and the minimum number of blocks. Then, a level table is constructed based on the preset level, the reference subspace, and the reference data volume. This allows the data to be processed to determine the appropriate preset level from the level table based on its data volume for memory allocation management, thereby improving memory allocation efficiency. At the same time, the use of a level table makes it easy to update and maintain the data according to real-time conditions, ensuring the timeliness of memory allocation.

[0056] The above steps for obtaining the preset level table, which includes N preset levels and their corresponding reference subspaces and reference data volumes, can conveniently and quickly guide the data to be processed to allocate appropriate cache space, thereby improving the efficiency of cache space allocation.

[0057] Step S203: Determine the minimum preset level among all preset levels corresponding to reference subspaces that are greater than the maximum subspace as the target level, and update the reference subspace corresponding to the target level in the level table with the maximum subspace to obtain the updated level table.

[0058] The target level can refer to the preset level to be updated, and the updated level table can refer to the level table that has been updated based on the largest subspace.

[0059] Specifically, there may be more than one preset level corresponding to the reference subspace that is larger than the maximum subspace. In order to avoid waste during memory allocation, which would prevent other data to be processed from being allocated enough memory space and affect the data processing efficiency of multiple data to be processed, the smallest preset level among all the preset levels corresponding to the reference subspace that is larger than the maximum subspace is selected as the target level.

[0060] Since the memory space required for the same data to be processed may be different when using different operators, and the memory space required for the same operator to process the data to be processed in different scenarios may also be different, it is necessary to determine the minimum preset level that can be used and update the reference subspace in the level table. In this embodiment, "can be used" means that when using the preset level, it will not cause memory allocation waste.

[0061] Optionally, determining the minimum preset level among all preset levels corresponding to reference subspaces larger than the maximum subspace as the target level includes:

[0062] The initial iteration count is zero, and a preset level with the same iteration count is used as a temporary level.

[0063] Compare the maximum subspace with the reference subspace corresponding to the temporary level. If the maximum subspace is smaller than the reference subspace corresponding to the temporary level, then the temporary level is determined as the target level.

[0064] If the maximum subspace is greater than the reference subspace corresponding to the temporary level, the iteration count is incremented by one, and the process returns to the previous step of using the preset level with the same number of iterations as the temporary level and comparing the maximum subspace with the reference subspace corresponding to the temporary level, until the maximum subspace is greater than the reference subspace corresponding to the temporary level or the iteration count is the same as the maximum value among the N preset levels, at which point the iteration stops.

[0065] Here, the number of iterations can refer to the iteration rounds in the iteration process, and the temporary level can refer to the preset level corresponding to the current iteration round.

[0066] Specifically, if the number of iterations is zero, the preset level with the same number of iterations is level0. Level0 is used as the temporary level. The reference subspace corresponding to the temporary level is read through the level table. The maximum subspace is compared with the reference subspace corresponding to the temporary level. If the maximum subspace is less than the reference subspace corresponding to the temporary level, the temporary level is determined as the target level, and the iteration process can be exited.

[0067] If the maximum subspace is greater than the reference subspace corresponding to the temporary level, it means that the reference subspace corresponding to the temporary level cannot meet the maximum memory requirements for data processing. Therefore, iteration needs to continue, increasing the iteration count by one (to 1). The process returns to the previous iteration, using the same preset level as the iteration count as the temporary level (level1). The maximum subspace is then compared with the reference subspace corresponding to the temporary level. If the maximum subspace is still greater than the reference subspace, the iteration process continues until the maximum subspace is greater than the reference subspace, meaning a preset level that meets the maximum memory requirements for data processing has been determined. Alternatively, the iteration count can be the same as the maximum value among the N preset levels, meaning all preset levels have been compared, and the iteration stops. Clearly, using iteration from the minimum level to determine the target level effectively reduces the number of comparisons between the reference subspace and the maximum subspace corresponding to the preset level, thus improving the efficiency of the overall memory allocation process.

[0068] In this embodiment, traversing all preset levels in the level table from the lowest level can effectively reduce the number of comparisons between the reference subspace corresponding to the preset level and the largest subspace after data block division of the data to be processed, simplifying the calculation process, reducing the extra consumption of computing resources, and thus effectively improving the efficiency of cache allocation.

[0069] Optionally, after the number of iterations is the same as the maximum value among the N preset levels, the following is also included:

[0070] If the largest subspace is still smaller than the reference subspace corresponding to the temporary level, then new preset levels are added sequentially after the N preset levels to obtain a preliminary updated level table.

[0071] The maximum value of all preset levels in the initially updated level table is determined to be the target level.

[0072] The new preset level can refer to a preset level other than the preset levels already present in the level table, and the initially updated level table can refer to a level table that includes the new preset level.

[0073] Specifically, when the number of iterations is the same as the maximum value among the N preset levels, the maximum subspace is still smaller than the reference subspace corresponding to the temporary level. This indicates that the maximum preset level cannot meet the maximum memory requirements of the data to be processed. Therefore, a new preset level needs to be set to meet the maximum memory requirements of the data to be processed.

[0074] The new preset level can be one position forward from the existing preset levels in the level table. For example, if the existing preset levels in the level table are level0, level1, level2, level3, and level4, then the new preset level can be level5.

[0075] The maximum value of all preset levels in the initially updated level table is the new preset level added to the level table.

[0076] The largest subspace is used as the reference subspace for the new preset level. The product of the largest subspace and the preset coefficient is used as the reference data volume for the new preset level. The reference subspace and the reference data volume for the new preset level also need to be updated in the level table. That is, the initially updated level table can be a level table that includes the new preset level, the reference subspace for the new preset level, and the reference data volume for the new preset level.

[0077] In this embodiment, a new preset level is set to meet the maximum memory requirements of the data to be processed, thereby ensuring the stability of the data processing and avoiding interruptions, terminations, or stuttering during data processing, thus improving the accuracy of memory allocation and management.

[0078] The steps described above—identifying the minimum preset level among all preset levels corresponding to reference subspaces larger than the maximum subspace as the target level, updating the reference subspace corresponding to the target level in the level table with the maximum subspace, and obtaining the updated level table—ensure that the reference subspace of the target level in the updated level table can adapt to the maximum subspace after the data to be processed is divided into data blocks. This ensures that the memory requirements after the data to be processed is met, while avoiding memory waste during memory allocation, improving the accuracy of memory allocation management, and thus improving the overall processing efficiency after the cache memory allocation.

[0079] Step S204: Obtain the actual data volume and minimum cache space of the target data, and determine the range of available levels based on the preset value and the target level. For any preset level within the range of available levels, determine the adjacent levels of the preset level, and read the updated subspace of the adjacent levels from the updated level table.

[0080] Among them, actual data volume can refer to the real data volume of the target data, minimum cache space can refer to the minimum memory space used by the target data, target data can refer to the block data after the data to be processed is divided into blocks, preset value can refer to the preset starting level, and available level range can refer to the level range corresponding to the preset level that the target data can be applied to.

[0081] Adjacent level can refer to a preset level that is adjacent to a preset level, and updated subspace can refer to the updated reference subspace in the updated level table.

[0082] Specifically, in actual use, multiple data to be processed may be allocated memory in the cache at the same time, and the target levels corresponding to each data to be processed are different. Therefore, there may be a situation where multiple preset level reference subspaces are updated. If there is no conflict in the target levels, that is, the preset levels corresponding to different target levels of multiple data to be processed are also different, then the reference subspaces corresponding to all target levels in the level table are updated directly before reading. That is, the updated subspaces of adjacent levels are read from the updated level table. It should be noted that if the reference subspaces of adjacent levels have not been updated, then the reference subspaces can be used as the updated subspaces.

[0083] If there is a conflict in the target levels, that is, if different target levels of multiple data to be processed correspond to the same preset level, the data to be processed with conflict will be divided into different batches and allocated in the memory of the cache to ensure the data processing effect of all data to be processed.

[0084] Optionally, the range of available levels can be determined based on preset values ​​and target levels, including:

[0085] The preset value is used as the lower boundary of the available level range, and the target level is used as the upper boundary of the available level range.

[0086] Determine the range of available levels based on the upper and lower boundaries.

[0087] The lower boundary can refer to the minimum value of the available grade range, and the upper boundary can refer to the maximum value of the available grade range.

[0088] Specifically, the preset value can be set to level0. For example, if the target level is level4, the available level range can be represented as [level0, level1, level2, level3, level4].

[0089] The amount of memory space required for the target data varies during data transfer and data processing. The memory space required for the same target data at different stages may fluctuate between the minimum cache space and the maximum subspace. Therefore, the preset level for adaptation is determined based on the range of available levels, and the memory allocation space of the target data cache area can be dynamically adjusted to make more efficient use of the overall memory space.

[0090] In this embodiment, the range of available levels is determined based on preset values ​​and target levels, so that the preset level selected for the target data can be determined from the range of available levels, adapting to different needs of the target data, improving the flexibility of the memory allocation process, and thus improving the accuracy of memory allocation.

[0091] Optionally, determining the adjacent levels of the preset level includes:

[0092] Determine the position of the preset level in the updated level table;

[0093] The preset level corresponding to the position before it is used as the adjacent level.

[0094] Here, "position" can refer to the column number of the preset level in the row of the preset level in the updated level table, and the preceding digit of the position can refer to the position after subtracting one from the column number.

[0095] Specifically, the updated grade table contains a row corresponding to a preset grade. This row includes multiple preset grades. In this embodiment, the grade table is constructed in ascending order of the preset grades. Therefore, the column number of a preset grade in the preset grade row of the updated grade table is the position of the preset grade in the preset grade sorting.

[0096] The position preceding the preset level is the position corresponding to the preset level after subtracting one from its position in the updated level table.

[0097] In this embodiment, the adjacent levels of each preset level are determined by the positional relationship in the preset level sorting, which facilitates the subsequent comparison of the minimum cache space of the target data with the reference subspace corresponding to the adjacent levels to determine the preset level that the target data is adapted to, thereby effectively improving the memory allocation accuracy of the target data cache area.

[0098] The above steps of obtaining the actual data volume and minimum cache space of the target data, determining the available level range based on preset values ​​and target levels, determining the adjacent levels of any preset level within the available level range, and reading the updated subspace of the adjacent levels from the updated level table, obtain the actual information of the target data and determine the available level range. This facilitates the subsequent determination of the preset level for target data adaptation, thereby improving the memory allocation accuracy of the target data cache area.

[0099] Step S205: If the actual data volume is less than the reference data volume of the preset level and the minimum cache space is less than the update subspace, then the update subspace is used as the allocation cache space for the target data.

[0100] In this context, "allocating cache space" can refer to the size of the memory space allocated to the cache area corresponding to the target data.

[0101] Specifically, if the actual data volume is less than the reference data volume of a preset level, it means that the memory space provided by the preset level has exceeded the actual data processing requirements of the target data. If the minimum cache space is less than the update subspace, it means that the memory space provided by the adjacent levels of the preset level can meet the actual minimum requirements of the target data.

[0102] When the actual data volume is less than the reference data volume of the preset level and the minimum cache space is less than the update subspace, it means that the memory space provided by the preset level exceeds the actual data processing requirements of the target data. However, the memory space provided by the adjacent levels of the preset level can meet the actual minimum requirements of the target data. In order to avoid wasting memory resources, the adjacent levels of the preset level are used as the allocation level, and the update subspace corresponding to the adjacent levels of the preset level is used as the allocation cache space for the target data.

[0103] Optionally, after determining the adjacent levels of any preset level within the available level range, and reading the update subspace of the adjacent levels from the updated level table, the method further includes:

[0104] Iterate through each preset level within the available level range;

[0105] If the actual data volume is not less than the reference data volume corresponding to each preset level within the available level range, or the minimum cache space is not less than the update subspace of the adjacent level corresponding to each preset level within the available level range, then the update subspace corresponding to the maximum value of all preset levels within the available level range shall be used as the allocation cache space for the target data.

[0106] In this embodiment, if the actual data volume is not less than the reference data volume corresponding to each preset level within the available level range, it indicates that the memory space provided by all preset levels cannot meet the actual data processing needs of the target data.

[0107] If the minimum cache space is not less than the update subspace of the adjacent level corresponding to each preset level within the available level range, it means that the memory space provided by the adjacent levels of all preset levels cannot meet the actual minimum requirements of the target data.

[0108] At this point, if none of the preset levels can meet the memory allocation requirements of the target data, then the memory space provided by the maximum value of all preset levels should be the closest to the memory allocation requirements of the target data. Therefore, the updated subspace corresponding to the maximum value of all preset levels within the available level range is used as the allocation cache space for the target data.

[0109] It should be noted that, in order to simplify the calculation, in this embodiment, the range of available levels is adjusted to start from level 1, that is, the range of available levels does not include level 0.

[0110] In this embodiment, based on the comparison results of the actual data volume of the target data and the reference data volume corresponding to the preset level, as well as the comparison results of the minimum cache space of the target data and the reference data volume of the adjacent levels corresponding to the preset level, the cache area memory space most suitable for the target data is determined, thereby ensuring the processing efficiency of the target data as much as possible.

[0111] The above steps, where the actual data volume is less than the preset level of reference data volume and the minimum cache space is less than the update subspace, involve allocating cache space using the update subspace as the target data.

[0112] In this embodiment, the grading table is updated in real time by acquiring the total memory space, the number of cache areas, the actual data volume of the target data, and the minimum cache space. The allocated cache space for the target data is dynamically determined based on the updated grading table, balancing the cache space allocation for data migration and data computing power, thereby improving the efficiency and accuracy of memory allocation.

[0113] Corresponding to the dynamic allocation method of the cache area in the above embodiment, Figure 3 A structural block diagram of a dynamic cache allocation device provided in Embodiment 2 of the present invention is shown. This dynamic cache allocation device is applied to a client. The computer device corresponding to the client connects to a corresponding server to obtain the remaining total memory space, the number of cache areas, and a preset level table from the server. The number of cache areas can refer to the number of cache areas set in the memory management method. The remaining total memory space can refer to the amount of space available for memory allocation within the server. The preset level table can be used for real-time adjustment of cache space allocation. The computer device corresponding to the client obtains the target data, the actual data volume of the target data, and the minimum cache space from the user terminal. The actual data volume can be the data volume of the target data, and the minimum cache space can be used to determine the minimum allocated space size for the target data. For ease of explanation, only the parts related to the embodiments of the present invention are shown.

[0114] See Figure 3 The dynamic allocation mechanism for the cache includes:

[0115] The space acquisition module 31 is used to acquire the number of cache areas and the total remaining memory space, calculate the ratio of the total memory space to the number of cache areas, and determine the ratio calculation result as the maximum subspace.

[0116] The table acquisition module 32 is used to acquire a preset level table, which includes N preset levels and their corresponding reference subspaces and reference data volumes, where N is an integer greater than zero.

[0117] The table update module 33 is used to determine the minimum preset level among all preset levels corresponding to reference subspaces that are greater than the maximum subspace as the target level, and update the reference subspace corresponding to the target level in the level table with the maximum subspace to obtain the updated level table.

[0118] The space reading module 34 is used to obtain the actual data volume and minimum cache space of the target data, and determine the available level range according to the preset value and the target level. For any preset level within the available level range, it determines the adjacent levels of the preset level and reads the updated subspace of the adjacent level from the updated level table.

[0119] The space allocation module 35 is used to allocate cache space with the update subspace as the target data if the actual data volume is less than the reference data volume of the preset level and the minimum cache space is less than the update subspace.

[0120] Optionally, the above table acquisition module 32 includes:

[0121] The first relation establishment unit is used to establish mapping relationships between N preset levels and their corresponding reference subspaces, thereby obtaining N first mapping relationships;

[0122] The second relationship establishment unit is used to multiply the reference subspace and preset coefficients for any reference subspace, determine the multiplication result as the reference data quantity corresponding to the reference subspace, traverse each reference subspace to obtain the reference data quantity of the corresponding reference subspace, and establish a second mapping relationship between N preset levels and the corresponding reference data quantities.

[0123] The table splicing unit is used to splice N sets of preset levels, reference subspaces, and reference data in ascending order of N preset levels to obtain a level table.

[0124] Optionally, the above table update module 33 includes:

[0125] An initialization unit is used to initialize the iteration count to zero, and uses a preset level with the same iteration count as a temporary level.

[0126] The spatial comparison unit is used to compare the maximum subspace with the reference subspace corresponding to the temporary level. If the maximum subspace is smaller than the reference subspace corresponding to the temporary level, the temporary level is determined as the target level.

[0127] The iteration judgment unit is used to increment the iteration count by one if the maximum subspace is greater than the reference subspace corresponding to the temporary level, and return to execute the steps of taking the preset level with the same number of iterations as the temporary level, comparing the maximum subspace with the reference subspace corresponding to the temporary level, until the maximum subspace is greater than the reference subspace corresponding to the temporary level or the number of iterations is the same as the maximum value among the N preset levels, and then stop the iteration.

[0128] Optionally, the above table update module 33 also includes:

[0129] The level addition unit is used to add a new preset level in sequence after N preset levels if the maximum subspace is still smaller than the reference subspace corresponding to the temporary level, so as to obtain a preliminary updated level table.

[0130] The target level determination unit is used to determine the maximum value of all preset levels in the initially updated level table as the target level.

[0131] Optionally, the aforementioned space reading module 34 includes:

[0132] The boundary determination unit is used to use a preset value as the lower boundary of the available level range and the target level as the upper boundary of the available level range.

[0133] The range determination unit is used to determine the range of available levels based on the upper and lower boundaries.

[0134] Optionally, the aforementioned space reading module 34 also includes:

[0135] The position determination unit is used to determine the position of the preset level in the updated level table;

[0136] The adjacent level determination unit is used to determine the adjacent level based on the preset level corresponding to the previous position.

[0137] Optionally, the dynamic allocation device for the aforementioned cache area also includes:

[0138] The level traversal module is used to traverse each preset level within the available level range;

[0139] The space setting module is used to allocate cache space for target data if the actual data volume is not less than the reference data volume corresponding to each preset level within the available level range, or the minimum cache space is not less than the update subspace of the adjacent level corresponding to each preset level within the available level range.

[0140] It should be noted that the information interaction and execution process between the above modules and units are based on the same concept as the method embodiments of the present invention. For details on their specific functions and technical effects, please refer to the method embodiments section, which will not be repeated here.

[0141] Figure 4 This is a schematic diagram of the structure of a computer device provided in Embodiment 3 of the present invention. Figure 4 As shown, the computer device of this embodiment includes: at least one processor (in...) Figure 4 Only one is shown in the diagram), a memory, and a computer program stored in the memory that can run on at least one processor, which, when executing the computer program, implements the steps in the embodiments of the dynamic allocation method for any of the above-described cache areas.

[0142] This computer device may include, but is not limited to, a processor and memory. Those skilled in the art will understand that... Figure 4 The examples of computer devices are merely examples and do not constitute a limitation on computer devices. Computer devices may include more or fewer components than shown in the illustration, or combinations of certain components, or different components, such as network interfaces, displays, and input devices.

[0143] The term "processor" can refer to a CPU, but it can also refer to other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor can refer to a microprocessor, or it can be any conventional processor.

[0144] Memory includes readable storage media, internal memory, etc., where internal memory can refer to the RAM of a computer device. Internal memory provides an environment for the operation of the operating system and computer-readable instructions stored in the readable storage media. The readable storage media can refer to the hard disk of a computer device, or in some embodiments, to external storage devices of the computer device, such as plug-in hard disks, smart media cards (SMC), secure digital cards (SD), flash cards, etc., all equipped on the computer device. Furthermore, memory can include both internal storage units and external storage devices of the computer device. Memory can be used to store operating systems, applications, bootloaders, data, and other programs, such as program code for computer programs. Memory can also be used to temporarily store data that has been output or will be output.

[0145] Those skilled in the art will understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is used as an example. In practical applications, the functions described above can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments 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. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this invention. The specific working process of the units and modules in the above device can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here. 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 computer-readable storage medium. Based on this understanding, the present invention can implement all or part of the processes in the methods of the above embodiments by instructing related hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the above method embodiments. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. A computer-readable medium can include at least: any entity or device capable of carrying computer program code, a recording medium, a computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media. Examples include USB flash drives, portable hard drives, magnetic disks, or optical disks. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electrical carrier signals or telecommunication signals.

[0146] The present invention can implement all or part of the processes in the methods of the above embodiments, or it can be accomplished by a computer program product. When the computer program product is run on a computer device, the computer device executes the steps in the above method embodiments.

[0147] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0148] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.

[0149] In the embodiments provided by this invention, it should be understood that the disclosed apparatus / computer devices and methods can be implemented in other ways. For example, the apparatus / computer device 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 system, 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 apparatuses or units may be electrical, mechanical, or other forms.

[0150] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0151] The above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention 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 spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included within the protection scope of the present invention.

Claims

1. A method for dynamically allocating a buffer, characterized in that, The dynamic allocation method includes: Obtain the number of cache areas and the total remaining memory space, calculate the ratio of the total memory space to the number of cache areas, and determine the ratio calculation result as the maximum subspace; Obtain a preset level table, the level table including Each preset level and its corresponding reference subspace and reference data volume Integers greater than zero; The minimum preset level among all preset levels corresponding to reference subspaces greater than the maximum subspace is determined as the target level. The reference subspace corresponding to the target level is updated in the level table with the maximum subspace to obtain an updated level table. In the updated level table, the updated reference subspace corresponding to the target level is the maximum subspace. The reference subspaces corresponding to other levels besides the target level are not updated. Obtain the actual data volume and minimum cache space of the target data, and determine the available level range according to the preset value and the target level. For any preset level within the available level range, determine the adjacent levels of the preset level, read the update subspace of the adjacent level from the updated level table, and if the reference subspace of the adjacent level has not been updated, then use the reference subspace as the update subspace. If the actual data volume is less than the reference data volume of the preset level and the minimum cache space is less than the update subspace, then the update subspace is used as the allocation cache space for the target data.

2. The dynamic allocation method according to claim 1, characterized in that, The process of obtaining the preset level table includes: Establish The mapping relationship between each preset level and its corresponding reference subspace is obtained. The first mapping relationship; For any reference subspace, multiply the reference subspace by a preset coefficient, and determine the multiplication result as the reference data volume corresponding to the reference subspace. This process is repeated for each reference subspace to obtain the reference data volume for that subspace, thus establishing... The second mapping relationship between each preset level and the corresponding reference data volume; According to the above The preset levels will be ordered from smallest to largest. The preset levels, reference subspaces, and reference data volumes are concatenated to obtain the level table.

3. The dynamic allocation method according to claim 1, characterized in that, The step of determining the minimum preset level among all preset levels corresponding to reference subspaces larger than the maximum subspace as the target level includes: The initial iteration count is zero, and a preset level with the same iteration count is used as a temporary level. The maximum subspace is compared with the reference subspace corresponding to the temporary level. If the maximum subspace is smaller than the reference subspace corresponding to the temporary level, the temporary level is determined to be the target level. If the maximum subspace is greater than the reference subspace corresponding to the temporary level, then the iteration count is incremented by one, and the process returns to the step of using a preset level with the same iteration count as the temporary level, comparing the maximum subspace with the reference subspace corresponding to the temporary level, until the maximum subspace is less than the reference subspace corresponding to the temporary level or the iteration count is greater than the reference subspace corresponding to the temporary level. If the maximum values ​​in all preset levels are the same, stop the iteration.

4. The dynamic allocation method according to claim 3, characterized in that, The number of iterations and the After the maximum values ​​in each preset level are the same, the following are also included: If the largest subspace is still larger than the reference subspace corresponding to the temporary level, then proceed in the following order: After adding a new preset level, a preliminary updated level table is obtained; The maximum value of all preset levels in the initially updated level table is determined to be the target level.

5. The dynamic allocation method according to claim 1, characterized in that, The step of determining the available level range based on the preset value and the target level includes: The preset value is used as the lower boundary of the available level range, and the target level is used as the upper boundary of the available level range. The range of available grades is determined based on the upper and lower boundaries.

6. The dynamic allocation method according to claim 1, characterized in that, The determination of adjacent levels of the preset level includes: Determine the position of the preset level in the updated level table; The preset level corresponding to the position preceding the given position is taken as the adjacent level.

7. The dynamic allocation method according to any one of claims 1 to 6, characterized in that, After determining the adjacent levels of any preset level within the range of available levels, and reading the updated subspace of the adjacent levels from the updated level table, the method further includes: Iterate through each preset level within the range of available levels; If the actual data volume is not less than the reference data volume corresponding to each preset level within the available level range, or the minimum cache space is not less than the update subspace of the adjacent level corresponding to each preset level within the available level range, then the update subspace corresponding to the maximum value of all preset levels within the available level range shall be used as the allocation cache space for the target data.

8. A dynamic allocation device for a buffer area, characterized in that, The dynamic allocation device includes: The space acquisition module is used to acquire the number of cache areas and the total remaining memory space, calculate the ratio of the total memory space to the number of cache areas, and determine the ratio calculation result as the maximum subspace. The table acquisition module is used to acquire a preset level table, the level table including... Each preset level and its corresponding reference subspace and reference data volume Integers greater than zero; The table update module is used to determine the minimum preset level among all preset levels corresponding to reference subspaces that are greater than the maximum subspace as the target level, and update the reference subspace corresponding to the target level in the level table with the maximum subspace to obtain an updated level table. In the updated level table, the updated reference subspace corresponding to the target level is the maximum subspace, and the reference subspaces corresponding to other levels are not updated. The space reading module is used to obtain the actual data volume and minimum cache space of the target data, and determine the available level range according to the preset value and the target level. For any preset level within the available level range, the adjacent level of the preset level is determined, and the updated subspace of the adjacent level is read from the updated level table. If the reference subspace of the adjacent level has not been updated, the reference subspace is used as the updated subspace. The space allocation module is used to use the updated subspace as the allocation cache space for the target data if the actual data volume is less than the reference data volume of the preset level and the minimum cache space is less than the updated subspace.

9. A computer device, characterized in that, The computer device includes a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements the dynamic allocation method as described in any one of claims 1 to 7.

10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the dynamic allocation method as described in any one of claims 1 to 7.