State transition method and device

By identifying hot regions in the DFA and constructing a fast state transition table, high-speed parallel jumps are achieved using vector instructions, and black hole state detection escape is introduced, thus solving the problem of low access efficiency of the DFA state transition table and realizing high-performance state jumps.

CN121636767APending Publication Date: 2026-03-10HUAWEI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-10
Publication Date
2026-03-10

AI Technical Summary

Technical Problem

In existing technologies, the access efficiency of the state transition table in DFA is low, resulting in low efficiency of table lookup and jump operations, especially when using L3 cache or external storage.

Method used

By identifying the hot regions of the state machine, a fast state transition table is constructed, high-speed parallel state transitions are performed using vector instructions, and a black hole state is introduced to detect escape transitions. A complete transition is performed by combining the full state transition table, and a two-level table structure is adopted to improve transition performance.

Benefits of technology

It achieves high-performance state transitions within hot zones, improves the state transition performance of DFA, ensures the accuracy and efficiency of transitions, and adapts to business scenarios with a large number of states.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121636767A_ABST
    Figure CN121636767A_ABST
Patent Text Reader

Abstract

The invention provides a state transition method and device, and belongs to the technical field of computers.The method comprises the steps that a hot area of a state machine is determined, the hot area comprises a plurality of states, the number of the states in the hot area is smaller than or equal to a first threshold value, and the probability that the states in the hot area jump out of the hot area is smaller than or equal to a second threshold value; and constructing a fast state transition table of the hot area, wherein each row of the fast state transition table is used for indicating the state jump in the hot area under one input. According to the invention, high-performance state jump in the hot area can be realized, and the state jump performance of the state machine is improved. The method is used for state transition of the state machine.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computers, and in particular to a state transition method and device. BACKGROUND

[0002] Deterministic finite automaton (DFA) can intuitively and quickly run through table lookup (state transition table) jumping, and has wide application in many fields. For example, it can be applied to firewall, intrusion detection and defense, deep packet inspection and other rule matching based scenarios, and scenarios requiring lexical analysis in artificial intelligence (AI) preprocessing.

[0003] In the related art, the state transition table of DFA is a two-dimensional table located in cache or memory. Each row represents the jump of a state of DFA under all inputs, and the number of rows is equal to the number of states. After receiving an input, the next jump state of the current state under the input is determined by querying the state transition table, and the determined next jump state is jumped to.

[0004] However, the running performance of table lookup jumping is limited by the access efficiency of the state transition table. The number of states of the state transition table is usually large, resulting in low running efficiency of table lookup jumping. Moreover, when the state transition table is located in L3 cache or external storage, the running efficiency of table lookup jumping will be further reduced. SUMMARY

[0005] The present application provides a state transition method and device, which solves the problem of low running efficiency of table lookup jumping limited by the access efficiency of the state transition table in the related art, and can realize high-performance state jumping in the hot area and improve the state jumping performance of DFA.

[0006] In a first aspect, the present application provides a state transition method, which includes: determining a hot area of a state machine, the hot area including a plurality of states, the number of states in the hot area being less than or equal to a first threshold, and the probability of a state in the hot area jumping out of the hot area being less than or equal to a second threshold; and constructing a fast state transition table of the hot area, each row of the fast state transition table being used to indicate the jump of a state in the hot area under an input.

[0007] The hot zone can be regarded as a set of states in all states of the state machine, i.e., the hot zone includes multiple states. The number of states less than or equal to the first threshold value indicates that the number of states of the hot zone is small, and the state jump can be performed by using the instruction when the number of bytes of the vector and the instruction operation supported by the processor is less than or equal to the number of bytes. In addition, the row of the fast state transition table represents the input, and the column represents the state. The instruction reads the operand in the column, and the form of the fast state transition table can make the operand read by the vector in the column continuous, facilitating the instruction operation.

[0008] The number of states in the hot zone needs to be less than or equal to the number of bytes of the vector and the instruction operation supported by the processor, so as to ensure the normal operation of the vector instruction. Therefore, the jump operation can be performed by using the vector instruction. The probability of jumping out of the hot zone is less than or equal to the second threshold value, which indicates that the hot zone is not easy to jump out. These characteristics make the majority of state jump processes of the DFA in the hot zone.

[0009] The fast state transition table can be located in a cache (for example, an L1 cache) or a register.

[0010] The beneficial effect is that for the state jump in the hot zone, the fast and parallel state jump can be performed by using the instruction based on the fast state transition table, the time delay of the instruction is low, and the throughput is high, so compared with the related art, the embodiment of the application can realize the high-performance state jump in the hot zone. In addition, based on the characteristics of the hot zone in the embodiment of the application, the majority of state jump processes of the DFA are in the hot zone, and most of the state jumps of the DFA are processed by using the instruction in the fast state transition table, thereby further improving the state jump performance of the DFA.

[0011] In a possible implementation, the process of determining the hot zone in the state transition diagram includes: determining a candidate state from the states of the state machine, the number of paths from an initial state to the candidate state being greater than a third threshold value; and searching the states of the state machine starting from the candidate state to obtain the hot zone.

[0012] For example, the state diagram of the DFA can be searched by using a breadth first search (BFS) algorithm or a depth first search (DFS) algorithm starting from the candidate state to gradually expand the candidate hot zone.

[0013] In a possible implementation, the candidate state satisfies at least one of the following conditions: the number of incoming edges is greater than a fourth threshold value, has a spin, or is in a strongly connected component.

[0014] In this context, a state having spin means that, under certain inputs, the next hop state of that state is itself. A state being in a strongly connected component means that that state can transition to other states, i.e., there are mutually reachable edges between that state and other states in the state graph.

[0015] Its beneficial effect is that the characteristics of the candidate state ensure that most state transitions in the DFA will occur in the subsequently obtained hot region.

[0016] In one possible implementation, the fast state transition table includes a black hole state, which represents a state that is not in the hot region of the fast state transition table; the fast state transition table includes the next-hop state of the black hole state under each input, and the black hole state spins under each input.

[0017] Its beneficial effect is that when performing jumps on the fast state transition table, if a jump to the black hole state occurs, it can be determined that a jump escape has occurred. Furthermore, since the black hole state is a spin state under each input, once a jump to the black hole state is made, there will be no further jumps or subsequent erroneous jumps, making escape jumps detectable and traceable.

[0018] In one possible implementation, the method further includes: based on a fast state transition table, performing a transition from the current first state to a second state under a first input, wherein the first state belongs to a hot region and the second state is the next-hop state of the first state under the first input in the fast state transition table; in the case that the fourth state is a black hole state, performing a transition from the first state to a third state under the first input based on a full state transition table, wherein the third state is the next-hop state of the first state under the first input in the full state transition table; wherein the full state transition table is used to indicate the state transitions of each state of the state machine under various inputs, and the states in the hot region are a subset of the states in the full state transition table.

[0019] Its beneficial effect is that when jumping to the black hole state on the fast state transition table, switching to the full state transition table for the correct jump effectively ensures the accuracy of state transitions.

