A binary-set-based program dependence cluster detection method

By using binary sets and bitwise operations, the time and space efficiency issues in large program dependency cluster detection are solved, achieving efficient program dependency cluster detection and caching, reducing analysis overhead, and improving detection accuracy and efficiency.

CN115185818BActive Publication Date: 2026-05-05NANJING UNIV OF POSTS & TELECOMM
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
NANJING UNIV OF POSTS & TELECOMM
Filing Date
2022-06-20
Publication Date
2026-05-05

AI Technical Summary

Technical Problem

Existing methods for detecting program dependency clusters suffer from time and space efficiency bottlenecks in large programs. In particular, the construction process based on the System Dependency Graph (SDG) is complex and time-consuming, making it impossible to meet the needs of dependency cluster detection and analysis in large programs.

Method used

The dependency set data structure is defined in binary set form, and dependency relationships are calculated through the general set operation interface of bitwise operations. The native basic data type Integer of Haskell language is used for data processing and serialization. The MapReduce concept is combined for distributed computing to realize the correction and caching of dependency analysis results.

Benefits of technology

It significantly reduces the time and space overhead of program dependency cluster detection, improves analysis efficiency, can correctly detect program dependency clusters, and is easy to serialize and deserialize, reducing network load and the complexity of distributed computing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115185818B_ABST
    Figure CN115185818B_ABST
Patent Text Reader

Abstract

The application discloses a kind of program dependence cluster detection methods based on binary set, method is: with binary set form data structure definition dependent set, and input general set operation interface based on bit operation, obtain new dependent set data storage to each instruction node of general set operation interface program, and traverse each instruction node of program;Dependency relationship between instructions is calculated using general set operation interface, and dependency analysis data of each instruction node is obtained;According to the set content in the new set data, the dependency analysis results obtained are reorganized and classified, and the corrected dependency analysis results are obtained to correctly detect the program dependence cluster in program source code.The application defines set data structure with binary set, defines operation interface according to data structure, calculates dependence by calling interface, corrects dependence result, saves the correction result, thereby significantly reduces the space overhead problem during analysis.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of program analysis, specifically relating to a program dependency cluster detection method based on binary sets. Background Technology

[0002] As software scales up, the difficulty of software maintenance also increases. One important reason is the unavoidable interdependencies between software components. These interdependencies form program dependency clusters, and correctly detecting the widespread dependency clusters in a program is of great significance for software understanding, testing, and maintenance.

[0003] Currently, domestic and international research focuses on analyzing the causes of program dependency clusters, without further research on how to improve program dependency cluster detection methods. Traditional dependency cluster detection algorithms rely on System Dependency Graphs (SDGs), which are graphical representations of control and data dependencies between software programs. Edges represent dependencies, and a node's unique identifier (Id) represents an element of the dependency set. During detection, a graph reachability traversal algorithm is used to collect dependencies for each node. Finally, the dependency analysis results of all nodes are integrated to obtain slicing criteria with the same dependency set. This means that the nodes corresponding to these criteria are mutually dependent, thus detecting a dependency cluster in the program. However, the SDG construction process is complex and difficult to understand, especially when analyzing inter-process dependencies. The construction process needs to consider different parameter passing scenarios, often resulting in significant time overhead. Furthermore, using the unique identifier of an SDG node to correspond to an element of the dependency set is particularly problematic for large programs with many SDG nodes, leading to significant space consumption issues. Therefore, SDG-based dependency cluster detection methods cannot meet the time and space efficiency requirements for dependency cluster detection and analysis in large programs. Summary of the Invention

[0004] Purpose of the invention: In order to overcome the shortcomings of the prior art, the present invention provides a program dependency cluster detection method based on binary sets. The binary set defines the set data structure, and the operation interface is defined according to the data structure. The interface is called to calculate the dependency, the dependency result is corrected, and the correction result is saved, thereby significantly reducing the space overhead during analysis and solving the problem of excessive time and space overhead under traditional detection methods.

[0005] Technical Solution: Firstly, this invention provides a method for detecting program dependency clusters based on binary sets, comprising:

[0006] Dependency sets are defined using a binary set data structure, and the binary set data is input into a general set operation interface based on bitwise operations to obtain new dependency set data.

[0007] The new dependency set data is stored in each instruction node of the general set operation interface program, and each instruction node of the program is traversed; during the traversal, the dependency relationship between instructions is calculated using the general set operation interface to obtain the dependency analysis data of each instruction node.

