Directed acyclic graph generation and transaction execution method and device
By reordering directed acyclic graphs using priority calculation models and weighted summing algorithms in the blockchain system, the problem of insufficient consideration of resource reuse and resource state during transaction processing is solved, and performance and efficiency improvements are achieved.
Patent Information
- Application Number
- CN202411979674.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-31
- Publication Date
- 2025-05-09
AI Technical Summary
The existing blockchain systems lack resource reuse mechanisms and DAG generation algorithms when processing transactions, resulting in inadequate system performance and resource utilization efficiency.
By calculating the thread priority and cache hit rate of the transaction based on the pre-constructed priority calculation model, weighted summing is performed to obtain the comprehensive priority, and reorder the directed acyclic graph according to the comprehensive priority, optimizing the transaction execution order.
It significantly improves the overall performance and resource utilization efficiency of the blockchain system, reduces resource switching overhead, and improves transaction processing capabilities while ensuring system security and consistency.
Smart Images

Figure CN119960933A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of blockchain and distributed computing technology, and in particular to a directed acyclic graph generation and transaction execution method and device. Background Art
[0002] Blockchain technology has been widely used in finance, supply chain, digital identity and other fields due to its decentralization, immutability and transparency. With the continuous expansion of blockchain application scenarios, the number of transactions that the system needs to process has increased dramatically, which puts higher requirements on the transaction processing performance of blockchain. In the blockchain system, the execution process of transactions involves complex operations such as calling smart contracts and reading and writing state data. These operations usually require the launch of independent threads or processes to complete. Traditional blockchain systems often use simple thread / process scheduling strategies when processing transactions of consecutive blocks, which causes the system to frequently create, switch and destroy computing resources, seriously affecting the overall performance of the system.
[0003] At present, mainstream blockchain platforms have the following problems in transaction execution: First, there is a lack of an effective reuse mechanism for thread / process resources. The transaction execution of each new block may lead to a large amount of resource reallocation, resulting in unnecessary system overhead. Second, the existing DAG (directed acyclic graph) generation algorithm mainly focuses on the dependencies between transactions and fails to fully consider the resource status of the execution environment, which makes the generated DAG structure unable to maximize the use of existing computing resources. In addition, slave nodes usually adopt a fixed scheduling strategy when executing transactions, and fail to dynamically adjust the execution order according to local resource conditions, resulting in inefficient resource utilization.
[0004] How to improve the system's transaction processing performance through intelligent resource scheduling and DAG optimization strategies is a technical problem that needs to be solved at present. Summary of the invention
[0005] The present invention provides a directed acyclic graph generation and transaction execution method and device to solve the defects in the prior art.
[0006] The present invention provides a directed acyclic graph generation and transaction execution method, comprising the following steps: Calculating multiple transactions based on a pre-built priority calculation model to obtain a thread priority and a cache hit rate of each of the multiple transactions; Performing a weighted summation on the thread priority and the cache hit rate of each transaction to obtain a comprehensive priority of each transaction; The transaction nodes in the basic directed acyclic graph are reordered according to the comprehensive priority of each transaction to obtain an optimized directed acyclic graph, and the transactions are executed according to the structural order of the optimized directed acyclic graph; wherein the basic directed acyclic graph is constructed based on the dependency relationship between each transaction, and one transaction corresponds to one transaction node.
[0007] According to a directed acyclic graph generation and transaction execution method provided by the present invention, the plurality of transactions are calculated based on a pre-built priority calculation model to obtain the thread priority of each transaction in the plurality of transactions, which is implemented by the following formula: ThreadPriority(T) = 1 - (ThreadIndex / TotalThreads) Among them, ThreadPriority(T) represents the thread priority of transaction T, ThreadIndex represents the thread index sorted by quantity priority, and TotalThreads represents the total number of threads processing contract transactions.
[0008] According to a directed acyclic graph generation and transaction execution method provided by the present invention, the plurality of transactions are calculated based on a pre-built priority calculation model to obtain a cache hit rate of each of the plurality of transactions, which is implemented by the following formula: CacheHitRatio(T) = CacheHits(T) / TotalAccesses(T) Among them, CacheHitRatio(T) represents the cache hit ratio of transaction T, CacheHits(T) represents the number of hits when transaction T accesses the cache, and TotalAccesses(T) represents the total number of cache accesses by transaction T.
[0009] According to a directed acyclic graph generation and transaction execution method provided by the present invention, the thread priority and the cache hit rate of each transaction are weighted and summed to obtain the comprehensive priority of each transaction, which is implemented by the following formula: P(T) = α * ThreadPriority(T) + β * CacheHitRatio(T) Where P(T) represents the comprehensive priority of transaction T, α and β represent weight coefficients, ThreadPriority(T) represents the thread priority of transaction T, and CacheHitRatio(T) represents the cache hit ratio of transaction T.
[0010] According to a directed acyclic graph generation and transaction execution method provided by the present invention, before reordering the transaction nodes in the basic directed acyclic graph according to the comprehensive priority of each transaction to obtain an optimized directed acyclic graph, the method further includes: Calculate the ranking weight of each transaction according to the comprehensive priority of each transaction and the predetermined hierarchical depth of each transaction; The step of reordering the transaction nodes in the basic directed acyclic graph according to the comprehensive priority of each transaction to obtain an optimized directed acyclic graph includes: The transaction nodes in the basic directed acyclic graph are reordered according to the sorting weight of each transaction to obtain an optimized directed acyclic graph.
[0011] According to a directed acyclic graph generation and transaction execution method provided by the present invention, the ranking weight of each transaction is calculated based on the comprehensive priority of each transaction and the predetermined hierarchical depth of each transaction, which is implemented by the following formula: W(T) = P(T) * LayerDepth(T) Among them, W(T) represents the sorting weight of transaction T, P(T) represents the comprehensive priority of transaction T, and LayerDepth(T) represents the layer depth of transaction T.
[0012] According to a directed acyclic graph generation and transaction execution method provided by the present invention, after executing the transaction in the structural order of the optimized directed acyclic graph, the method further includes: The local thread pool and cache status are updated according to the transaction execution status, so as to dynamically adjust the execution order of the transactions based on the updated thread pool and cache status.
[0013] The present invention also provides a directed acyclic graph generation and transaction execution device, comprising the following modules: A first calculation module, configured to calculate a plurality of transactions based on a pre-built priority calculation model to obtain a thread priority and a cache hit rate of each of the plurality of transactions; A second calculation module, configured to perform a weighted summation of the thread priority and the cache hit rate of each transaction to obtain a comprehensive priority of each transaction; A generation and execution module is used to reorder the transaction nodes in the basic directed acyclic graph according to the comprehensive priority of each transaction to obtain an optimized directed acyclic graph, and execute transactions according to the structural order of the optimized directed acyclic graph; wherein the basic directed acyclic graph is constructed based on the dependency relationship between each transaction, and one transaction corresponds to one transaction node.
[0014] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the directed acyclic graph generation and transaction execution method as described in any one of the above methods is implemented.
[0015] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements any of the directed acyclic graph generation and transaction execution methods described above.
[0016] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the directed acyclic graph generation and transaction execution method as described in any one of the above methods is implemented.
[0017] The present invention provides a directed acyclic graph generation and transaction execution method and device, which calculates multiple transactions based on a pre-built priority calculation model to obtain the thread priority and cache hit rate of each transaction in the multiple transactions; performs weighted summation on the thread priority and cache hit rate of each transaction to obtain the comprehensive priority of each transaction; reorders the transaction nodes in the basic directed acyclic graph according to the comprehensive priority of each transaction to obtain an optimized directed acyclic graph, and executes transactions according to the structural order of the optimized directed acyclic graph; wherein the basic directed acyclic graph is constructed based on the dependency relationship between each transaction, and one transaction corresponds to one transaction node. It can be seen that the present invention realizes intelligent resource scheduling and reuse in the blockchain transaction execution process by innovatively combining the thread / process priority queue structure and the cache management mechanism. On the premise of ensuring the security and consistency of the blockchain system, the overall performance and resource utilization efficiency of the system are significantly improved by optimizing the DAG generation strategy and the transaction execution order. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0019] Figure 1 It is a flow chart of the directed acyclic graph generation and transaction execution method provided by the present invention.
[0020] Figure 2 It is a schematic diagram of thread / process priority score calculation provided by the present invention.
[0021] Figure 3It is a schematic diagram of cache hit score calculation provided by the present invention.
[0022] Figure 4 It is a schematic diagram of priority sorting and slave node weight calculation provided by the present invention.
[0023] Figure 5 It is a structural schematic diagram of the directed acyclic graph generation and transaction execution device provided by the present invention.
[0024] Figure 6 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0025] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0026] Combine the following Figure 1-Figure 6 A directed acyclic graph generation and transaction execution method and device of the present invention are described.
[0027] It should be noted that, at present, mainstream blockchain platforms have the following problems in transaction execution: First, there is a lack of effective reuse mechanism for thread / process resources. The transaction execution of each new block may lead to a large amount of resource reallocation, resulting in unnecessary system overhead. Second, the existing DAG (directed acyclic graph) generation algorithm mainly focuses on the dependencies between transactions and fails to fully consider the resource status of the execution environment, which makes the generated DAG structure may not maximize the use of existing computing resources. In addition, slave nodes usually adopt a fixed scheduling strategy when executing transactions, and fail to dynamically adjust the execution order according to local resource conditions, resulting in inefficient resource utilization. For example, when processing smart contract transactions, if multiple consecutive transactions need to access the same contract code or data, traditional solutions will repeatedly load these resources without making full use of the system cache. Similarly, when multiple transactions need to use similar computing resources, due to the lack of a priority scheduling mechanism, the system cannot effectively arrange the execution order of these transactions, resulting in frequent resource switching. These problems are particularly prominent in high-concurrency scenarios, which seriously restricts the performance improvement of blockchain systems.
[0028] Some studies have attempted to improve system performance by optimizing the order of transaction execution, but most of these solutions focus on the parallelism between transactions and rarely consider the reuse of computing resources. Other solutions have proposed cache-based optimization strategies, but have failed to organically combine resource scheduling with DAG generation, making it difficult to achieve global optimal resource utilization. Based on this, the present invention provides a directed acyclic graph generation and transaction execution method to solve at least one of the above problems.
[0029] Figure 1 It is a flow chart of the directed acyclic graph generation and transaction execution method provided by the present invention, such as Figure 1 As shown, the method includes the following: Step 100: Calculate multiple transactions based on a pre-built priority calculation model to obtain the thread priority and cache hit rate of each transaction in the multiple transactions.
[0030] It should be noted that this embodiment mainly solves the problem of resource reuse in the blockchain during the execution of continuous blocks, reduces thread / process switching overhead through intelligent task scheduling, and improves the overall performance of the system. The core idea is to build priorities based on the following two dimensions: 1. The current state of resources in the thread / process pool; 2. The hit status of the data cache. The key components involved include: thread / process priority queue manager, cache collection manager, DAG generator, and transaction execution scheduler.
[0031] Specifically, in the blockchain system, the priority of transaction execution should comprehensively consider the utilization efficiency of computing resources and storage resources. This embodiment designs a two-dimensional priority calculation model, taking thread / process resource utilization and cache hit rate as two core evaluation dimensions.
[0032] Thread priority evaluation is based on the following considerations: 1. Resource reusability: Give priority to the thread that is currently executing the relevant contract to avoid thread switching overhead.
[0033] 2. Load balancing: Consider the load of each thread in the thread pool to prevent resource imbalance.
[0034] 3. Historical affinity: Consider the historical execution relationship between threads and contracts to establish a stable binding relationship.
[0035] Specifically, thread priority is implemented through the following formula: ThreadPriority(T) = 1 - (ThreadIndex / TotalThreads) Among them, ThreadPriority(T) represents the thread priority of transaction T, ThreadIndex represents the thread index sorted by quantity priority, and TotalThreads represents the total number of threads processing contract transactions.
[0036] It should be noted that thread priority calculation is normalized, so that thread priority can be mapped to the [0,1] interval, which is convenient for weighted calculation with other dimensions. Figure 2 is a schematic diagram of thread / process priority score calculation provided by the present invention, specifically as follows Figure 2 shown.
[0037] Cache hit ratio evaluation is based on the following principles: 1. Data locality: Prioritize transactions with good data locality.
[0038] 2. Cache utilization efficiency: Improve the efficiency of cache resource utilization.
[0039] 3. Access pattern recognition: Identify and exploit data access patterns of transactions.
[0040] Specifically, the cache hit rate is achieved through the following formula: CacheHitRatio(T) = CacheHits(T) / TotalAccesses(T) Among them, CacheHitRatio(T) represents the cache hit ratio of transaction T, CacheHits(T) represents the number of hits when transaction T accesses the cache, and TotalAccesses(T) represents the total number of cache accesses by transaction T.
[0041] It should be noted that the cache hit rate is calculated using a simple ratio. Figure 3 is a schematic diagram of cache hit score calculation provided by the present invention, specifically as follows Figure 3 shown.
[0042] Step 200: Perform a weighted summation on the thread priority and the cache hit rate of each transaction to obtain a comprehensive priority of each transaction.
[0043] Specifically, the comprehensive priority is achieved through the following formula: P(T) = α * ThreadPriority(T) + β * CacheHitRatio(T) Where P(T) represents the comprehensive priority of transaction T, α and β represent weight coefficients, ThreadPriority(T) represents the thread priority of transaction T, and CacheHitRatio(T) represents the cache hit ratio of transaction T.
[0044] It should be noted that the weight coefficients α and β can be selected as follows: 1. System characteristics: Compute-intensive systems may require higher α values.
[0045] 2. Workload characteristics: I / O-intensive workloads may require higher β values.
[0046] 3. Dynamic adjustment: The system can dynamically adjust weights based on real-time monitoring data.
[0047] Furthermore, after calculating the comprehensive priority of each transaction, the method further includes: The ranking weight of each transaction is calculated based on the comprehensive priority of each transaction and the predetermined hierarchical depth of each transaction.
[0048] It should be noted that, after calculating the comprehensive priority of each transaction, this embodiment introduces the concept of hierarchical depth factor. Considerations for introducing hierarchical depth factor: 1. Critical path optimization: Transactions at deeper levels are often on the critical path.
[0049] 2. Parallelism balance: Balance the execution pressure of each layer by adjusting the layer weight.
[0050] 3. Warm-up effect: Transactions executed earlier can warm up the cache, which is beneficial for subsequent transactions.
[0051] Specifically, the sorting weight is implemented by the following formula: W(T) = P(T) * LayerDepth(T) Among them, W(T) represents the sorting weight of transaction T, P(T) represents the comprehensive priority of transaction T, and LayerDepth(T) represents the layer depth of transaction T.
[0052] Step 300: reorder the transaction nodes in the basic directed acyclic graph according to the comprehensive priority of each transaction to obtain an optimized directed acyclic graph, and execute transactions according to the structural order of the optimized directed acyclic graph; wherein the basic directed acyclic graph is constructed based on the dependency relationship between each transaction, and one transaction corresponds to one transaction node.
[0053] This embodiment specifically describes the algorithm design of the master node and the slave node.
[0054] The core goal of the master node DAG generation algorithm is to build a priority-optimized directed acyclic graph.
[0055] The algorithm first builds the basic DAG structure through the BuildBasicDAG function to ensure that the dependencies between transactions are correctly expressed. Then, the system's current thread pool and cache status information are obtained, which will be used for subsequent priority calculations. The key to the algorithm is to evaluate the priority of each transaction node. The evaluation process comprehensively considers the two dimensions of thread affinity and cache hit rate. The priority score based on the thread pool status is calculated through the CalculateThreadPriority function, which reflects the degree of match between the transaction and the thread; at the same time, the cache affinity of the transaction is evaluated through the CalculateCacheHitRatio function, which is quantified by the cache hit situation of statistical access. Finally, the algorithm reorders the transactions of each layer according to the calculated comprehensive priority while maintaining the original dependency relationship, thereby obtaining a DAG structure that satisfies the dependency constraints and optimizes execution efficiency. Figure 4 This is a schematic diagram of priority sorting and slave node weight calculation provided by the present invention, specifically as follows Figure 4 shown.
[0056] The code example is as follows: / / Input: transaction collection transactions / / Output: DAG after optimization and sorting function GenerateOptimizedDAG(transactions): / / Step 1: Build the basic DAG dag = BuildBasicDAG(transactions) / / Step 2: Get thread pool status threadPool = GetThreadPoolStatus() / / Step 3: Get cache status cacheStatus = GetCacheStatus() / / Step 4: Calculate the priority of each transaction foreach transaction in dag.allNodes: threadPriority = CalculateThreadPriority(transaction, threadPool) cacheHitRatio = CalculateCacheHitRatio(transaction, cacheStatus) transaction.priority = α * threadPriority + β * cacheHitRatio / / Step 5: Reorder while maintaining dependencies foreach layer in dag.layers: SortLayerByPriority(layer) return dag / / Thread priority calculation function CalculateThreadPriority(transaction, threadPool): contractAddress = transaction.contractAddress thread = threadPool.findThread(contractAddress) return 1 - (thread.index / threadPool.size) / / Cache hit rate calculation function CalculateCacheHitRatio(transaction, cacheStatus): hits = 0 total = 0 foreach access in transaction.dataAccesses: total++ if cacheStatus.contains(access): hits++ return hits / total The slave node execution algorithm is mainly responsible for efficiently executing transactions in the optimized DAG order. The algorithm uses the priority queue as the core data structure to manage pending transactions through dynamic maintenance and updates.
[0057] First, obtain the local thread pool and cache status information, and add the first-layer nodes of the DAG to the queue according to the locally calculated priority. During the execution process, the algorithm continuously takes out the highest priority transactions from the queue for execution, and updates the local thread pool and cache status in time after the execution is completed. For the transaction that has just been executed, the algorithm will check all its successor nodes. When it is found that all the predecessor dependencies of a successor node have been executed, the local priority of the node will be calculated and added to the priority queue. This execution method based on the priority queue not only ensures the correctness of transaction execution, but also can dynamically adjust the execution order according to the local resource status, thereby optimizing the execution efficiency. The CalculateLocalPriority function plays a key role in this process. It ensures that the execution order can continue to adapt to the actual situation of local resources.
[0058] The code example is as follows: / / Input: sorted DAG / / Output: Execution result function ExecuteDAG(sortedDAG): / / Initialize the priority queue priorityQueue = new PriorityQueue() / / Get the thread pool and cache status of the current node localThreadPool = GetLocalThreadPoolStatus() localCacheStatus = GetLocalCacheStatus() / / Add the first-level nodes to the priority queue foreach transaction in sortedDAG.firstLayer: priority = CalculateLocalPriority(transaction, localThreadPool,localCacheStatus) priorityQueue.push(transaction, priority) / / Execute transactions in the queue while not priorityQueue.isEmpty(): transaction = priorityQueue.pop() / / Execute the transaction ExecuteTransaction(transaction) / / Update the thread pool and cache status UpdateThreadPoolStatus(localThreadPool, transaction) UpdateCacheStatus(localCacheStatus, transaction) / / Add successor nodes to the queue foreach successor in transaction.successors: if AllPredecessorsExecuted(successor): priority = CalculateLocalPriority(successor, localThreadPool,localCacheStatus) priorityQueue.push(successor, priority) / / Local priority calculation function CalculateLocalPriority(transaction, localThreadPool,localCacheStatus): threadPriority = CalculateThreadPriority(transaction,localThreadPool) cacheHitRatio = CalculateCacheHitRatio(transaction, localCacheStatus) return α * threadPriority + β * cacheHitRatio The directed acyclic graph generation and transaction execution method provided in the embodiment of the present invention is dedicated to solving the problem of computing resource scheduling in the process of block generation and transaction verification of the blockchain system, especially for thread / process resource management and cache utilization efficiency during smart contract execution. The embodiment of the present invention realizes intelligent resource scheduling and reuse in the process of blockchain transaction execution by innovatively combining the thread / process priority queue structure and the cache management mechanism. Under the premise of ensuring the security and consistency of the blockchain system, the present invention significantly improves the overall performance and resource utilization efficiency of the system by optimizing the DAG generation strategy and transaction execution order. The present invention is particularly suitable for high-concurrency transaction processing scenarios, such as enterprise-level blockchain platforms, cross-chain transaction systems, decentralized finance (DeFi) applications, and other environments that require efficient processing of a large number of smart contract transactions. In addition, the resource reuse strategy of the present invention is of great significance for improving the computing efficiency of blockchain nodes and reducing resource switching overhead, and provides a new technical path for building a high-performance blockchain system.
[0059] The above is a step description of the directed acyclic graph generation and transaction execution method provided by the present invention. From the description of the above steps, it can be seen that according to the directed acyclic graph generation and transaction execution method provided by the present invention, multiple transactions are calculated based on a pre-built priority calculation model to obtain the thread priority and cache hit rate of each transaction in the multiple transactions; the thread priority and the cache hit rate of each transaction are weighted and summed to obtain the comprehensive priority of each transaction; the transaction nodes in the basic directed acyclic graph are reordered according to the comprehensive priority of each transaction to obtain an optimized directed acyclic graph, and the transaction is executed in the structural order of the optimized directed acyclic graph; wherein the basic directed acyclic graph is: constructed based on the dependency relationship between each transaction, and one transaction corresponds to one transaction node. It can be seen from this that the present invention realizes intelligent resource scheduling and reuse in the execution process of blockchain transactions by innovatively combining the thread / process priority queue structure and the cache management mechanism. Under the premise of ensuring the security and consistency of the blockchain system, the overall performance and resource utilization efficiency of the system are significantly improved by optimizing the DAG generation strategy and the transaction execution order.
[0060] The directed acyclic graph generation and transaction execution device provided by the present invention is described below. The directed acyclic graph generation and transaction execution device described below and the directed acyclic graph generation and transaction execution method described above can be referenced to each other.
[0061] Figure 5 is a schematic diagram of the structure of the directed acyclic graph generation and transaction execution device provided by the present invention, such as Figure 5 As shown, the directed acyclic graph generation and transaction execution device provided by the present invention includes: A first calculation module 501 is used to calculate multiple transactions based on a pre-built priority calculation model to obtain a thread priority and a cache hit rate of each transaction in the multiple transactions; A second calculation module 502, configured to perform a weighted summation of the thread priority and the cache hit rate of each transaction to obtain a comprehensive priority of each transaction; The generation and execution module 503 is used to reorder the transaction nodes in the basic directed acyclic graph according to the comprehensive priority of each transaction to obtain an optimized directed acyclic graph, and execute transactions according to the structural order of the optimized directed acyclic graph; wherein the basic directed acyclic graph is constructed based on the dependency relationship between each transaction, and one transaction corresponds to one transaction node.
[0062] The directed acyclic graph generation and transaction execution device provided by the present invention calculates multiple transactions based on a pre-built priority calculation model to obtain the thread priority and cache hit rate of each transaction in the multiple transactions; performs weighted summation on the thread priority and cache hit rate of each transaction to obtain the comprehensive priority of each transaction; reorders the transaction nodes in the basic directed acyclic graph according to the comprehensive priority of each transaction to obtain an optimized directed acyclic graph, and executes transactions according to the structural order of the optimized directed acyclic graph; wherein the basic directed acyclic graph is constructed based on the dependency relationship between each transaction, and one transaction corresponds to one transaction node. It can be seen from this that the present invention realizes intelligent resource scheduling and reuse in the blockchain transaction execution process by innovatively combining the thread / process priority queue structure and the cache management mechanism. On the premise of ensuring the security and consistency of the blockchain system, the overall performance and resource utilization efficiency of the system are significantly improved by optimizing the DAG generation strategy and the transaction execution order.
[0063] Based on the above embodiment, in this embodiment, the first calculation module 501 is implemented by the following formula: ThreadPriority(T) = 1 - (ThreadIndex / TotalThreads) Among them, ThreadPriority(T) represents the thread priority of transaction T, ThreadIndex represents the thread index sorted by quantity priority, and TotalThreads represents the total number of threads processing contract transactions.
[0064] Based on the above embodiment, in this embodiment, the first calculation module 501 is implemented by the following formula: CacheHitRatio(T) = CacheHits(T) / TotalAccesses(T) Among them, CacheHitRatio(T) represents the cache hit ratio of transaction T, CacheHits(T) represents the number of hits when transaction T accesses the cache, and TotalAccesses(T) represents the total number of cache accesses by transaction T.
[0065] Based on the above embodiment, in this embodiment, the second calculation module 502 is implemented by the following formula: P(T) = α * ThreadPriority(T) + β * CacheHitRatio(T) Where P(T) represents the comprehensive priority of transaction T, α and β represent weight coefficients, ThreadPriority(T) represents the thread priority of transaction T, and CacheHitRatio(T) represents the cache hit ratio of transaction T.
[0066] Based on the above embodiment, in this embodiment, the device further includes a third calculation module, which is specifically used to: Before reordering the transaction nodes in the basic directed acyclic graph according to the comprehensive priority of each transaction to obtain the optimized directed acyclic graph, the sorting weight of each transaction is calculated according to the comprehensive priority of each transaction and the predetermined hierarchical depth of each transaction; The generation and execution module 503 is specifically used for: The transaction nodes in the basic directed acyclic graph are reordered according to the sorting weight of each transaction to obtain an optimized directed acyclic graph.
[0067] Based on the above embodiment, in this embodiment, the third calculation module is implemented by the following formula: W(T) = P(T) * LayerDepth(T) Among them, W(T) represents the sorting weight of transaction T, P(T) represents the comprehensive priority of transaction T, and LayerDepth(T) represents the layer depth of transaction T.
[0068] Based on the above embodiment, in this embodiment, the device further includes an updating module, which is specifically used to: After executing the transactions in the structural order of the optimized directed acyclic graph, the local thread pool and cache status are updated according to the transaction execution status, so as to dynamically adjust the execution order of the transactions based on the updated thread pool and cache status.
[0069] Figure 6An example of a physical structure diagram of an electronic device is shown in FIG. Figure 6 As shown, the electronic device may be a robot or other electronic device, and the electronic device may include: a processor 610, a communications interface 620, a memory 630, and a communication bus 640, wherein the processor 610, the communications interface 620, and the memory 630 communicate with each other through the communication bus 640. The processor 610 may call the logic instructions in the memory 630 to execute the directed acyclic graph generation and transaction execution method, including: Calculating multiple transactions based on a pre-built priority calculation model to obtain a thread priority and a cache hit rate of each of the multiple transactions; Performing a weighted summation on the thread priority and the cache hit rate of each transaction to obtain a comprehensive priority of each transaction; The transaction nodes in the basic directed acyclic graph are reordered according to the comprehensive priority of each transaction to obtain an optimized directed acyclic graph, and the transactions are executed according to the structural order of the optimized directed acyclic graph; wherein the basic directed acyclic graph is constructed based on the dependency relationship between each transaction, and one transaction corresponds to one transaction node.
[0070] In addition, the logic instructions in the above-mentioned memory 630 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.
[0071] On the other hand, the present invention further provides a computer program product, the computer program product includes a computer program, the computer program can be stored in a non-transitory computer-readable storage medium, when the computer program is executed by a processor, the computer can execute the directed acyclic graph generation and transaction execution method provided by the above methods, including: Calculating multiple transactions based on a pre-built priority calculation model to obtain a thread priority and a cache hit rate of each of the multiple transactions; Performing a weighted summation on the thread priority and the cache hit rate of each transaction to obtain a comprehensive priority of each transaction; The transaction nodes in the basic directed acyclic graph are reordered according to the comprehensive priority of each transaction to obtain an optimized directed acyclic graph, and the transactions are executed according to the structural order of the optimized directed acyclic graph; wherein the basic directed acyclic graph is constructed based on the dependency relationship between each transaction, and one transaction corresponds to one transaction node.
[0072] In another aspect, the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, which is implemented when the computer program is executed by a processor to execute the directed acyclic graph generation and transaction execution method provided by the above methods, including: Calculating multiple transactions based on a pre-built priority calculation model to obtain a thread priority and a cache hit rate of each of the multiple transactions; Performing a weighted summation on the thread priority and the cache hit rate of each transaction to obtain a comprehensive priority of each transaction; The transaction nodes in the basic directed acyclic graph are reordered according to the comprehensive priority of each transaction to obtain an optimized directed acyclic graph, and the transactions are executed according to the structural order of the optimized directed acyclic graph; wherein the basic directed acyclic graph is constructed based on the dependency relationship between each transaction, and one transaction corresponds to one transaction node.
[0073] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0074] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0075] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A directed acyclic graph generation and transaction execution method, characterized in that: include: Calculating multiple transactions based on a pre-built priority calculation model to obtain a thread priority and a cache hit rate of each of the multiple transactions; Performing a weighted summation on the thread priority and the cache hit rate of each transaction to obtain a comprehensive priority of each transaction; The transaction nodes in the basic directed acyclic graph are reordered according to the comprehensive priority of each transaction to obtain an optimized directed acyclic graph, and the transactions are executed according to the structural order of the optimized directed acyclic graph; wherein the basic directed acyclic graph is constructed based on the dependency relationship between each transaction, and one transaction corresponds to one transaction node.
2. The directed acyclic graph generation and transaction execution method according to claim 1, characterized in that: The calculation of multiple transactions based on the pre-built priority calculation model to obtain the thread priority of each transaction in the multiple transactions is implemented by the following formula: ThreadPriority(T) = 1 - (ThreadIndex / TotalThreads) Among them, ThreadPriority(T) represents the thread priority of transaction T, ThreadIndex represents the thread index sorted by quantity priority, and TotalThreads represents the total number of threads processing contract transactions.
3. The directed acyclic graph generation and transaction execution method according to claim 1, characterized in that: The cache hit rate of each transaction in the plurality of transactions is obtained by calculating the plurality of transactions based on the pre-built priority calculation model, which is implemented by the following formula: CacheHitRatio(T) = CacheHits(T) / TotalAccesses(T) Among them, CacheHitRatio(T) represents the cache hit ratio of transaction T, CacheHits(T) represents the number of hits when transaction T accesses the cache, and TotalAccesses(T) represents the total number of cache accesses by transaction T.
4. The directed acyclic graph generation and transaction execution method according to claim 3, characterized in that: The thread priority and cache hit rate of each transaction are weighted and summed to obtain the comprehensive priority of each transaction, which is achieved by the following formula: P(T) = α * ThreadPriority(T) + β * CacheHitRatio(T) Where P(T) represents the comprehensive priority of transaction T, α and β represent weight coefficients, ThreadPriority(T) represents the thread priority of transaction T, and CacheHitRatio(T) represents the cache hit ratio of transaction T.
5. The directed acyclic graph generation and transaction execution method according to claim 1, characterized in that: Before reordering the transaction nodes in the basic directed acyclic graph according to the comprehensive priority of each transaction to obtain the optimized directed acyclic graph, the method further includes: Calculate the ranking weight of each transaction according to the comprehensive priority of each transaction and the predetermined hierarchical depth of each transaction; The step of reordering the transaction nodes in the basic directed acyclic graph according to the comprehensive priority of each transaction to obtain an optimized directed acyclic graph includes: The transaction nodes in the basic directed acyclic graph are reordered according to the sorting weight of each transaction to obtain an optimized directed acyclic graph.
6. The directed acyclic graph generation and transaction execution method according to claim 5, characterized in that: The ranking weight of each transaction is calculated based on the comprehensive priority of each transaction and the predetermined hierarchical depth of each transaction, which is implemented by the following formula: W(T) = P(T) * LayerDepth(T) Among them, W(T) represents the sorting weight of transaction T, P(T) represents the comprehensive priority of transaction T, and LayerDepth(T) represents the layer depth of transaction T.
7. The directed acyclic graph generation and transaction execution method according to claim 1, characterized in that: After executing the transaction in the structure order of the optimized directed acyclic graph, the method further includes: The local thread pool and cache status are updated according to the transaction execution status, so as to dynamically adjust the execution order of the transactions based on the updated thread pool and cache status.
8. A directed acyclic graph generation and transaction execution device, characterized in that: include: A first calculation module, configured to calculate a plurality of transactions based on a pre-built priority calculation model to obtain a thread priority and a cache hit rate of each of the plurality of transactions; A second calculation module, configured to perform a weighted summation of the thread priority and the cache hit rate of each transaction to obtain a comprehensive priority of each transaction; A generation and execution module is used to reorder the transaction nodes in the basic directed acyclic graph according to the comprehensive priority of each transaction to obtain an optimized directed acyclic graph, and execute transactions according to the structural order of the optimized directed acyclic graph; wherein the basic directed acyclic graph is constructed based on the dependency relationship between each transaction, and one transaction corresponds to one transaction node.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the directed acyclic graph generation and transaction execution method as described in any one of claims 1 to 7 is implemented.
10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the directed acyclic graph generation and transaction execution method as described in any one of claims 1 to 7 is implemented.