[0020] In one possible implementation, the method further includes: based on a fast state transition table, performing a jump from the current fourth state to the fifth state under the second input, where the fourth state belongs to the hot region; wherein the fifth state is the next jump state of the fifth state under the second input in the fast state transition table.

[0021] In a possible implementation, the method further includes: based on the full-state transition table, performing a jump from a current sixth state to a seventh state under a third input, the sixth state not belonging to the hot region, and the seventh state being a next jump state of the sixth state under the third input in the full-state transition table; and wherein the full-state transition table is used to indicate state jumps of each state of the state machine under respective inputs, and the states in the hot region are a subset of the states in the full-state transition table.

[0022] An advantage is that a hybrid jump model is proposed, which decomposes a DFA with a large number of states into a hot region and a non-hot region, and constructs a fast state transition table for the hot region on the basis of a traditional full-state transition table, and uses a two-level table (full-state transition table + fast state transition table) to express the DFA. For states in the hot region, high-performance state jumps are implemented based on the fast state transition table through instructions. For states in the non-hot region, table lookup jumps are implemented through the traditional full-state transition table. In a large number of state business scenarios, complete jumps of all states can be implemented through the full-state transition table, and fast jumps of part of the states can be implemented through the fast state transition table, which has both the integrity of the full-state transition table and the high performance of the fast state transition table.

[0023] In a possible implementation, the method further includes: using the shuffle instruction to perform a jump of a state in the hot region based on the fast state transition table.

[0024] For example, the current state can be expressed by using a control vector of the shuffle instruction, a corresponding row of the input character in the fast state transition table is used as a source vector, and a target vector returned by the shuffle instruction is a next jump state of the current state under the input character. The first threshold value can be a source vector width.

[0025] An advantage is that different state values can be enumerated by different bytes of the control vector, so that micro-instruction-level jump parallelism on a single core can be implemented.

[0026] In a possible implementation, the probability of jumping out of the hot region is a ratio of a first number of out-edges to a second number of out-edges, the first number of out-edges being a number of out-edges jumping out of the hot region, and the second number of out-edges being a number of out-edges of all states in the hot region.

[0027] In a second aspect, the present application provides a state transition apparatus, which includes: a hot region determination module configured to determine a hot region of a state machine, the hot region including a plurality of states, a number of states in the hot region being less than or equal to a first threshold value, and a probability of a state in the hot region jumping out of the hot region being less than or equal to a second threshold value; and a state table construction module configured to construct a fast state transition table of the hot region, each row of the fast state transition table being used to indicate a jump of a state in the hot region under an input.

[0028] In a possible implementation, the hot region determining module is specifically configured to: determine a candidate state from the states of the state machine, and a number of paths from an initial state to the candidate state is greater than a third threshold; and search the states of the state machine starting from the candidate state to obtain the hot region.

[0029] In a possible implementation, the candidate state satisfies at least one of the following conditions: a number of entry edges is greater than a fourth threshold, has a spin, or is in a strongly connected component.

[0030] In a possible implementation, the fast state transition table includes a black hole state, and the black hole state is used to represent a state in the fast state transition table that does not belong to the hot region; the fast state transition table includes a next-hop state of the black hole state under each input, and the black hole state spins under each input.

[0031] In a possible implementation, the apparatus further includes a state jump module configured to: based on the fast state transition table, perform a jump from a current first state to a second state under a first input, the first state belonging to the hot region, and the second state being a next-hop state of the first state under the first input in the fast state transition table; and in a case where the second state is a black hole state, based on the full state transition table, perform a jump from the first state to a third state under the first input, the third state being a next-hop state of the first state under the first input in the full state transition table; and the full state transition table is used to indicate state jumps of each state of the state machine under each input, and the states in the hot region are a subset of the states in the full state transition table.

[0032] In a possible implementation, the state jump module is further configured to: based on the fast state transition table, perform a jump from a current fourth state to a fifth state under a second input, the fourth state belonging to the hot region; and the fifth state is a next-hop state of the fifth state under the second input in the fast state transition table.

[0033] In a possible implementation, the state jump module is further configured to: based on the full state transition table, perform a jump from a current sixth state to a seventh state under a third input, the sixth state not belonging to the hot region, and the seventh state being a next-hop state of the sixth state under the third input in the full state transition table; and the full state transition table is used to indicate state jumps of each state of the state machine under each input, and the states in the hot region are a subset of the states in the full state transition table.

[0034] In a possible implementation, the state jump module is further configured to: based on the fast state transition table, perform a jump of a state in the hot region by using a shuffle instruction.

[0035] In a possible implementation, the probability of jumping out of the hot region is a ratio of a first number of edges to a second number of edges, the first number of edges being a number of edges jumping out of the hot region, and the second number of edges being a number of edges of all states in the hot region.

[0036] In a third aspect, the present application provides a state transition apparatus, comprising: one or more processors; a memory for storing one or more computer programs or instructions; when the one or more computer programs or instructions are executed by the one or more processors, the one or more processors implement the method of any one of the first aspect.

[0037] In a fourth aspect, the present application provides a state transition apparatus, comprising: a processor for executing the method of any one of the first aspect.

[0038] In a fifth aspect, the present application provides a state transition apparatus, comprising: a processing circuit and an interface circuit; wherein the interface circuit is configured to couple with a memory outside the state transition apparatus and provide a communication interface for the processing circuit to access the memory; and the processing circuit is configured to execute program instructions in the memory to implement the method of any one of the first aspect.

[0039] In the implementation process, the state transition apparatus can be a chip, the input circuit can be an input pin, the output circuit can be an output pin, and the processing circuit can be a transistor, a gate circuit, a flip-flop, and various logic circuits. The input signal received by the input circuit can be received and input by, for example but not limited to, a receiver, the output signal output by the output circuit can be output to and transmitted by, for example but not limited to, a transmitter, and the input circuit and the output circuit can be the same circuit which is used as the input circuit and the output circuit at different times. The present application does not limit the specific implementation of the processor and various circuits.

[0040] In a sixth aspect, the present application provides a computer readable storage medium, the computer readable storage medium storing program codes, the program codes being executed by a processor to implement the method of any one of the first aspect.

[0041] In a seventh aspect, the present application provides a chip, comprising: at least one processor. The at least one processor is configured to execute the method of any one of the first aspect.

[0042] Optionally, the chip further comprises a memory. The at least one processor is configured to execute codes in the memory, and when the at least one processor executes the codes, the chip implements the method of any one of the first aspect.

[0043] Optionally, the chip can also be an integrated circuit.

[0044] Eighthly, this application provides a computer program product containing instructions that, when run on a computer, cause the computer to perform the method as described in any one of the first aspects. Attached Figure Description

[0045] Figure 1 A state diagram of a DFA provided in an embodiment of this application;

[0046] Figure 2 A flowchart illustrating a state transition method provided in an embodiment of this application;

[0047] Figure 3 A flowchart illustrating another state transition method provided in an embodiment of this application;

[0048] Figure 4 Another state diagram of a DFA provided in this application embodiment;

[0049] Figure 5 A schematic diagram of a black hole state provided for an embodiment of this application;

