Cache management method and device for flow graph processing
By calculating the importance index value of the vertex during the incremental processing of the flow graph and replacing the lowest-important cache line when the cache misses are made, the problem of high cache miss rate in incremental processing of the flow graph is solved, and cache utilization efficiency and system performance are improved.
Patent Information
- Application Number
- CN202411927672.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-25
- Publication Date
- 2025-05-30
AI Technical Summary
In the incremental processing of the flow graph, the affected vertices account for only a small part of the entire graph and are distributed in a dispersed manner, resulting in a high cache miss rate and the existing cache management strategy is not ideal.
By selecting the data related to the vertex from the virtual address, extracting the importance factors and calculating the importance metric value to evaluate the importance level of the vertex, the relevant information of the vertex is replaced with the relevant information of the cache line with the least significant cache line when the cache misses.
This method can more accurately identify important vertices in flow graph processing, reduce unnecessary cache replacement, improve cache hit rate, and improve overall system performance and response speed.
Smart Images

Figure CN120066980A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of flow graph processing in computers, and particularly to a cache management method and device for flow graph processing. Background Art
[0002] A flow graph is a graph structure that continuously updates over time, and this change is triggered by batch updates of the graph. Flow graphs have wide applications in many fields, such as recommendation systems, financial fraud detection, anomaly detection, etc. These applications require fast support for the calculations and updates in the flow graph. To achieve a fast response to graph calculations and updates, incremental computing is widely adopted. Research shows that the value of a vertex before update is usually closer to the new snapshot result than the initial value. In incremental computing, using the vertex value before the graph structure update can reduce the impact of the update batch on the vertex state. Subsequently, the vertex state propagates along the topological structure of the graph to calculate the latest results of other affected vertices.
[0003] However, in the incremental processing of flow graphs, there are two main challenges: First, only a small part of the vertices in the graph are affected during graph update, and they are relatively scattered; Second, there are a large number of irregular access patterns during graph processing, which leads to a high cache miss rate. Therefore, how to improve the efficiency of cache management is a problem that needs to be solved. Improving the cache management efficiency can effectively reduce cache misses and data access latency, thereby improving the speed and efficiency of flow graph processing.
[0004] An effective cache replacement policy can significantly reduce cache thrashing in flow graph processing. Traditional policies usually rely on the recent access time and access frequency of data, and perform replacement based on the timeliness and frequency of access. However, due to the particularity of the graph structure and irregular access patterns, these policies often have limited effects. To solve this problem, the prior art has proposed cache management policies for graph computing.
[0005] For example, GRASP reduces cache thrashing by analyzing the characteristics of graph data, regarding high-degree vertices as highly reusable vertices and retaining them in the cache. P-OPT selects the vertex with the latest future use to achieve the best cache replacement by accessing the adjacency matrix of the graph and its transpose. However, in the incremental computing of flow graphs, the degree of a vertex does not accurately reflect its reusability. In addition, only a small part of the vertices in the whole graph are affected and they are scattered, resulting in an irregular data access order. Therefore, the cache management policies of the prior art have low cache efficiency in the process of processing flow graph data.
[0006] CN107493327A discloses a distributed cache management system, which is applied to a distributed cache network composed of at least one client, a routing layer for performing hash operations, and multiple storage nodes. Among them, at least one cache instance is preset in each storage node, multiple cache instances are determined from multiple storage nodes and a service request is submitted; and according to the specified redundancy, multiple cache instances are configured into multiple sets of cache instance sets including a primary cache instance and at least one secondary cache instance, which can ensure that the primary cache instance and the secondary cache instance mapped to the same interval or hash slot are configured on different storage nodes, thereby ensuring that even if all cache instances on a storage node are suspended, it will not cause partial loss of service data, and thus can ensure that the operation service can run normally. Specifically, the distributed cache management system described in this technical solution mainly focuses on data redundancy and fault tolerance, and ensures data persistence by configuring primary caches and secondary caches on different storage nodes. However, this design is not very applicable in the scenario of flow graph processing, because flow graph processing requires fast real-time response and efficient dynamic update. The redundancy mechanism of this technical solution introduces additional latency and resource overhead, which is not conducive to meeting the high-efficiency requirements of flow graph processing. In addition, the irregularity and locality of the flow graph data access mode do not match the traditional hash distribution strategy, affecting the cache hit rate and performance.
[0007] As described above, traditional cache management strategies do not consider the characteristics of flow graphs when processing flow graph data, resulting in serious cache misses. Therefore, in the incremental processing scenario of flow graphs, how to effectively manage caches to reduce cache misses is a technical problem to be solved.
[0008] In addition, on the one hand, there are differences in the understanding of those skilled in the art; on the other hand, although the applicant studied a large number of literatures and patents when making this invention, all details and content are not listed in detail due to space limitations. However, this does not mean that this invention does not possess the features of these prior arts. On the contrary, this invention already possesses all the features of the prior arts, and the applicant reserves the right to add relevant prior arts in the background art. Summary of the Invention
[0009] Traditional methods often determine the replacement strategy based on the recent access time and access frequency of data items, and perform elimination according to the freshness and frequency of data access. However, due to the complexity of graphs and the irregularity of data access, these traditional methods usually have limited effects when processing graph data.
[0010] In existing technologies, the GRASP algorithm identifies the characteristics of graph data, regards frequently connected vertices as potential reused nodes, and retains them in the cache to reduce cache jitter. The P-OPT algorithm analyzes the adjacency matrix of the graph and its transpose, and selects those nodes that are expected to be accessed the latest in the future to perform optimal cache replacement. However, in the dynamic calculation of the flow graph, the connectivity of the node does not always accurately reflect its possibility of reuse. At the same time, only a few and scattered vertices are affected in this way, which leads to irregularity in the order of data access. Therefore, the cache management strategy of the existing technology does not have ideal cache performance when processing flow graph data.
[0011] In view of the deficiencies in the prior art, the present invention provides a cache management method for flow graph processing from a first aspect, the method comprising: selecting data related to a vertex from a virtual address; extracting importance factors from the data related to the vertex and calculating importance index values to evaluate the importance of the vertex during incremental flow graph processing; identifying and selecting the vertex with the lowest importance index value in the last-level cache based on the importance index value; and in the event of a cache miss, replacing the relevant information of the vertex with the relevant information of the cache line with the lowest importance in the last-level cache.
[0012] The present invention selects vertex-related data from virtual addresses and extracts importance factors from these data to calculate importance index values, in order to evaluate the importance of vertices during flow graph incremental processing. This method can more accurately identify which vertices are more important in flow graph processing, so that when the cache misses, the vertices with the lowest importance index values are replaced first, reducing cache misses and improving cache utilization efficiency.
[0013] According to a preferred embodiment, the importance factors of the importance index value include: the degree of association affected by the vertex state, the path distance of the vertex, and whether the vertex will be updated. By setting the importance factors in this way, it is possible to more accurately predict which vertices are more likely to be reused in future flow graph processing, so that these important vertices are preferentially retained when the cache misses. This method helps to reduce unnecessary cache replacements and improve cache hit rates, thereby improving the overall performance and response speed of the system. In this way, cache resources can be used more effectively, cache misses can be reduced, and the processing efficiency of flow graph data can be optimized.
[0014] According to a preferred embodiment, the step of selecting data related to the vertex includes: recording the first address of the state array related to the vertex, the number of vertices and the size of the data; comparing and classifying the virtual address with a predetermined address range to obtain the ID of the currently visited vertex, so as to extract the importance factor based on the ID of the currently visited vertex.
[0015] The present invention records the starting address of the status array related to vertices, the number of vertices, and the size of the data, and compares the virtual address with a pre-determined address range, aiming to quickly and accurately identify the currently accessed vertex. This method can ensure that when making cache replacement decisions, the specific vertex can be quickly located, thereby improving the response speed and accuracy of cache management.
[0016] According to a preferred embodiment, the calculation method of the correlation degree of the vertex status affected includes: setting the initial value of the correlation degree of the vertex status affected to zero; when there is a status propagation passing through the vertex, the correlation degree of the vertex status affected increases by 1; when the vertex is processed, the correlation degree of the vertex status affected decreases by 1.
[0017] The present invention sets the initial value of the correlation degree of the vertex status affected to zero and dynamically adjusts this value according to status propagation and vertex processing, aiming to reflect the active status of the vertex in the flow graph in real time. This method can dynamically evaluate the importance of the vertex, enabling the cache replacement strategy to adapt to the dynamic changes of the flow graph and improving the cache hit rate.
[0018] According to a preferred embodiment, the calculation method of the path distance of the vertex includes: recording the hierarchical information of the vertex; calculating the difference between the level of the vertex and the level of the currently accessed vertex.
[0019] The present invention records the hierarchical information of the vertex and calculates the difference between the level of the vertex and the level of the currently accessed vertex, aiming to identify the vertices that are closer to the current activity in the flow graph. This method can identify those vertices that are more likely to be accessed currently, so that these vertices can be preferentially retained during cache replacement, reducing the performance loss caused by cache misses.
[0020] According to a preferred embodiment, the calculation method of whether a vertex will be updated includes: when the correlation degree of the vertex status affected is greater than 0, it indicates that the vertex will be updated, and the importance index value of whether the vertex will be updated is represented as 1; when the correlation degree of the vertex status affected is 0, it indicates that the vertex will not be updated, and the importance index value of whether the vertex will be updated is represented as 0.
[0021] The present invention determines whether a vertex will be updated by judging whether the correlation degree of the vertex status affected is greater than 0, aiming to predict the possibility of the vertex being accessed. This method can identify in advance the vertices that may be accessed in the future, so that these vertices can be preferentially retained during cache replacement, reducing the cache misses generated when accessing the vertices.
[0022] According to a preferred embodiment, the method further includes: selecting the cache line where the vertex with a negative path distance is located for replacement; or, when the path distance of the vertex is positive, selecting the cache line where the vertex with a larger path distance is located for replacement.
[0023] In the present invention, vertices with a negative or positive path distance and a large distance are selected for replacement, aiming to preferentially eliminate those vertices that are far from the current activity. This method can optimize the use of cache space, make room for vertices that are more likely to be reused, and improve the utilization efficiency of the cache.
[0024] According to a preferred embodiment, the steps of calculating the importance index value include:
[0025]
[0026] Among them, α represents the weight factor of the correlation degree (X) of the vertex state being affected; β represents the weight factor of the path distance (Y) of the vertex; X max and X min respectively represent the maximum and minimum values of the correlation degree of the vertex state being affected in the dataset; X represents the correlation degree of the vertex state being affected, Y represents the path distance of the vertex, and Z represents the value indicating whether the vertex will be updated.
[0027] Such calculation can more accurately evaluate the importance of vertices. Through weighted and normalization processing, this method can more balancedly reflect the multiple characteristics of vertices, making the cache replacement decision more comprehensive and accurate. In this way, the efficiency of cache line replacement can be improved, unnecessary cache misses can be reduced, and thus the overall cache performance can be enhanced.
[0028] The present invention provides a cache management device for flow graph processing from a second aspect, including a processor; the processor is configured to: select data related to vertices from a virtual address; extract importance factors in the data related to vertices and calculate an importance index value to evaluate the importance degree of vertices during the incremental processing of the flow graph; identify and select the vertex with the lowest importance index value in the last-level cache based on the importance index value; in the case of a cache miss, replace the relevant information of the vertex with the relevant information of the cache line with the lowest importance in the last-level cache.
[0029] The present invention provides a cache management device for flow graph processing from a third aspect, including a processor; the processor includes an address classifier, an evaluation unit, and a cache management unit. The address classifier is used to select data related to vertices from a virtual address; the evaluation unit is used to extract importance factors in the data related to vertices and calculate an importance index value to evaluate the importance degree of vertices during the incremental processing of the flow graph; the cache management unit is used to identify and select the vertex with the lowest importance index value in the last-level cache based on the importance index value; in the case of a cache miss, replace the relevant information of the vertex with the relevant information of the cache line with the lowest importance in the last-level cache. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Figure 1 It is a schematic diagram of a cache management method for flow graph processing provided by the present invention;
[0031] Figure 2 It is a schematic diagram of the module connection of a cache management device for flow graph processing provided by the present invention;
[0032] Figure 3 It is a schematic diagram of the operation logic of a cache management device for flow graph processing provided by the present invention;
[0033] Figure 4 It is a schematic diagram of the original flow graph provided by the present invention;
[0034] Figure 5 It is a schematic diagram of the newly added edges of the flow graph provided by the present invention.
[0035] List of reference numerals
[0036] 100: Address classifier; 200: Evaluation unit; 300: Cache management unit. Detailed implementation manners
[0037] The following is a detailed description with reference to the accompanying drawings.
[0038] The present invention explains some noun terms.
[0039] Cache thrashing: In cache management, due to frequent cache replacements or unreasonable cache policies, the data in the cache is continuously replaced, resulting in the actual accessed valid data not being able to stay in the cache for a long time, thus leading to frequent cache misses and performance degradation. This situation usually occurs in scenarios where the access pattern is irregular or does not conform to the cache replacement policy, resulting in low cache efficiency.
[0040] Address classifier 100: It is a tool for parsing and classifying memory addresses or network addresses. Its function is to divide the input address data into different categories according to specific rules or characteristics. Through effective classification of addresses, the address classifier 100 can support optimizing system performance, enhancing security, and improving the accuracy of data analysis. The address classifier 100 can be implemented by dedicated physical hardware. Such hardware usually includes application-specific integrated circuits (ASICs) in routers and switches for quickly processing and classifying network addresses. In addition, content-addressable memory (CAM), especially ternary CAM (TCAM), can also be used in network devices to achieve fast address lookup and classification. The memory management unit (MMU) in the processor is responsible for memory address translation, although not specifically for classification, it is also involved in address parsing.
[0041] Evaluation unit 200: It is used to calculate the importance index value of the vertices of the graph. The evaluation unit 200 can be a processor or an application-specific integrated circuit (ASIC) that executes the calculation method of the importance index value of the present invention. The evaluation unit 200 includes a calculation engine.
[0042] Cache management unit 300: It is used to execute the cache management policy, that is, replace the cache line with the lowest importance index value according to the importance index value of the vertices of the graph. The cache management unit 300 is a processor or an application-specific integrated circuit (ASIC) that executes the encoded program of the cache management policy of the present invention.
[0043] Embodiment 1
[0044] Traditional strategies usually rely on the recent access time and access frequency of data, and perform replacement based on the timeliness and frequency of access. However, due to the particularity of the flow graph structure and the irregular access pattern, these strategies often have limited effects. In the incremental processing scenario of the flow graph, how to effectively manage the cache to reduce cache misses is a technical problem that needs to be solved.
[0045] The present invention provides a cache management method and device for flow graph processing. The present invention can also provide a processor for running the encoded program of the cache management method for flow graph processing. The present invention can also provide a storage medium for storing the encoded program of the cache management method for flow graph processing. The present invention can also provide a flow graph cache management system, including a processor and a storage medium.
[0046] As Figure 2 and Figure 3 shown, the cache management device for flow graph processing of the present invention includes a processor. The processor may further include an address classifier 100, an evaluation unit 200, and a cache management unit 300. The output end of the address classifier 100 is connected to the input end of the evaluation unit 200. The output end of the evaluation unit 200 is connected to the input end of the cache management unit 300. The input end of the address classifier 100 is used to receive the virtual address obtained from the CPU decoding stage.
[0047] Preferably, the input end of the address classifier 100 can also use a high-performance data bus to receive information, such as a PCIe interface, to ensure fast and reliable data transmission. PCIe slots or USB-C interfaces are common port models, suitable for connecting to other system components or external devices.
[0048] The output end of the address classifier 100 and the input end of the evaluation unit 200 are connected by an internal bus or by a data line for data transmission. Preferably, a high-speed serial connection, such as I2C, SPI, or LVDS, can also be used between the two. These interfaces can support fast data transmission.
[0049] The evaluation unit 200 is connected to the cache management unit 300 through a data line.
[0050] For the output port of the cache management unit 300, its output result directly acts on the replacement logic circuit of the cache block. As Figure 1 shown, the cache management method for flow graph processing of the present invention includes:
[0051] S1: Select data related to vertices from the virtual address;
[0052] S2: Extract the importance factors in the data related to vertices and calculate the importance index value to evaluate the importance degree of vertices in the process of flow graph incremental processing;
[0053] S3: Based on the importance index value, identify and select the vertex with the lowest importance index value in the last-level cache; in the case of cache miss, replace the relevant information of the vertex with the relevant information of the cache line with the lowest importance in the last-level cache.
[0054] The principle of the present invention is that the address classifier 100 is used to identify the virtual address and obtain the ID of the currently accessed vertex through address offset. When accessing the vertex, if a cache miss occurs, the evaluation unit 200 calculates the importance index value of the cache line. The cache management unit 300 replaces the cache line with the lowest importance index value.
[0055] Preferably, the address classifier 100 can be an address comparison logic unit. The address values received at the input end of the address classifier 100 include the address value used by the central processing unit CPU for memory access and the value of the boundary address of the graph data and non-graph data stored in the register.
[0056] The information output at the output end of the address classifier 100 is: whether a data is graph data. If it is graph data, the address classifier 100 also calculates the vertex number (ID) according to the address value.
[0057] Preferably, the address classifier 100 separates the data related to the vertices of the graph, namely the state array (Vertex Data), from the data.
[0058] Preferably, three registers are set in the address classifier 100: the first register 、 the second register and the third register to record the start address, the number of vertices, and the size of each data of the state array (Vertex Data) respectively. The three registers belong to the storage components in the address classifier 100. The values of the registers are fixed values input by the central processing unit CPU at the start stage of data processing.
[0059] When the processor connected to the address classifier 100 executes the graph algorithm and processes the update of the flow graph data for each batch, the above three registers respectively receive the flow graph data update information from the external central processing unit CPU, and respectively determine the virtual address range Vertex of the status array (Vertex Data) start ~Vertex end 。
[0060] The vertex data is stored in the virtual address in a continuous manner. Vertex start and Vertex end respectively represent the start and end addresses of the entire range occupied by the vertex data.
[0061] Preferably, Vertex start =Vertex base 。Vertex start represents the starting vertex. That is, the first register determines and identifies the starting address of the virtual address range. This means that the storage of vertex data starts from a reference address.
[0062] Vertex end =Vertex start +Vertex nums *Vertex size 。This formula calculates the total number of bytes required from the starting position (starting address) to the end of the last vertex. That is, the position of the last vertex starts from the starting address and increases by a certain number of bytes to reach the end position.
[0063] Among them, Vertex nums represents the number of vertices, and Vertex size represents the data size of each vertex (usually in bytes).
[0064] When reading the address information, the address classifier 100 compares the address with Vertex start and Vertex end to achieve address classification and obtain the ID of the currently accessed vertex.
[0065] CurrVisitId=(Addr-Vertex start ) / Vertex size )。
[0066] CurrVisitId represents the index or ID of the currently accessed vertex. It is usually used to find or reference a specific vertex in an array or list. Addr represents the pointer or address pointing to a specific vertex. In memory, each vertex may have a unique memory address.
[0067] The calculation principle of this formula is: Addr-Vertex start The offset from the starting vertex to the current vertex is calculated. The offset is divided by Vertex size , and the number of vertices from the start of the array to the current vertex is obtained. This number is the index or ID of the current vertex.
[0068] As described above, the address classifier 100 classifies data related to the vertices of the graph (such as the status array) from other data, laying the foundation for the calculation of the importance index value of the vertices. The address classifier 100 uses three registers to record the basic information of the status array respectively, and calculates its virtual address range, so as to determine the valid access of specific data.
[0069] By comparing the read address with Vertex start and Vertex end , the address classifier 100 can effectively identify the ID of the currently accessed vertex. This solves the address resolution problem in graph data access, ensures the efficiency and accuracy of data access, and avoids unnecessary memory access errors. That is to say, by comparing the read address with Vertex start and Vertex end , the address classifier 100 can quickly determine whether the address belongs to the data related to the vertices of the graph. This enables the address classifier 100 to accurately locate the required data, rather than performing an invalid search in the entire memory space. This greatly improves the data search efficiency and reduces the access latency.
[0070] Traditional memory access may cause access conflicts or errors due to unclear address ranges. The address classifier 100 of the present invention reduces this risk through clear definition. By screening and classifying the vertex data by the address classifier 100, memory errors caused by improper address access can be avoided.
[0071] The address classifier 100 of the present invention can enable the evaluation unit 200 to preferentially load and process the vertex data of the graph and preferentially retain the data with high relevance in the cache by screening the address. This targeted access mode optimizes the data flow, avoids the loading of irrelevant data, and thus improves the overall processing efficiency.
[0072] The address classifier 100 of the present invention can quickly determine whether the graph vertex data is involved in multiple data access requests, which enables the subsequent evaluation unit 200 to better schedule computing resources and optimize the parallel processing ability. The evaluation unit 200 can execute multiple threads more effectively at the same time, reducing the waiting time and resource conflicts.
[0073] Preferably, the address classifier 100 sends the importance array corresponding to the vertices of the graph to the evaluation unit 200. The importance array stores the importance factors of the vertices.
[0074] The importance array includes importance factors (X, Y, Z). X represents the degree of association by which the vertex state is affected; Y represents the path distance of the vertex, and Z represents whether the vertex will be updated. The evaluation unit 200 calculates the importance array and can calculate the importance index value of the vertices of the graph.
[0075] The importance index value of the vertices of the graph is used to represent the priority of a vertex being accessed at a certain moment during the calculation process. The larger the value of the importance index value of the vertices of the graph, the higher the probability that the vertex will be accessed; conversely, the smaller the value of the importance index value of the vertices of the graph, the lower the probability that the vertex will be accessed.
[0076] In the evaluation unit 200, the value of the cache line is defined as the maximum value of the importance index values of the vertices in the cache line. When cache replacement occurs, the cache line with the lowest current value is selected for replacement, which can reduce cache misses.
[0077] Preferably, the steps for the address classifier 100 to calculate the degree of association X by which the vertex state is affected are as described below.
[0078] S110: Set the initial value of the degree of association by which each vertex state is affected to zero. When performing a depth-first traversal, first determine whether the vertex has been visited. If the vertex has not been visited, perform a depth-first traversal with it as the root; if the vertex has already been visited, it means that the propagation state of this path has been counted, and propagation will not continue further.
[0079] S120: Each time a state propagates through this vertex, the degree of association by which the vertex state is affected increases by 1. Each time the vertex is processed, the degree of association by which the vertex state is affected decreases by 1.
[0080] Preferably, the steps for the address classifier 100 to calculate the path distance Y of the vertex are as described below.
[0081] S210: Record the hierarchical information of all vertices in each snapshot. The level of a vertex is the minimum value of the depth from the source vertex of the query to this vertex. The level starts from 1. The level of a vertex is used to represent the order in which the vertex is visited. The smaller the level of the vertex, the earlier the order in which the vertex is visited. The path distance of the vertex is defined as the difference between the vertex and the level of the currently visited vertex.
[0082] S220: When performing cache replacement, preferentially select the cache line where the vertex with a negative path distance is located for replacement. If there are multiple cache lines with negative path distances, randomly select one. When the path distance is negative, the vertex is the predecessor node of the currently accessed vertex, indicating that the vertex has been accessed. When all path distances are positive, preferentially select the cache line where the vertex with a larger path distance is located during cache replacement.
[0083] Preferably, the steps for the address classifier 100 to calculate the value Z indicating whether a vertex will be updated are as described below.
[0084] Whether a vertex will be updated determines whether the vertex will be accessed, and the importance of a vertex that will not be updated is 0. Whether a vertex will be updated depends on the degree of association by which the vertex state is affected.
[0085] When the degree of association by which the vertex state is affected is greater than 0, it indicates that the vertex will be updated, and it is represented by the value 1. When the degree of association by which the vertex state is affected is 0, it indicates that the vertex will not be updated, and it is represented by the value 0.
[0086] Preferably, the evaluation unit 200 calculates the importance index value of a vertex based on the ID of the currently accessed vertex (CurrVisitId) and the vertex-related data of the graph. The evaluation unit 200 uses an importance array to store the importance factors of the vertices of the graph. Specifically, a calculation engine is set in the evaluation unit 200. The calculation engine calculates the importance index value of the vertices of the graph according to a preset calculation method.
[0087] Preferably, the calculation engine takes the ID of the currently accessed vertex and the ID of a certain vertex ( ve rtexId) as parameters, and calculates the importance index value of a certain vertex ( ve rtexId) relative to the currently accessed vertex according to the evaluation index expression.
[0088] When calculating the importance index value of a certain vertex, the corresponding X, Y, and Z values of the vertex will be calculated first, and then the importance index value of the vertex will be obtained according to the importance evaluation formula.
[0089] Preferably, the specific steps for the calculation engine to calculate the importance index value of a vertex are as follows.
[0090] Use F(X, Y, Z) to represent the importance index value of the vertex.
[0091] X and Z are in a positive relationship with the degree of importance of the vertex. Z determines whether the vertex is important. Y is in an inverse relationship with the degree of importance, and when Y is negative, the degree of importance of accessing the vertex is 0. The importance evaluation formula is as follows:
[0092]
[0093] Among them, α represents the weight factor of the correlation degree (X) of the vertex state being affected; β represents the weight factor of the path distance (Y) of the vertex; X max and X min respectively represent the maximum and minimum values of the correlation degree of the vertex state being affected in the dataset; X represents the correlation degree of the vertex state being affected, Y represents the path distance of the vertex, and Z represents the value indicating whether the vertex will be updated. X is regularized, while Y and Z are not. Exemplary data of the importance index values are shown in Table 1.
[0094] Table 1: Exemplary Data of Importance Index Values
[0095] <![CDATA[X min > <![CDATA[X max > X Y Z α β F(X, Y, Z) The first group 0 20 14 1 1 0.2 0.8 0.94 The second group 0 8 6 3 1 0.4 0.6 0.5 The third group 0 32 24 0 1 0.7 0.3 0.525
[0096] During the incremental processing of the flow graph, when the correlation degree (X) of the vertex state being affected is 0, this vertex will not be accessed and should not occupy cache space. In addition, as the vertex state propagates, the importance of other vertices will also change.
[0097] Traditional cache management techniques do not consider the characteristic that the importance of vertices will change dynamically during the incremental calculation of the flow graph and cannot accurately reflect the importance index values of vertices. The present invention measures the importance of vertices in real time through three dimensions of X, Y, and Z, so that the importance of vertices can be obtained more accurately, enabling the subsequent cache management unit 300 to more accurately find the vertices that need to be replaced out of the cache when performing cache replacement. The cache management unit 300 preferentially replaces the vertices that will not be used through the importance index values of the vertices and retains the more important vertices in the cache, avoiding invalid cache replacements and reducing the number of cache replacements, thereby reducing cache misses.
[0098] Preferably, the computing engine sends the calculated importance index values of the vertices to the cache management unit 300.
[0099] In order to quickly obtain the importance index values of vertices during cache replacement and reduce the memory access overhead generated by accessing the importance index values of the vertices of the graph, the cache management unit 300 selects some vertices and stores the importance index values F(X, Y, Z) of the vertices in the last-level cache.
[0100] Preferably, the cache management unit 300 uses a hash table (abbreviated as htable) to index the elements in the importance array of the vertices of the graph. Each item in the hash table is represented by a binary tuple <htableID, vertexID>. htableID represents the element subscript of the hash table, and vertexID represents the ID of the vertex.
[0101] To store more vertex data of the graph (importance factors of the vertices of the graph) in the last-level cache and reduce the impact on the original last-level cache, the cache management unit 300 determines the size of the importance array of the vertices of the graph based on three factors: the average degree of the vertices of the graph, the number of vertices, and the size of the last-level cache.
[0102] The size of the importance array of the vertices of the graph is defined as follows.
[0103] significance nums =Max(cache size *8% / sizeof(significant[0]), vertex nums *1%,
[0104] avg degree (exp(3))).
[0105] Where cache size *8% represents the usage of the last-level cache. Vertex nums represents the number of vertices of the graph. avg degree represents the average value of the vertex degrees. avg degree (exp(3)) represents considering the vertices within three steps of the distance from the currently accessed vertex. Exemplary data related to the size of the importance array of the vertices of the graph is shown in Table 2.
[0106] Table 2: Exemplary data for calculating the size of the importance array
[0107]
[0108] In the first set of data, the size of the importance array is 1000. In the second set of data, the size of the importance array is 512. In the third set of data, the size of the importance array is 1728.
[0109] In the initialization phase, the cache management unit 300 stores the vertices in the importance array of the vertices of the graph where the value of the path distance of the vertex in the importance factor of the vertex is 1 (Y = 1) and the value of whether the vertex will be updated is 1 (Z = 1).
[0110] When the number of stored vertices is less than the capacity of the importance array of the vertices of the graph, the cache management unit 300 gradually adds vertices with Z value of 1 in ascending order of the path distance (Y) value of the vertices until the importance array of the vertices of the graph is filled. During the processing of the cache management unit 300, when the Z value of a vertex is 0, the importance factor of this vertex will be replaced from the last-level cache and the corresponding tuple in the hash table will be deleted. At the same time, the cache management unit 300 selects a vertex with the same path distance (Y) value as the current maximum vertex in the importance array of the vertices and stores the importance factor of this vertex into the importance array of the vertices. If there is no vertex with the same path distance (Y) value, a vertex with a path distance of Y+1 is selected and the importance factor of this vertex is added to the importance array of the vertices of the graph.
[0111] As described above, the importance array is responsible for storing the importance factors of those vertices with high importance, which are considered more likely to be accessed in future graph processing due to their path distance and update possibility. By obtaining the importance factors of these vertices preferentially, the importance array helps to optimize the use of cache space and allows the cache to dynamically adjust its content to adapt to changes in the importance of vertices in the graph. In addition, when vertices are no longer considered to be updated, their importance factors are replaced from the cache, and the importance array participates in this replacement decision to ensure that only the vertices most likely to be reused are retained in the cache. Ultimately, the importance array helps to improve the cache hit rate, reduce the need to access the main memory, and thus enhance the overall system performance by pre-storing the importance factors of vertices that may be accessed.
[0112] When a cache miss occurs, the cache management unit 300 executes a cache replacement policy, that is, obtains the importance metric values of each cache line in the cache blocks (cachelines) and selects the cache line with the lowest importance metric value for replacement.
[0113] Specifically, the cache management unit 300 first finds the cache lines that do not contain data related to the vertices of the graph according to the address ranges Vertex start and Vertex end .
[0114] If there is such a cache line, the cache management unit 300 evicts the first cache line that does not contain data related to the vertices of the graph.
[0115] If there is no such cache line, that is, all cache lines contain data related to the vertices of the graph, the cache management unit 300 calculates the importance metric values for each cache line. Specifically, the cache management unit 300 passes the ID of the currently accessed vertex and the Ids of all vertices in the cache line to the evaluation unit 200 to obtain the importance metric values of the vertices in the cache line.
[0116] The cache management unit 300 compares the importance metric values of all cache lines and selects the cache line with the smallest importance metric value for eviction.
[0117] This cache replacement policy can make the vertices that are no longer accessed be preferentially replaced out of the cache, and make the vertices with low access frequencies be preferentially replaced out of the cache. At the same time, it preferentially retains the vertices with high importance in the cache. This enables invalid data not to occupy the cache space, and also enables the vertices that need to be accessed to exist in the cache preferentially, reducing the number of cache replacements and thus reducing cache misses.
[0118] If this cache replacement policy is not executed, some useless data will occupy the cache space, causing ineffective waste of the cache space, and the vertices that need to be accessed cannot be stored in the cache preferentially, resulting in more cache replacements and larger cache misses.
[0119] The prior art does not adopt this policy in the cache replacement policy, that is, it does not consider the real-time change of the importance of vertices, cannot accurately measure the importance of vertices, making the more important vertices not exist in the cache preferentially, resulting in more cache replacements and larger cache misses. The present invention considers multiple influencing factors related to memory access, can more accurately measure the degree of importance of vertices, and uses it in the cache replacement policy to reduce cache misses.
[0120] Figure 4 is the original flow graph. Compared with Figure 4 , Figure 5 Two new edges v1→v4 and v3→v7 are added in . For the newly added edges v1→v4 and v3→v7, the levels of v1, v3, v4, v7, v8, and v9 are 1, 2, 2, 3, 4, and 5 respectively. Level is used to represent the depth of the vertex in the hierarchical structure.
[0121] Then, according to the traditional cache management policy, when the currently accessed vertex is v4, the path distance from v1 to v4 is -1 (1 - 2 = -1). A negative number represents that the access order of v1 is before v4. The path distance from v7 to v4 is 1 (3 - 2 = 1). The path distance from v8 to v4 is 2 (4 - 2 = 2). The path distance from v9 to v4 is 3 (5 - 2 = 3). In the worst case, v7 may be replaced out first. However, when v7 is accessed next, v7 will be replaced in and v8 will be replaced out. When v8 is accessed, v8 will be replaced in and v9 will be replaced out. When v9 is accessed, v9 will be replaced in again. This will result in three memory accesses.
[0122] If the policy is based on the path distance of the currently accessed vertex in the present invention, v9 will be replaced first, directly accessing v7 hits, accessing v8 hits, and v9 is replaced into the cache, resulting in only one memory access. This case shows that the path distance of the currently accessed vertex in the present invention can improve the cache hit rate.
[0123] Embodiment 2
[0124] This embodiment is a further illustration of Embodiment 1, and repeated content will not be elaborated.
[0125] The device of the present invention is applied to the dynamic cache management of an online social platform.
[0126] In a large online social platform, user-generated content and interactions are very frequent, and user behavior will affect the graph structure in real time (such as user follow relationships, post interactions, etc.). In such an environment, the online social platform needs to efficiently manage the cache to ensure that users can quickly access dynamically updated content.
[0127] The online social platform adopts the cache management method of the present invention to optimize the processing efficiency of its graph data. The specific steps of the cache management of the online social platform are as follows.
[0128] Each user (vertex) in the online social platform is assigned an importance index value according to their interaction frequency with other users, activities such as comments and likes. When a user posts new content, the system will perform a depth-first traversal of the states of the users participating in the interaction and calculate the degree of association of their states being affected.
[0129] For example, user A posts a status, and users B, C, and D comment on it. In this process, the degree of association of the states of B, C, and D being affected will increase, while the degree of association of user E who did not participate in the interaction remains zero.
[0130] Record the hierarchical information of all users. For example, the level of user A is 1 (root user), the levels of users B and C are 2 (directly connected to A), the level of user D is 3 (connected through C), and the level of user E is 4 (connected through D).
[0131] After user A posts new content, B, C, and D are preferentially retained in the cache, while E will be preferentially replaced because its path distance is positive and its importance index value is low.
[0132] Based on the degree of association of the vertex state being affected, determine which vertices (users) will be updated. Only when the degree of association is greater than 0 will the user be considered important, otherwise it will no longer be cached.
[0133] By implementing the above efficient cache management method, the online social platform achieves the following technical effects:
[0134] (1) Improve access speed: By accurately identifying and caching users (B, C, D) who interact frequently with user A, the platform can ensure that user A can quickly view the content of user B or C with whom they interact frequently. For example, if user C comments on user A's post, the system can quickly display the latest status of D (such as D's likes or comments), significantly enhancing the user experience.
[0135] (2) Reduce system burden: During peak periods (such as during large-scale events or discussions of popular topics), user activities increase significantly. Through cache management based on the importance of vertices, the system effectively reduces the cache miss rate, thereby avoiding frequent data access overhead and backend service calls, and reducing the system burden. This enables the platform to support more concurrent users without performance degradation.
[0136] (3) Enhance the user interaction experience: By updating the cache related to user interactions in real time, when users participate in comments and interactions, they can quickly see the latest feedback. For example, when user C sees user A's new post, they can immediately see the comments of B and D, enhancing the real-time nature of social interactions and improving the user's sense of participation.
[0137] (4) Optimize resource utilization: Due to reducing cache jitter and access latency, the social platform can utilize server resources more efficiently. The system no longer frequently loads unnecessary data, thereby reducing the overall operating cost. For example, during a large-scale event, the cache management strategy can be dynamically adjusted to focus on retaining the data of active users, ensuring fast and smooth access for key users. This commercial case demonstrates the successful application of the cache management strategy based on the importance of vertices in the social platform. By optimizing the cache strategy, not only is the data access speed improved, but also the user experience and satisfaction are effectively enhanced. Such a technical solution can help the business stand out in the highly competitive market, increasing user retention rate and activity.
[0138] It should be noted that the above specific embodiments are exemplary. Those skilled in the art can come up with various solutions inspired by the disclosure of the present invention, and these solutions also fall within the scope of the disclosure of the present invention and within the protection scope of the present invention. Those skilled in the art should understand that the description and drawings of the present invention are illustrative and do not constitute a limitation on the claims. The protection scope of the present invention is defined by the claims and their equivalents. The description of the present invention contains multiple inventive concepts. For example, "preferably" and "according to a preferred embodiment" each indicate that the corresponding paragraph discloses an independent inventive concept. The applicant reserves the right to file divisional applications based on each inventive concept.
Claims
1. A cache management method for flow graph processing, characterized in that: The method comprises: Select data associated with the vertex from the virtual address; Extracting importance factors from vertex-related data and calculating importance index values to evaluate the importance of vertices during incremental processing of the flow graph; Identify and select the vertex with the lowest importance index value in the last level cache based on the importance index value; In case of a cache miss, the relevant information of the vertex is replaced with the relevant information of the least important cache line in the last level cache.
2. The cache management method for stream graph processing according to claim 1, characterized in that: The importance factors of the importance index value include: the degree of association affected by the vertex state, the path distance of the vertex, and whether the vertex will be updated.
3. The cache management method for stream graph processing according to claim 1 or 2, characterized in that: The step of selecting data associated with the vertex comprises: Record the first address of the state array related to the vertex, the number of vertices and the size of the data; The virtual address is compared with a predetermined address range and classified to obtain the ID of the currently visited vertex, so as to extract the importance factor according to the ID of the currently visited vertex.
4. The cache management method for stream graph processing according to any one of claims 1 to 3, characterized in that: The calculation method of the degree of relevance of the vertex state affected includes: Set the initial value of the affected vertex state's associativity to zero; When the state propagates through the vertex, the degree of association affected by the vertex state increases by 1; when the vertex is processed, the degree of association affected by the vertex state decreases by 1.
5. The cache management method for stream graph processing according to any one of claims 1 to 4, characterized in that: The calculation method of the path distance of the vertex includes: Record the level information of the vertex; Computes the difference between a vertex and the currently visited vertex level.
6. The cache management method for stream graph processing according to any one of claims 1 to 5, characterized in that: The calculation method for whether a vertex will be updated includes: When the degree of association of the vertex state being affected is greater than 0, it means that the vertex will be updated, and the importance index value of whether the vertex will be updated is 1; When the degree of association of the vertex state being affected is 0, it means that the vertex will not be updated, and the importance index value of whether the vertex will be updated is 0.
7. The cache management method for stream graph processing according to any one of claims 1 to 6, characterized in that: The method further comprises: Select the cache line where the vertex with negative path distance is located for replacement; Alternatively, when the path distance of the vertex is a positive number, the cache line where the vertex with a large path distance is located is selected for replacement.
8. The cache management method for stream graph processing according to any one of claims 1 to 7, characterized in that: The steps to calculate the importance index value include: Among them, α represents the weight factor of the association degree (X) affected by the vertex state; β represents the weight factor of the path distance (Y) of the vertex; X max and X min They represent the maximum and minimum values of the degree of association affected by the vertex state in the data set; X represents the degree of association affected by the vertex state, Y represents the path distance of the vertex, and Z represents the value of whether the vertex will be updated.
9. A cache management device for flow graph processing, comprising a processor; characterized in that: The processor is configured to: select data associated with a vertex from a virtual address; Extracting importance factors from vertex-related data and calculating importance index values to evaluate the importance of vertices during incremental processing of the flow graph; Identify and select the vertex with the lowest importance index value in the last level cache based on the importance index value; In case of a cache miss, the relevant information of the vertex is replaced with the relevant information of the least important cache line in the last level cache.
10. A cache management device for flow graph processing, comprising a processor; characterized in that: The processor comprises: An address classifier (100) selects data associated with a vertex from a virtual address; An evaluation unit (200) extracts importance factors from data related to vertices and calculates importance index values to evaluate the importance of vertices during flow graph incremental processing; A cache management unit (300) selects a vertex with the lowest importance index value in the last level cache based on the importance index value identification; in the case of a cache miss, replaces the relevant information of the vertex with the relevant information of the cache line with the lowest importance in the last level cache.
Citation Information
Patent Citations
Distributed cache management method, system and data management system
CN107493327A
Cited By
Graph database adjacency list cache management method and system based on dynamic weight
CN121071190A