Data replacement method, data management system, and storage medium
By dividing the storage space into subspaces and comprehensively evaluating the value of the data, the problem of data replacement affecting hit rate and performance in existing technologies is solved, and efficient storage space management is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- BEIJING OCEANBASE TECHNOLOGY CO LTD
- Filing Date
- 2026-03-05
- Publication Date
- 2026-06-05
AI Technical Summary
Existing data replacement technologies may replace high-value data when freeing up storage space, affecting the system's data hit rate and performance, and have high computational complexity and overhead.
The storage space is divided into larger-granularity subspaces, and the data value in the subspaces is comprehensively evaluated. The data scores are assessed through multiple dimensions, and the data in the subspace with the lowest score is selected for data replacement, thereby reducing computational complexity and improving data hit rate.
This improves the data hit rate, reduces the computational complexity and overhead of data scoring and comparison, and ensures the stability and efficiency of system performance.
Smart Images

Figure CN122152240A_ABST
Abstract
Description
Technical Field
[0001] This specification relates to the field of computer storage, and in particular to a data replacement method, a data management system, and a storage medium. Background Technology
[0002] With the rapid development of internet technology, the scale of data generated by various service platforms is growing exponentially, leading to continuous storage pressure on data storage systems. Given limited storage resources and a surge in data volume, efficient storage space management has become crucial for the continuous and stable operation of systems. Data replacement technology emerged to address this challenge. Its purpose is to free up space for new data by selecting and replacing some stored data when storage space is nearing saturation, thus ensuring service continuity. However, replacing high-value data during data replacement may lead to a decrease in subsequent data hit rates, thereby affecting the overall performance and service quality of the system.
[0003] The information in the background section is merely information known only to the inventor and does not imply that such information had entered the public domain before the date of this application, nor does it imply that it can be considered prior art in this disclosure. Summary of the Invention
[0004] This specification provides a data replacement method, a data management system, and a storage medium. It divides the storage space into subspaces with larger granularity and comprehensively evaluates the data value in the subspaces from multiple dimensions, improving the comprehensiveness and accuracy of the evaluation, avoiding the limitations of single-dimensional evaluation, increasing the data hit rate, and maintaining data scores at the subspace granularity, which can also reduce the computational complexity and overhead of data score comparison.
[0005] Firstly, this specification provides a data replacement method applied to a data management system. The data management system controls data replacement in a target storage space, which includes multiple subspaces, each subspace including multiple storage units for storing data. The method includes: in response to detecting a storage request for target data, when the target storage space is full, obtaining data scores corresponding to N candidate subspaces that are each full, wherein the data score for each candidate subspace is determined based on multiple evaluation dimensions, and N is an integer greater than 1; and determining a target subspace based on the data scores of the N candidate subspaces, and replacing at least a portion of the data in the target subspace with the target data.
[0006] In some embodiments, the plurality of evaluation dimensions include at least two of the following dimensions: the access time of data in the candidate subspace; the access frequency of data in the candidate subspace; the value level of data in the candidate subspace; or the historical hit status of data in the candidate subspace.
[0007] In some embodiments, the method further includes: periodically updating the data score of each candidate subspace based on the plurality of evaluation dimensions.
[0008] In some embodiments, in the current period, the data score S of each candidate subspace is updated based on the following formula:
[0009] Among them, the The candidate subspace represents the data score in the previous period, τ represents the time decay factor, and F represents the data score in the previous period. i P represents the access frequency of the i-th data item in the candidate subspace in the current period. i The S represents the value level of the i-th data item in the candidate subspace. D This at least indicates the hit rate of data in the candidate subspace during the current period.
[0010] In some embodiments, the S D Determined based on the following formula:
[0011] Among them, the At least indicating the hit rate of data in the candidate subspace in the previous period, the H i This indicates the number of times the i-th data item in the candidate subspace is hit in the current period.
[0012] In some embodiments, the plurality of subspaces include at least one first subspace and at least one second subspace, wherein the first subspace and the second subspace employ different data management strategies.
[0013] In some embodiments, the method further includes: for each first subspace, determining whether there exists at least one piece of data in the first subspace that satisfies a migration condition, the migration condition being characterized by the number of times the data is accessed being greater than or equal to a target threshold; and if so, migrating the at least one piece of data from the first subspace to the second subspace.
[0014] In some embodiments, for each first subspace, determining whether there is at least one piece of data in the first subspace that satisfies the migration condition includes: periodically determining whether there is at least one piece of data in each first subspace that satisfies the migration condition, wherein the migration condition characterizes the number of times the data is accessed in the current period being greater than or equal to the target threshold.
[0015] In some embodiments, the target threshold is determined based on at least one of the following: the number of times all data in the first subspace is accessed in the current period; the number of data items in the first subspace; or a preset threshold.
[0016] In some embodiments, the data management system performs a task to determine whether the relevant data meets the migration conditions through a first thread. The migration of the at least one piece of data from the first subspace to the second subspace includes: determining whether the data in the first subspace is currently being used by other threads besides the first thread; and if it is not being used by the other threads, migrating the at least one piece of data from the first subspace to the second subspace.
[0017] In some embodiments, the data management system performs a data replacement task through a second thread, wherein replacing at least a portion of the data in the target subspace with the target data includes: determining whether the data in the target subspace is currently being used by other threads besides the second thread; and replacing at least a portion of the data in the target subspace with the target data if it is not being used by the other threads.
[0018] In some embodiments, replacing at least a portion of the data in the target subspace with the target data includes: clearing all data in the target subspace and storing the target data in any storage unit of the target subspace.
[0019] In some embodiments, replacing at least a portion of the data in the target subspace with the target data includes: clearing the data stored in the target storage unit in the target subspace and storing the target data in the target storage unit.
[0020] In some embodiments, determining the target subspace based on the data scores corresponding to each of the N candidate subspaces includes: selecting the candidate subspace with the smallest data score from the N candidate subspaces as the target subspace.
[0021] In some embodiments, the target storage space is a cache.
[0022] Secondly, this specification also provides a data management system, comprising: at least one storage medium storing at least one instruction set; and at least one processor communicatively connected to the at least one storage medium, wherein the at least one processor reads the at least one instruction set during operation and executes the method as described in the first aspect according to the instructions of the at least one instruction set.
[0023] Thirdly, this specification provides a computer-readable non-transitory storage medium, wherein the computer-readable non-transitory storage medium stores at least one instruction set, which, when executed by at least one processor, implements the method as described in the first aspect.
[0024] Other functionalities of the data replacement methods, data management systems, and storage media provided in this specification will be partially listed in the following description. The inventive aspects of the data replacement methods, data management systems, and storage media provided in this specification can be fully understood through practice or use of the methods, systems, and combinations described in the detailed examples below. Attached Figure Description
[0025] To more clearly illustrate the technical solutions in the embodiments of this specification, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this specification. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0026] Figure 1 A schematic diagram illustrating an application scenario of data replacement provided according to embodiments of this specification is shown; Figure 2 A hardware structure diagram of a computing system provided according to an embodiment of this specification is shown; Figure 3 A flowchart of a data replacement method provided according to an embodiment of this specification is shown; Figure 4 A schematic diagram illustrating data replacement in a target storage space according to an embodiment of this specification is shown; and Figure 5 A schematic diagram of data migration provided according to an embodiment of this specification is shown. Detailed Implementation
[0027] The following description provides specific application scenarios and requirements for this specification, intended to enable those skilled in the art to make and use the contents of this specification. Various partial modifications to the disclosed embodiments will be apparent to those skilled in the art, and the general principles defined herein can be applied to other embodiments and applications without departing from the spirit and scope of this specification. Therefore, this specification is not limited to the embodiments shown, but rather to the widest scope consistent with the claims.
[0028] The terminology used herein is for the purpose of describing particular exemplary embodiments only and is not restrictive. For example, unless the context clearly indicates otherwise, the singular forms “a,” “an,” and “the” used herein may also include the plural forms. Unless otherwise stated, the term “a plurality of” refers to two or more, and “at least one item” refers to one or more items. The terms “first,” “second,” etc., may be used in this specification to describe various information, but such information should not be limited to these terms. These terms are used to distinguish information of the same type from one another and do not necessarily imply a specific order or sequence. For example, “first” may also be referred to as “second” without departing from the scope of embodiments described herein, and similarly, “second” may also be referred to as “first.”
[0029] The term "at least one of A, B, or C" includes seven cases: A only, B only, C only, both A and B, both A and C, both B and C, and both A, B, and C. Similarly, the statement "at least one of multiple items" refers to all possible combinations based on these items. The term "and / or" refers to any or all possible combinations of one or more related listed items. For example, "A and / or B" includes three cases: A only, B only, and both A and B. "A, B, and / or C" is equivalent to "at least one of A, B, or C". The character " / " generally indicates that the preceding and following objects are in an "or" relationship.
[0030] The term "comprising" is an open-ended description and should be understood as "including but not limited to," potentially including other content beyond what has been described. When used in this specification, the terms "comprising," "including," and / or "containing" mean the presence of the associated integers, steps, operations, elements, and / or components, but do not exclude the presence of one or more other features, integers, steps, operations, elements, components, and / or groups, or the possibility of adding other features, integers, steps, operations, elements, components, and / or groups to the system / method.
[0031] Considering the following description, these and other features of this specification, as well as the operation and function of the related components of the structure, and the economy of assembly and manufacture of the parts, can be significantly improved. All of these form part of this specification with reference to the accompanying drawings. However, it should be clearly understood that the drawings are for illustrative and descriptive purposes only and are not intended to limit the scope of this specification. It should also be understood that the drawings are not drawn to scale.
[0032] The flowcharts used in this specification illustrate operations implemented according to some embodiments of this specification. It should be clearly understood that the operations in the flowcharts may not be implemented in a sequential order. Instead, the operations may be implemented in reverse order or simultaneously. Furthermore, one or more additional operations may be added to the flowcharts. One or more operations may be removed from the flowcharts.
[0033] Figure 1 A schematic diagram illustrating an application scenario for data replacement provided according to embodiments of this specification is shown. For example... Figure 1 As shown, scenario 100 includes service system 10, temporary storage space 20, persistent storage space 30, and data management system 40.
[0034] Service system 10 is the generator and user (or consumer) of data, and can be a module, processor, or device that provides functional services to users. Service system 10 can also be a backend server for an application (APP). This application includes, but is not limited to, APPs that provide transaction services or financial services.
[0035] For example, the service system 10 can be a device operating system, an APP client, or an APP server, etc., which needs to perform data reading and storage (or writing) operations when processing user requests or executing tasks. The data read by the service system 10 comes from the data storage system, or it can be data generated during the storage service process of the data storage system or data submitted by the user.
[0036] The data storage system needs to handle the load of massive online transaction processing (OLTP) of the service system (e.g., the sum of various requests and operations that the data storage system needs to handle, including query, insert, update, delete, etc.), and has strict requirements for data hit rate, service latency and stability.
[0037] For example, a data storage system may include temporary storage space 20 and persistent storage space 30. The data storage system may be a distributed architecture storage system (such as OceanBase) or a storage system with other architectures, which are not limited in this specification. When the data storage system is a distributed architecture, scenario 100 may include multiple temporary storage spaces 20 and multiple persistent storage spaces 30, and different temporary storage spaces 20 or different persistent storage spaces 30 may be located in different geographical regions.
[0038] Temporary storage space 20 is a nearby storage layer introduced between service system 10 and persistent storage space 30. It can be used to store data that service system 10 frequently accesses, and the data retention time is relatively short. Temporary storage space 20 can reduce direct access of service system 10 to persistent storage space 30, reduce access latency, relieve pressure on persistent storage space 30, and improve the throughput and stability of service system 10 in high-concurrency scenarios, thereby improving the performance and response speed of service system 10. Temporary storage space 20 can be, for example, a cache or memory.
[0039] Persistent storage space 30 is responsible for long-term data storage, such as data generated during the service provisioning process of storage service system 10. Even if the system relying on data in persistent storage space 30 shuts down, restarts, or fails, the data stored in persistent storage space 30 will not be lost without cause, exhibiting high stability and reliability. Persistent storage space 30 may be, for example, a hard drive or a database.
[0040] During the operation of service system 10, the data read / write system ( Figure 1 (Not shown) Frequently accessed data can be loaded from persistent storage space 30 to temporary storage space 20, and temporary data in temporary storage space 20 can be persistently saved to persistent storage space 30. The data read / write system can be built into temporary storage space 20, persistent storage space 30, or set up independently; this specification does not impose any restrictions on this.
[0041] For example, after receiving a data read request from service system 10, the data read / write system can determine the request type and then determine the path to read the data based on the request type. During the read process, the data read / write system can check if the corresponding data exists in temporary storage space 20. If it exists, it directly returns the corresponding data to service system 10. If the data read / write system determines that the corresponding data does not exist in temporary storage space 20, it can read the corresponding data from persistent storage space 30, load the corresponding data into temporary storage space 20, and return the corresponding data to service system 10. In this way, the corresponding data can be directly retrieved from temporary storage space 20 in subsequent processes, reducing access time.
[0042] The data management system 40 can monitor the storage status of the temporary storage space 20. When the storage space is insufficient or full, it can select some data to clear or replace to ensure that the temporary storage space 20 can continuously accept new frequently accessed data. For example, when the data read / write system determines to load relevant data into the temporary storage space 20, and the temporary storage space 20 is full (or saturated), the data management system 40 can clear or replace the stored data in the temporary storage space 20. This data replacement mechanism can avoid the service performance degradation caused by the exhaustion of storage resources in the temporary storage space 20, supporting the continuous, stable, and efficient operation of the service system 10.
[0043] The data management system 40 and the data read / write system can be the same system, different systems, or different subsystems of the same system; this specification does not impose any restrictions on this. Furthermore, the data management system 40 can be located inside or outside the temporary storage space 20; this specification does not impose any restrictions on this.
[0044] In some embodiments, the data management system 40 may employ a recently accessed replacement strategy to replace data in the temporary storage space 20. For example, when the temporary storage space 20 is insufficient, the data management system 40 decides which data items to replace based on the "most recently accessed time" of each data item (which can be understood as data stored in the smallest storage unit) in the temporary storage space 20. The data management system 40 may maintain a timestamp or sequence number for each data item in the temporary storage space 20 to identify the relative order in which it was last accessed. When data needs to be replaced to free up storage space, the data management system 40 compares the timestamps or sequence numbers maintained for each data item, selects the data item that has not been accessed for the longest time or has been accessed the most recently, and uses the freed storage space to store new data.
[0045] Recent access replacement strategies include Least Recently Used (LRU) and Most Recently Used (MRU). The LRU strategy prioritizes removing data that has not been accessed for the longest time. The MRU strategy prioritizes removing data that has been accessed most recently.
[0046] The Recently Access Replacement (LIBOR) strategy is highly sensitive to sequential scan operations. A complete sequential traversal updates the timestamps of all data items to "latest," causing truly hot data to be mistakenly identified as "least used" and evicted in subsequent replacements. When the working set size of the service system exceeds the capacity of the temporary storage space 20, the cache hit rate will plummet. Because the strict ordering mechanism of strategies like LRU cannot effectively accommodate slightly larger working sets, it may trigger continuous cache thrashing. Furthermore, when implementing the LIBOR strategy, the data management system 40 needs to maintain the global access order of data items in the temporary storage space 20. On hardware, this often requires a costly O(N) linked list or O(log N) implementation. In a multi-core environment with frequent access, maintaining this global order becomes a performance bottleneck and results in poor scalability.
[0047] In some embodiments, the data management system 40 may employ a frequency-based replacement strategy to replace data in the temporary storage space 20. For example, the data management system 40 maintains an access counter for each data item in the temporary storage space 20 to track its frequency of use, incrementing the counter value of the corresponding data item with each read, and prioritizing the removal of data items with the lowest or highest counter values during replacement. This type of strategy aims to retain the most frequently accessed hot data to improve the hit rate of long-term accesses.
[0048] Frequency-based replacement strategies include Least Frequently Used (LRU) and Most Frequently Used (MFU). The LRU strategy prioritizes evicting data items with low access counts. The MFU strategy prioritizes evicting data items with high access counts.
[0049] Frequency-based replacement strategies suffer from the historical "pseudo-hotspot" problem, where frequently accessed data that is no longer important occupies storage space for a long time due to its high count value, making it unable to quickly respond to changes in the working set of the service system. In addition, the hardware implementation overhead is large, requiring the maintenance and frequent updating of multi-bit wide counters, and its storage resource consumption and dynamic power consumption are usually higher than those of the most recent access strategy, which only maintains timestamps.
[0050] In some embodiments, the data management system 40 may employ a time / sequence-based replacement strategy to replace data in the temporary storage space 20. For example, the data management system 40 records the time or sequence number of each data item entering the temporary storage space 20. When replacement is required, the data management system 40 may target and eliminate the data item that entered the temporary storage space 20 earliest or reached the lifespan threshold based on the recorded information, or it may perform random elimination.
[0051] Time / sequence-based replacement strategies include First In First Out (FIFO), Time To Live (TTL), and Random Replacement (RR). The FIFO strategy evicts data items in the order they enter the temporary storage space 20, with the first item to enter being removed first. The TTL strategy sets a fixed time-to-live threshold for each data item; items exceeding this threshold are automatically removed regardless of whether they have been accessed. The RR strategy randomly selects data items for eviction, independent of time, sequence, or access records.
[0052] Time-of-use (TTL) replacement strategies ignore the data access behavior of the service system; sequential scan operations can cause all data items in the temporary storage space 20 to become invalid or expire. TTL strategies are highly dependent on system clock accuracy, requiring complex clock synchronization mechanisms in distributed or multi-node environments. Furthermore, such strategies cause significant performance fluctuations in the service system, making them unsuitable for service scenarios with stringent performance requirements.
[0053] In some embodiments, the data management system 40 may employ a classification / predictive replacement strategy to replace data in the temporary storage space 20. For example, the data management system 40 maintains additional metadata (status bits or counters) for each data item in the temporary storage space 20 to classify and label it as "near reuse distance" or "far reuse distance". When replacement is required, the data management system 40 prioritizes retaining data items predicted to be "near reuse distance" while discarding data items predicted to be "far reuse distance".
[0054] Categorical / predictive replacement strategies include Low Inter-Reference Recency Set (LIRS) and Re-Reference Interval Prediction (RRIP). The LIRS strategy divides data in the data management system 40 into LIR (Low Inter-Reference Recency) and HIR (High Inter-Reference Recency) data items. LIR data items have shorter intervals between their last two visits, indicating frequent access. HIR data items have longer intervals between their last two visits, or have only been accessed once, and are the primary targets for replacement. RRIP maintains a Re-Reference Prediction Value (RRPV) for each data item. New data is marked with a higher RRPV; when a data item is matched, its RRPV is reduced, and during replacement, the data item with the highest RRPV is prioritized for elimination.
[0055] Classification / prediction-based replacement strategies have high metadata overhead. Each data item not only needs to store the predicted state bit but may also need to store a global predictor table and sampling queue, significantly increasing storage consumption and power consumption, making implementation complex. Secondly, some strategies require model training, which leads to training lag. When the data access pattern of the service system changes (such as service switching or phase switching), the model needs time to relearn, and during this period, the hit rate may actually be lower than strategies like LRU. Furthermore, these strategies are sensitive to parameters such as initial predicted values, thresholds, and prediction window length. These parameters need to be finely tuned for specific loads; improper settings in general scenarios can lead to a decrease in data access performance.
[0056] In view of this, this specification provides a data replacement method P300 to overcome the above-mentioned problems. The data management system 40 is a device with certain data processing capabilities, capable of executing the data replacement method P300 described herein. For example, the data management system 40 stores data and instructions for implementing the data replacement method P300, and can execute or be used to execute said data and instructions. In some embodiments, the data management system 40 may include hardware devices with data information processing functions and the necessary programs required to drive the hardware devices to operate.
[0057] It should be understood that Figure 1 The number of service systems 10, temporary storage space 20, persistent storage space 30, and data management system 40 shown is merely illustrative. Depending on implementation needs, any number of service systems 10, temporary storage space 20, persistent storage space 30, and data management system 40 can be included.
[0058] Figure 2 A hardware structure diagram of a computing system 200 provided according to an embodiment of this specification is shown. The computing system 200 may be... Figure 1 The data management system 40 in the device, or the device or device cluster with the data management system 40 built in, is not limited to this specification.
[0059] like Figure 2 As shown, the computing system 200 may include at least one storage medium 230 and at least one processor 220. In some embodiments, the computing system 200 may also include a communication port 250 and an internal communication bus 210. Furthermore, the computing system 200 may also include I / O components 260.
[0060] The internal communication bus 210 can connect to different system components. For example, the internal communication bus 210 can connect to storage medium 230, processor 220, communication port 250, and I / O component 260.
[0061] I / O component 260 supports input / output between computing system 200 and other components.
[0062] Communication port 250 is used for data communication between computing system 200 and the outside world. For example, communication port 250 can be used for data communication between computing system 200 and a network. Communication port 250 can be a wired communication port or a wireless communication port.
[0063] In some embodiments, the network can be any type of wired or wireless network, or a combination thereof. For example, the network may include a cable network, a wired network, a fiber optic network, a telecommunications network, an intranet, the Internet, a local area network (LAN), a wide area network (WAN), a wireless local area network (WLAN), a metropolitan area network (MAN), a public switched telephone network (PSTN), a Bluetooth network™, a ZigBee™ short-range wireless network, a near field communication (NFC) network, or a similar network.
[0064] In some embodiments, the network may include one or more network access points. For example, the network may include wired or wireless network access points, such as base stations or internet switching points. Through these access points, one or more components of various devices corresponding to the computing system 200 can connect to the network to exchange data or information.
[0065] Storage medium 230 may include a data storage device. The data storage device may be a non-transitory storage medium or a temporary storage medium. For example, the data storage device may include one or more of a disk 232, a read-only storage medium (ROM) 234, or a random access storage medium (RAM) 236. Storage medium 230 also includes at least one instruction set stored in the data storage device. The instruction set may include computer program code, which may include programs, routines, objects, components, data structures, procedures, modules, etc., that execute the data replacement methods provided in this specification.
[0066] Processor 220 can be communicatively connected to storage medium 230. Processor 220 is used to execute at least one of the above-described instruction sets. When computing system 200 is running, processor 220 reads the at least one instruction set and executes the data replacement method provided in this specification according to the instructions of the at least one instruction set.
[0067] Processor 220 may be in the form of one or more processors. In some embodiments, processor 220 may include one or more hardware processors, such as microcontrollers, microprocessors, reduced instruction set computers (RISC), application-specific integrated circuits (ASICs), application-specific instruction set processors (ASIPs), central processing units (CPUs), graphics processing units (GPUs), physical processing units (PPUs), microcontroller units, digital signal processors (DSPs), field-programmable gate arrays (FPGAs), advanced RISC machines (ARMs), programmable logic devices (PLDs), any circuit or processor capable of performing one or more functions, or any combination thereof.
[0068] For the purpose of illustrating the point only, in the appendix Figure 2 Only one processor 220 is shown in the computing system 200. However, it should be noted that the computing system 200 may also include multiple processors. Therefore, the operation and / or method steps disclosed in this specification may be executed by one processor as described in this specification, or they may be executed jointly by multiple processors. For example, if processor 220 of computing system 200 in this specification executes steps A and B, it should be understood that steps A and B may also be executed jointly or separately by two different processors 220 (e.g., the first processor executes step A, the second processor executes step B, or the first and second processors jointly execute steps A and B).
[0069] Figure 3 A flowchart of a data replacement method P300 according to an embodiment of this specification is shown. A data management system can control data replacement in a target storage space by executing the data replacement method P300.
[0070] The target storage space comprises M subspaces, each containing multiple storage units for storing data, where M is an integer greater than 1. These M subspaces can be obtained by dividing the target storage space. The data size that each subspace can hold can be the same or different; this specification does not impose any restrictions on this. A storage unit can be understood as the smallest unit for storing data within each subspace. Taking a cache as an example, the storage unit in the target storage space can be a cache line; this specification does not impose any restrictions on this. Data stored in a storage unit can be called a data item or a piece of data; this specification does not impose any restrictions on this.
[0071] like Figure 3 As shown, the data replacement method P300 includes the following steps.
[0072] S310: In response to the detection of a storage request for target data, if the target storage space is full, obtain the data scores corresponding to each of the N candidate subspaces that are full. The data score corresponding to each candidate subspace is determined based on multiple evaluation dimensions, where N is an integer greater than 1.
[0073] The target data is the data to be stored or written to the target storage space. Taking temporary storage space 20 as an example, the target storage space can be new data generated by the service system during the execution of a task (such as data that does not exist in either temporary storage space 20 or persistent storage space 30), or it can be data that the service system did not find (or did not hit) in the target storage space during the execution of a task, but exists in persistent storage space 30. This specification does not impose any restrictions on this.
[0074] During the monitoring of the target storage space, if the data management system detects a request from a service system or data read / write system to store or write target data to the target storage space, it can first determine the status of the target storage space. If the target storage space is not full, the data management system can store the target data into a subspace with remaining capacity. If the target storage space is full (also known as data saturation), the data management system obtains the data scores corresponding to each of the N candidate subspaces.
[0075] In some embodiments, the M subspaces correspond to the same type, and the data management system can store data in each subspace sequentially according to a predetermined order during the process of storing data to the target storage space. For example, Figure 4 As shown, the M subspaces include subspace 1, subspace 2, ..., subspace M. If subspace 1 is not full, the data management system can store the target data in a storage unit within subspace 1 that is not full. If subspace 1 is full and subspace 2 is not full, the data management system can store the target data in a storage unit within subspace 2 that is not full, and so on.
[0076] A storage unit being in a partially full state can be understood as: the storage unit contains no data, or the remaining capacity of the storage unit can still store the data to be stored. A subspace being in a partially full state can be understood as: the subspace contains at least one storage unit that is not full. A target storage space being in a partially full state can be understood as: at least one subspace among the M subspaces is not full.
[0077] A full storage unit can be understood as either the storage unit already containing data, or the remaining capacity of the storage unit is insufficient to store the data to be stored (i.e., the remaining capacity of the storage unit is less than the size of the data to be stored; here, the data size is used to measure the amount of storage space occupied by the data, or the amount of network transmission). A full subspace can be understood as either all storage units in the subspace being full, or the remaining capacity of the partially full storage units in the subspace being insufficient to store the data to be stored. A full target storage space can be understood as either all M subspaces being full, or the remaining capacity of the partially full subspaces in the M subspaces being insufficient to store the data to be stored.
[0078] Each subspace can have different states at different stages, including but not limited to: idle state, used state, or full state. The idle state indicates that no data is stored. The used state indicates that data has been stored but the data is not yet saturated; it is a state between the idle state and the full state.
[0079] In some embodiments, the M subspaces include at least one first subspace and at least one second subspace, wherein the first and second subspaces employ different data management strategies. The data management strategies can be used to determine when and / or what type of data is stored in the corresponding subspace.
[0080] Data management systems can use data management strategies to decide when to store which types of data in different types of subspaces. For example, a data management system might use a data management strategy for the first subspace to decide when to store what types of data in the first subspace, and a data management strategy for the second subspace to decide when to store what types of data in the second subspace. Data types include new data (such as data that does not currently exist in the target storage space) or migrated data (such as data migrated between subspaces). Timing includes new data storage timing or migration timing. In some examples, the data management system can also use a data management strategy for the first subspace to decide how to replace (or discard) data when the first subspace is full; and use a data management strategy for the second subspace to decide how to replace (or discard) data when the second subspace is full.
[0081] It should be noted that the first and second subspaces do not need to be pre-defined and cannot be changed subsequently. As data is stored, the data management system can gradually classify the various subspaces. With data replacement, the classification identifiers (identifiers for the first or second subspace) of some subspaces can also be updated. For example, each subspace is marked as idle before any data is stored. When data storage is required, the data management system stores the new data in any of the M subspaces, and the subspace where the data is stored can be marked as the first subspace. The data management system can migrate frequently accessed data from the first subspace to an idle subspace. After storing the migrated data, this subspace can be marked as the second subspace.
[0082] For example, the first subspace is used to store new data, and the second subspace is used to store frequently accessed data from the first subspace. In this case, after the data management system detects a storage request for the target data, if there is a first subspace that is not full, the data management system can store the target data in that first subspace with remaining capacity. If all first subspaces are full, and there are no idle subspaces among the M subspaces (subspaces that do not belong to either the first or second subspace and do not store any data), then the data management system determines that the target storage space is full and obtains the data scores corresponding to each of the N candidate subspaces.
[0083] The N candidate subspaces can be any of the M subspaces that are currently full; this specification does not impose any restrictions on this. The data score corresponding to each candidate subspace can be stored within that candidate subspace. For example, the data score for candidate subspace 1 can be stored in a specific storage unit within candidate subspace 1. Alternatively, the data scores for all candidate subspaces can be stored in the same location (such as the same storage unit or the same subspace); this specification does not impose any restrictions on this. The data management system can obtain the data scores corresponding to each of the N candidate subspaces from the aforementioned storage locations in the target storage space. The data management system can maintain data scores for each subspace in the target storage space, or it can maintain data scores only for subspaces that are currently full; this specification does not impose any restrictions on this. The following explanation primarily uses the example of maintaining data scores only for subspaces that are currently full.
[0084] The data score for each candidate subspace is determined based on a comprehensive evaluation of multiple dimensions. Taking candidate subspace 1 as an example, the data score for candidate subspace 1 can be used to characterize the likelihood of data items in candidate subspace 1 being accessed at a future time (or in the near future, such as within the next period). The lower the data score for candidate subspace 1, the lower the likelihood of data items in candidate subspace 1 being accessed at a future time. Conversely, the higher the data score for candidate subspace 1, the higher the likelihood of data items in candidate subspace 1 being accessed at a future time. The following uses candidate subspace 1 as an example to introduce the method for determining its data score. The method for determining the data scores for other candidate subspaces is similar and will not be repeated here.
[0085] In some embodiments, the data management system determines the data score of candidate subspace 1 based on at least two of the following evaluation dimensions: the access time of the data in candidate subspace 1; the access frequency (or number of times) of the data in candidate subspace 1; the value level of the data in candidate subspace 1; or the historical hit rate of the data in candidate subspace 1.
[0086] For example, the data management system determines the data score of candidate subspace 1 at time 1 (e.g., before the data management system executes S310). The access time of data in candidate subspace 1 can be a statistical value of the access time of each data item in candidate subspace 1 by the service system. The access frequency of data in candidate subspace 1 can be a statistical value of the access frequency of each data item in candidate subspace 1 by the service system before time 1. The number of times data in candidate subspace 1 is accessed can be a statistical value of the number of times each data item in candidate subspace 1 is accessed by the service system before time 1. The value level of data in candidate subspace 1 can be a statistical value of the value levels of different types of data items in candidate subspace 1. The historical hit rate of data in candidate subspace 1 can be a statistical value of the number of times each data item in candidate subspace 1 is hit by the service system at historical times (before time 1).
[0087] The value levels of different types of data items can be preset. Table 1 shows the value levels of different types of data items. The value level of a data item represents its importance. The more important the data item, the higher its value level, and the greater its priority value (quantified value level). During data replacement, the data management system can prioritize replacing data items with lower value levels.
[0088] Table 1
[0089] The statistical values corresponding to each of the above evaluation dimensions are, for example, the mean, median, and variance, etc., and this specification does not impose any restrictions on them. For example, the access frequency of data in candidate subspace 1 can be the average access frequency of each data item in candidate subspace 1 by the service system. The meanings of other statistical values are similar and will not be elaborated further.
[0090] In the above embodiments, the time interval between the access time of data in candidate subspace 1 and time 1 can be inversely correlated with the data score corresponding to candidate subspace 1. The access frequency of data in candidate subspace 1, the value level of data in candidate subspace 1, and the historical hit rate of data in candidate subspace 1 are all positively correlated with the data score corresponding to candidate subspace 1. The larger the statistical value of the evaluation dimension with an inverse correlation, the lower the data score corresponding to candidate subspace 1. The larger the statistical value of each evaluation dimension with a positive correlation, the higher the data score corresponding to candidate subspace 1.
[0091] In some embodiments, the data management system can also preset weights for each evaluation dimension, thereby determining the data score of candidate subspace 1 based on the statistical value of each evaluation dimension and the preset weights. After determining the data score for each candidate subspace, the data management system can store it in the corresponding storage location of the target storage space.
[0092] In the above embodiments, the data management system constructs a relatively scientific comprehensive evaluation method based on multiple evaluation dimensions. It can intelligently, accurately, and comprehensively identify real hot data (i.e., high-frequency access data, data accessed more than a preset number of times) and potential high-value data, effectively avoiding the inherent defects of scoring based on a single evaluation dimension (such as the problems of the LRU and LFU strategies mentioned above). Under dynamically changing workloads, it retains frequently accessed high-value data, improves data hit rate, and maximizes the utilization of storage resources.
[0093] In some embodiments, the data management system can periodically update the data score of each subspace based on the aforementioned multiple evaluation dimensions. That is, the data management system treats each subspace as an object to be updated, not just candidate subspaces that are in a full state.
[0094] For example, the update cycle can be at the minute level, such as 5 minutes, 10 minutes, 30 minutes, etc., or at the hour level, such as 1 hour, etc., or other larger or smaller levels; this specification does not limit this. After the data management system calculates the data score for each subspace in the current cycle, it can update the historical data score of each subspace to the data score calculated in the current cycle in the target storage space.
[0095] In some embodiments, the data management system may periodically update the data score of each subspace (such as a candidate subspace) that is in a full state based on the above-mentioned multiple evaluation dimensions.
[0096] For example, the update cycle is 1 hour. At 00:00 on February 11, 2026, the data management system determines that subspaces 1 and 2 are in a full state, and calculates and stores the data scores for subspaces 1 and 2 based on the aforementioned multiple evaluation dimensions. At 01:00 on February 11, 2026, if the data management system determines that subspaces 1, 2, and 3 are in a full state, it can calculate the data scores for subspaces 1, 2, and 3 based on the aforementioned multiple evaluation dimensions, update the data scores for subspaces 1 and 2 at the corresponding locations in the target storage space, and store the data score for subspace 3 at the corresponding locations in the target storage space.
[0097] It should be noted that for a subspace that is in a full state, when the data management system calculates its data score and performs statistical analysis on some evaluation dimensions, it can statistically analyze relevant values within the current period. For example, the data management system can determine the access time of data in the candidate subspace within the current period, the access frequency of data in the candidate subspace within the current period, and the hit rate of data in the candidate subspace within the current period.
[0098] Furthermore, the calculation method for data scores in a full subspace can differ from that in a non-full subspace; this specification does not impose any restrictions on this. Once the data management system determines that a subspace is full, it can set the status field of that subspace to "full".
[0099] It's understandable that subspaces that are not yet full continue to store new data, making their data scoring unstable. Regularly updating the data scores of full subspaces dynamically adjusts the future access value of the data within those subspaces. This allows the data management system to flexibly track and adapt to changes in the value of data within those subspaces due to variations across multiple dimensions, offering greater flexibility. Regular updates also prevent storage stagnation caused by historical data assessments, ensuring that data scores always reflect the latest access trends and data value, laying the foundation for replacing low-value data later.
[0100] In some embodiments, in the current period, the data score S of the subspace that is not yet full is updated based on the following formula:
[0101] Where S' represents the data score of the subspace in the previous period, "·" represents multiplication (the same applies below), τ represents the time decay factor (i.e., the degree to which the data score of the subspace in the previous period decays to the current period as time passes, which can be a pre-set fixed value, such as 0.9, and this specification does not impose any restrictions on it), F i P represents the frequency of access to the i-th data item in the current period within this subspace. i This represents the value level (e.g., priority in Table 1) of the i-th data item in this subspace. If this is the first time the data management system is calculating its data score for this subspace, S' can be a preset fixed value. The data management system can preset the same fixed value for all subspaces. ,or, This specification does not impose any restrictions on this, where n represents the number of data items in the subspace.
[0102] In some embodiments, the data score S of candidate subspace 1 can be updated based on the following formula in the current period:
[0103] Where S' represents the data score of candidate subspace 1 in the previous period, τ represents the time decay factor (i.e., the degree to which the data score of a subspace in a full state decays from the previous period to the current period as time passes, which can be a pre-set fixed value, such as 0.9, and this specification does not impose any restrictions on it), F i P represents the frequency of access to the i-th data item in candidate subspace 1 during the current period. i S represents the value level (priority as shown in Table 1) of the i-th data item in candidate subspace 1. D It at least indicates the hit rate of data in candidate subspace 1 within the current period, and can quantify the change in the probability of data in candidate subspace 1 being accessed in the future due to the hit rate of data in the current period by the service system. This can be understood as a weighted statistical value of the number of visits. That is, weight.
[0104] For example, ,or, , where n represents the number of data items in candidate subspace 1. When the data management system calculates the data score of candidate subspace 1 for the first time, S' can be a preset fixed value. The data management system can preset the same fixed value for all subspaces that are in a full state, and this specification does not impose any restrictions on this.
[0105] Taking a 1-hour update cycle as an example, if the data management system determines the data score of a subspace at 02:00 on February 11, 2026 (i.e., the current time of update calculation), then the current cycle can be the 1 hour between 01:00 and 02:00 on February 11, 2026. The data score of the previous cycle is the data score calculated by the data management system for that subspace at 01:00 on February 11, 2026. The terms "current cycle," "previous cycle," and "next cycle" in this specification can be deduced similarly.
[0106] In the above embodiments, during periodic updates, the data management system uses the data score from the previous period as a basis, introduces a time decay factor, and overlays the dynamic hit rate of the current period to achieve a smooth update mechanism. The time decay factor can systematically reduce the weight of historical evaluations, preventing outdated hot data from occupying storage space for a long time. At the same time, if data is continuously hit in the candidate subspace within the current period, the data score of that subspace can be improved, reducing the possibility of being eliminated. This combination of "inheritance + decay" allows the data score to accumulate long-term value trends while quickly responding to short-term hits, enabling more accurate prediction of the likelihood of data in the corresponding subspace being accessed in the future, thus improving the subsequent data hit rate.
[0107] In some embodiments, S corresponding to candidate subspace 1 D Determined based on the following formula:
[0108] in, H represents at least the hit rate of data in candidate subspace 1 in the previous period. i This represents the number of times the i-th data item in candidate subspace 1 is hit in the current period. This can be understood as a weighted statistical value of the number of hits. That is, weight.
[0109] For example, ,or, This specification does not impose any limitations on this. When the data management system calculates the data score for candidate subspace 1 for the first time, It can be a preset fixed value, or it can be the cumulative number of times or the average value of all data in candidate subspace 1 being hit at historical moments. This specification does not impose any restrictions on this.
[0110] In this embodiment, the data score calculated by the data management system based on the hit count in the current period can more accurately reflect the likelihood of data in the candidate subspace being accessed in the future. The introduction of value levels makes the scoring mechanism go beyond simple hit count statistics, which can improve the data score of the subspace with high value level, ensure the stability of high value level data, and thus retain data that is likely to be accessed in the future, thereby improving the data hit rate of the service system in the target storage space.
[0111] S320: Determine the target subspace based on the data scores corresponding to each of the N candidate subspaces, and replace at least a portion of the data in the target subspace with the target data.
[0112] In some embodiments, the data management system selects the candidate subspace with the smallest data score from the N candidate subspaces as the target subspace. This approach, ranking data scores at the subspace level, reduces the computational overhead and complexity of replacement decisions.
[0113] For example, the data management system constructs a min-heap based on the data scores of each of the N candidate subspaces. A min-heap is a binary tree data structure where each node corresponds to a candidate subspace, and the value of each node is its data score for that subspace. The value of each node is less than or equal to the values of its child nodes. The data management system can select the candidate subspace corresponding to the top node of the min-heap as the target subspace. After replacing the data in the target subspace, the data management system can update the min-heap to determine the replacement target when storing new data in the target storage space later.
[0114] In some embodiments, the data management system executes the data replacement task through thread 1 (i.e., the second thread in the invention). The data replacement task includes, but is not limited to: obtaining data scores for N candidate subspaces, determining the target subspace, and performing data replacement. The data management system can determine whether the data in the target subspace is currently being used by other threads besides thread 1. If it is not being used by other threads, it replaces at least a portion of the data in the target subspace with the target data.
[0115] For example, when other threads use data items in the target subspace, they can write a hazard pointer to their local memory before accessing the data item, indicating that they are using the data item and should not delete it. Before replacing data in the target subspace, the data management system can check the hazard pointers of all threads except thread 1 to determine if any other threads are using data items in the target subspace. If the data management system determines that no other threads are currently using data items in the target subspace, it can replace at least some data items in the target subspace with the target data, or overwrite at least some data items in the target subspace with the target data. If the data management system determines that other threads are currently using data items in the target subspace, it can monitor the usage of other threads and replace at least some data in the target subspace with the target data after the other threads have finished using it. The hazard pointer is a lock-free concurrent programming technique that can solve the ABA problem and use-after-free problem in memory reclamation in multi-threaded environments.
[0116] In this embodiment, the data management system can ensure the safety of data replacement in multi-threaded concurrent scenarios by performing data replacement when it is determined that no other threads are using the data. This avoids the replacement data from affecting the task execution of other threads (such as the "dangling pointer" problem and data corruption or program crash caused by data replacement), thereby improving the performance and stability of the service system.
[0117] In some embodiments, the data management system can clear all data in the target subspace and store the target data in any storage unit within the target subspace.
[0118] For example, the target subspace is Figure 4 In subspace 2, the data management system can clear or delete data items in all storage units of subspace 2 and store the target data in any storage unit of the released space (such as storage unit 21).
[0119] In this embodiment, the data management system can release a large amount of storage space in one batch, avoiding the problem of high overhead caused by multiple replacements and the release of small amounts of space each time.
[0120] In some embodiments, the data management system clears the data stored in the target storage unit within the target subspace and stores the target data in the target storage unit. The target storage unit may be one or more storage units, and this specification does not limit this.
[0121] For example, the data management system selects the storage unit corresponding to the data item with the lower value level as the target storage unit based on the size of the target data and the value level of the data items stored in each storage unit in the target subspace. Then, it clears the data stored in the target storage unit and stores the target data in the target storage unit. Alternatively, the data management system can perform data clearing at the tenant level. For instance, if the service system serves multiple merchants, the data management system can select a specific merchant's data in the target subspace for clearing.
[0122] In this embodiment, the data management system replaces some data, which can maintain the hit rate of the retained data in the target subspace, achieve a smoother and more gradual replacement, avoid the risk of a sudden drop in hit rate caused by clearing all data in the target subspace, and provide more stable service performance.
[0123] The following section mainly introduces the data management in the first and second subspaces out of the M subspaces.
[0124] For example, the data management strategy for the first subspace includes a first replacement strategy. The data management strategy for the second subspace includes a second replacement strategy. When the data management system determines that the target subspace is the first subspace and decides to replace some data in the first subspace, it can use the first replacement strategy to decide which data to replace. When the data management system determines that the target subspace is the second subspace and decides to replace some data in the second subspace, it can use the second replacement strategy to decide which data to replace. Additionally, when data in the first subspace needs to be migrated to the second subspace, and all second subspaces are full, and there are no idle subspaces among the M subspaces, the data management system can also select one of the full second subspaces and perform data replacement and storage migration according to the second replacement strategy. The first replacement strategy is based on the data access time. The second replacement strategy is based on the data access frequency. The first replacement strategy will be illustrated using LRU as an example, and the second replacement strategy will be illustrated using LFU as an example, but this specification is not limited to these examples.
[0125] This specification categorizes the various subspaces containing data, allowing identification of the data's lifecycle stage (recently stored data or frequently accessed data) within each subspace. This facilitates performance monitoring and troubleshooting of the service system, and provides flexibility for future strategy optimization or feature expansion. However, it's important to note that when the data management system executes method P300, the data scoring method for the first and second subspaces is consistent. When determining the target subspace, selection can be made from all subspaces, simplifying the data replacement logic. Physically dividing the target storage space into independent first and second subspaces improves concurrency performance through physical isolation. For example, read and write operations can be distributed across different subspaces, fundamentally reducing lock contention between threads. This allows data access and replacement operations in a multi-threaded environment to be processed in parallel, improving the overall throughput and response speed of the service system.
[0126] For example, to support two different data management strategies within the target storage space, the data management system can maintain a unified instance management structure. For instance, the data management system uses ObKVCacheInst as the instance management structure, manages the subspace handles for both strategies (LRU or LFU) through the `handles_` array, and uses `lru_mb_cnt_` to count the number of items in the first subspace and `lfu_mb_cnt_` to count the number of items in the second subspace, which are used to calculate the average hit count. The metadata for each subspace handle includes, but is not limited to: a policy identifier field (`policy_`) to identify the data management strategy to which each subspace belongs; the total number of accesses (`get_cnt_`) for all data items in that subspace throughout its entire lifecycle (from the start of data storage in that subspace to the current time); the total number of accesses (`recent_get_cnt_`) for all data items in that subspace within the current period; and the data score for that subspace.
[0127] The following describes the process by which a data management system migrates frequently accessed data from the first subspace to the second subspace.
[0128] In some embodiments, for each first subspace, the data management system can determine whether there is at least one piece of data in the first subspace that satisfies the migration condition, and if so, migrate at least one piece of data from the first subspace to the second subspace. The migration condition indicates that the number of times the data has been accessed is greater than or equal to a target threshold.
[0129] In the above embodiments, new data can be stored in the first subspace, and frequently accessed data can be automatically migrated to the second subspace to avoid the frequently accessed data in the first subspace being squeezed out by new data, which would reduce the hit rate. This method of distinguishing between cold and hot data (cold data such as newly stored data, and hot data such as frequently accessed data) can improve the hit rate.
[0130] The data management system can determine in real time whether there are migrateable data items (i.e., data items that meet the migration conditions) in each first subspace, or it can determine whether there are migrateable data items in a first subspace after a data item in the first subspace has been accessed or after a first subspace has been marked as full. This specification does not impose any restrictions on when the data management system determines migrateable data items.
[0131] For example, such as Figure 5 As shown, taking the first subspace R1 as an example, if the data management system determines at time t1 that the number of times data item 1 stored in storage unit r11 of the first subspace R1 has been accessed before time t1 is greater than or equal to the target threshold, that is, it determines that data item 1 meets the migration condition, that is, data item 1 is a migrateable data item.
[0132] In some embodiments, the data management system may periodically determine whether at least one piece of data exists in each first subspace that satisfies a migration condition. This migration condition characterizes the number of times the data is accessed within the current period as greater than or equal to a target threshold.
[0133] For example, the migration cycle is 24 hours, and the data management system determines the migration time at 00:00. The data management system can check at 00:00 each day whether there are data items in each first subspace that meet the migration conditions. Figure 5 As shown, if the data management system determines that the number of times data item 1 stored in storage unit r11 of the first subspace R1 is accessed on a given day is greater than or equal to the target threshold, then the data management system determines that data item 1 meets the migration conditions. The above migration period is only an example, and this specification does not impose any limitations on it; the migration period can also be a longer or shorter time period.
[0134] In the above embodiments, the data management system periodically determines whether there is data that meets the migration conditions, avoiding the problem of high overhead of real-time judgment, and also avoiding the problem of untimely space release caused by starting the judgment at a specific time (such as after the first subspace is full).
[0135] The target threshold can be a fixed value preset by the data management system (different first subspaces can correspond to the same target threshold), or it can be dynamically changing (different first subspaces can correspond to different target thresholds). This specification does not impose any restrictions on this.
[0136] In some embodiments, the target threshold is determined based on at least one of the following: the number of times all data in the first subspace is accessed in the current period; the number of data items in the first subspace; or a preset threshold. The number of times all data in the first subspace is accessed in the current period is positively correlated with the target threshold. The number of data items in the first subspace is inversely correlated with the target threshold. The following explanation primarily uses the example of a target threshold determined based on a combination of the above three factors.
[0137] For example, the migration cycle is 24 hours. Taking the first subspace R1 as an example, when determining whether there are migrateable data items in the first subspace R1, the data management system can base its determination on the total number of accesses V of all data items in the first subspace R1 within the day (i.e., the cumulative number of accesses of each data item in the first subspace R1 within the day), the number of data items N in the first subspace R1, and a preset threshold TH. B Determine the target threshold.
[0138] Specifically, the data management system can determine the target threshold TH of the first subspace R1 based on the following formula, and the method for determining the target threshold of other first subspaces is similar.
[0139]
[0140] Where c is a constant, which can avoid the denominator being zero. For example, it can take the value 1. This manual does not restrict this.
[0141] It should be noted that when the data management system determines which data items are transferable for different first subspaces, it presets a threshold TH. B They can be the same.
[0142] In this embodiment, the data management system dynamically calculates the target threshold so that the decision criteria can adapt to the differentiated access situations of different first subspaces, and the migration decision is dynamically adjusted as the number of accesses changes, thereby more accurately identifying the high-frequency access data that is truly worth migrating.
[0143] In some embodiments, the data management system performs a task to determine whether relevant data meets the migration conditions through thread 2 (i.e., the first thread in the invention). Before performing data migration, the data management system determines whether the data in the first subspace is currently being used by other threads besides thread 2. If it is not being used by other threads, at least one piece of data that meets the migration conditions is migrated from the first subspace to the second subspace.
[0144] For example, after the data management system determines a migrateable data item, it can acquire a bucket-level lock (hash bucket) corresponding to the data item. This bucket-level lock indicates that data in a certain first subspace is currently being processed, preventing the writing of new data into this first subspace and thus avoiding disruption of the order of data items in the corresponding hash bucket linked list. After acquiring the bucket-level lock, the data management system traverses the hash bucket linked list corresponding to the first subspace until it finds the target node corresponding to the migrateable data item 1, thereby migrating data item 1 corresponding to the target node. During the migration process, it can determine whether other threads are currently using the data in the first subspace, or whether other threads are currently using data item 1. The determination method is as described above and will not be repeated here.
[0145] See also Figure 5 If no other thread is using the data item, the data management system removes data item 1 from storage unit r11 in the first subspace R1 and stores it in a storage unit marked as not full in the second subspace F2. It also updates the hash bucket linked list to the nodes adjacent to the target node. After the migration is complete, the data management system can release the aforementioned bucket-level lock, indicating that the data in the first subspace has been migrated and can be stored normally in the first subspace. If other threads are using the data item, the data management system waits for them to finish before migrating it. The migration process is similar and will not be described further.
[0146] When the data management system determines the second subspace (e.g., second subspace F2) for storing data item 1, it can choose a second subspace that is not full or a subspace that is free. When all second subspaces are full and there are no free subspaces, the data management system can select the second subspace storing the associated data of data item 1 and use the second replacement strategy to replace some data with data item 1.
[0147] In this embodiment, the data management system can ensure the security of data migration by performing data migration when it is determined that no other threads are using it. This avoids the accidental deletion of data items during the migration process, which could affect the task execution of other threads and thus impact the performance and stability of the service system.
[0148] In some embodiments, the target storage space is a cache. Data in the cache is updated rapidly. Evaluating the data score of the corresponding subspace using multiple evaluation dimensions can more accurately predict the likelihood of accessing data in the corresponding subspace at future times, thereby retaining higher-value data and improving data hit rate and service system response speed when cache storage resources are limited.
[0149] In summary, the data replacement method, data management system, and storage medium provided in this specification divide the target storage space into multiple subspaces. Each candidate subspace in a full state is comprehensively evaluated from multiple assessment dimensions to obtain a data score that more accurately and comprehensively represents the future access probability of data in the candidate subspaces. This allows for the replacement of data with low future access probability during data replacement. This replacement method maintains data scores at the subspace level within the target storage space, reducing the amount of metadata required for replacement decisions and avoiding the high overhead of maintaining data scores for each storage unit. It retains high-value data during the data replacement process, improving the data hit rate of the target storage space, avoiding access time and service stability issues caused by replacing hot data, and overcoming the limitations of evaluating and replacing data from a single dimension (see previous description).
[0150] This specification, in another aspect, provides a computer-readable non-transitory storage medium storing at least one set of executable instructions for data replacement. When the executable instructions are executed by a processor, they instruct the processor to perform the steps of the data replacement method P300 described in this specification. In some possible embodiments, various aspects of this specification can also be implemented as a program product comprising program code. When the program product is run on a computing system 200, the program code causes the computing system 200 to perform the steps of the method P300 described in this specification. The program product for implementing the above method may employ a portable compact disc read-only memory (CD-ROM) containing program code and may run on the computing system 200. However, the program product of this specification is not limited thereto. In this specification, the readable storage medium may be any tangible medium containing or storing a program that may be used by or in conjunction with an instruction execution system. The program product may employ any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of readable storage media include: electrical connections having one or more wires, portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. The computer-readable storage medium may include data signals propagated in baseband or as part of a carrier wave, carrying readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable storage medium may also be any readable medium other than a readable storage medium that can send, propagate, or transmit programs for use by or in connection with an instruction execution system, apparatus, or device. Program code contained on a readable storage medium may be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof. Program code for performing the operations described herein can be written in any combination of one or more programming languages, including object-oriented programming languages such as Java and C++, and conventional procedural programming languages such as C or similar languages. The program code can be executed entirely on computing system 200, partially on computing system 200, as a standalone software package, partially on computing system 200 and partially on a remote electronic device, or entirely on a remote electronic device.
[0151] The foregoing has described specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require a specific or sequential order to achieve the desired result. In some embodiments, multitasking and parallel processing are possible or may be advantageous.
[0152] In summary, after reading this detailed disclosure, those skilled in the art will understand that the foregoing detailed disclosure is presented by way of example only and is not restrictive. Although not explicitly stated herein, those skilled in the art will understand that this specification requires various reasonable changes, improvements, and modifications to the embodiments. These changes, improvements, and modifications are intended to be made by this specification and are within the spirit and scope of the exemplary embodiments described herein.
[0153] Furthermore, certain terms in this specification have been used to describe embodiments of this specification. For example, "an embodiment," "an embodiment," and / or "some embodiments" mean that a particular feature, structure, or characteristic described in connection with that embodiment may be included in at least one embodiment of this specification. Therefore, it is to be emphasized and understood that two or more references to "an embodiment" or "an embodiment" or "alternative embodiment" in various parts of this specification do not necessarily refer to the same embodiment. Moreover, specific features, structures, or characteristics may be suitably combined in one or more embodiments of this specification.
[0154] It should be understood that in the foregoing description of the embodiments in this specification, various features are combined in a single embodiment, drawing, or description for the purpose of simplifying the description and aiding in the understanding of a feature. However, this does not mean that the combination of these features is necessary, and those skilled in the art will readily identify some of them as separate embodiments when reading this specification. That is, the embodiments in this specification can also be understood as an integration of multiple secondary embodiments. It is also valid when each secondary embodiment contains fewer than all the features of a single foregoing disclosed embodiment.
[0155] Every patent, patent application, publication of a patent application, and other material cited herein, such as articles, books, specifications, publications, documents, and literature (excluding any related historical examination documents), is referenced for all purposes relevant to this document, including in the specification and claims herein. However, in the event of any inconsistency or conflict between the descriptions, definitions, and / or terms used in the foregoing and those used herein, the descriptions, definitions, and / or terms used herein shall prevail.
[0156] Finally, it should be understood that the embodiments disclosed herein are illustrative of the principles of the embodiments described in this specification. Other modified embodiments are also within the scope of this specification. Therefore, the embodiments disclosed in this specification are merely examples and not limitations. Those skilled in the art can implement the applications described in this specification using alternative configurations based on the embodiments in this specification. Therefore, the embodiments in this specification are not limited to the embodiments precisely described in the applications.
Claims
1. A data replacement method applied to a data management system, the data management system being used to control data replacement in a target storage space, the target storage space comprising multiple subspaces, each subspace comprising multiple storage units for storing data, the method comprising: In response to the detection of a storage request for target data, if the target storage space is full, the data scores corresponding to each of the N candidate subspaces that are full are obtained. The data score corresponding to each candidate subspace is determined based on multiple evaluation dimensions, where N is an integer greater than 1. as well as Based on the data scores corresponding to the N candidate subspaces, a target subspace is determined, and at least a portion of the data in the target subspace is replaced with the target data.
2. The method according to claim 1, wherein, The multiple evaluation dimensions include at least two of the following dimensions: The access time of the data in the candidate subspace; The frequency of data access in the candidate subspace; The value level of the data in the candidate subspace; or The historical hit data in the candidate subspace.
3. The method according to claim 1, wherein, The method further includes: The data score for each candidate subspace is periodically updated based on the multiple evaluation dimensions.
4. The method according to claim 3, wherein, In the current period, the data score S for each candidate subspace is updated based on the following formula: Among them, the The candidate subspace represents the data score in the previous period, τ represents the time decay factor, and F represents the data score in the previous period. i P represents the access frequency of the i-th data item in the candidate subspace in the current period. i The S represents the value level of the i-th data item in the candidate subspace. D This at least indicates the hit rate of data in the candidate subspace during the current period.
5. The method according to claim 4, wherein, The S D Determined based on the following formula: Among them, the At least indicating the hit rate of data in the candidate subspace in the previous period, the H i This indicates the number of times the i-th data item in the candidate subspace is hit in the current period.
6. The method according to claim 1, wherein, The plurality of subspaces includes at least one first subspace and at least one second subspace, wherein the first subspace and the second subspace employ different data management strategies.
7. The method according to claim 6, wherein, The method further includes: For each first subspace, determine whether there exists at least one piece of data in the first subspace that satisfies a migration condition, wherein the migration condition represents that the number of times the data is accessed is greater than or equal to a target threshold; and If present, the at least one piece of data is migrated from the first subspace to the second subspace.
8. The method according to claim 7, wherein, For each first subspace, determine whether there exists at least one piece of data in the first subspace that satisfies the migration conditions, including: Periodically determine whether there is at least one piece of data in each first subspace that satisfies the migration condition, wherein the migration condition represents that the number of times the data is accessed in the current period is greater than or equal to the target threshold.
9. The method according to claim 7, wherein, The target threshold is determined based on at least one of the following: The number of times all data in the first subspace is accessed during the current period; The number of data items in the first subspace; or Preset threshold.
10. The method of claim 7, wherein, The data management system executes a task through a first thread to determine whether the relevant data meets the migration conditions. The migration of at least one piece of data from the first subspace to the second subspace includes: Determine whether the data in the first subspace is currently being used by a thread other than the first thread; and If the data is not being used by the other threads, the at least one piece of data is migrated from the first subspace to the second subspace.
11. The method according to claim 1, wherein, The data management system executes a data replacement task through a second thread, wherein replacing at least a portion of the data in the target subspace with the target data includes: Determine whether the data in the target subspace is currently being used by a thread other than the second thread; and If the data in the target subspace is not used by the other threads, at least a portion of the data is replaced with the target data.
12. The method according to claim 11, wherein, The step of replacing at least a portion of the data in the target subspace with the target data includes: Clear all data in the target subspace and store the target data in any storage unit within the target subspace.
13. The method according to claim 11, wherein, The step of replacing at least a portion of the data in the target subspace with the target data includes: The data stored in the target storage unit in the target subspace is cleared, and the target data is stored in the target storage unit.
14. The method according to claim 1, wherein, The step of determining the target subspace based on the data scores corresponding to each of the N candidate subspaces includes: The candidate subspace with the smallest data score is selected from the N candidate subspaces as the target subspace.
15. The method according to claim 1, wherein, The target storage space is a cache.
16. A data management system, comprising: At least one storage medium storing at least one instruction set; as well as At least one processor is communicatively connected to the at least one storage medium, wherein the at least one processor reads the at least one instruction set during operation and performs the method as described in any one of claims 1-15 according to the instructions of the at least one instruction set.
17. A computer-readable non-transitory storage medium, wherein, The computer-readable non-transitory storage medium stores at least one set of instructions, which, when executed by at least one processor, implement the method as described in any one of claims 1-15.