[0050] Figure 6 A schematic diagram of multiple thermal regions divided from the state diagram of the DFA provided for embodiments of this application;

[0051] Figure 7 A block diagram of a state transition device provided in an embodiment of this application;

[0052] Figure 8 A block diagram of another state transition device provided in the embodiments of this application;

[0053] Figure 9 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application;

[0054] Figure 10 This is a schematic diagram of the structure of a state transition device provided in an embodiment of this application. Detailed Implementation

[0055] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0056] The terms "first," "second," etc., used in the specification, embodiments, claims, and drawings of this application are for distinguishing purposes only and should not be construed as indicating or implying relative importance or order. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion, such as including a series of steps or units. A method, system, product, or apparatus is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to these processes, methods, products, or apparatuses.

[0057] It should be understood that in this application, "at least one (item)" means one or more, and "more than" means two or more. "And / or" is used to describe the relationship between related objects, indicating that three relationships can exist. For example, "A and / or B" can represent three cases: only A exists, only B exists, and both A and B exist simultaneously, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one (item) of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one (item) of a, b, or c can represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c can be single or multiple.

[0058] A Directed Acyclic Graph (DFA) is a computational model that enables state transitions. A DFA consists of a finite number of states (initial state, intermediate states, and final state) and can transition between states based on the input and a transition function. A DFA can be represented as a state graph (a directed graph), which includes multiple nodes representing states and directed edges (also called transition edges) between these nodes. For a given state and a given input, the next state to transition to can be uniquely determined.

[0059] The state transition process of a DFA involves inputting characters from a string sequentially into the DFA. Starting from the initial state, the DFA reads each input character one by one. After each character is read, the DFA transitions from the current state to the next state according to a given transition function. If the input ends (i.e., the entire string has been read) and the DFA is in the terminating state, it indicates that the string has been accepted. A language that can be described by a DFA is called a regular language; a DFA can be considered equivalent to a regular expression.

[0060] A DFA can also be represented using a state transition table, and jumps can be made by looking up the state transition table. Each row in the state transition table represents the next jump state for a given state under all inputs. The state transition table can have 256 columns, corresponding to 256 possible input values ​​per byte.

[0061] For example, please refer to Figure 1 , Figure 1 The present application provides a state diagram of a DFA, the regular expression of which is / .*a+b.*c+d / , and its state transition table can be referred to Table 1 below. Figure 1 The edge weights in the equation indicate the inputs under which the state will undergo the corresponding state transition.

[0062] like Figure 1 As shown in Table 1, when the current state is state 0, inputting 'a' will transition to state 1; inputting any other character besides 'a' will cause a spin and remain in state 0. When the current state is state 1, inputting 'a' will cause a spin and remain in state 1; inputting 'b' will jump to state 2; inputting any other character besides 'a' and 'b' will transition to state 0. When the current state is state 2, inputting 'c' will jump to state 3; inputting any other character besides 'c' will cause a spin and remain in state 2. When the current state is state 3, inputting 'c' will cause a spin and remain in state 3; inputting 'd' will jump to state 4; inputting any other character besides 'c' and 'd' will jump to state 2. When the current state is state 4, inputting 'c' will jump to state 3; inputting any other character besides 'c' will jump to state 2.

[0063] Table 1. State Transition Table of DFA

[0064] st … a b c d … 0 … 1 0 0 0 … 1 … 1 2 0 0 … 2 … 2 2 3 2 … 3 … 2 2 3 4 … 4 … 2 2 3 2 …

[0065] Figure 1 Table 1 is merely an illustrative example and does not limit the state diagram and state transition table of the DFA in the embodiments of this application.

[0066] DFAs can be applied to scenarios such as firewalls, intrusion detection and prevention, deep packet inspection, and lexical analysis. In intrusion detection, regular expressions are used to represent the characteristics of intrusion behavior; that is, regular expressions represent the rules for intrusion behavior. When detecting network behavior, the network behavior can be matched against the regular expression to determine whether the network behavior is an intrusion. This regular expression can be represented as a DFA, where the state of the DFA represents the rules of intrusion behavior, and the input is the network behavior to be detected.

[0067] This application provides a state transition method. Please refer to the following embodiments. Figure 2 , Figure 2 This is a flowchart illustrating a state transition method provided in an embodiment of this application. The method may include the following processes:

[0068] 101. Determine the hot regions of the state machine. The number of states in the hot regions is less than or equal to the first threshold, and the probability of a state in a hot region transitioning out of the hot region is less than or equal to the second threshold.

[0069] A state machine can be a Directed Acyclic Graph (DFA). A hot region can be viewed as a set of states within the entire state machine; that is, a hot region includes multiple states. The probability of escaping a hot region (also called the escape rate) can be expressed as the ratio of the number of first outgoing edges to the number of second outgoing edges. The first outgoing edge count represents the number of edges that escape the hot region, and the second outgoing edge count represents the total number of outgoing edges from all states within the hot region. A lower probability of escaping a hot region means it is less likely to escape during the transition process. A higher probability of escaping a hot region means it is easier to escape during the transition process.

[0070] In one possible implementation, jumps within hot regions can be performed using vector instructions, that is, state transitions are performed by using vectors to represent states within the hot regions. The number of states in a hot region needs to be less than or equal to the number of bytes of vector and instruction operations that the processor can support to ensure the normal operation of vector instructions. Therefore, the number of states in a hot region needs to be less than or equal to a first threshold to enable jumps using vector instructions.

[0071] For example, the first threshold relates to the number of bytes of vector and instruction operations that the processor can support. The first threshold can be set based on hardware characteristics. For instance, assuming the central processing unit (CPU) is capable of supporting a maximum of 16-byte (128-bit) / 32-byte (256-bit) / 64-byte (512-bit) / 128-byte (1024-bit) vector and instruction operations, then the maximum value of the first threshold would be 16 (i.e., first threshold ≤ 16) / 32 (i.e., first threshold ≤ 32) / 64 (i.e., first threshold ≤ 64) / 128 (i.e., first threshold ≤ 128).

[0072] The second threshold can be set based on actual business requirements. For example, if the business needs to prevent easily jumping out of the hot zone, the second threshold can be set relatively small, such as 0.01 (maximum allowable escape rate of 1%), 0.015 (maximum allowable escape rate of 1.5%), or 0.02 (maximum allowable escape rate of 2%). Since a higher escape rate also results in a higher success rate in finding the hot zone, if the business needs to improve the success rate of finding the hot zone, the second threshold can be appropriately increased, for example, it can be 0.09 (maximum allowable escape rate of 9%), 0.1 (maximum allowable escape rate of 10%), or 0.15 (maximum allowable escape rate of 15%).

[0073] In one possible implementation of determining hot regions, the state nodes in the DFA state graph are traversed first to identify candidate states from the state machine's states. Then, starting with these candidate states, the state machine's states are searched to obtain the hot regions. These candidate states can be considered the entry points to the hot regions and are therefore also called entry candidate states. The number of paths from the initial state to the entry candidate state is greater than a third threshold, making it easy to jump from other states to the entry candidate state. This ensures that subsequent states can easily transition into the hot regions.