[0008] After all instruction nodes have been traversed, the obtained dependency analysis results are reorganized and classified according to the contents of the new set data to obtain the corrected dependency analysis results.

[0009] Based on the corrected dependency analysis results, the program dependency clusters in the program source code can be correctly detected.

[0010] In a further embodiment, the data structure is in binary form, the smallest unit of the data structure is a bit, and it is represented by an extended integer method, thereby replacing the traditional 0-64 bit integer representation. The extended integer method of the data structure is as follows:

[0011] By using the Integer primitive data type from the functional programming language Haskell to perform bitwise operations and serialization on the data structure, the storage length of the data structure can be extended indefinitely.

[0012] In a further embodiment, the basic representation method of the dependent set data is as follows: 0 represents the empty set, and an integer binary string represents the non-empty set. In the case of a non-empty set, the element storage status of the dependent set data is determined based on whether the binary string is 0 or 1.

[0013] In a further embodiment, inputting the dependency set data in binary set form into a general set operation interface based on bit operations to obtain new dependency set data also includes predefining a general set operation interface;

[0014] The method for defining the general collection operation interface is as follows:

[0015] Input the element value associated with the operation interface and determine whether the element value belongs to the general set of the operation interface;

[0016] Based on the judgment result, select to add an element value with no belonging relationship to the general set of the operation interface, thereby merging the general set before and after the judgment. The merged general set does not contain duplicate element values. Finally, define the operation interface associated with the new element value as the general set operation interface.

[0017] In a further embodiment, the general set operation interface processes the input dependent set data based on bitwise operations. The bitwise operations have multiple operation categories, including: AND (&), OR (|), right shift (>>), and left shift (<<).

[0018] In a further embodiment, each instruction node of the program is traversed; wherein, during traversal, the dependency relationships between instructions are calculated using a general set operation interface to obtain dependency analysis data for each instruction node, as follows:

[0019] The dependency set data utilizes a general set operation interface to calculate the program dependency data of the relevant dependency set data under each instruction node, thereby obtaining the dependency analysis data of each instruction node; among which, the dependency includes data dependency between instructions due to the definition and use of variables, and control dependency between instructions due to jump relationships;

[0020] The dependency analysis data for each instruction node is stored as key-value pairs. The unique identifier of each instruction is used as the index key, and the binary-stored dependency set data is used as the index value.

[0021] In a further embodiment, the method for reorganizing and classifying the stored dependency analysis results to obtain the corrected dependency analysis results is as follows:

[0022] When extracting the data stream values ​​of each instruction node and performing dependency analysis, the results are indexed using key-value pairs to query the dependency set corresponding to each instruction node.

[0023] Remap the key-value pairs associated with the query dependency set to obtain the remapped key-value pairs;

[0024] Based on the remapped key-value pair relationship, the index is re-indexed, key-value pairs with the same index key are extracted and merged, and the recombined and merged key-value pair relationship is obtained, thus completing the correction of the dependency analysis results.

[0025] The corrected dependency analysis results serve as the standard for detecting whether the program dependency clusters in the source code of the analysis program are correct.

[0026] In a further embodiment, a method for persistently caching data based on cluster detection results is described:

[0027] By leveraging the native serialization methods supported by the Haskell language, integer data can be quickly stored on local hard drives and in distributed databases. During the storage process, Python algorithms are used for caching, and the native integer serialization methods are simply called during the caching process.

[0028] In a further embodiment, the method for correctly detecting program dependency clusters in the program source code based on the corrected dependency analysis results is as follows:

[0029] The results of program dependency cluster detection are persistently cached so that when the same program is analyzed later, the dependency analysis results can be loaded directly.

[0030] When program dependency cluster analysis begins, it loads the historical dependency analysis results that have been cached on the local hard drive and in the distributed database.

[0031] After the program dependency cluster analysis is completed, the complete dependency cluster analysis results are saved repeatedly for subsequent on-demand loading and access.

[0032] Beneficial effects: Compared with the prior art, the present invention has the following advantages:

[0033] (1) Binary set representation has significant advantages in both time efficiency and space usage. At the same time, compared with common set compression methods such as binary decision graphs, its bitwise operations between sets have lower time complexity. In addition, this representation is easier to serialize and deserialize, which is conducive to caching and reloading intermediate calculation results. Binary sets define set data structures, define operation interfaces based on data structures, call interfaces to calculate dependencies, and correct dependency results, thereby significantly reducing the space overhead of analysis.

