Incremental graph calculation method and calculation system for power grid analysis application
By introducing a three-layer structure graph and a heuristic cache replacement strategy into the incremental graph computing system, the problems of redundant traversal and high storage pressure in the existing system are solved, and efficient incremental graph computing and storage resource management are achieved, improving Improved power grid data processing capabilities.
Patent Information
- Application Number
- CN202410805665.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-21
- Publication Date
- 2024-10-22
AI Technical Summary
When existing incremental graph computing systems process dynamic and large-scale power grid graph data, redundant traversal and iterative operations lead to high computational complexity, too many intermediate results, and large storage resource usage, which affects system stability and scalability.
A three-layer structure diagram is adopted, including the original layer, intermediate sub-layer and top layer. All intermediate results are stored in external memory, and some intermediate results are dynamically stored in internal memory. A heuristic cache replacement strategy is introduced to optimize storage and computing efficiency.
It significantly reduces the computational complexity and the generation of intermediate results, optimizes the use of storage resources, improves system stability and scalability, reduces memory usage by 40%-60%, and enhances real-time data processing capabilities.
Smart Images

Figure CN118819829A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of graph computing, specifically to the field of incremental graph computing, and more specifically to an incremental graph computing method and computing system for power grid analysis applications. Background Art
[0002] In the context of the rapid development of big data and high-speed network technology, the scale, diversity and growth rate of data in power grid systems have also shown unprecedented expansion. As a structured data type that can effectively describe the interaction between various components within a complex system, graph data plays an important role in multiple power grid application fields such as power system monitoring, optimization and fault analysis. In application scenarios such as power grid management, the interaction and state between devices and nodes continue to change, making the power grid structure increasingly complex. The resulting continuous increase in nodes and edges in the graph urgently requires dynamic graphs to describe these changes. However, traditional large-scale static graph computing systems often perform poorly when faced with such dynamic power grid graph data because they cannot capture and accurately update graph structure changes in real time. In addition, traditional graph algorithms are often not suitable for rapidly changing power grid graph scenarios. The dynamic changes in graph data will also lead to a significant increase in computational complexity, making it difficult for existing systems to update calculation results in real time.
[0003] In response to these problems, many researchers have begun to explore and develop dynamic graph computing systems, especially systems based on incremental graph computing. Such systems effectively reduce the need for repeated calculations by storing the intermediate results of previous calculations, thereby significantly improving the performance of graph computing. Since changes in the power grid structure usually only involve local areas, the incremental graph computing system can reuse existing calculation results and only perform necessary calculations on the changed parts, greatly improving processing efficiency. This strategy not only enables dynamic graph computing systems to manage dynamic power grid data more efficiently, but also improves the speed of data analysis and can return the data mining algorithm results required by users in real time. Although the increase in the scale and complexity of power grid data has brought new challenges to incremental graph computing systems, these challenges have also brought major opportunities to mine deep knowledge and value in large-scale dynamic power grid data, making such systems widely used in multiple power grid-related fields.
[0004] In dynamic power grid topology analysis, incremental graph computing systems avoid unnecessary repeated computations by storing intermediate results of each iteration (such as vertex state information or transmitted messages), which greatly improves computational efficiency. This incremental computing has promoted the development of graph computing systems. In order to alleviate the problem of excessive memory usage of intermediate results, different systems have adopted their own strategies: some systems choose to store only the final state information and dependencies of vertices, supporting graph algorithms with monotonous convergence; others choose not to directly store intermediate results, but only maintain dependencies, which is suitable for graph algorithms that are insensitive to the initial state; and some systems design a variety of intermediate result storage strategies based on different graph algorithm requirements, aiming to find a balance between reducing memory usage and maintaining system versatility. However, when dealing with large-scale power grid analysis applications, specific topology analysis algorithms still inevitably need to store intermediate results in all iterations. As the scale of power grid graph data continues to grow, the storage of intermediate results has an increasing demand for memory, which not only seriously aggravates the system's memory pressure, but may also affect the system's performance and scalability. Especially in key applications such as power grid operation monitoring, fault prediction and response, the requirements for data real-time and processing efficiency are extremely strict. The challenges faced by existing graph computing systems in processing dynamic and large-scale power grid graph data are particularly prominent.
[0005] Based on the above analysis, the existing incremental graph computing system has the following problems: (1) The existing incremental graph computing system performs graph computing based on the original structure of the incremental graph, and there are many redundant traversal and iteration operations, which not only increases the complexity of the calculation, but also generates too many intermediate results, which leads to a large occupation of storage resources. (2) Although the existing system uses memory storage to store intermediate results to improve the reading speed, this storage strategy puts great pressure on memory resources when facing a large amount of intermediate data, which may affect the stability, response speed and scalability of the system.
[0006] It should be noted that this background technology is only used to introduce the relevant information of the present invention to help understand the technical solution of the present invention, but it does not mean that the relevant information is necessarily the prior art. If there is no evidence that the relevant information has been disclosed before the application date of the present invention, the relevant information shall not be regarded as the prior art. Summary of the invention
[0007] Therefore, the purpose of the present invention is to overcome the defects of the above-mentioned prior art and provide an incremental graph computing system combining internal and external memory
[0008] The objective of the present invention is achieved through the following technical solutions:
[0009] According to the first aspect of the present invention, an incremental graph calculation method is proposed for calculating constantly changing graph data, the method comprising: a layer construction step: constructing a three-layer structure graph for calculation based on the original graph data, the three-layer structure graph comprising an original layer, an intermediate sub-layer, and a top layer, wherein: the original layer is a graph structure composed of vertices and edges corresponding to the original graph data; the intermediate sub-layer comprises a plurality of intermediate sub-graph structures, each of which is a graph structure composed of internal vertices and edges of a sub-graph in a plurality of sub-graphs obtained after the original layer is successively simplified and divided into sub-graphs, and each sub-graph corresponds to an intermediate sub-graph. Graph structure; the top-level layer is a graph structure composed of the exit vertices and entry vertices of all subgraphs; calculation steps: respond to changes in graph data, adjust the internal structure of the three-layer structure graph to achieve incremental calculation of the constantly changing graph data, and perform multiple rounds of iterations for each calculation until the graph structure converges, wherein, during the calculation process, all intermediate results of graph calculation are stored in an external memory, and part of the intermediate results of graph calculation are dynamically stored in an internal memory, and the intermediate results are read or stored in both the external memory and the internal memory using the intermediate subgraph structure as the storage unit, wherein all intermediate results of the top-level layer are stored as a whole.
[0010] Preferably, the layer construction step includes: graph structure simplification: identifying strongly connected components in the original layer, configuring a representative vertex for each strongly connected component, connecting all vertices in each strongly connected component to the representative vertex corresponding to the strongly connected component, and redirecting the edges connecting all vertices in the strongly connected component to the external vertices to the representative vertex corresponding to the strongly connected component so that all representative vertices and other vertices form a new graph structure to achieve graph structure simplification; subgraph partitioning: dividing the simplified graph structure into several subgraphs, wherein the number of vertices in each subgraph does not exceed a preset threshold; intermediate sub-layer construction: extracting all vertices other than the exit vertex and the entry vertex in each subgraph and the edges between these vertices to form an intermediate sub-graph structure corresponding to the subgraph, and all intermediate sub-graph structures are combined into an intermediate sub-layer; top-level layer construction: extracting the entry and exit vertices of all subgraphs and the edges between these vertices, and combining them to form a top-level layer.
[0011] Preferably, the preset threshold is determined by:
[0012]
[0013] Among them, K is the preset threshold, and G is the number of vertices of the simplified graph structure.
[0014] Preferably, the internal structure of the three-layer graph is adjusted in the following manner: respond to changes in the graph data and determine the type of graph data change: if the graph data change type is deleting nodes or edges, then reconstruct the three-layer graph structure; if the graph data change type is adding nodes or edges, then determine the magnitude of the increase; if the graph data change is adding less than or equal to 10 edges, then make adjustments from top to bottom on the existing three-layer graph structure; otherwise, reconstruct the three-layer graph structure.
[0015] Preferably, for graph data changes that add less than or equal to 10 edges, adjustments are made from top to bottom on the existing three-layer graph structure in the following manner: the newly added edges are directly added to the top-level layer, and graph traversal is performed on the top-level layer until the top-level layer converges; the state value updates of each vertex in the top-level graph are aggregated, and the aggregated results are synchronously updated to the vertices in the middle sub-layer to complete the cross-layer transfer of the state value.
[0016] Preferably, all intermediate results of graph calculations are stored in an external memory in the following manner: after each round of calculations in the incremental calculations, a new storage partition is defined in the external memory, and all intermediate results generated by the current iteration round are divided into multiple storage units and stored in corresponding storage partitions, wherein the intermediate results of the intermediate sub-layers are divided into multiple storage units based on the intermediate sub-graph structure, and all intermediate results of the top-level layer are used as one storage unit.
[0017] Preferably, partial intermediate results of graph calculations are dynamically stored in the internal memory in the following manner: based on a preset top-level graph cache size, a top-level graph cache is divided in the internal memory for storing intermediate states of vertices in the top-level layer, and based on a preset intermediate subgraph cache block size and number, an intermediate subgraph cache is divided in the internal memory including multiple intermediate subgraph cache blocks of the same size for respectively storing partial intermediate results in multiple intermediate subgraph structures, wherein each intermediate subgraph cache block stores partial intermediate results in one intermediate subgraph structure.
[0018] Preferably, the preset top-level graph cache size is the product of the number of top-level layer vertices and the size of a single intermediate result.
[0019] Preferably, the preset intermediate sub-image cache block size is determined by:
[0020] m=1 / 3*(K*α)*b
[0021] Wherein, m is the size of the intermediate subgraph cache block, K is the number of vertices of the subgraph, α is the correction coefficient, and b is the size of a single intermediate result; the preset number of intermediate subgraph cache blocks is determined in the following manner: the size of the intermediate subgraph cache block is configured based on the determined preset intermediate subgraph cache block size, the number of intermediate subgraph cache blocks is randomly changed to form multiple intermediate subgraph cache area models, and the cache hit rate and occupied storage space of each intermediate subgraph cache area model are evaluated, the intermediate subgraph cache area model with the best performance is screened out, and the number of intermediate subgraph cache blocks of this model is used as the preset number of intermediate subgraph cache blocks, wherein the cache hit rate is the ratio of the number of intermediate results successfully obtained in the intermediate subgraph cache area during the calculation process to the total number of attempts to obtain the intermediate results.
[0022] Preferably, in each round of calculation, part of the intermediate results of the intermediate subgraph structure stored in the intermediate subgraph cache are dynamically replaced based on a heuristic cache replacement strategy.
[0023] Preferably, the dynamic replacement based on the heuristic cache replacement strategy includes: responding to the computing access demand, if the intermediate result required for the computing does not exist in the intermediate subgraph cache area, reading the storage unit corresponding to the intermediate subgraph structure to which the intermediate result belongs from the external memory, and extracting the intermediate result and multiple adjacent intermediate results from the read storage unit based on the size of the preset intermediate subgraph cache block to construct a target intermediate subgraph cache block; judging the occupancy of the intermediate subgraph cache blocks in the current intermediate subgraph cache area, if the number of occupied intermediate subgraph cache blocks is less than the preset number of intermediate subgraph cache blocks, adding the target intermediate subgraph cache block to the intermediate subgraph cache area; otherwise, sorting all subgraph cache blocks according to the priority of each intermediate subgraph cache block, replacing the intermediate subgraph cache block with the lowest priority with the target intermediate subgraph cache block, wherein the priority of the intermediate subgraph cache block is determined by the average degree of its vertices, and the higher the average degree, the higher the priority of the corresponding intermediate subgraph cache block.
[0024] According to a second aspect of the present invention, an incremental graph data calculation system based on any method described in the first aspect of the present invention is proposed, which is used for performing incremental calculation on graph data, and the system includes: a graph structure management module, which is used to construct the original graph data into a three-layer structure graph, which is a top layer, an intermediate sub-layer, and an original layer from the top layer to the bottom layer, and in the incremental calculation process, adjust the internal structure of the three-layer structure graph to adapt to the incremental calculation of the constantly changing graph data; a storage module, which includes an external memory and an internal memory, wherein the external memory is used to store all intermediate results of graph calculation, and the internal memory is used to dynamically store part of the intermediate results of graph calculation, and the intermediate results are read or stored in the external memory and the internal memory in the intermediate sub-graph structure as the storage unit, and all the intermediate results of the top layer are stored as a whole, wherein the storage module is configured to adopt a heuristic cache replacement strategy to obtain the intermediate results required for incremental calculation from the external memory, and use them to update the intermediate results stored in the intermediate sub-graph cache area in the internal memory.
[0025] According to a third aspect of the present invention, a computer-readable storage medium stores a computer program thereon, wherein the computer program can be executed by a processor to implement the steps of any method described in the first aspect of the present invention.
[0026] According to a fourth aspect of the present invention, an electronic device comprises: one or more processors; and a memory, wherein the memory is used to store executable instructions; the one or more processors are configured to implement the steps of any method described in the first aspect of the present invention by executing the executable instructions.
[0027] Compared with the prior art, the advantages of the present invention are:
[0028] First, the present invention constructs a three-layer structure graph including the original layer, the middle sub-layer and the top layer based on the original incremental graph, and uses the constructed incremental graph as the calculation framework. Each calculation operation of the incremental graph is limited to the middle sub-layer and the top layer, thereby avoiding invalid traversal and repeated iteration, significantly reducing the complexity of calculation, reducing the generation of intermediate results, and optimizing the use of storage resources. Secondly, the present invention proposes a storage scheme based on the combination of internal and external memory of the three-layer graph structure graph, which uses the external memory to store all the intermediate results of the graph calculation to utilize its larger storage capacity; at the same time, the internal memory is used to store part of the intermediate results of the data graph calculation to improve the response speed. In addition, the present invention also introduces a heuristic cache replacement strategy, which can call in the necessary intermediate results from the external memory according to the real-time calculation requirements, and can only replace the data in the internal memory according to the priority. The graph calculation system constructed according to the above method significantly reduces the memory usage in the large-scale incremental graph calculation process, and the average reduction can reach 40%-60% compared with the existing graph calculation system, and also enhances the stability and scalability of the system. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] The embodiments of the present invention are further described below with reference to the accompanying drawings, in which:
[0030] Figure 1 A schematic diagram of a three-layer structure according to an embodiment of the present invention;
[0031] Figure 2 A schematic diagram of internal / memory partitioning according to an embodiment of the present invention;
[0032] Figure 3 A flow chart for calculating a single subgraph according to an embodiment of the present invention;
[0033] Figure 4 A schematic diagram of a heuristic cache replacement strategy according to an embodiment of the present invention;
[0034] Figure 5 is a diagram showing the relationship between the size of the intermediate sub-graph cache area and the cache hit rate according to an embodiment of the present invention;
[0035] Figure 6 This is a graph showing memory overhead comparison experiment data according to an embodiment of the present invention. DETAILED DESCRIPTION
[0036] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail by specific embodiments below. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0037] As mentioned in the background technology section, the existing incremental graph computing system has the following problems: (1) The existing incremental graph computing system performs graph computing based on the original structure of the incremental graph, and there are many redundant traversal and iteration operations, which not only increases the complexity of the calculation, but also generates too many intermediate results, which leads to a large occupation of storage resources. (2) Although the existing system uses memory storage to store intermediate results to improve the reading speed, this storage strategy puts great pressure on memory resources when facing a large amount of intermediate data, which may affect the stability, response speed and scalability of the system.
[0038] To solve the above problems, the present invention proposes a new graph structure solution and an incremental computing solution based on the same. In the solution of the present invention, in order to solve the problem of redundant traversal and iterative operations in the existing incremental graph computing system, the present invention proposes a solution to construct a three-layer structure graph including the original layer, the intermediate sub-layer, and the top layer based on the original graph data, and use the three-layer structure graph as the incremental computing framework; to solve the problem that the existing storage strategy cannot cope with the storage of a large amount of intermediate data, the present invention proposes a storage strategy based on the combination of internal and external memory, storing all intermediate results in the external memory, and only dynamically storing part of the intermediate results in the internal memory to alleviate the storage pressure of the internal memory; at the same time, in response to the incremental computing data access requirements, the present invention proposes a heuristic-based cache replacement strategy to dynamically replace the intermediate results in the internal memory.
[0039] In order to better understand the present invention, the present invention is described in detail below with reference to the accompanying drawings and embodiments:
[0040] According to an embodiment of the present invention, a method for calculating incremental graph data is proposed. The method is used to calculate the constantly changing graph data, and during the calculation process, a storage strategy combining internal and external memory is adopted to save the intermediate results of the graph calculation. The incremental graph data calculation method includes a layer construction step and a calculation step. In order to better understand the present invention, each step is described in detail below in combination with specific embodiments.
[0041] 1. Layer construction steps
[0042] In the layer construction step, a three-layer structure graph for calculation is constructed based on the original graph data, and the three-layer structure graph includes an original layer, an intermediate sub-layer, and a top layer, wherein: the original layer is a graph structure composed of vertices and edges corresponding to the original graph data; the intermediate sub-layer includes multiple intermediate sub-graph structures, each intermediate sub-graph structure is a graph structure composed of internal vertices and edges of a sub-graph among multiple sub-graphs obtained after the original layer is sequentially simplified and sub-graph divided, and each sub-graph corresponds to an intermediate sub-graph structure; the top layer is a graph structure composed of the exit vertices and entry vertices of all sub-graphs; constructing a three-layer structure graph can limit most of the graph traversal to the top-level graph, and at the same time, after each graph update, the incremental calculation will only traverse and iterate in individual sub-graphs and skeleton graphs, thereby achieving faster incremental graph calculation performance. In addition, the intermediate result storage strategy of the present invention is also designed based on the multi-layer graph structure.
[0043] According to one embodiment of the present invention, the layer construction step includes: (1) graph structure simplification: identifying strongly connected components in the original layer, configuring a representative vertex for each strongly connected component, and connecting all vertices in each strongly connected component to the representative vertex corresponding to the strongly connected component, and redirecting the edges connecting all vertices in the strongly connected component to the external vertex to the representative vertex corresponding to the strongly connected component so that all representative vertices and other vertices form a new graph structure to achieve graph structure simplification; (2) subgraph partitioning: dividing the simplified graph structure into several subgraphs, wherein the number of vertices in each subgraph does not exceed a preset threshold; (3) intermediate subgraph layer construction: extracting all vertices other than the exit vertex and the entry vertex in each subgraph and the edges between these vertices to form an intermediate subgraph structure corresponding to the subgraph, and all intermediate subgraph structures are combined into an intermediate subgraph layer; (4) top-level layer construction: extracting the entry vertices and exit vertices of all subgraphs, as well as the edges between these vertices, and combining them to form a top-level layer, wherein the preset threshold is determined by the following method
[0044]
[0045] Wherein, K is a preset threshold, and G is the number of vertices of the simplified incremental graph.
[0046] In order to better understand the steps of constructing the three-layer graph structure, the following will be described in detail with reference to the accompanying drawings.
[0047] Indicative, reference Figure 1 , which shows the structural framework of the three-layer structure diagram and the steps of building the three-layer structure diagram. Figure 1Detailed description. First, the strongly connected component algorithm is used to search for strongly connected components in the original layer. The strongly connected components in the graph include the local graph {1, 2, 3, 5} and the local graph {9, 11, 12}. Vertices 1 and 6 are used as representative vertices respectively, and all vertices in each strongly connected component are connected to the representative vertex corresponding to the strongly connected component, and the edges connecting all vertices in the strongly connected component with external vertices are redirected to the representative vertex corresponding to the strongly connected component, so that the representative vertex and other vertices form a new graph structure to simplify the graph structure. Then, the community discovery algorithm is used to divide the simplified graph structure into multiple subgraphs of uniform size based on the preset subgraph size, namely, subgraphs G1 and G2 in the graph. Then, extract all vertices other than the exit vertex and the entry vertex in each subgraph and the edges between these vertices to form multiple intermediate subgraph structures, namely the intermediate subgraph structure G1'{1,3,4} and the intermediate subgraph structure G2'{8,9}, G1' and G2' are combined into an intermediate subgraph layer, and finally, extract the exit vertex, the entry vertex and the edges connecting these vertices of the subgraph, namely the vertex 5 and vertex 2 of subgraph G1 and the vertex 7 and vertex 9 of subgraph G2, and the edges of these vertices to form the top-level layer. By constructing a three-layer structure graph, on the one hand, the redundant traversal of strongly connected components in incremental calculations can be reduced, and on the other hand, the traversal and iteration of graph calculations can be limited between the subgraph and the top-level layer, reducing the computational complexity and the number of generated intermediate results, so as to improve the efficiency of graph calculations. It should be understood that the strongly connected component algorithm is an implementation method for searching for strongly connected quantities in graph data, and the community discovery algorithm is an implementation method for implementing subgraph partitioning. The present invention does not limit the specific implementation methods for searching for strongly connected components and subgraph partitioning, and users can choose other algorithms that can achieve the same function according to their needs.
[0048] According to one embodiment of the present invention, the reasoning process of the calculation formula of the preset threshold is that, from the aforementioned layer construction steps, the following conclusion can be obtained: the top-level graph consists of all subgraphs, namely, the entry vertices and exit vertices and the edges between these vertices. Obviously, the number of vertices in the top-level layer is twice the number of subgraphs. Assuming that the number of vertices of the subgraph is K, the number of vertices of the simplified graph structure is G, the calculation formula of the number of subgraphs T is T=G / K, and the number of vertices of the top-level graph is 2*T. When the size of the top-level skeleton graph and the subgraph is close, the best calculation speed can be achieved. Therefore, the equation (2*G) / K=K is established, and the calculation formula of the preset size of the subgraph can be obtained.
[0049] 2. Calculation steps
[0050] The calculation step is a step of performing graph calculation based on the aforementioned three-layer structure graph, which is: in response to changes in graph data, the internal structure of the three-layer structure graph is adjusted to achieve incremental calculation of the constantly changing graph data, and each calculation is performed for multiple rounds of iterations until the graph structure converges. In the calculation process, all intermediate results of graph calculation are stored in an external memory, and part of the intermediate results of graph calculation are dynamically stored in an internal memory. In addition, intermediate subgraph structures are used as storage units in both the external memory and the internal memory to read or store intermediate results, and all intermediate results of the top-level layer are stored as a whole.
[0051] According to an embodiment of the present invention, in order to ensure that the three-layer structure graph proposed in the present invention can adapt to the constantly changing graph data, different graph data are selected according to the graph data change type and change magnitude during the calculation process. Figure 3 The layer graph structure adjustment path includes: first, determine the type of graph data change. If the graph data change is to delete nodes or edges, rebuild the three-layer structure graph; if the graph data change is to add nodes or edges, determine the magnitude of the graph data change: if the graph data change is to add less than or equal to 10 edges, adjust the existing three-layer graph structure from top to bottom, otherwise, reconstruct the three-layer graph structure. For graph data changes that add less than or equal to 10 edges, adjust the existing three-layer graph structure in the following ways: add the newly added edges directly to the top layer, perform graph traversal on the top layer until the top layer converges; aggregate the state value updates of each vertex in the top-level graph, and synchronously update the aggregated results to the vertices in the middle sub-layer to complete the cross-layer transfer of state values.
[0052] According to one embodiment of the present invention, the storage partitions of the internal memory and the external memory are as follows: Figure 2 As shown, the internal memory includes a top-level graph cache and an intermediate subgraph cache, wherein, because the vertices in the top-level layer are accessed very frequently during the graph calculation process, the designed top-level graph cache is dedicated to storing the intermediate results of all vertices in the top-level layer, while the vertices in the intermediate subgraph layer are accessed less frequently than the top-level graph, and it is not necessary to store the intermediate results in all the intermediate subgraph layers in the internal memory for a long time, so the designed intermediate subgraph cache includes a plurality of intermediate subgraph cache blocks of the same size, each intermediate subgraph cache block stores the intermediate results of some vertices in an intermediate subgraph structure, and the intermediate subgraph cache block can be replaced dynamically. The external memory is divided into a plurality of storage partitions according to the iteration rounds, which are used to store the intermediate results generated by each iteration round in the graph calculation, and each storage partition is used to store all the intermediate results of an iteration round.
[0053] According to one embodiment of the present invention, after each round of calculation, a new storage partition is defined in the external memory, and all intermediate results generated in the current iteration cycle are divided into multiple storage units to be saved in the corresponding storage partitions, wherein the intermediate results of the intermediate sub-layers are stored in the intermediate sub-graph structure, and the intermediate results of the top-level layers are stored in the top-level graph structure. In order to better understand the way in which the external memory stores intermediate results, it will be explained below with reference to specific examples. Schematically, in the graph calculation process, the intermediate results in the next sub-graph of each iteration round are saved in a file, and the file naming is identified using batch_ID (round mark) and vertex_ID (vertex mark) to facilitate reading in subsequent calculations. At the same time, the intermediate results of the intermediate sub-layers are divided into multiple storage units in units of the intermediate sub-graph structure, and the middle of each round of calculation of the top-level layer is divided into a storage unit, and each storage unit is compressed using an existing compression algorithm (Gzip, bzip2, 7z, etc.), thereby ensuring the storage and reading rate of the intermediate results.
[0054] According to an embodiment of the present invention, the internal memory and the external memory both use the intermediate subgraph structure in the three-layer structure graph as a unit to save and read the intermediate results, wherein all the intermediate results of the top layer are stored as a whole. Because each graph update is in the same subgraph or top graph or between two different subgraphs, using the top graph or the intermediate subgraph structure as a unit for caching can better utilize the principle of locality, improve the cache hit rate and the efficiency of saving and reading the intermediate results.
[0055] According to one embodiment of the present invention, the size of the top-level graph cache area and the size and number of the intermediate sub-graph cache blocks will directly affect the memory overhead and the cache hit rate. During the calculation process, the cache hit rate and memory overhead of the intermediate sub-graph cache need to be taken into account. Therefore, it is particularly important to design the size of the top-level graph cache area and the size and number of the intermediate sub-graph cache blocks. Among them, the designed size of the top-level graph cache area is the product of the number of top-level graph vertices and a single intermediate result. The size and number of the intermediate sub-graph cache blocks need to be determined by combining theoretical deduction with experiments. In order to better understand the method of determining the size and number of the intermediate sub-graph cache blocks, it will be described in detail with examples below.
[0056] Schematically, assume that two different subgraphs are accessed for each calculation, and consider the average cache hit rate for each access. First, consider the hit probability of accessing any vertex in the subgraph in each subsequent calculation. If the vertex of a subgraph has been cached, then the hit probability of accessing this subgraph is P1=n / K, where n is the size of the intermediate subgraph cache block, that is, the number of intermediate states of vertices in the intermediate subgraph cache block, and K is the aforementioned preset threshold, that is, the number of vertices in the subgraph. Since the system has m cache blocks, but each intermediate subgraph cache block can cache the intermediate results of n vertices, and in each calculation, the data in the cache block will be replaced with the vertex information of the subgraph currently being calculated. In each subsequent access, a cache hit can only occur when the cached subgraph is accessed again. Since the number of cache blocks m is small relative to the total number of subgraphs T, assuming that the subgraphs accessed in each calculation are uniformly randomly selected, then the probability that a specific subgraph is still in the cache in the next calculation is P2=m / T. Therefore, it can be used to approximate the probability that any subgraph still exists in the cache in each calculation. The cache hit probability for any subsequent access to the intermediate state of any vertex in the subgraph is P = (m×n) / (K*T). According to the above theoretical derivation, it is known that in theory, the size and number of intermediate subgraph cache blocks are positively correlated with the cache hit probability. In actual graph calculations, vertex access is not random, and each graph data follows certain rules. It is also necessary to find the optimal configuration parameters for the number and size of intermediate subgraph cache blocks in actual tests. For example, taking Twitter-2009 graph data as an example, the graph data contains a list of all user-to-user links captured from Twitter. When the number of its vertices is 41652230, the subgraph size K = 9127, and the number of subgraphs T is about 4500. The size m of the intermediate subgraph cache block is calculated by the formula m = 1 / 3*(K*α)*b, where α is the correction coefficient and b is the size of a single intermediate result. In this example, the size of a single intermediate result is 8 Byte. The same intermediate subgraph cache block size m and different numbers of intermediate subgraph cache blocks are configured to obtain multiple intermediate subgraph cache area configuration models with different memory overheads. Then, a cache hit rate test and space occupancy test are performed on a server running CentOS 7. The server is equipped with an Intel(R) Xeon(R) E5-2640 v4 CPU with an x86_64 architecture, a main frequency of 2.40 GHz, and 128 GB of RAM memory. The final experimental results are as follows: Figure 4As shown in the figure, through experimental analysis, it is found that when the cache size is greater than 32MB, the cache hit rate increases very slowly. Therefore, considering the memory overhead and cache hit rate, it is more appropriate to choose 32MB as the cache size of the intermediate result. The corresponding intermediate subgraph cache block size is 32768Byte (32KB), and the number of intermediate subgraph cache blocks is 1024. It should be understood that the experimental environment will directly affect the experimental results. In order to ensure the validity of the configured intermediate subgraph cache block parameters, the experimental environment should be a computing device of the deployment graph computing system.
[0057] According to one embodiment of the present invention, in the calculation step, the intermediate result of the graph calculation is accessed as follows: Figure 3 As shown in the figure, the intermediate result saving and reading process of the subgraph iterative calculation in the incremental calculation is demonstrated. Before each subgraph iterative calculation, the system will adopt the cache replacement strategy to update the intermediate results in the internal memory to ensure that the intermediate results required for this iterative calculation are stored in the internal memory. When the iterative calculation is completed, the intermediate results generated by this calculation are saved in the external memory. At the same time, in order to ensure the data required for the next iterative calculation, some of the intermediate results saved in the internal memory will also be updated to the intermediate results generated by their corresponding vertices in the current iteration round.
[0058] According to an embodiment of the present invention, each update and replacement operation of the intermediate results in the intermediate subgraph cache involves the process of querying the intermediate results in the external memory and then copying them to the internal memory. This process not only consumes system resources but also affects the efficiency of graph calculation. Therefore, in order to reduce the frequency of replacement of intermediate results in the intermediate subgraph cache, the present invention proposes a heuristic cache replacement strategy, the detailed steps of which are: during the graph calculation process, determine whether the intermediate subgraph cache contains the intermediate results required for the current calculation: if the intermediate subgraph cache contains the intermediate results required for the calculation, then maintain the intermediate subgraph cache unchanged; otherwise, according to the vertex corresponding to the intermediate result required for the current calculation, retrieve the storage unit of the intermediate subgraph structure corresponding to the vertex from the external memory to obtain the intermediate results of the vertex and its multiple adjacent vertices in the corresponding intermediate subgraph structure, so as to construct the target intermediate subgraph cache block; then After that, the occupancy of the current intermediate subgraph cache area is determined. If the number of intermediate subgraph cache blocks occupied is less than the preset number of intermediate subgraph cache blocks, the target intermediate subgraph cache block is added to the intermediate subgraph cache area. On the contrary, if the number of intermediate subgraph cache blocks occupied is greater than or equal to the preset number of intermediate subgraph cache blocks, all subgraph cache blocks are sorted according to the priority of each intermediate subgraph cache block, and the intermediate subgraph cache block with the lowest priority is replaced with the target intermediate subgraph cache block, wherein the priority of the intermediate subgraph cache block is determined by the average degree of its vertices. The higher the average degree, the higher the priority of the corresponding intermediate subgraph cache block. The heuristic cache replacement strategy is designed based on the properties of the graph structure. In the power grid topology, vertices with high degrees, such as main substations or key distribution nodes, are often connected to more other nodes, which means that these key vertices may be frequently accessed during the graph calculation process of power grid monitoring and fault response. By preferentially retaining the state information of these vertices, the cache hit rate can be significantly improved, thereby speeding up the calculation speed and reducing the need to access external storage. In addition, this cache strategy uses the structural information of the graph to guide cache replacement decisions. Compared with traditional cache strategies such as Least Recently Used (LRU) or Least Frequently Used (LFU), it can better adapt to the characteristics of power grid graph calculations. Especially when processing dynamic power grid data, this strategy can dynamically adjust the cache content according to the real-time changes in the power grid graph structure to adapt to the dynamic and complexity of power grid operation. This vertex degree-based cache replacement strategy not only enhances the efficiency of power grid data processing, but also improves the overall performance of the system. It is particularly suitable for meeting the needs of real-time data analysis and rapid fault location in power grids.
[0059] Schematically, the process of calculating the priority and performing cache replacement based on the average degree of the vertices in the intermediate subgraph cache block is as follows: Figure 5As shown in the figure, this strategy uses the average degree of all vertices in the cache block as the basis for priority sorting, and the average degrees of intermediate subgraph cache blocks 1 to 5 are 3.3, 2.4, 5.6, 1.7, and 2.8 respectively. Then, the low-priority intermediate subgraph cache blocks with low average degrees are eliminated, that is, the intermediate subgraph cache block 4 is eliminated, and then the target intermediate subgraph cache block 6 is added to the intermediate subgraph cache area.
[0060] According to one embodiment of the present invention, based on the aforementioned incremental graph calculation method, an incremental graph calculation system is proposed for calculating input graph data, the system comprising: (1) a graph structure construction module, which is a module for constructing the original graph data into a three-layer structure graph from the top layer to the bottom layer, which is a top layer, an intermediate sublayer, and an original layer, and in the graph calculation process, adjusts the internal structure of the three-layer structure graph to adapt to the incremental calculation of the constantly changing graph data; (2) a storage management module, which comprises an external memory and an internal memory, wherein the external memory is used to store all intermediate results of the graph calculation, and the internal memory is used to dynamically store part of the intermediate results of the graph calculation, and in the external memory and the internal memory The intermediate results are read or stored in the intermediate subgraph structure as the storage unit, and all the intermediate results of the top layer are stored as a whole, wherein the storage module is configured to adopt a heuristic cache replacement strategy to obtain the intermediate results required for graph calculation from the external memory, and use them to update the intermediate results stored in the intermediate subgraph cache area in the internal memory to meet the computing requirements; (3) a computing control module, which is used to perform incremental graph calculation based on the three-layer structure graph, and coordinate the graph data processing module, the storage management module and the cache replacement unit module; (4) a user interface module, which is used to input the original graph data, and configure the size of the top-level graph cache area in the internal memory, the size and number of the intermediate subgraph cache blocks.
[0061] In order to better verify the beneficial effects of the present invention, the inventors designed a memory usage comparison experiment to compare the memory management performance of the incremental graph computing system proposed in the present invention with that of the prior art. The technical effects of the present invention are further demonstrated below in combination with the comparative experiment and the comparative experimental results.
[0062] The memory usage comparison experiment uses five graph datasets from the real world, as shown in Table 1. The graph datasets shown in the table include: web-BerkStan (WB), which contains web page nodes from the berkeley.edu and stanford.edu domains, and represents the hyperlink relationship between these web pages through directed edges. cit-Patents (CP), which is a US patent dataset published and maintained by the National Bureau of Economic Research (NBER). The dataset covers all utility patents granted between 1963 and 1999 and all patent citations between 1975 and 1999. wiki-topcats (WT), which is a network graph dataset containing the hyperlink network in Wikipedia in September 2011. soc-LiveJournal1 (SL) comes from LiveJournal, a free online community with nearly 10 million members. The dataset contains its network graph information. tech-p2p (TP), which is a graph dataset from the P2P file sharing network software eDonkey. These datasets provide rich actual graph data for experiments, covering a variety of fields from hyperlinks on web pages, patent citation networks, to online communities and file sharing networks. These datasets of different fields and sizes can better simulate the performance of this work in different real-world scenarios.
[0063] Table 1: Graph dataset parameter table
[0064]
[0065] The graph computing method proposed in this invention and the traditional graph computing method are used to calculate the graph datasets WB, WT, SL and TP, and the memory overhead of the two methods is obtained, as shown in FIG. Figure 6 As shown, the method of the present invention significantly reduces memory overhead by 40% to 60% compared to traditional graph computing methods. This improvement not only significantly reduces the memory burden of the system when processing large-scale incremental graph computing, but also effectively avoids the potential impact on system performance caused by excessive memory usage.
[0066] It should be noted that although the above describes the various steps in a specific order, it does not mean that the various steps must be executed in the above specific order. In fact, some of these steps can be executed concurrently or even in a different order as long as the required functions can be achieved.
[0067] The present invention may be a system, a method and / or a computer program product. The computer program product may include a computer-readable storage medium carrying computer-readable program instructions for causing a processor to implement various aspects of the present invention.
[0068] Computer readable storage medium can be a tangible device that holds and stores instructions used by an instruction execution device. Computer readable storage medium can include, for example, but is not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination thereof. More specific examples (non-exhaustive list) of computer readable storage medium include: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a static random access memory (SRAM), a portable compact disk read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanical encoding device, for example, a punch card or a protruding structure in a groove on which instructions are stored, and any suitable combination thereof.
[0069] The embodiments of the present invention have been described above, and the above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The selection of terms used herein is intended to best explain the principles of the embodiments, practical applications, or technical improvements in the market, or to enable other persons of ordinary skill in the art to understand the embodiments disclosed herein.
Claims
1. An incremental graph computing method for computing continuously changing graph data, characterized in that: The method comprises: Layer construction step: construct a three-layer structure graph for calculation based on the original graph data. The three-layer structure graph includes the original layer, the middle sub-layer, and the top layer, where: The original layer is a graph structure consisting of vertices and edges corresponding to the original graph data; The intermediate sub-layer includes multiple intermediate sub-graph structures, each of which is a graph structure composed of internal vertices and edges of one of the multiple sub-graphs obtained by sequentially simplifying the graph structure and dividing the sub-graphs of the original layer, and each sub-graph corresponds to an intermediate sub-graph structure; The top layer is a graph structure consisting of the exit vertices and entry vertices of all subgraphs; Calculation steps: respond to changes in graph data, and adjust the internal structure of the three-layer graph to achieve incremental calculation of the constantly changing graph data. Each calculation is performed for multiple rounds of iterations until the graph structure converges. During the calculation process, all intermediate results of graph calculation are stored in external memory, and some intermediate results of graph calculation are dynamically stored in internal memory. In addition, intermediate subgraph structures are used as storage units in both external and internal memories to read or store intermediate results. All intermediate results of the top-level layers are stored as a whole.
2. The method according to claim 1, characterized in that The layer construction steps include: Graph structure simplification: Identify the strongly connected components in the original layer, assign a representative vertex to each strongly connected component, connect all vertices in each strongly connected component to the representative vertex corresponding to the strongly connected component, and redirect the edges connecting all vertices in the strongly connected component to the external vertices to the representative vertex corresponding to the strongly connected component so that all representative vertices and other vertices form a new graph structure to achieve graph structure simplification; Subgraph partitioning: Divide the simplified graph structure into several subgraphs, where the number of vertices in each subgraph does not exceed a preset threshold; Intermediate sub-layer construction: extract all vertices except the exit vertex and the entry vertex in each sub-graph and the edges between these vertices to form an intermediate sub-graph structure corresponding to the sub-graph. All intermediate sub-graph structures are combined into an intermediate sub-layer. Top-level layer construction: Extract the entry and exit vertices of all subgraphs and the edges between these vertices, and combine them to form the top-level layer.
3. The method according to claim 2, characterized in that The preset threshold is determined by: Among them, K is the preset threshold, and G is the number of vertices of the simplified graph structure.
4. The method according to claim 1, characterized in that: Adjust the internal structure of the three-layer structure diagram in the following ways: Respond to changes in graph data and determine the type of graph data change: If the graph data change type is deleting nodes or edges, the three-layer graph structure is reconstructed; If the graph data change type is adding nodes or edges, the magnitude of the increase is determined. If the graph data change is adding less than or equal to 10 edges, the existing three-layer graph structure is adjusted from top to bottom. Otherwise, the three-layer graph structure is reconstructed.
5. The method according to claim 4, characterized in that For graph data changes that add less than or equal to 10 edges, the following method is used to adjust the existing three-layer graph structure from top to bottom: Add the newly added edges directly to the top layer, and perform graph traversal on the top layer until the top layer converges; Aggregate the state value updates of each vertex in the top-level graph, and synchronously update the aggregation results to the vertices in the middle sub-layer to complete the cross-layer transfer of state values.
6. The method according to claim 1, characterized in that All intermediate results of graph computation are stored in external memory as follows: After each round of calculation in the incremental calculation is completed, a new storage partition is delineated in the external memory, and all intermediate results generated by the current iteration round are divided into multiple storage units and stored in the corresponding storage partitions. Among them, the intermediate results of the intermediate sub-layer are divided into multiple storage units based on the intermediate sub-graph structure, and all intermediate results of the top-level layer are taken as one storage unit.
7. The method according to claim 1, characterized in that Dynamically store some intermediate results of graph computation in internal memory in the following way: Based on a preset top-level graph cache size, a top-level graph cache is divided in the internal memory for storing intermediate states of vertices in the top-level layer, and based on a preset intermediate sub-graph cache block size and number, an intermediate sub-graph cache containing multiple intermediate sub-graph cache blocks of the same size is divided in the internal memory for respectively storing partial intermediate results in multiple intermediate sub-graph structures, wherein each intermediate sub-graph cache block stores a partial intermediate result in an intermediate sub-graph structure.
8. The method according to claim 7, characterized in that The preset top-level graph cache size is the product of the number of top-level layer vertices and the size of a single intermediate result.
9. The method according to claim 7, characterized in that: The preset intermediate sub-image cache block size is determined by: Where m is the size of the intermediate subgraph cache block, K is the number of vertices of the subgraph, α is the correction coefficient, and b is the size of a single intermediate result; The preset number of intermediate sub-image cache blocks is determined by: The size of the intermediate sub-graph cache block is configured based on the determined preset intermediate sub-graph cache block size, the number of the intermediate sub-graph cache blocks is randomly changed to form multiple intermediate sub-graph cache area models, and the cache hit rate and the occupied storage space of each intermediate sub-graph cache area model are evaluated, and the intermediate sub-graph cache area model with the best performance is screened out, and the number of intermediate sub-graph cache blocks of this model is used as the preset number of intermediate sub-graph cache blocks, wherein the cache hit rate is the ratio of the number of intermediate results successfully obtained in the intermediate sub-graph cache area during the calculation process to the total number of attempts to obtain the intermediate results.
10. The method according to claim 7, characterized in that In each round of calculation, some intermediate results of the intermediate subgraph structure stored in the intermediate subgraph cache are dynamically replaced based on the heuristic cache replacement strategy.
11. The method according to claim 10, characterized in that The dynamic replacement based on the heuristic cache replacement strategy includes: In response to a computing access demand, if the intermediate result required for the computing does not exist in the intermediate subgraph cache area, a storage unit corresponding to the intermediate subgraph structure to which the intermediate result belongs is read from an external memory, and the intermediate result and multiple adjacent intermediate results are extracted from the read storage unit based on a preset size of the intermediate subgraph cache block to construct a target intermediate subgraph cache block; Determine the occupancy of the intermediate subgraph cache blocks in the current intermediate subgraph cache area. If the number of intermediate subgraph cache blocks occupied is less than the preset number of intermediate subgraph cache blocks, add the target intermediate subgraph cache block to the intermediate subgraph cache area; otherwise, sort all subgraph cache blocks according to the priority of each intermediate subgraph cache block, and replace the intermediate subgraph cache block with the lowest priority with the target intermediate subgraph cache block, wherein the priority of the intermediate subgraph cache block is determined by the average degree of its vertices, and the higher the average degree, the higher the priority of the corresponding intermediate subgraph cache block.
12. An incremental graph data computing system based on the method according to any one of claims 1 to 11, used for performing incremental computing on graph data, characterized in that: The system comprises: A graph structure management module is used to construct the original graph data into a three-layer structure graph, which is a top layer, an intermediate sublayer, and an original layer from the top layer to the bottom layer, and to adjust the internal structure of the three-layer structure graph to adapt to the incremental calculation of the constantly changing graph data during the incremental calculation process; A storage module includes an external memory and an internal memory, wherein the external memory is used to store all intermediate results of graph calculations, and the internal memory is used to dynamically store part of the intermediate results of graph calculations, and intermediate results are read or stored in both the external and internal memories using intermediate subgraph structures as storage units, and all intermediate results of the top layer are stored as a whole, wherein the storage module is configured to adopt a heuristic cache replacement strategy to obtain intermediate results required for incremental calculations from the external memory, and use them to update the intermediate results stored in the intermediate subgraph cache area in the internal memory.
13. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and the computer program can be executed by a processor to implement the steps of the method according to any one of claims 1 to 11.
14. An electronic device, characterized in that: include: one or more processors; as well as A memory, wherein the memory is used to store executable instructions; The one or more processors are configured to implement the steps of the method of any one of claims 1 to 11 by executing the executable instructions.