[0074] For example, in order for the number of paths to jump from the initial state to the entry candidate state to be greater than the third threshold, the entry candidate state can satisfy at least one of the following conditions: the number of incoming edges is greater than the fourth threshold, or it has a spin or is in a strongly connected component.

[0075] Here, the number of incoming edges in a state represents the entry condition of that state. The larger the number of incoming edges, the easier it is to jump from other states to that state. The smaller the number of incoming edges, the less likely it is to jump from other states to that state. If an entry candidate state satisfies the condition that the number of incoming edges is greater than the fourth threshold, it is relatively easy to jump from other states to the entry candidate state. For the subsequently obtained hot regions, this makes it easier for states to jump into the hot regions.

[0076] The fourth threshold can also be set based on hardware hotspots and actual business requirements. For example, if a large number of entry conditions for the candidate entry state are needed, the third threshold can be set to half or more of the total number of characters in the DFA's character table. If fewer entry conditions for the candidate entry state are needed, the third threshold can be set to less than half of the total number of characters in the DFA's character table. For instance, assuming the DFA's character table contains 256 characters, if a large number of entry conditions for the candidate entry state are needed, the third threshold can be set to 128, 129, 134, or 140, etc.

[0077] A state with spin means that, given some inputs, its next hop state is itself. A state in a strongly connected component means that it can transition to other states, i.e., there are reachable edges between this state and other states in the state graph. Therefore, a state with spin or in a strongly connected component is unlikely to escape from that state or its strongly connected component. Similarly, if an entry candidate state has spin and / or is in a strongly connected component, it is unlikely to escape from that entry candidate state or its strongly connected component; this is analogous to a state in a hot region being unlikely to escape from the hot region.

[0078] As described above, the hot region obtained in this application embodiment has at least one of the following characteristics: Characteristic 1. The number of states is relatively small, allowing for jump operations using vector instructions (corresponding to a number of states less than or equal to a first threshold); Characteristic 2. It is easy to enter (corresponding to entry conditions including at least one of the following: the number of incoming edges of the state is greater than a third threshold, the state has a spin, or the state is in a strongly connected component); Characteristic 3. It is not easy to jump out (corresponding to a probability of jumping out of the hot region less than or equal to a second threshold). These characteristics of the hot region ensure that most state jump processes of the DFA will occur within the hot region. These three characteristics can be arbitrarily combined; for example, the hot region can simultaneously satisfy characteristic 1 and characteristic 2, or the hot region can simultaneously satisfy characteristic 1, characteristic 2, and characteristic 3.

[0079] For the search process after determining the candidate entry state, for example, we can start from the candidate entry state and search the state graph of the DFA using a breadth-first search algorithm or a depth-first search algorithm to gradually expand the candidate hot regions. At the same time, we evaluate whether the candidate hot regions are qualified (where qualified means that the number of states in the candidate hot region is less than or equal to a first threshold and the probability of jumping out of the candidate hot region is less than or equal to a second threshold), and thus the qualified candidate hot regions are designated as hot regions.

[0080] For example, the specific search process can be as follows: any state found in the search is called a candidate state, and the process is illustrated using a candidate state as an example. If the candidate hot region is qualified after adding the candidate state to it, then the candidate state is retained in the candidate hot region.

[0081] If, after adding a candidate state to the candidate hot region, the number of states in the candidate hot region is less than or equal to a first threshold, but the probability of exiting the candidate hot region is greater than a second threshold, then at least one successor state of the candidate hot region can be added to the candidate hot region. If the candidate hot region is qualified after adding at least one successor state, then the candidate state and at least one successor state are retained in the candidate hot region. If, after adding at least one successor state, the number of states in the candidate hot region has reached the first threshold, but the probability of exiting the candidate hot region is greater than the second threshold, then the candidate state and at least one successor state are removed from the candidate hot region. Here, the successor state of a candidate state refers to the state that can be jumped to from the candidate state.

[0082] 102. Construct a fast state transition table for hot regions. Each row of the fast state transition table is used to indicate the state transition in the hot region under an input.

[0083] Each row of the fast state transition table represents the next-hop state for each state in the hot region given an input. This state can be located in a cache (e.g., L1 cache) or a register. The fast state transition table can have 256 rows, corresponding to 256 possible input values ​​per byte. The number of columns represents the number of states in the hot region.

[0084] In summary, the state transition method provided in this application first determines the hot regions of the state machine. The number of states in the hot regions is less than or equal to a first threshold, and the probability of a state transitioning out of the hot region is less than or equal to a second threshold. Then, a fast state transition table is constructed for the hot regions. Each row of the fast state transition table indicates a state transition within the hot region under a given input. For state transitions within the hot regions, high-speed and parallel state transitions can be performed using instructions based on the fast state transition table. The instructions have low latency and high throughput. Therefore, compared to related technologies, this application embodiment can achieve high-performance state transitions within hot regions. Furthermore, based on the characteristics of the hot regions in this application embodiment, most state transitions of the DFA will occur within the hot regions. By using instructions in the fast state transition table to process most of the DFA's state transitions, the state transition performance of the DFA is further improved.

[0085] Please refer to Figure 3 , Figure 3 A flowchart illustrating another state transition method provided in this application embodiment, the method may include the following processes:

[0086] 201. Determine the hot regions of the state machine. The number of states in the hot regions is less than or equal to the first threshold, and the probability of a state in a hot region transitioning out of the hot region is less than or equal to the second threshold.

[0087] This process can refer to the aforementioned process 101, and will not be repeated here in the embodiments of this application.

[0088] For example, please refer to Figure 4 , Figure 4 Another state diagram of a DFA provided in this application embodiment, to Figure 4 The process will be further explained using an example. Figure 4 The state diagram shown describes a DFA with a large number of states (states 0 to 4 and states 129 to 131 are shown as examples).

[0089] Referring to the process for determining the hot region described in process 101 above, firstly, a first threshold is set to 16 (i.e., the maximum number of states within the hot region is 16), a second threshold is set to 0.01 (i.e., a maximum allowable escape rate of 1%), and a third threshold is set to 128 (i.e., the number of incoming edges of the candidate entry state is greater than 128). For example... Figure 4As shown, the number of incoming edges in state 0 is 255 (the total number of non-a inputs), and state 0 has a spin (it remains in state 0 even with non-a inputs). Therefore, state 0 can be used as an entry candidate state.

[0090] Starting with state 0, a BFS is performed. After adding states 1 and 2 to the candidate hot regions, both candidate hot regions are considered valid, so states 1 and 2 can be retained. After adding state 129 to the candidate hot region, the probability of exiting the candidate hot region is greater than 0.01. At least one successor state of state 129 (e.g., state 130, state 131, etc.) is added to the candidate hot region sequentially. If the candidate hot region is valid, state 129 and at least one successor state are retained. If, when the number of states in the candidate hot region has reached 16, the probability of exiting the candidate hot region fails to converge to 0.01 or less, state 129 and at least one successor state are discarded. This process is repeated until a valid hot region consisting of states 0, 1, 2, 3, and 4 is obtained.