[0034] (2) Compared with the method of constructing a large system dependency graph and using the graph reachability traversal algorithm to detect program dependency clusters, the present invention uses bit operations to instantiate a series of set operations in binary representation to merge control dependencies and data dependencies. This not only can correctly detect program dependency clusters, but also greatly reduces the time and space overhead of analysis. Attached Figure Description

[0035] Figure 2 This invention relates to a program dependency cluster detection method based on binary sets.

[0036] Figure 1 illustrates the process of caching and loading program dependency clusters according to the present invention. Detailed Implementation

[0037] To better understand the technical content of the present invention, the technical solution of the present invention will be further introduced and explained below with reference to specific embodiments, but is not limited thereto.

[0038] like Figure 1 The method for detecting program dependency clusters based on binary sets, as shown, includes:

[0039] Dependency sets are defined using a binary set data structure, and the binary set data is input into a general set operation interface based on bitwise operations to obtain new dependency set data.

[0040] The new dependency set data is stored in each instruction node of the general set operation interface program, and each instruction node of the program is traversed; during the traversal, the dependency relationship between instructions is calculated using the general set operation interface to obtain the dependency analysis data of each instruction node.

[0041] After all instruction nodes have been traversed, the obtained dependency analysis results are reorganized and classified according to the contents of the new set data to obtain the corrected dependency analysis results.

[0042] Based on the corrected dependency analysis results, the program dependency clusters in the program source code can be correctly detected.

[0043] The data structure is in binary form, with the smallest unit being a bit. It uses an extended integer method for integer representation, replacing the traditional 0-64 bit integer representation. The extended integer method for the data structure is as follows:

[0044] By using the Integer primitive data type from the functional programming language Haskell to perform bitwise operations and serialization on the data structure, the storage length of the data structure can be extended indefinitely.

[0045] The basic representation of dependent set data is as follows: use 0 to represent the empty set and use an integer binary string to represent the non-empty set. In the case of a non-empty set, the storage status of the elements of the dependent set data is determined by whether the binary string is 0 or 1.

[0046] Inputting dependency set data in binary set form into a general set operation interface based on bitwise operations to obtain new dependency set data also includes predefined general set operation interfaces;

[0047] The method for defining the general collection operation interface is as follows:

[0048] Input the element value associated with the operation interface and determine whether the element value belongs to the general set of the operation interface;

[0049] Based on the judgment result, select to add an element value with no belonging relationship to the general set of the operation interface, thereby merging the general set before and after the judgment. The merged general set does not contain duplicate element values. Finally, define the operation interface associated with the new element value as the general set operation interface.

[0050] The general set operation interface is based on bitwise operations to process the input dependent set data. Bitwise operations have multiple operation categories, including: AND (&), OR (|), right shift (>>), and left shift (<<).

[0051] The main idea of ​​binary set representation is to use bits 0 or 1 to represent whether the corresponding position number belongs to the element in the set. Since the range of the corresponding unique identifier (integer) of each variable in the source code is determined, any binary representation of the dependent set is a subset of a universal set A, which is represented by a binary integer of all 1s.

[0052] For example, A = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], its binary representation is 1111111111. This representation uses the native basic data type Integer in Haskell, which supports integer data of unlimited length.

[0053] Let A1 = [2, 4, 6] and A2 = [1, 3, 5] be two subsets of A. Based on the idea of ​​representing a set of numbers with 0 / 1, we can obtain the binary representation of A1 as 0001010100 and the binary representation of A2 as 0000101010. It should be noted that the insertion order of elements is from right to left, and the index starts from 0. For example, the number 1 in the 0th position from right to left represents the number 0.

[0054] A1 È A2 can be obtained by bitwise AND operation: 0001010100 | 0000101010 = 0001111110, which corresponds to the set representation [1, 2, 3, 4, 5, 6], which is consistent with the expected result of merging the two sets.

[0055] Adding element 3 to A1 can be achieved by using a bitwise AND operation to obtain 0001010100 | 0000001000 = 0001011100, which corresponds to the set [2, 3, 4, 6], consistent with the expected result after adding element 3 to A1.

[0056] The program iterates through each instruction node; during this iteration, it uses a general set operation interface to calculate the dependencies between instructions, obtaining the dependency analysis data for each instruction node as follows:

[0057] The dependency set data utilizes a general set operation interface to calculate the program dependency data of the relevant dependency set data under each instruction node, thereby obtaining the dependency analysis data of each instruction node; among which, the dependency includes data dependency between instructions due to the definition and use of variables, and control dependency between instructions due to jump relationships;

[0058] The dependency analysis data for each instruction node is stored as key-value pairs. The unique identifier of each instruction is used as the index key, and the binary-stored dependency set data is used as the index value.

[0059] The method for reorganizing and classifying the stored dependency analysis results to obtain the corrected dependency analysis results is as follows:

[0060] When extracting the data stream values ​​of each instruction node and performing dependency analysis, the results are indexed using key-value pairs to query the dependency set corresponding to each instruction node.

[0061] Remap the key-value pairs associated with the query dependency set to obtain the remapped key-value pairs;

[0062] Based on the remapped key-value pair relationship, the index is re-indexed, key-value pairs with the same index key are extracted and merged, and the recombined and merged key-value pair relationship is obtained, thus completing the correction of the dependency analysis results.

[0063] The corrected dependency analysis results serve as the standard for detecting whether the program dependency clusters in the source code of the analysis program are correct.

[0064] Specifically, to address the problem of insufficient computing power in large-scale program dependency cluster detection and analysis tasks, an open-source cloud computing framework can be used to perform MapReduce on a distributed computing cluster. This "mapping-reduction" approach remaps the key-value pairs <slicing criteria, <unique variable identifier (integer), dependency set> in step 4.1 to obtain new key-value pairs: <dependency set, slicing criteria>. Simultaneously, reduction (the Reduce process) is performed so that slicing criteria with the same slicing results can be clustered, thereby enabling the detection of program dependency clusters.

[0065] At the same time, because the dependency set uses a binary set representation, the intermediate results obtained in the MapReduce process are easier to transmit between nodes, reducing network load. Using a single integer as the key also speeds up the internal sorting and comparison process, improving the efficiency of distributed computing.

[0066] Methods for persistently caching cluster detection results:

[0067] By leveraging the native serialization methods supported by the Haskell language, integer data can be quickly stored on local hard drives and in distributed databases. During the storage process, Python algorithms are used for caching, and the native integer serialization methods are simply called during the caching process.

[0068] Based on the corrected dependency analysis results, the method for correctly detecting program dependency clusters in the program source code is as follows:

[0069] The results of program dependency cluster detection are persistently cached so that when the same program is analyzed later, the dependency analysis results can be loaded directly.

[0070] When program dependency cluster analysis begins, it loads the historical dependency analysis results that have been cached on the local hard drive and in the distributed database.

[0071] After the program dependency cluster analysis is completed, the complete dependency cluster analysis results are saved repeatedly for subsequent on-demand loading and access.

[0072] Specifically, caching is the process of converting dependency cluster information that is not currently needed for computation into a form that can be stored or transmitted, based on the analysis requirements. The loading process, on the other hand, involves reading dependency cluster information from storage to continue analysis. This process can utilize networked transmission or local storage for corresponding operations, such as using a local database, a master-slave database in a distributed environment, or NAS (Network Attached Storage).

[0073] The binary set representation of this invention has significant advantages in both time efficiency and space consumption. Furthermore, compared to common set compression methods such as binary decision graphs, its bitwise-based inter-set operations have lower time complexity. This representation is also easier to serialize and deserialize, facilitating the caching and reloading of intermediate computation results. The binary set defines the set data structure, defines operation interfaces based on the data structure, calls these interfaces to calculate dependencies, and corrects the dependency results, thereby significantly reducing the space overhead of the analysis.

[0074] Secondly, compared to constructing a large system dependency graph and using graph reachability traversal algorithms to detect program dependency clusters, this invention, in binary representation, uses bitwise operations to instantiate a series of set operations to merge control dependencies and data dependencies. This not only correctly detects program dependency clusters but also greatly reduces the time and space overhead of analysis.

[0075] Embodiments of this application may be provided as methods, systems, or computer program products. Therefore, this application may take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0076] Embodiments of this application may be provided as methods, systems, or computer program products. Therefore, this application may take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0077] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0078] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0079] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0080] The above description is only a preferred embodiment of the present invention. Without departing from the technical principle of the present invention, several improvements and modifications can be made, and these improvements and modifications should also be considered within the scope of protection of the present invention.

Claims

