Graph structure analysis load balancing optimization method based on cache perception
By sub-graph division and reordering the graph data, the problem of unbalanced workload of graph structure analysis in shared memory multi-core systems is solved, and the cache efficiency and graph computing performance are improved.
Patent Information
- Application Number
- CN202411575403.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-06
- Publication Date
- 2025-02-28
AI Technical Summary
In shared memory multi-core systems, the workload of graph structure analysis is unbalanced, resulting in irregular memory access patterns, high cache miss rate, and the graph computing performance cannot be fully utilized.
By measuring the local skewness of the graph, dividing and reordering the subgraphs of the graph data, ensuring that the number of height vertices and low-degree vertices in each partition subgraph is relatively balanced, thereby optimizing the storage and calculation of graph data.
It improves the cache efficiency of the graph computing system, realizes load balancing, reduces memory access time, and improves the execution efficiency of the graph algorithm.
Smart Images

Figure CN119536938A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of parallel computing, and in particular to a cache-aware graph structure analysis load balancing optimization method. Background Art
[0002] As a computing method that focuses on analyzing and processing graph data structures, graph computing has been widely used in various fields of life, such as protein structure recognition, social network analysis, fraud detection, economic construction, public safety, medical and health services, and other important fields. At the same time, as the scale and complexity of the data generated in these fields continue to grow, graph structure analysis is crucial to achieving high performance of graph computing. At present, graph structure analysis has been widely used in many big data applications such as social computing, network search, and recommendation systems.
[0003] Although much previous research has focused on scaling graph analytics in distributed environments, single-node, multi-core shared memory systems are able to handle increasingly larger graphs and adapt to more complex application scenarios. This makes it possible to perform real-time or near-real-time graph data analysis on shared memory systems. In shared memory graph computing, graph data is divided into multiple partitions, and its multiple partitions can be processed simultaneously on multiple cores with high bandwidth between processor cores. However, the performance of graph computing on multi-core single-node shared memory systems is far from optimal. Due to the highly random memory access patterns during graph processing, the computing power of the underlying multi-core platform is still not fully utilized. Therefore, performance optimization of shared memory graph computing systems still faces great challenges.
[0004] Prior art shows that graph processing exhibits irregular memory access patterns during execution, resulting in poor spatial and temporal locality in the memory access flow. Poor locality may cause graph applications to spend more than 80% of their execution time stagnating on main memory access. Although irregular memory access patterns do not allow for optimal use of cache, the structural characteristics of many real-world graphs provide opportunities to improve graph locality, namely, improve the data layout of the graph. Due to the uneven distribution of the degree of graph data vertices, the number of edges in the partitions appears unevenly concentrated in a small part when the GraphMat graph computing framework stores data in the form of sparse matrices, presenting a power-law skewed distribution, such as Figure 1 As shown in the figure, it becomes very difficult to improve memory bandwidth, balance system load, and minimize the communication overhead between memory and cache data. Summary of the invention
[0005] The purpose of the present invention is to overcome the shortcomings of the prior art and provide a cache-aware graph structure analysis load balancing optimization method to improve the workload imbalance problem of graph applications in a shared memory multi-core system, accelerate the efficiency of graph algorithms, and achieve performance optimization of a multi-core shared memory graph computing system.
[0006] In order to achieve the above purpose, the technical solution adopted by the present invention is: a cache-aware graph structure analysis load balancing optimization method, the specific steps are:
[0007] S1, measure the local skewness of the graph, estimate the imbalance of the graph, and determine whether to proceed to step S2 based on the skewness;
[0008] S2. Divide the graph data into subgraphs and reorder them according to the characteristics of the vertex degree of the graph data, including:
[0009] S201, calculate the high degree vertices and low degree vertices in the graph,
[0010] S202, dividing the graph vertex set into at least one partition subgraph,
[0011] S203. To make the workload equal, reorder the high-degree vertices and low-degree vertices, calculate the vertex threshold in each partition subgraph, and compare the number of high-degree vertices in each partition subgraph with the vertex threshold. If the number of high-degree vertices in the partition subgraph exceeds the vertex threshold, the partition subgraph overflows, and its excess high-degree vertices will be exchanged with the first low-degree vertex of the next partition and used as the first high-degree vertex of the next partition.
[0012] Preferably, the calculation formula of the local skewness of the graph of S1 is as follows:
[0013]
[0014] Where s is the sorted subgraph partition, Headσ refers to the sum of the out-degrees of the subgraph partitions of s that account for the first σ, Tailσ refers to the sum of the out-degrees of the subgraph partitions of s that account for the last σ, and σ is a percentage set by yourself.
[0015] Furthermore, S201 specifically calculates the average degree of the graph data, and refers to vertices in the graph whose degrees are higher than the average degree as high-degree vertices, and vertices whose degrees are lower than the average degree as low-degree vertices.
[0016] Furthermore, the S202 is specifically as follows: firstly, the vertex set of the graph is divided into at least one partition subgraph, the size of each partition subgraph is fixed to the L2 cache size, and then the number of edges in each partition subgraph is determined. The number of vertices in the partition subgraph can be calculated by the following formula (2):
[0017] Npart =N v / Size(L2) (2)
[0018] Among them, N v Represents the number of graph vertices, N part It indicates the number of vertices in the partition subgraph, and Size(L2) indicates the L2 cache size.
[0019] Furthermore, the calculation formula of the vertex threshold is as follows:
[0020] n=N h / N part (3)
[0021] Among them, n represents the vertex threshold, N h Represents the number of high-degree vertices in the graph.
[0022] Furthermore, each partition subgraph contains high- and low-degree vertices in the same proportion as the original graph data, and the relative order of the high- and low-degree vertices remains unchanged.
[0023] Furthermore, the structure and relative order of the graph data after reordering in S203 remain unchanged.
[0024] Furthermore, the storage mode of the graph data after the S2 reordering is a Graphmat shared memory framework based on matrix calculation, and only non-zero elements are stored to reduce storage and computing burdens.
[0025] The advantages of the present invention are: (1) the present invention accelerates the convergence of the graph algorithm without changing the data structure used and implemented by the graph algorithm to optimize the performance of the shared memory graph computing system.
[0026] (2) The present invention can preserve the structure of the graph without destroying it, and keep the relative order of vertices unchanged while ensuring its light weight, i.e., low time cost, and has good acceleration efficiency for multiple graph algorithms.
[0027] (3) The present invention reasonably distributes the computing tasks among multiple system cores of the shared memory, fully utilizes the underlying cache resources, and improves the cache efficiency, thereby achieving a more balanced system workload to a certain extent. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] The following is a brief description of the contents expressed in the drawings of the present invention and the symbols in the drawings:
[0029] Figure 1 This is the ratio of the number of edges in each partition of the Flickr graph data on Graphmat;
[0030] Figure 2It is a graph locality map showing a power-law skewed distribution;
[0031] Figure 3 The following diagram is a diagram of the interaction between data and private cache in the sorting model of the present invention;
[0032] Figure 4 This is a diagram of the classic Graphmat data storage method;
[0033] Figure 5 A comparison diagram of cache utilization efficiency before and after sorting the partitioned graphs of the present invention;
[0034] Figure 6 It is the experimental result figure of the present invention;
[0035] Figure 7 A comparative diagram of the effect of graph vertex positions on graph locality. DETAILED DESCRIPTION
[0036] The specific implementation of the present invention will be further explained in detail below by describing the optimal embodiment with reference to the accompanying drawings.
[0037] To achieve the above objectives, the present invention is implemented through the following technical solutions. The present invention provides a cache-aware graph structure analysis load balancing optimization method, which includes:
[0038] S1. Measure the degree of local skewness of the graph, estimate the imbalance of the graph, and judge whether the locality of the graph meets the requirements based on the degree of local skewness of the graph. If it meets the requirements, there is no need to adjust the graph. If it does not meet the requirements, enter step S2, and divide the graph data into sub-graphs and reorder them in step S2.
[0039] S2. Divide the graph data into subgraphs and reorder them according to the characteristics of the vertex degree of the graph data. If the local deviation is large when the graph algorithm checks the vertices of the graph data, it will cause certain defects in the operation of the algorithm. Therefore, the degree of graph local deviation is quantitatively measured, and then based on the obtained quantitative measurement data, it is determined whether the graph locality needs to be resolved. If not, the graph data is not operated. If the graph data needs to be operated, step S2 is used to divide the graph data into subgraphs and reorder them. When the reordered graph data is called and used by the graph algorithm, the defects of the original graph locality can be overcome. The specific steps are as follows:
[0040] In real graph data, a large amount of graph data in the real world has a "long tail" phenomenon in the distribution of vertex out-degree, that is, a skewed distribution that follows a power law. This phenomenon in which high and low out-degree vertices in the graph are randomly and unevenly distributed and hot vertices tend to gather and occur in a concentrated manner is called graph locality. This paper proposes a new method for evaluating the skewness of graph locality to define the quantitative standard of graph locality, see Formula 1. Through the method proposed in this paper, the skewness of graph locality is used to evaluate the imbalance of the graph, and while optimizing performance, the imbalance of the graph is improved indirectly. The imbalance of the graph is evaluated from the data through the calculated graph locality inclination parameter, and step S2 is entered when the graph is in locality. This local imbalance is improved through step S2, and at the same time, the impact of the load balancing optimization method based on cache-aware graph structure analysis of the present invention on graph balance can be evaluated through step S1.
[0041] The degree of each vertex in the graph data is not large, and the degree of each vertex is not much different. However, in the real world, a large amount of graph data has a "long tail" distribution of vertex out-degrees, that is, it follows a power-law skewed distribution. Figure 2 As shown in the figure, this phenomenon of uneven distribution of high and low degree vertices and the tendency of high degree vertices to cluster and occur in a concentrated manner is called graph locality. Poor graph locality may cause graph applications to spend more than 80% of their execution time stuck in main memory access. Improving graph locality can make the graph more balanced, thereby making the workload of graph applications more balanced on multi-core systems. The calculation formula for graph locality skewness is as follows,
[0042]
[0043] Where s is the sorted subgraph partition, Headσ refers to the out-degree sum of the s subgraph partition with the first σ proportion, Tailσ refers to the out-degree sum of the s subgraph partition with the last σ proportion, and σ is a percentage set by yourself. Table 1 shows the Locality under different graphs and different proportions σ. σCalculate the value. Step S2 refers to the scheme step after reordering. The graph locality skewness calculation can be performed before and after reordering. Comparing the changes in graph locality skewness before and after can measure the impact of this method on graph imbalance. Graph imbalance is also an optimization of the graph data itself, especially for relatively skewed graphs. Reducing the graph locality skewness can alleviate the disadvantages caused by the inherent imbalance problem of the graph itself, and can effectively improve the workload and cache efficiency during graph calculation in multi-core shared memory systems (because previous research has shown that poor graph locality leads to irregular memory access patterns during graph calculation execution, and may cause graph applications to spend more than 80% of their execution time on main memory access. Irregular memory access patterns cannot make optimal use of the cache, and we provide opportunities to improve graph locality based on the structural characteristics of graphs in the real world, that is, to improve the data layout of the graph).
[0044] Table 1 Graph local skewness under different variables σ
[0045] σ 1% 10% 20% 30% 40% 50% urand 1.00 1.00 1.00 1.00 1.00 1.00 kron 1.20 1.13 1.10 1.08 1.07 1.06 pld 2.83 1.86 1.61 1.46 1.36 1.29 live 25.89 21.24 13.19 9.34 6.54 4.48 wiki 39.12 17.60 12.04 9.03 7.17 5.69 twitter 192.12 30.61 15.56 10.47 7.90 6.35 mpi 432.43 56.12 22.69 12.82 8.21 5.93
[0046] S2. Dividing the graph data into subgraphs and reordering them according to the characteristics of the vertex degrees of the graph data includes:
[0047] The positions of graph vertices and the relationships between them have a significant impact on graph locality. Consider Figure 7 Let's take the example in , and assume that the vertices are stored in an array in order of vertex ID. We assume that the graph algorithm examines the relationship between each vertex and its neighbors in order. Our goal is to observe the access patterns associated with vertices 0 and 1. Figure 7 In the random graph of (a), the access pattern is 0-2-5-1-3-4, each vertex is visited only once, there is poor temporal locality, and the vertices do not coexist in the array, that is, the spatial locality is poor. Figure 7 (b) is the reordered vertex data layout, which optimizes the vertex order of the graph. The access pattern of the corresponding vertices 0 and 1 in the reordered graph becomes 0-1-2-1-0-2. The locality of the graph can also be represented by the sparse matrix of the random graph and the reordered graph. Figure 7 This can be seen intuitively in (c) and (d). Figure 7 (c) shows that the matrix elements representing vertex connections of a random graph are sparsely distributed. In contrast, Figure 7The reordered sparse matrix in (d) contains two dense diagonal blocks, showing better graph locality. This cache-aware graph structure analysis load balancing optimization method achieves better graph locality from the perspective of optimizing the graph data layout, thereby improving irregular memory access during the execution of multi-core systems and improving cache efficiency during the execution of graph computing tasks, thereby achieving load balancing during the execution of graph tasks by multi-core systems. The specific reordering optimization graph data layout process is as follows:
[0048] S201, calculate the average degree of each graph data, and call the vertices in the graph whose vertex degrees are higher than the average degree high-degree vertices, and vice versa low-degree vertices. Average degree of graph data = total vertex degree / number of vertices.
[0049] S202, establish the perception between graph locality and cache. The processing of the graph will show irregular memory access patterns, which have a significant impact on cache behavior. The worse the graph locality, the higher the cache miss rate during the execution of the graph application. Most of the time may be wasted on memory access, which greatly increases the total time and limits the performance improvement.
[0050] According to the cache characteristics, the vertex set of the graph can be further divided into multiple partitions, and the size of the partition is fixed to the L2 cache size. Therefore, the subgraph partitioning needs to first determine the number of partitions, and then determine the number of edges in each partition (threshold). The number of vertices in the partitioned subgraph can be calculated by the following formula (2):
[0051] N part =N v / Size(L2) (2)
[0052] Among them, N v Represents the number of graph vertices, N part It indicates the number of vertices in the partition subgraph, and Size(L2) indicates the L2 cache size.
[0053] Through the above operations, each subgraph along its vertex array can be installed in the L2 cache of a system core. And each partitioned subgraph contains high and low degree vertices in the same proportion as the original graph data. High degree vertices and low degree vertices are divided into two sections, high area and low area, in the subgraph, and the relative order of vertices in these two sections is preserved.
[0054] S203, in order to make the workload equal, the high degree vertex N h and low-degree vertices N l Redistribute, that is, reorder, and the implementation process is as follows Figure 3 This requires calculating the vertex threshold in each partition subgraph. The calculation formula for the vertex threshold n is as follows:
[0055] n=Nh / N part (3)
[0056] The number of high-degree vertices in each partition is compared with the threshold. If the number of high-degree vertices in the subgraph exceeds the threshold n, the partition is considered to be overflowed. Once a partition overflows, its excess high-degree vertices will be exchanged with the first low-degree vertex of the next partition and used as the first high-degree vertex of the next partition.
[0057] like Figure 3 As shown, let the vertex set of the graph be subdivided into cacheable disjoint partitions of size equal to the L2 cache. The vertex set of the graph is subdivided into cacheable disjoint partitions of size equal to the L2 cache. Each subgraph contains the same ratio of high and low vertex degrees as the original graph. High-degree vertices and low-degree vertices are divided into two segments in the subgraph. And the relative order of vertices in the high segment and the low segment is preserved. The core process of reordering is divided into two steps: collection and distribution. The specific implementation of the reordering process is as follows Figure 3 As shown in the figure, we use a cache block-level graph data partitioning method, which can make the vertices in the cache block occupy the cache independently while retaining the graph structure.
[0058] The vertices to be modified are determined on a first-come, first-served basis, so the relative order of the graph data is preserved and the data structure is not destroyed. The same is true for the low-degree vertices in each partition subgraph.
[0059] Reordered graph data storage mode: On the Graphmat shared memory framework based on matrix calculation, multiple graph algorithms are iteratively run to improve the performance of the framework system and reduce graph imbalance. Figure 4 It is the storage method of the classic GraphMat graph computing framework.
[0060] After deploying the swap reorder, the vertex order within each subgraph partition in the L2 cache is further refined by dividing the vertices in each subgraph partition into high and low segments. From the perspective of the memory-cache hierarchy, the workload is balanced in the main memory, and then the graph locality is improved in the private L2 cache.
[0061] After reading the graph data in the graph reading phase, the program adopts the vertex reordering method designed by S2 to classify the graph data and count the distribution of high-degree vertices and low-degree vertices in the graph data, and calculate the local skewness of the graph. Then the graph is partitioned according to the cache size and the subgraphs are reordered to increase the balance within the subgraph and the independence between subgraphs without destroying the data structure of the graph, such as Figure 5 As shown. Then, according to the storage and operation mode of the GraphMat framework, the graph data is stored. In a sparse matrix, only non-zero elements are stored, which can reduce the storage and computational burden caused by the long tail effect. Figure 5 As shown, Figure 5 (a) is the original memory-cache access situation. Irregular access to graph vertices will lead to poor spatial locality of the cache, and the destruction of the graph structure will further lead to poor cache locality. In our optimized data layout and storage mode, data is randomly reordered in the memory in the form of cache blocks instead of individual vertices, and the vertices in the cache block are moved as a group, such as Figure 5 As shown in (b), we make vertices that need to frequently interact with other vertices interact with the cache together. Therefore, the cache occupancy of vertices with large data computation is not affected, and any change in performance can be directly attributed to the change in graph structure.
[0062] In addition, large matrices are decomposed into smaller blocks, and these blocks are calculated separately. This helps to use cache and memory more effectively, thereby improving the efficiency of processing long-tail vertices. Due to the "long tail" phenomenon in the vertex degree distribution of graphs in reality, it becomes very difficult to achieve load balancing between nodes and minimize communication overhead in large-scale graph data partitioning. Therefore, Graphmat's backend sparse matrix calculation is used to process the graph data, and different graph algorithms are executed to obtain the final experimental results.
[0063] The present invention is experimentally evaluated on a graph dataset containing seven real graphs. Table 2 shows the number of vertices, the number of edges, and the interval size of subgraph partitions of the seven real graphs.
[0064] Table 2 Data information of seven real images
[0065] Graphs Number of vertices Number of edges Partition interval size urand 67.1M 2.1B 7.9M kron 67.1M 2.1B 2.8M pld 42.9M 0.6B 1.6M live 4.8M 68.5M 0.8M wiki 18.3M 0.2B 0.5M twitter 41.7M 1.5B 2.3M mpi 52.6M 2.0B 1.6M
[0066] The experimental results are as follows Figure 6 As shown in the figure, with the improvement of cache efficiency under the optimal number of threads, the performance of different graph applications is improved to a certain extent, especially graph MPI, which achieves a two-fold acceleration in performance.
[0067] The present invention accelerates the convergence of graph algorithms without changing the data structure used and implemented by the graph algorithms to optimize the performance of the shared memory graph computing system. This design can keep the structure of the graph intact and the relative order between vertices unchanged on the basis of ensuring lightweight, i.e., low time cost, and has good acceleration efficiency for multiple graph algorithms. By reasonably allocating the amount of computing tasks among multiple system cores in the shared memory, the underlying cache resources are fully utilized, and the cache efficiency is improved, thereby achieving a more balanced workload of the system to a certain extent.
[0068] Obviously, the specific implementation of the present invention is not limited to the above-mentioned methods. As long as various non-substantial improvements are made using the method concept and technical solution of the present invention, they are all within the protection scope of the present invention.
Claims
1. A cache-aware graph structure analysis load balancing optimization method, characterized by: The method comprises: S1, measuring the local skewness of the graph, estimating the imbalance of the graph, and judging whether to proceed to step S2 based on the local deviation of the graph; S2. Divide the graph data into subgraphs and reorder them according to the characteristics of the vertex degrees of the graph data.
2. The method for optimizing load balancing based on cache-aware graph structure analysis according to claim 1, characterized in that: Step S2 includes: S201, calculate the high degree vertices and low degree vertices in the graph, S202, dividing the graph vertex set into at least one partition subgraph, S203. Reorder high-degree vertices and low-degree vertices, calculate the vertex threshold in each partition subgraph, compare the number of high-degree vertices in each partition subgraph with the vertex threshold, if the number of high-degree vertices in the partition subgraph exceeds the vertex threshold, the partition subgraph overflows, and its redundant high-degree vertices will be exchanged with the first low-degree vertex of the next partition and used as the first high-degree vertex of the next partition.
3. The method for optimizing load balancing based on cache-aware graph structure analysis according to claim 1, characterized in that: The calculation formula of the local skewness of the graph of S1 is as follows: Where s is the sorted subgraph partition, Headσ refers to the sum of the out-degrees of the subgraph partitions of s that account for the first σ, Tailσ refers to the sum of the out-degrees of the subgraph partitions of s that account for the last σ, and σ is a percentage set by yourself.
4. The method for optimizing load balancing based on cache-aware graph structure analysis according to claim 3, characterized in that: Step S201 includes calculating the average degree of the graph data, and calling the vertices in the graph whose degrees are higher than the average degree high-degree vertices, and the vertices whose degrees are lower than the average degree low-degree vertices.
5. The method for optimizing load balancing based on cache-aware graph structure analysis according to claim 3, characterized in that: Step S202 includes first dividing the vertex set of the graph into at least one partition subgraph, the size of each partition subgraph is fixed to the L2 cache size, and then determining the number of edges in each partition subgraph. The number of vertices in the partition subgraph can be calculated by the following formula (2): N part =N v / Size(L2) (2) Among them, N v Represents the number of graph vertices, N part It indicates the number of vertices in the partition subgraph, and Size(L2) indicates the L2 cache size.
6. The method for optimizing load balancing based on cache-aware graph structure analysis according to claim 2, characterized in that: The calculation formula of the vertex threshold is as follows: n=N h / N part (3) Among them, n represents the vertex threshold, N h Represents the number of high-degree vertices in the graph.
7. The method for optimizing load balancing based on cache-aware graph structure analysis according to claim 2, characterized in that: The modification of the vertices in step S203 requires that each partition subgraph contains the same proportion of high and low degree vertices as the original graph data, and the relative order of the high and low degree vertices remains unchanged.
8. The cache-aware graph structure analysis load balancing optimization method according to claim 2, characterized in that: The structure and relative order of the reordered graph data in S203 remain unchanged.
9. The method for optimizing load balancing based on cache-aware graph structure analysis according to claim 2, characterized in that: The storage mode of the graph data after the reordering in S2 is to store the graph data according to the storage and operation mode of the GraphMat framework.