[0091] from Figure 4 It can be seen that the state is easy to jump into the hot zone, and the probability of the state in the hot zone jumping out of the hot zone is low. It will jump out of the hot zone and into state 129 only when the input c is received in state 1.

[0092] 202. Construct a fast state transition table for hot regions. Each row of the fast state transition table is used to indicate the state transition in the hot region under an input.

[0093] For example, with Figure 4 Taking the hot region shown as an example, the fast state transition table can be referred to Table 2 below. Table 2 exemplarily shows the next-hop state for states 0 to 4 under inputs a, b, c, and d, respectively.

[0094] Table 2. Fast State Transition Table

[0095] st 0 1 2 3 4 … … … … … … … … … … a 1 1 2 2 2 … … b 0 2 2 2 2 … … c 0 129 3 3 3 … … d 0 0 2 4 2 … … … … … … … … … …

[0096] It should be noted that Table 2 is for illustrative purposes only and does not constitute a limitation on the fast state transition table.

[0097] 203. Based on the full state transition table, perform the jump from the current first state to the second state under the first input.

[0098] The full state transition table is used to indicate the state transitions of each state of the state machine under various inputs. Specifically, each row of the full state transition table represents the next jump state of a state under all inputs. The full state transition table includes all states of the state machine, and the states in the hot region are a subset of the states in the full state transition table. In this embodiment, the fast state transition table is obtained by transposing a portion of the full state transition table.

[0099] The first state is not in the hot zone. The second state is the next jump state of the first state under the first input in the full state transition table.

[0100] In this embodiment, if the current state is located in a non-hot region (also known as a cold region), a lookup table can be used to jump to the next state using a traditional full state transition table. The full state transition table includes not only the next-hop state of each state in the hot region under all inputs, but also the next-hop state of each state in the non-hot region under all inputs.

[0101] As mentioned above Figure 4 For example, the full state transition table can be referred to Table 3 below. Table 3 shows the next-hop state of states 0 to 4 under inputs a, b, c and d respectively, the next-hop state of state 129 under input b, and the next-hop state of state 130 under input c.

[0102] Table 3. Full State Transition Table

[0103] st … a b c d … 0 … 1 0 0 0 … 1 … 1 2 129 0 … 2 … 2 2 3 2 … 3 … 2 2 3 4 … 4 … 2 2 3 2 … … … … … … … … 129 … … 130 … … … 130 … … … 131 … … 131 … … … … … … … … … … … … …

[0104] It should be noted that Table 3 is for illustrative purposes only and does not constitute a limitation on the full state transition table.

[0105] As shown in Table 3 above, if the first state is state 129 and the first input is input b, then by consulting Table 3, the system jumps from state 129 to state 130 (i.e., the second state).

[0106] 204. Based on the fast state transition table, perform the transition from the current third state to the fourth state under the second input.

[0107] The third state belongs to the hot region. The fourth state is the next-hop state after the third state with the second input in the fast state transition table.

[0108] As shown in Table 2 above, if the third state is state 1 and the second input is input b, then by consulting Table 2, the system jumps from state 1 to state 2 (i.e., the fourth state).

[0109] In one possible implementation, instructions based on a fast state transition table can be used to jump between states in a hot region. For example, a shuffle instruction based on a fast state transition table can be used to jump from the current third state to the fourth state under a second input.

[0110] The shuffle instruction works as follows: one operand is a source vector, and the other is a control vector; the result is a target vector. The shuffle instruction uses each byte in the control vector as an index, placing the byte value at the indexed position in the source vector into the target vector at the offset of that index. In process 204, the control vector represents the current state, and the corresponding row of the input character in the fast state transition table is used as the source vector. Therefore, the target vector returned by the shuffle instruction is the state of the next jump after the input character. For example, the high four bits of each byte in the control vector can be erased, and the remaining low four bits after erasing the high four bits can be used as an index.

[0111] Since the source vector represents a row in the fast state transition table, the maximum number of columns in the fast state transition table (i.e., the number of states in the hot region) is equal to the total width of the source vectors. For example, the first threshold can be the total width of the source vectors. The shuffling instruction can support concatenating multiple source vectors, and the total width of the concatenation only needs to be within the index range of each byte of the control vector. Because different state values ​​can be enumerated using different bytes of the control vector, microinstruction-level parallel jumps can be achieved on a single core.

[0112] As another example, the gather instruction can be used to jump from the current third state to the fourth state based on a fast state transition table, using a second input.

[0113] This application proposes a hybrid jump model that decomposes a large number of states in a Direct Automated Forms Analysis (DFA) into hot and non-hot regions. Based on the traditional full state transition table, a fast state transition table is constructed for the hot regions, using a two-level table structure (full state transition table + fast state transition table) to represent the DFA. For states in hot regions, high-performance state transitions are achieved through instructions based on the fast state transition table. For states in non-hot regions, table lookups are performed using the traditional full state transition table for jumps. In business scenarios involving a large number of states, this model can achieve complete jumps for all states using the full state transition table, and also achieve fast jumps for some states using the fast state transition table, combining the completeness of the full state transition table with the high performance of the fast state transition table.

[0114] In this embodiment, when performing a state transition based on a fast transition state table, the transition may escape to a non-hot region. That is, some states in the hot region may transition to states in the non-hot region under certain inputs. When this process 204 is executed by an instruction, since the instruction may not check the accuracy of the operands, it lacks the ability to detect escape, and erroneous transitions may occur. Specifically, when a state in the hot region receives an input and transitions to a state in the non-hot region, the non-hot region state, as an operand of the instruction, may have its high-order information truncated, resulting in an erroneous transition, or it may have its highest activated bit used to make an erroneous transition, resulting in a situation where a state jumps out of the hot region and immediately jumps back into the hot region.

[0115] As mentioned above Figure 4 This example illustrates the situation where an error jump occurs under a shuffle command. Figure 4 As shown, the initial state is 0, and the input is acb. The normal jump process is as follows: after processing the character 'a', the DFA jumps from state 0 to state 1; after processing the character 'c', it escapes the hot region and jumps from state 1 to state 129; and after processing the character 'b', it jumps from state 129 to state 130.

[0116] However, the jump process using the fast state transition table is as follows: After processing character 'a', the DFA still jumps from state 0 to state 1; after processing character 'c', it still escapes the hot region and jumps from state 1 to state 129. Then, when processing character 'b', the current state 129, as the value in the control vector of the shuffle instruction, might have its high-order bits truncated and be treated as state 1 for subsequent jumps, thus incorrectly jumping to state 2. Alternatively, it might be treated as state 0 based on the highest activated bit, thus remaining in state 0. From this jump process, it can be seen that after escaping the hot region and jumping to state 129, it returns to the hot region; the escape behavior is missed, causing errors in subsequent jumps.

[0117] This application addresses the issue of missed escape behavior by introducing a black hole state into the hot region. For example, the fast state transition table includes a black hole state, which represents a state in the fast state transition table that is not in the hot region. Essentially, all states in the fast state transition table not in the hot region are replaced with black hole states. The fast state transition table includes the next-hop state for each input, and the black hole state spins for each input.