1. A method for detecting program dependency clusters based on binary sets, characterized in that, include: Dependency sets are defined using a binary set data structure, and the binary set data is input into a general set operation interface based on bitwise operations to obtain new dependency set data. The new dependency collection data is stored in the various instruction nodes of the general collection operation interface program, and each instruction node of the program is traversed. During the traversal, the dependency relationship between instructions is calculated using the general set operation interface to obtain the dependency analysis data of each instruction node. After all instruction nodes have been traversed, the obtained dependency analysis results are reorganized and classified according to the contents of the new set data to obtain the corrected dependency analysis results. Based on the corrected dependency analysis results, the program dependency clusters in the program source code can be correctly detected. Iterate through each instruction node of the program; During traversal, the method for calculating the dependencies between instructions using a general set operation interface to obtain dependency analysis data for each instruction node is as follows: The dependency set data utilizes a general set operation interface to calculate the program dependency data of the relevant dependency set data under each instruction node, thereby obtaining the dependency analysis data of each instruction node; among which, the dependency includes data dependency between instructions due to the definition and use of variables, and control dependency between instructions due to jump relationships; The dependency analysis data of each instruction node is stored as key-value pairs. The unique identifier of each instruction is used as the index key, and the binary-stored dependency set data is used as the index value. The method for reorganizing and classifying the stored dependency analysis results to obtain the corrected dependency analysis results is as follows: When extracting the data stream values ​​of each instruction node and performing dependency analysis, the results are indexed using key-value pairs to query the dependency set corresponding to each instruction node. Remap the key-value pairs associated with the query dependency set to obtain the remapped key-value pairs; Based on the remapped key-value pair relationship, the index is re-indexed, key-value pairs with the same index key are extracted and merged, and the recombined and merged key-value pair relationship is obtained, thus completing the correction of the dependency analysis results. The corrected dependency analysis results serve as the standard for detecting whether the program dependency clusters in the source code of the analysis program are correct.

2. The method for detecting program dependency clusters based on binary sets according to claim 1, characterized in that, The data structure is in binary form, with its smallest unit being a bit. It employs an extended integer method for integer representation, replacing the traditional 0-64 bit integer representation. The extended integer method for this data structure is as follows: By using the Integer primitive data type from the functional programming language Haskell to perform bitwise operations and serialization on the data structure, the storage length of the data structure can be extended indefinitely.

3. The method for detecting program dependency clusters based on binary sets according to claim 1, characterized in that, The basic representation of dependent set data is as follows: use 0 to represent the empty set and use an integer binary string to represent the non-empty set. In the case of a non-empty set, the storage status of the elements of the dependent set data is determined by whether the binary string is 0 or 1.

4. The method for detecting program dependency clusters based on binary sets according to claim 1, characterized in that, Inputting dependency set data in binary set form into a general set operation interface based on bitwise operations to obtain new dependency set data also includes predefined general set operation interfaces; The method for defining the general collection operation interface is as follows: Input the element value associated with the operation interface and determine whether the element value belongs to the general set of the operation interface; Based on the judgment result, select to add an element value with no belonging relationship to the general set of the operation interface, thereby merging the general set before and after the judgment. The merged general set does not contain duplicate element values. Finally, define the operation interface associated with the new element value as the general set operation interface.

5. The method for detecting program dependency clusters based on binary sets according to claim 1, characterized in that, The general set operation interface is based on bitwise operations to process the input dependent set data. The bitwise operations have multiple operation categories, including: AND, OR, right shift, and left shift.

6. The method for detecting program dependency clusters based on binary sets according to claim 1, characterized in that, Methods for persistently caching cluster detection results: By leveraging the native serialization methods supported by the Haskell language, integer data can be quickly stored on local hard drives and in distributed databases. During the storage process, Python algorithms are used for caching, and the native integer serialization methods are simply called during the caching process.

7. The method for detecting program dependency clusters based on binary sets according to claim 1, characterized in that, Based on the corrected dependency analysis results, the method for correctly detecting program dependency clusters in the program source code is as follows: The results of program dependency cluster detection are persistently cached so that when the same program is analyzed later, the dependency analysis results can be loaded directly. When program dependency cluster analysis begins, it loads the historical dependency analysis results that have been cached on the local hard drive and in the distributed database. After the program dependency cluster analysis is completed, the complete dependency cluster analysis results are saved repeatedly for subsequent on-demand loading and access.

Citation Information

Patent Citations

  • Program dependence relationship analysis method and system based on tree optimization

    CN103793653A

  • Software local plagiarism detection method based on dynamic instruction dependency graph birthmark

    CN108399321A