Method and apparatus for shortening configuration file execution time in network device
By dynamically learning the probability of commands appearing in network devices, the system predicts and prioritizes matching commands in the configuration file, thus solving the problem of excessively long configuration file execution time and achieving efficient configuration file execution.
Patent Information
- Application Number
- CN202411350938.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-26
- Publication Date
- 2025-11-11
- Estimated Expiration
- 2044-09-26
AI Technical Summary
In network devices, the command lookup and matching process for configuration files is too time-consuming and difficult to optimize.
By dynamically learning the probability of the next command appearing for each command, a lookup table is built to record the probability of the next command appearing for each command. Based on this, the predicted command that can be matched with the next statement to be executed is predicted, and it is matched with it first. If the match is successful, it is executed directly.
This significantly reduces the execution time of configuration files and improves processing efficiency.
Smart Images

Figure CN119316281B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of network device system management technology, specifically to a method and apparatus for shortening the execution time of configuration files in network devices. Background Technology
[0002] In network devices, a common way to store configurations is by using command-line configuration files. The advantage of this method is that it has excellent compatibility, is not limited by the device implementation scheme, and can be smoothly upgraded.
[0003] Network devices register numerous command lines. The registration information typically includes the command's format definition and the processing function to be executed. The command's format definition is a special string containing multiple fields, where each field can be a keyword or a parameter. The input text that a parameter can match is variable, and special symbols are often used to define the matching rules. For example, in an OLT device: [...] indicates that the parameter can match one of a set of options, while <...> indicates that it can match any input.
[0004] Users input text statements through the command-line terminal. The command-line kernel parses the text and then searches for a matching command in the system's registered command-line list. This requires matching the input statement with the format of each registered command-line, a complex pattern matching process that is difficult to optimize using conventional methods. Once a matching command-line is found, the corresponding processing function and parameter list are obtained, and the corresponding processing is then executed.
[0005] The configuration file stores the user's settings and contains a large number of command statements. Upon device reboot, the configuration is restored by executing each command statement in the file sequentially. This process is very time-consuming, with a significant portion of the overall configuration execution time spent searching for and matching each statement against the list of registered command lines.
[0006] Therefore, optimizing the command lookup and matching process during the execution of network device configuration files, thereby shortening the overall execution time of the configuration files, is a problem that urgently needs to be solved by those skilled in the art. Summary of the Invention
[0007] The purpose of this invention is to provide a method and apparatus for shortening the execution time of configuration files in network devices. Based on dynamic learning and prediction, the process of command lookup and matching during the execution of network device configuration files is optimized, thereby shortening the overall execution time of the configuration file.
[0008] To achieve the above objectives, in a first aspect, embodiments of the present invention provide a method for shortening the execution time of a configuration file in a network device. The method includes: during the execution of the configuration file, dynamically learning the probability of occurrence of the next command after each command; predicting a matching command that can be matched with the next statement to be executed based on the probability, and matching it; when a match is successful, directly executing the matched predictive command.
[0009] In conjunction with the first aspect, in one implementation, the dynamic learning of the probability of the next command appearing for each command includes: establishing a lookup table to record the probability of the next command appearing for each command that has been executed; the lookup table is generated through dynamic learning, and after each command is executed, the lookup table is updated using the combination of the current command and the previous command.
[0010] In conjunction with the first aspect, in one implementation, the index of the lookup table is each command that has been executed in the current configuration file; the contents of the table entries are a set of the next command after each command in the current configuration file, sorted in descending order of the number of times they have appeared; the elements of the set are the next command and the count of the command's appearance.
[0011] In conjunction with the first aspect, in one implementation, the matchable prediction command is one or more commands.
[0012] In conjunction with the first aspect, in one implementation, predicting the next statement to be executed based on the probability and matching it includes: when executing the next statement, using the previous command as an index to search in the lookup table; if found, using one or more commands ranked first in the set of corresponding table entries as the predicted command and matching it with the statement to be executed; if not found, matching the statement to be executed with the entire set of registered command lines.
[0013] Secondly, embodiments of the present invention also provide an apparatus for shortening the execution time of a configuration file in a network device, the apparatus comprising a learning module and a prediction and execution module;
[0014] The learning module is used to: dynamically learn the probability of the next command appearing after each command during the execution of the configuration file;
[0015] The prediction and execution module is used to: predict the next statement to be executed that can be matched based on the probability, and match it; when the match is successful, directly execute the matched prediction command.
[0016] In conjunction with the second aspect, in one implementation, the learning module dynamically learns the probability of the occurrence of the next command after each command, specifically including the following operations:
[0017] The learning module establishes a lookup table to record the probability of the next command appearing for each command that has been executed. The lookup table is generated through dynamic learning, and after each command is executed, the lookup table is updated using the combination of the current command and the previous command.
[0018] In conjunction with the second aspect, in one implementation, the index of the lookup table established by the learning module is each command that has been executed in the current configuration file; the contents of the lookup table entries are a set of the next command after each command in the current configuration file, sorted from largest to smallest according to the number of times they have appeared; the elements of the set are the next command and the count of the command's appearance.
[0019] In conjunction with the second aspect, in one implementation, the prediction command predicted by the prediction and execution module is one or more commands.
[0020] In conjunction with the second aspect, in one implementation, the prediction and execution module predicts the matching command that can be matched with the next statement to be executed based on the probability, and matches it, specifically including the following operations:
[0021] When executing the next statement, the prediction and execution module uses the previous command as an index to search in the lookup table;
[0022] If found, the top-ranked command in the corresponding table entry set is used as the predicted command and matched with the statement to be executed.
[0023] If not found, the statement to be executed will be matched against the entire set of registered command lines.
[0024] The beneficial effects of the technical solutions provided in this application include:
[0025] This embodiment leverages the fixed format of command statements in the configuration file. During execution, it dynamically learns the probability of the next command appearing for each command and, based on this, predicts the most likely matching command for the next statement to be executed. Then, it prioritizes matching with the predicted command. When a match is successful (i.e., when the prediction hits), the process of matching with the entire set of registered command lines can be skipped, effectively saving search and matching time. This significantly shortens the execution time of the configuration file, improves processing efficiency, and meets the needs of practical applications. Attached Figure Description
[0026] Figure 1 This is a flowchart illustrating an embodiment of a method for shortening configuration file execution time in a network device according to this application;
[0027] Figure 2A specific example diagram illustrating command matching during the execution of a configuration file;
[0028] Figure 3 This is a flowchart illustrating a method for shortening configuration file execution time in a network device, as shown in the example.
[0029] Figure 4 This is a functional module diagram of an embodiment of the apparatus for shortening configuration file execution time in the network device of this application. Detailed Implementation
[0030] To make the technical problems, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be described in detail below with reference to the accompanying drawings and specific embodiments.
[0031] However, it should be noted that the examples described below are merely specific examples and are not intended to limit the embodiments of the present invention to the specific steps, values, conditions, data, order, etc. All other embodiments obtained by those skilled in the art based on the embodiments in this application without inventive effort are within the scope of protection of this application.
[0032] Example 1
[0033] See Figure 1 As shown, this embodiment provides a method for shortening the configuration file execution time in a network device, the method including the following steps:
[0034] A. During the execution of the configuration file, dynamically learn the probability of the next command appearing after each command;
[0035] B. Based on the probability, predict the next statement to be executed that can be matched with the predicted command, and match it with the predicted command; when the match is successful, execute the matched predicted command directly.
[0036] It is understandable that the command statements in the configuration file (or configuration script) are not randomly distributed, but arranged according to a fixed format (generally a fixed sequence of multi-level nested iterations). Regardless of the format, they generally share the characteristic that the next command after each command is fixed most of the time. Therefore, based on this premise, this embodiment proposes a solution: leveraging the fixed format of command statements in the configuration file, during execution, the probability of the next command after each command is dynamically learned, and based on this, one or more commands that are most likely to match the next statement to be executed are predicted, and then matched with the predicted commands first; when the prediction is successful, the matching with the entire set of registered command lines can be skipped, thereby reducing the execution time.
[0037] Furthermore, as an optional implementation, in this embodiment, when dynamically learning the probability of the next command to appear for each command, a lookup table can be established to record the probability of the next command to appear for each command that has been executed; the lookup table is generated through dynamic learning, and after each command is executed, the lookup table is updated using the combination of the current command and the previous command.
[0038] In this embodiment, the index of the lookup table is each command that has been executed in the current configuration file; the content of each entry is a set of the next command after each command in the current configuration file, sorted in descending order of frequency; the elements of the set are the next command and the count of the command's occurrence. For example, in the executed command sequence AAABB, the case where the next command after A is A appears twice, and the case where the next command after B appears once. That is, the content of entry A is the set {A:2,B:1}. Furthermore, it can be understood that this lookup table is initially empty and will be gradually updated through learning during the execution of the configuration file.
[0039] For example, in practical applications, step A involves dynamically learning the probability of the next command appearing for each command, specifically including the following operations:
[0040] A1. Each time the configuration file is executed, a lookup table is created.
[0041] A2. After each statement is executed, the previous command is used as an index to search the lookup table. If the statement is not found, a new entry is added to the current lookup table, and the process proceeds to step A3. If the statement is found, the process proceeds directly to step A3.
[0042] A3. Add the current command to the set of the next command in the corresponding table entry, and update the count and sort. Specifically, if the current command does not exist in the set, add it to the end of the set, and set the count (the count of commands that have appeared) to 1; if the current command already exists in the set, increment the count of the corresponding command by 1, and if the count exceeds the count of the preceding commands, move the sort of the current command forward, until the entire set satisfies the descending order of counts.
[0043] Furthermore, as an optional implementation, step B in this embodiment may include:
[0044] B1. When executing the next statement, the previous command is used as an index to search the lookup table. If the result is found, proceed to step B2; otherwise, proceed to step B3.
[0045] B2. Use one or more commands ranked first in the corresponding table set as prediction commands and match them with the statement to be executed; if the match fails, proceed to step B3; if the match succeeds, execute the matched command. It is understood that in actual operation, the number of prediction commands selected can be set and adjusted according to specific application requirements, and this embodiment does not impose a specific limitation.
[0046] B3. Following the traditional method, the statement to be executed is matched against the entire set of registered command lines, and the matched command is executed.
[0047] Understandably, in this embodiment, the command most likely to match the next statement is predicted based on the existing lookup table (i.e., one or more commands ranked at the top of the corresponding table entry set), and these predicted commands are matched first. If the match is successful, that is, the prediction is hit, the process of matching with the entire set of command lines can be skipped, and the process of executing the processing function can be directly entered, which can save a lot of time.
[0048] For example, see Figure 2 As shown, Figure 2 This is a specific example diagram illustrating command matching during the execution of a configuration file. For example... Figure 2 As shown, assuming command A in the configuration file has been executed and the next question mark statement is about to be executed, a lookup using command A reveals that among the executed statements, the next command after command A appears most frequently, 15 times; followed by B, 7 times (e.g., ...). Figure 2 (See the lookup table above). For the next question mark statement, the most likely matches are commands A and B, so we prioritize matching with A and B. Assuming a successful match for B, we update the count in the lookup table for when the next command after A is B to 8 (e.g., ...). Figure 2 The lookup table is shown below. Assuming execution continues with the next question mark statement after B, a lookup using command B reveals that among the executed statements, the next command after B appears most frequently, 10 times; followed by C, 5 times (e.g., ...). Figure 2 (See the lookup table below). For the next question mark statement following B, the most likely matches are commands B and C, so we prioritize matching with B and C. Using this approach, the probability of a match is actually very high. Most of the time, the statement only needs to match a small number of predicted commands, rather than the entire set of registered command lines, thus significantly reducing the configuration file execution time.
[0049] To better understand the overall flow of the first embodiment of the method for shortening configuration file execution time in the network device of this application, the following will be combined with... Figure 3As shown, a specific example is used to illustrate the overall implementation process of Embodiment 1 above. For example... Figure 3 As shown, a method for shortening the configuration file execution time in a network device includes:
[0050] S301. After starting the configuration file execution, the lookup table is established and initialized;
[0051] S302. Use the previous command as an index to search in the lookup table. If found, proceed to step S303; if not found, proceed to step S304. It is understandable that when the first command is executed, since there is no previous command and the lookup table is still empty, it will not be found in the lookup table. Therefore, it will proceed to step S304 to perform the matching of the entire set of command lines in the traditional way, and then complete the learning and update the lookup table.
[0052] S303. Use one or more commands ranked first in the set of corresponding entries as the predicted command and match them with the statement to be executed; if the match fails, proceed to step S304; if the match succeeds, proceed to step S305.
[0053] S304. Following the traditional method, match the statement to be executed with the complete set of registered command lines, and proceed to step S305.
[0054] S305. Execute the matched command and proceed to step S306;
[0055] S306. Use the previous command as an index to search in the lookup table. If not found, proceed to step S307; if found, proceed to step S308.
[0056] S307. Add a new entry to the current lookup table and proceed to step S308;
[0057] S308. Add the current command to the set of the next command for the corresponding table entry, and update the count and sort.
[0058] S309. Determine whether to continue executing the next statement. If yes, return to step S302; otherwise, end the execution of the configuration file.
[0059] As can be seen from the above, this solution utilizes the fixed format of command statements in the configuration file. During execution, it dynamically learns the probability of the next command appearing after each command, and based on this, predicts one or more commands that are most likely to match the next statement to be executed. Then, it prioritizes matching with the predicted commands. When a match is successful (i.e., when the prediction is correct), the process of matching with the entire set of registered command lines can be skipped, effectively saving search and matching time, thereby significantly shortening the execution time of the configuration file, improving execution efficiency, and meeting the needs of practical applications.
[0060] Example 2
[0061] join Figure 4 As shown, based on the same inventive concept, this embodiment of the invention also provides an apparatus for shortening the execution time of configuration files in a network device, the apparatus comprising: a learning module and a prediction and execution module.
[0062] The learning module is used to dynamically learn the probability of the next command appearing after each command during the execution of the configuration file. The prediction and execution module is used to predict the command that can be matched with the next statement to be executed based on the probability, and match it with the predicted command; when the match is successful, the matched predicted command is executed directly.
[0063] Understandably, in this embodiment, the learning module can dynamically learn the probability of the next command appearing after each command during the configuration file execution process. Based on the learned probability, the prediction and execution module can predict one or more commands that are most likely to match the next statement to be executed, and then prioritize matching with the predicted commands. When a match is successful (i.e., when the prediction is correct), the process of matching with the entire set of registered command lines can be skipped, effectively saving search and matching time, thereby significantly shortening the execution time of the configuration file, improving execution efficiency, and meeting the needs of practical applications.
[0064] It should be noted that the various variations and specific examples in the foregoing method embodiments are also applicable to the device in this embodiment. Through the detailed description of the foregoing method, those skilled in the art can clearly understand the implementation method of the device in this embodiment. Therefore, for the sake of brevity, they will not be described in detail here.
[0065] Note: The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0066] The terms "comprising" and "having," and any variations thereof, in the specification, claims, and accompanying drawings of this application are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to such process, method, product, or apparatus. The terms "first," "second," and "third," etc., are used to distinguish different objects, etc., and do not indicate a sequence, nor do they limit "first," "second," and "third" to different types.
[0067] In the description of the embodiments of this application, terms such as "exemplary," "for example," or "for instance" are used to indicate examples, illustrations, or explanations. Any embodiment or design described as "exemplary," "for example," or "for instance" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or designs. Specifically, the use of terms such as "exemplary," "for example," or "for instance" is intended to present the relevant concepts in a concrete manner.
[0068] In the description of the embodiments of this application, unless otherwise stated, " / " means "or". For example, A / B can mean A or B. The "and / or" in the text is merely a description of the relationship between related objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist simultaneously, and B exists alone. In addition, in the description of the embodiments of this application, "multiple" means two or more.
[0069] In some processes described in the embodiments of this application, multiple operations or steps are included in a specific order. However, it should be understood that these operations or steps may not be executed in the order they appear in the embodiments of this application, or they may be executed in parallel. The sequence number of the operation is only used to distinguish different operations, and the sequence number itself does not represent any execution order. In addition, these processes may include more or fewer operations, and these operations or steps may be executed sequentially or in parallel, and these operations or steps may be combined.
[0070] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes several instructions to cause a terminal device to execute the methods described in the various embodiments of this application.
[0071] The above are merely preferred embodiments of this application and do not limit the patent scope of this application. Any equivalent structural or procedural transformations made using the content of this application's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of this application.
Claims
1. A method for shortening the execution time of configuration files in a network device, characterized in that, The method includes: During the execution of the configuration file, the probability of the next command appearing for each command is dynamically learned, including: establishing a lookup table to record the probability of the next command appearing for each command that has been executed; the index of the lookup table is each command that has been executed in the current configuration file; the contents of the table entries are a set of the next commands for each command in the current configuration file, sorted from largest to smallest according to the number of times they have appeared; the elements of the set are the next command and the count of the command's appearance. Based on the probability, predict the next statement to be executed and match it; when the match is successful, execute the matched prediction command directly. The process of predicting the next statement to be executed based on the probability and matching it includes: when executing the next statement, using the previous command as an index to search in the lookup table; If found, the top-ranked command in the corresponding table entry set is used as the predicted command and matched with the statement to be executed. If not found, the statement to be executed will be matched against the entire set of registered command lines.
2. The method for shortening configuration file execution time in a network device as described in claim 1, characterized in that, The lookup table is generated through dynamic learning. After each command is executed, the lookup table is updated using the combination of the command and the previous command.
3. The method for shortening configuration file execution time in a network device as described in claim 2, characterized in that: The matchable prediction command can be one or more commands.
4. An apparatus for shortening the execution time of a configuration file in a network device, characterized in that: The device includes a learning module and a prediction and execution module; The learning module is used to: dynamically learn the probability of the next command appearing for each command during the execution of the configuration file, including: establishing a lookup table to record the probability of the next command appearing for each command that has been executed; the index of the lookup table is each command that has been executed in the current configuration file; the contents of the table entries are a set of the next commands for each command in the current configuration file, sorted in descending order of the number of times they have appeared; the elements of the set are the next command and the count of the command's appearance. The prediction and execution module is used to: predict the next statement to be executed based on the probability and match it; when the match is successful, directly execute the matched prediction command. The prediction and execution module predicts the matching command that can be matched with the next statement to be executed based on the probability, and matches it, including: when executing the next statement, using the previous command as an index to search in the lookup table; If found, the top-ranked command in the corresponding table entry set is used as the predicted command and matched with the statement to be executed. If not found, the statement to be executed will be matched against the entire set of registered command lines.
5. The apparatus for shortening configuration file execution time in a network device as described in claim 4, characterized in that, The lookup table is generated through dynamic learning. After each command is executed, the lookup table is updated using the combination of the command and the previous command.
6. The apparatus for shortening configuration file execution time in a network device as described in claim 5, characterized in that: The prediction command of the prediction and execution module can be one or more commands.
Citation Information
Patent Citations
Semiconductor device, method of controlling the same, and control program therefor
JP2011034408A
Method for improving data transmission speed in datastorage system and disc drive using the same
KR1020050024935A