[0118] Assuming the instruction vector width is N, capable of representing N states, then the hot region can encompass a maximum of N states. One vector can be used to represent the black hole state; for example, the black hole state could be state N-1. Since the black hole state occupies one state, the fast state transition table can represent a maximum of N-1 valid states, and the hot region can also contain a maximum of N-1 valid states.

[0119] Please refer to Figure 5 , Figure 5 This is a schematic diagram of a black hole state provided in an embodiment of this application. Figure 5 Is Figure 4 A black hole state is introduced into the hot region shown. The fast state transition table can be referenced in Table 4 below, where state N (e.g., N=15) is the black hole state. When a state transition is performed on Table 4, state 1 will transition to the black hole state under input c, instead of transitioning to state 129.

[0120] Table 4. Fast state transition table for introducing black hole state

[0121]

[0122]

[0123] The state not in the hot zone is the state transitioned to when escaping the hot zone. When performing a jump on the fast state transition table, if a jump to the black hole state occurs, it confirms that a jump escape has occurred. Furthermore, since the black hole state is a spin state under every input, once a jump to the black hole state is made, there will be no further jumps out, and no subsequent erroneous jumps will occur, allowing the escape jump to be detected and tracked. At this point, subsequent process 205 can be executed to switch to the full state transition table for a correct jump.

[0124] 205. In the case that the fourth state is the black hole state, based on the full state transition table, perform the jump from the third state to the fifth state under the second input.

[0125] In this context, the fifth state is the next jump state after the third state under the second input in the full state transition table. If a jump to the black hole state is detected, the state before the jump to the black hole state is determined to be the third state, and the correct jump is re-executed based on the full state transition table.

[0126] As mentioned above Figure 5 Taking Tables 3 and 4 as examples, assume the third state is state 1 and the second input is input c. As shown in Table 4, due to the introduction of the black hole state, in process 204, it will jump from state 1 to state N, where state N (the fourth state) is the black hole state. Therefore, referring to Table 3, under input c, it jumps from state 1 to state 129. Figure 5It can be seen that state 129 is the correct successor state of state 1 under input c.

[0127] The foregoing embodiments are all illustrated using the determination of a hot region and the state transition process of that hot region as examples. In one possible implementation, there can be multiple hot regions. The determination process of each hot region and the construction process of its fast state transition table can refer to the aforementioned processes 101 and 102, and processes 201 and 202. The state transition process in each hot region can refer to processes 204 and 205, which will not be elaborated upon in the embodiments of this application.

[0128] For example, please refer to Figure 6 , Figure 6 This is a schematic diagram of multiple thermal regions divided from the state diagram of the DFA provided in an embodiment of this application. Figure 6 The diagram shows three thermal regions: thermal region 0, thermal region 1, and thermal region 2, as well as the regular states located in the non-thermal regions.

[0129] In summary, the state transition method provided in this application identifies hot regions of the state machine. The number of states in a hot region is less than or equal to a first threshold, and the probability of a state transitioning out of a hot region is less than or equal to a second threshold. A fast state transition table for the hot regions is then constructed. Each row of the fast state transition table indicates a state transition within the hot region under a given input. When the current first state is a state outside the hot region, a transition from the first state to the second state is performed based on the full state transition table under the first input. When the current third state is a state within the hot region, a transition from the third state to the fourth state is performed based on the fast state transition table under the second input. By decomposing the large number of states in the DFA into hot and non-hot regions, a fast state transition table for the hot regions is constructed based on the traditional full state transition table, using a two-level table (full state transition table + fast state transition table) to represent the DFA. For states within the hot regions, high-performance state transitions are achieved through instructions based on the fast state transition table. For states outside the hot regions, a lookup table is used to perform transitions using the traditional full state transition table. When dealing with business scenarios involving a large number of states, it can achieve complete transitions to all states through a full state transition table, and also achieve rapid transitions to some states through a fast state transition table, combining the completeness of a full state transition table with the high performance of a fast state transition table.

[0130] Furthermore, the target state in the fast state transition table is replaced with a black hole state, which is not in the hot region. The fast state transition table includes the next-hop state for each input of the black hole state, which spins on each input. When the fourth state is the black hole state, a transition from the third to the fifth state is performed on the second input based on the full state transition table. When performing transitions on the fast state transition table, if a transition to the black hole state occurs, it indicates an escape transition. Since the black hole state spins on each input, a transition to the black hole state will not result in a subsequent erroneous transition, allowing escape transitions to be detected and tracked. At this point, switching to the full state transition table allows for a correct transition, effectively ensuring the accuracy of state transitions.

[0131] The order of the methods provided in the embodiments of this application can be appropriately adjusted, and the processes can be added or removed as appropriate. For example, the order of processes 203 and 204 can be interchanged. Any variations that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the protection scope of this application, and the embodiments of this application do not limit this.

[0132] The foregoing primarily describes the state transition method provided in this application from the perspective of the device. It is understood that the state transition apparatus for executing the above method includes corresponding hardware structures and / or software modules for executing each function in order to achieve the above functions. Those skilled in the art should readily recognize that, based on the algorithm steps of the examples described in conjunction with the embodiments disclosed herein, this application can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed in hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0133] This application embodiment can divide the state transition device into functional modules based on the above method example. For example, each function can be divided into its own functional modules, or two or more functions can be integrated into a processing subsystem. The integrated modules can be implemented in hardware (e.g., hardware accelerators) or in software (e.g., using instruction set acceleration libraries). It should be noted that the module division in this application embodiment is illustrative and only represents one logical functional division; other division methods may be used in actual implementation.

[0134] Figure 7This is a block diagram of a state transition device provided in an embodiment of this application. When each functional module is divided according to its corresponding function, the state transition device 300 may include: a hot zone determination module 301 and a state table construction module 302. Exemplarily, this state transition device can be a single device, or a chip or other combined device or component having the aforementioned state transition device functions. The functions of each module of this device are as follows:

[0135] The hot region determination module 301 is used to determine the hot region of the state machine. The hot region includes multiple states. The number of states in the hot region is less than or equal to a first threshold, and the probability of a state in the hot region jumping out of the hot region is less than or equal to a second threshold.

[0136] The state table construction module 302 is used to construct a fast state transition table for hot regions. Each row of the fast state transition table is used to indicate the state transition in the hot region under an input.

[0137] In conjunction with the aforementioned scheme, the hot region determination module 301 is specifically used to: determine candidate states from the states of the state machine, where the number of paths from the initial state to the candidate state is greater than a third threshold; and search the states of the state machine starting from the candidate states to obtain hot regions.

[0138] Combining the aforementioned scheme, the candidate state satisfies at least one of the following conditions: the number of incoming edges is greater than the fourth threshold, or it has a spin or is in a strongly connected component.

[0139] Combining the aforementioned scheme, the fast state transition table includes a black hole state, which is used to represent a state that does not belong to the hot region in the fast state transition table; the fast state transition table includes the next hop state of the black hole state under each input, and the black hole state spins under each input.

[0140] Please refer to Figure 8 , Figure 8 This is a block diagram of another state transition device provided in an embodiment of this application. Figure 7 Based on this, the device also includes:

[0141] The first state transition module 303 is used to perform a transition from the current first state to the second state based on the fast state transition table under the first input. The first state belongs to the hot region, and the second state is the next jump state of the first state under the first input in the fast state transition table.

[0142] The first state transition module 303 is also used to, when the second state is the black hole state, perform a transition from the first state to the third state based on the full state transition table under the first input, where the third state is the next jump state of the first state under the first input in the full state transition table.

[0143] The full state transition table is used to indicate the state transitions of each state of the state machine under various inputs, and the states in the hot region are a subset of the states in the full state transition table.

[0144] In conjunction with the aforementioned scheme, the first state transition module 303 is also used to perform a transition from the current fourth state to the fifth state under the second input based on the fast state transition table, wherein the fourth state belongs to the hot region; wherein the fifth state is the next jump state of the fifth state under the second input in the fast state transition table.

[0145] like Figure 8 As shown, the device also includes:

[0146] The second state transition module 304 is used to perform a transition from the current sixth state to the seventh state under the third input based on the full state transition table. The sixth state does not belong to the hot region, and the seventh state is the next jump state of the sixth state under the third input in the full state transition table. The full state transition table is used to indicate the state transition of each state of the state machine under each input. The states in the hot region are a subset of the states in the full state transition table.

[0147] In conjunction with the aforementioned scheme, the first state transition module 303 is also used to perform state transitions in the hot zone based on the fast state transition table using the shuffling instruction.

[0148] Combining the aforementioned scheme, the probability of jumping out of the hot zone is: the ratio of the first number of outgoing edges to the second number of outgoing edges, where the first number of outgoing edges is the number of outgoing edges that jump out of the hot zone, and the second number of outgoing edges is the number of outgoing edges in all states within the hot zone.

[0149] The state transition apparatus provided in this application embodiment is used to execute the state transition method provided above. Therefore, the beneficial effects it can achieve can be referred to the beneficial effects in the state transition method provided above, and will not be repeated here.

[0150] Figure 9 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. The electronic device 400 can be a chip or functional module in a state transition device. Figure 9 As shown, the electronic device 400 includes a processor 401, a transceiver 402, and a communication line 403.

[0151] Among them, processor 401 is used to perform such as Figure 2 and Figure 3 In any step of the method embodiment shown, when performing processes such as receiving input, the transceiver 402 and communication line 403 may be invoked to complete the corresponding operation.

[0152] Furthermore, the electronic device 400 may also include a memory 404. The processor 401, memory 404, and transceiver 402 can be connected via a communication line 403.

[0153] Transceiver 402 is used to communicate with other devices or other communication networks, such as Ethernet, radio access network (RAN), wireless local area network (WLAN), etc. Transceiver 402 can be a module, circuit, transceiver, or any device capable of enabling communication.

[0154] Transceiver 402 is mainly used for sending and receiving data, and may include a transmitter and a receiver to send and receive data, respectively. Operations other than sending and receiving data are implemented by the processor, such as determining hot regions and building a fast state transition table for hot regions.

[0155] Communication line 403 is used to transmit information between the various components included in electronic device 400.

[0156] In one design, the processor can be viewed as a logic circuit, and the transceiver as an interface circuit.

[0157] Memory 404 is used to store instructions. These instructions can be computer programs.

[0158] It should be noted that the memory 404 can exist independently of the processor 401, or it can be integrated with the processor 401. The memory 404 can be used to store instructions, program code, or some data, etc. The memory 404 can be located inside or outside the electronic device 400, without limitation. The processor 401 is used to execute the instructions stored in the memory 404 to implement the methods provided in the above embodiments of this application.

[0159] In one example, processor 401 may include one or more processors, for example Figure 9 Processor 0 and processor 1 in the system.

[0160] As an optional implementation, the electronic device 400 includes multiple processors, for example, besides Figure 9 In addition to processor 401, it may also include processor 407.

[0161] As an optional implementation, the electronic device 400 also includes an output device 405 and an input device 406. For example, the input device 406 is a device such as a keyboard, mouse, microphone, or joystick, and the output device 405 is a device such as a display screen or speaker.

[0162] As an optional implementation, the electronic device 400 may also include a hardware accelerator 408. The hardware accelerator 408 can be used to perform actions such as... Figure 2 and Figure 3 Any step in the method embodiments shown.

[0163] It should be noted that the electronic device 400 can be a chip system or... Figure 9 Devices with similar structures. The chip system can be composed of chips or include chips and other discrete components. Actions, terminology, etc., involved in the various embodiments of this application can be referenced interchangeably without limitation. The message names or parameter names in the messages used for interaction between devices in the embodiments of this application are merely examples; other names can be used in specific implementations without limitation. Furthermore, Figure 9 The structural composition shown does not constitute a limitation on the electronic device 400, except... Figure 9 In addition to the components shown, the electronic device 400 may include more than Figure 9 This may indicate more or fewer components, or combinations of certain components, or different component arrangements.

[0164] The processor and transceiver described in this application can be implemented on integrated circuits (ICs), analog ICs, radio frequency integrated circuits, mixed-signal ICs, application-specific integrated circuits (ASICs), printed circuit boards (PCBs), electronic devices, etc. The processor and transceiver can also be manufactured using various IC process technologies, such as complementary metal-oxide semiconductors (CMOS), n-metal-oxide-semiconductor (NMOS), positive-channel metal-oxide semiconductors (PMOS), bipolar junction transistors (BJTs), bipolar CMOS (BiCMOS), silicon germanium (SiGe), gallium arsenide (GaAs), etc.

[0165] The electronic device provided in this application embodiment is used to execute the state transition method described above. Therefore, the beneficial effects it can achieve can be referred to the beneficial effects in the state transition method described above, and will not be repeated here.

[0166] Figure 10This is a schematic diagram of a state transition device provided in an embodiment of this application. This state transition device is applicable to the scenarios shown in the above method embodiments. For ease of explanation, Figure 10 Only the main components of the state transition device are shown, including a processor, memory, control circuitry, and input / output devices. The processor is primarily used to process communication protocols and data, execute software programs, and process the data within those programs. The memory is mainly used to store software programs and data. The control circuitry is primarily used for power supply and the transmission of various electrical signals. The input / output devices are primarily used to receive user input data and output data to the user.

[0167] When the state transition device is a hardware device, the control circuit can be a motherboard, the memory includes storage media such as hard disks, RAM, and ROM, and the processor can include a baseband processor and a central processing unit (CPU). The baseband processor is mainly used to process communication protocols and communication data, while the CPU is mainly used to control the entire state transition device, execute software programs, and process data from the software programs. Input / output devices include displays, keyboards, and mice. The control circuit can further include or be connected to transceiver circuits or transceivers, such as network cable interfaces, for sending or receiving data or signals, such as for data transmission and communication with other devices. Furthermore, it can also include an antenna for data transmission and reception, for data / request transmission with other devices.

[0168] The state transition apparatus provided in this application embodiment is used to execute the state transition method provided above. Therefore, the beneficial effects it can achieve can be referred to the beneficial effects in the state transition method provided above, and will not be repeated here.

[0169] According to the method provided in the embodiments of this application, this application also provides a computer program product, which includes computer program code. When the computer program code is run on a computer, it causes the computer to perform any of the methods described in the embodiments of this application. For example, the computer program code may be a basic acceleration library utilizing an instruction set (e.g., a CPU instruction set).

[0170] This application also provides a computer-readable storage medium. All or part of the processes in the above method embodiments can be executed by a computer or a device with state transition capability, using computer programs or instructions to control related hardware. The computer program or set of instructions can be stored in the aforementioned computer-readable storage medium. When executed, the computer program or set of instructions can include the processes described in the above method embodiments. The computer-readable storage medium can be an internal storage unit of the state transition device in any of the foregoing embodiments, such as the hard disk or memory of the state transition device. The computer-readable storage medium can also be an external storage device of the state transition device, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc., equipped on the state transition device. Further, the computer-readable storage medium can include both internal storage units and external storage devices of the state transition device. The computer-readable storage medium is used to store the computer program or instructions and other programs and data required by the state transition device. The computer-readable storage medium can also be used to temporarily store data that has been output or will be output.

[0171] The computer program product and computer-readable storage medium provided in this application embodiment are both used to execute the state transition method provided above. Therefore, the beneficial effects they can achieve can be referred to the beneficial effects in the state transition method provided above, and will not be repeated here.

[0172] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0173] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the device described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0174] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.

[0175] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0176] In addition, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0177] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, ROM, RAM, magnetic disks, or optical disks.

[0178] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A state transfer method, characterized by, The method comprises: determining a hot region of a state machine, the hot region comprising a plurality of states, a number of the states in the hot region being less than or equal to a first threshold, and a probability of a state in the hot region jumping out of the hot region being less than or equal to a second threshold; constructing a fast state transition table of the hot region, each row of the fast state transition table being used to indicate a state jump in the hot region under one input.

2. The method of claim 1, wherein, The determination of the hot region in the state transition graph comprises: determining a candidate state from states of the state machine, a number of paths jumping from an initial state to the candidate state being greater than a third threshold; searching the states of the state machine starting from the candidate state to obtain the hot region.

3. The method of claim 2, wherein, The candidate state satisfies at least one of the following conditions: a number of incoming edges being greater than a fourth threshold, having a spin, or being in a strongly connected component.

4. The method according to any one of claims 1 to 3, characterized in that, The fast state transition table comprises a black hole state, the black hole state being used to represent a state not in the hot region in the fast state transition table; The fast state transition table comprises a next-hop state of the black hole state under each input, the black hole state spinning under each input.

5. The method of claim 4, wherein, The method further comprises: based on the fast state transition table, performing a jump from a current first state to a second state under a first input, the first state belonging to the hot region, the second state being a next-hop state of the first state under the first input in the fast state transition table; in a case where the second state is the black hole state, based on a full state transition table, performing a jump from the first state to a third state under the first input, the third state being a next-hop state of the first state under the first input in the full state transition table; wherein the full state transition table is used to indicate state jumps of each state of the state machine under respective inputs, states in the hot region being a subset of states in the full state transition table.

6. The method according to any one of claims 1 to 5, characterized in that, The method further comprises: based on the fast state transition table, performing a jump from a current fourth state to a fifth state under a second input, the fourth state belonging to the hot region; wherein the fifth state is a next-hop state of the fifth state under the second input in the fast state transition table.

7. The method according to any one of claims 1 to 6, characterized in that, The method further comprises: based on a full state transition table, performing a jump from a current sixth state to a seventh state under a third input, the sixth state not belonging to the hot region, the seventh state being a next-hop state of the sixth state under the third input in the full state transition table; wherein the full state transition table is used to indicate state jumps of each state of the state machine under respective inputs, states in the hot region being a subset of states in the full state transition table.

8. The method according to any one of claims 1 to 7, characterized in that, The method further comprises: performing jumps of the states in the hot region based on the fast state transition table by using a shuffle instruction.

9. The method according to any one of claims 1 to 8, characterized in that, A probability of jumping out of the hot region is a ratio of a first number of edges to a second number of edges, the first number of edges being a number of edges jumping out of the hot region, and the second number of edges being a number of edges of all states in the hot region.

10. A state transfer apparatus, characterized by, The apparatus comprises: a hot region determining module configured to determine a hot region of a state machine, the hot region comprising a plurality of states, a number of the states in the hot region being less than or equal to a first threshold, and a probability of the states in the hot region jumping out of the hot region being less than or equal to a second threshold; a state table constructing module configured to construct a fast state transition table of the hot region, each row of the fast state transition table being configured to indicate a state jump in the hot region under one input.

11. The apparatus of claim 10, wherein, The hot region determining module is specifically configured to: determine a candidate state from states of the state machine, a number of paths jumping from an initial state to the candidate state being greater than a third threshold; and search the states of the state machine starting from the candidate state to obtain the hot region.

12. The apparatus of claim 10 or 11, wherein, The fast state transition table comprises a black hole state, the black hole state being configured to represent a state not belonging to the hot region in the fast state transition table. The fast state transition table comprises a next-hop state of the black hole state under each input, the black hole state spinning under each input.

13. The apparatus of claim 12, wherein, The apparatus further comprises: a state jump module configured to perform a jump from a current first state to a second state under a first input based on the fast state transition table, the first state belonging to the hot region, and the second state being a next-hop state of the first state under the first input in the fast state transition table; the state jump module is further configured to, in a case that the second state is the black hole state, perform a jump from the first state to a third state under the first input based on a full state transition table, the third state being a next-hop state of the first state under the first input in the full state transition table; wherein the full state transition table is configured to indicate state jumps of each state of the state machine under respective inputs, and states in the hot region are a subset of states in the full state transition table.

14. The apparatus of any one of claims 10-13, wherein, The apparatus further comprises: a state jump module configured to perform a jump from a current fourth state to a fifth state under a second input based on the fast state transition table, the fourth state belonging to the hot region; wherein the fifth state is a next-hop state of the fifth state under the second input in the fast state transition table.

15. The apparatus of any one of claims 10 to 14, wherein, The apparatus further comprises: a state jump module configured to perform a jump from a current sixth state to a seventh state under a third input based on a full state transition table, the sixth state not belonging to the hot region, and the seventh state being a next-hop state of the sixth state under the third input in the full state transition table; wherein the full state transition table is configured to indicate state jumps of each state of the state machine under respective inputs, and states in the hot region are a subset of states in the full state transition table.

16. The apparatus of any one of claims 10 to 15, wherein, The apparatus further comprises: a state jump module to utilize a shuffle instruction to perform a jump of the state in the hot region based on the fast state transition table.

17. A computing device, comprising: The apparatus comprises: one or more processors; a memory to store one or more computer programs or instructions; when the one or more computer programs or instructions are executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1 to 9.

18. A computer program product comprising instructions, characterized in that, when the instructions are executed by a computing device, cause the computing device to perform the method of any one of claims 1 to 9.