Token bucket algorithm test method and device, computer equipment and storage medium
By automatically generating the acquisition command and data processing command for different types of token bucket samples, and combining the error comparison between the actual token bucket linear function and the theoretical token bucket linear function, the problem of limited token bucket parameters in the existing technology is solved. Improves the accuracy and efficiency of testing, achieving deeper and broader test coverage.
Patent Information
- Application Number
- CN202411203705.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-29
- Publication Date
- 2024-12-17
AI Technical Summary
In the prior art, the token bucket algorithm test method for multifunctional NVMe storage devices is not aware of user scenarios and the token bucket parameters are limited, resulting in insufficient test samples and low accuracy of the test results obtained.
By generating token bucket samples to obtain commands and data processing commands, according to the pre-tested token bucket algorithm type, the commands and data processing commands for different types of token bucket samples are automatically generated to ensure that the test instructions match the actual application scenario, and By comparing whether the error between the actual token bucket linear function and the theoretical token bucket linear function is within the preset error range, we judge whether the token bucket algorithm test passes.
It improves the accuracy and efficiency of token bucket algorithm testing, ensures the depth and wide applicability of test results, reduces the workload and time cost of manual parameter adjustment, and achieves more complete test sample coverage and deeper testing levels.
Smart Images

Figure CN119155208A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of performance testing, and in particular to a token bucket algorithm testing method, device, computer equipment and storage medium. Background Art
[0002] With the development of information technology, the requirements for data center server storage bandwidth are getting higher and higher. Researchers have designed many multi-channel based current limiting algorithms, and testers are required to test the functional correctness of the multi-channel based current limiting algorithms.
[0003] In the related art, the token bucket algorithm of the multifunctional NVMe storage device is tested by constructing different token bucket parameters, and determining the theoretical bandwidth corresponding to the different token bucket parameters of the storage device according to the different token bucket parameters and the token bucket linear function of the hardware design. The host sends different token bucket parameters to different functions in the storage device. For any function, the function executes data transmission according to the read and write commands and token bucket parameters issued by the host, and the host obtains the actual bandwidth of the function, and compares the actual bandwidth of the function with the theoretical bandwidth to determine whether the function effectively performs data transmission current limiting according to the designed token bucket linear function.
[0004] In the related art, the token bucket algorithm testing method for multi-functional NVMe storage devices is insufficient because product developers do not understand user scenarios and the constructed token bucket parameters are limited, resulting in insufficient test samples and low accuracy of the test results of the token bucket algorithm. Summary of the invention
[0005] In view of this, the present invention provides a token bucket algorithm testing method, device, computer equipment and storage medium to solve the problem in the related art that the product developers do not understand the user scenarios, the constructed token bucket parameters are limited, resulting in insufficient test samples and low accuracy of the test results of the token bucket algorithm obtained.
[0006] In a first aspect, the present invention provides a token bucket algorithm testing method, which is applied to a host side, and the method comprises:
[0007] Generate a token bucket sample acquisition command and a data processing command according to the pre-tested token bucket algorithm type;
[0008] Sending the token bucket sample acquisition command and the data processing command to the storage device, so that the storage device executes the token bucket sample acquisition command and the data processing command, obtains the actual bandwidth value corresponding to each token bucket sample, and sends the actual bandwidth value corresponding to each token bucket sample to the host end;
[0009] Based on the actual bandwidth value corresponding to each token bucket sample, determine the average bandwidth value corresponding to the token bucket sample;
[0010] Based on the token bucket sample acquisition command, determine a theoretical bandwidth value corresponding to the token bucket sample;
[0011] Determine an actual token bucket linear function based on a theoretical bandwidth value and an average bandwidth value corresponding to the token bucket sample;
[0012] Determine whether the error between the actual token bucket linear function and the theoretical token bucket linear function is within a preset error range;
[0013] When the error between the actual token bucket linear function and the theoretical token bucket linear function is within a preset error range, it is determined that the token bucket algorithm test has passed.
[0014] The token bucket algorithm testing method provided in this embodiment determines whether the token bucket algorithm test passes by comparing the error between the actual token bucket linear function and the theoretical token bucket linear function to see whether it is within a preset error range. More token bucket parameters can be covered by the change trend of the actual linear function, making the test sample more sufficient, and by comparing the error between the actual token bucket linear function and the theoretical token bucket linear function, the trend difference between the actual token bucket linear function and the theoretical token bucket linear function can be compared at the data theory level, and the test level is deeper, thereby improving the accuracy of the test results of the token bucket algorithm obtained.
[0015] In an optional implementation, the generating of a token bucket sample acquisition command and a data processing command according to a pre-tested token bucket algorithm type includes:
[0016] When the token bucket algorithm type of the pre-test is the token bucket algorithm for reading data, a token bucket sample acquisition command and a read command are generated;
[0017] When the token bucket algorithm type of the pre-test is the token bucket algorithm for writing data, a token bucket sample acquisition command and a write command are generated.
[0018] The token bucket algorithm testing method provided in this embodiment automatically generates corresponding token bucket sample acquisition commands and data processing commands according to different types of token bucket algorithm types, thereby ensuring the matching of test instructions with actual application scenarios and improving the accuracy and efficiency of the test.
[0019] In an optional implementation, the generating of a token bucket sample acquisition command and a data processing command according to a pre-tested token bucket algorithm type includes:
[0020] According to the pre-tested token bucket algorithm type and the protocol corresponding to the storage device, a token bucket sample acquisition command and a data processing command that conform to the protocol corresponding to the storage device are generated.
[0021] The token bucket algorithm testing method provided in this embodiment ensures the perfect connection between the test command and the storage device by customizing the token bucket sample acquisition command and the data processing command according to the specific protocol of the storage device, avoids test errors or failures caused by protocol mismatch, and improves the wide applicability and accuracy of the test.
[0022] In an optional implementation, sending the token bucket sample acquisition command and the data processing command to a storage device includes:
[0023] A token bucket sample acquisition command is sent to a token bucket sample acquisition command queue, and a data processing command is sent to a data processing command queue, so that the storage device obtains the token bucket sample acquisition command from the token bucket sample acquisition command queue based on the token bucket sample acquisition command queue address, and obtains the data processing command from the data processing command queue based on the data processing command queue address.
[0024] The token bucket algorithm testing method provided in this embodiment can realize asynchronous processing of commands by placing token bucket sample acquisition commands and data processing commands into independent queues. The storage device can obtain and execute commands from two queues in parallel, which significantly improves processing efficiency and reduces the time delay of command waiting and execution.
[0025] In an optional implementation, determining the theoretical bandwidth value corresponding to the token bucket sample based on the token bucket sample acquisition command includes:
[0026] Obtaining token bucket parameters in the token bucket sample acquisition command, wherein the token bucket parameters include a token replenishment interval and a single token replenishment number;
[0027] Based on the token bucket parameters, the theoretical bandwidth value corresponding to the token bucket sample is determined by the following formula:
[0028]
[0029] Wherein, y(x) is the theoretical bandwidth value corresponding to the token bucket sample, M is the number of tokens replenished at a time, and T is the token replenishment interval.
[0030] The token bucket algorithm testing method provided in this embodiment quantifies the token bucket mechanism through a mathematical formula, and can accurately calculate the theoretical bandwidth value corresponding to the token bucket sample, thereby ensuring the accuracy of the token bucket algorithm test.
[0031] In an optional implementation, determining the actual token bucket linear function based on the theoretical bandwidth value and the average bandwidth value corresponding to the token bucket sample includes:
[0032] Determine the loss function based on the theoretical token bucket linear function and the average bandwidth value;
[0033] Determine a deviation between the theoretical bandwidth value and the average bandwidth value based on the theoretical bandwidth value and the average bandwidth value corresponding to the token bucket sample;
[0034] Based on the deviation between the theoretical bandwidth value and the average bandwidth value, the first variable and the second variable in the loss function are adjusted until the deviation between the theoretical bandwidth value and the average bandwidth value is reduced to a preset deviation range to obtain an actual token bucket linear function.
[0035] The token bucket algorithm testing method provided in this embodiment can dynamically adjust the theoretical token bucket linear function to approximate the bandwidth performance during actual runtime through the introduction and optimization of the loss function, so as to obtain the actual token bucket linear function, and then determine the test result of the token bucket algorithm based on the difference between the actual token bucket linear function and the theoretical token bucket linear function, thereby ensuring the accuracy of the test result of the token bucket algorithm.
[0036] In an optional implementation, adjusting the first variable and the second variable in the loss function based on the deviation between the theoretical bandwidth value and the average bandwidth value includes:
[0037] Based on the deviation between the theoretical bandwidth value and the average bandwidth value, the first variable and the second variable in the loss function are adjusted by the following formula:
[0038] k 新 =k 旧 -weight×l k (x)
[0039] b 新 =b 旧 -weight×l b (x)
[0040] Among them, k 新 is the first variable after adjustment, k 旧 is the first variable before adjustment, weight is the learning rate, l k (x) is the partial derivative of the loss function with respect to the first variable, b 新 is the adjusted second variable, b 旧 is the second variable before adjustment, l b (x) is the partial derivative of the loss function with respect to the second variable.
[0041] The token bucket algorithm testing method provided in this embodiment realizes the automation of the optimization process by introducing the gradient descent method to automatically adjust the variables in the loss function. This method can efficiently explore the parameter space and find the optimal solution that minimizes the loss function, greatly reducing the workload and time cost of manual parameter adjustment.
[0042] In an optional implementation, the determining whether an error between an actual token bucket linear function and a theoretical token bucket linear function is within a preset error range includes:
[0043] Determine whether an error between a first variable in an actual token bucket linear function and a first variable in a theoretical token bucket linear function is within an error range of a preset first variable;
[0044] Determine whether an error between a second variable in an actual token bucket linear function and a second variable in a theoretical token bucket linear function is within an error range of a preset second variable;
[0045] When the error between the first variable in the actual token bucket linear function and the first variable in the theoretical token bucket linear function is within the error range of the preset first variable, and the error between the second variable in the actual token bucket linear function and the second variable in the theoretical token bucket linear function is within the error range of the preset second variable, it is determined that the token bucket algorithm test has passed.
[0046] The token bucket algorithm testing method provided in this embodiment can ensure the accuracy of the test results of the token bucket algorithm by respectively determining whether the error between the first variable in the actual token bucket linear function and the second variable in the theoretical token bucket linear function is within a preset error range, and then determining whether the token bucket algorithm test passes.
[0047] In an optional embodiment, the method further includes:
[0048] If the error between the first variable in the actual token bucket linear function and the first variable in the theoretical token bucket linear function is not within the error range of the preset first variable, or the error between the second variable in the actual token bucket linear function and the second variable in the theoretical token bucket linear function is not within the error range of the preset second variable, it is determined that the token bucket algorithm test has failed.
[0049] The token bucket algorithm testing method provided in this embodiment can ensure the accuracy of the test results of the token bucket algorithm by respectively determining whether the error between the first variable in the actual token bucket linear function and the second variable in the theoretical token bucket linear function is within a preset error range, and then determining whether the token bucket algorithm test passes.
[0050] In a second aspect, the present invention provides a token bucket algorithm testing method, which is applied to a storage device, and the method comprises:
[0051] Receiving a token bucket sample acquisition command and a data processing command sent by a host end, wherein the host end generates a token bucket sample acquisition command and a data processing command according to a pre-tested token bucket algorithm type;
[0052] Execute the token bucket sample acquisition command and the data processing command to obtain the actual bandwidth value corresponding to each token bucket sample, and send the actual bandwidth value corresponding to each token bucket sample to the host end, so that the host end determines the average bandwidth value corresponding to the token bucket sample based on the actual bandwidth value corresponding to each token bucket sample, determines the theoretical bandwidth value corresponding to the token bucket sample based on the token bucket sample acquisition command, determines the actual token bucket linear function based on the theoretical bandwidth value and the average bandwidth value corresponding to the token bucket sample, and determines whether the error between the actual token bucket linear function and the theoretical token bucket linear function is within a preset error range. If the error between the actual token bucket linear function and the theoretical token bucket linear function is within the preset error range, determine that the token bucket algorithm test is passed.
[0053] The token bucket algorithm testing method provided in this embodiment determines whether the token bucket algorithm test passes by comparing the error between the actual token bucket linear function and the theoretical token bucket linear function to see whether it is within a preset error range. More token bucket parameters can be covered by the change trend of the actual linear function, making the test sample more sufficient, and by comparing the error between the actual token bucket linear function and the theoretical token bucket linear function, the trend difference between the actual token bucket linear function and the theoretical token bucket linear function can be compared at the data theory level, and the test level is deeper, thereby improving the accuracy of the test results of the token bucket algorithm obtained.
[0054] In an optional implementation manner, the receiving the token bucket sample acquisition command and the data processing command sent by the host end includes:
[0055] Reading a data processing command queue address from a first address register, and acquiring a data processing command from the data processing command queue based on the data processing command queue address;
[0056] The token bucket sample acquisition command queue address is read from the second address register, and the token bucket sample acquisition command is acquired from the token bucket sample acquisition command queue based on the token bucket sample acquisition command queue address.
[0057] The token bucket algorithm testing method provided in this embodiment reduces the intermediate processing links by directly reading the command queue address from the address register, accelerates the process of obtaining data processing commands from the queue and obtaining commands from token bucket samples, improves the system response speed, and ensures the efficiency of command processing.
[0058] In an optional implementation, executing the data processing command includes:
[0059] Parsing the data processing command to determine the type of the data processing command and data processing parameters of the data processing command;
[0060] In a case where the type of the data processing command is a read command, executing the read command based on the data processing parameter;
[0061] In a case where the type of the data processing command is a write command, the write command is executed based on the data processing parameter.
[0062] The token bucket algorithm testing method provided in this embodiment dynamically executes read operations or write operations according to the type of data processing commands. This flexibility can cope with diverse data processing requirements and enable the system to support more complex business logic.
[0063] In an optional implementation, executing the token bucket sample acquisition command includes:
[0064] Parsing the token bucket sample acquisition command to obtain token bucket parameters;
[0065] Determining a token type based on the token bucket parameters;
[0066] When the token type is a read token type, writing the token bucket parameter into a read token parameter register;
[0067] When the token type is a write token type, writing the token bucket parameter into a write token parameter register;
[0068] Data transmission control and sample collection control are performed based on the token bucket parameters in the read token parameter register or the token bucket parameters in the write token parameter register.
[0069] The token bucket algorithm testing method provided in this embodiment realizes more precise data transmission control and sample collection control strategy by distinguishing between read token and write token types and writing corresponding token bucket parameters into corresponding registers, thereby improving the testing efficiency of the token bucket algorithm and the accuracy of the test results.
[0070] In an optional implementation, the data transmission control and sample collection control based on the token bucket parameters in the read token parameter register or the token bucket parameters in the write token parameter register include:
[0071] Performing data transmission control based on the token replenishment interval and the number of tokens replenished at a time in the token bucket parameters;
[0072] The sample collection control is performed based on the sample collection interval and the number of sample collection in the token bucket parameters.
[0073] The token bucket algorithm testing method provided in this embodiment realizes intelligent regulation of network traffic by dynamically adjusting the data transmission rate according to the token replenishment interval and the number of single replenishments in the token bucket parameters, and controls sample collection according to the sample collection interval and the number of collections, thereby ensuring that the required samples can be collected on time and in quantity during network monitoring, thereby improving the testing efficiency of the token bucket algorithm and the accuracy of the test results.
[0074] In an optional embodiment, the method further includes:
[0075] A first command status code is generated according to the execution status of the data processing command, and the first command status code is written into a first response queue, so that the host side obtains the first command status code from the first response queue, and determines the execution status of the data processing command based on the first command status code. When the execution status of the data processing command is that the data processing command is successfully executed, the data processing command continues to be sent. When the execution status of the data processing command is that the data processing command is failed to execute, the test process is exited.
[0076] The token bucket algorithm testing method provided in this embodiment automatically determines whether the data processing command is executed successfully according to the first command status code, and can respond quickly when the execution fails and exit the test process in time. When the data processing command is executed successfully, the system can seamlessly continue to send subsequent data processing commands without waiting for manual confirmation, thereby maintaining the continuity of the processing flow and improving the overall execution efficiency.
[0077] In an optional embodiment, the method further includes:
[0078] A second command status code is generated according to the execution status of the token bucket sample acquisition command, and the second command status code is written into the second response queue, so that the host end obtains the second command status code from the second response queue, and the execution status of the token bucket sample acquisition command is determined based on the second command status code. When the execution status of the token bucket sample acquisition command is that the token bucket sample acquisition command is successfully executed, the step of sending the actual bandwidth value corresponding to each token bucket sample to the host end is performed. When the execution status of the data processing command is that the token bucket sample acquisition command fails to execute, the test process is exited.
[0079] The token bucket algorithm testing method provided in this embodiment automatically determines the execution result of the token bucket sample acquisition command based on the second command status code, can respond quickly when an execution failure occurs, and immediately exit the test process. When the token bucket sample acquisition command is executed successfully, it continues to send the actual bandwidth value to the host side to determine the actual token bucket linear function, and then determine the test result of the token bucket algorithm.
[0080] In a third aspect, the present invention provides a token bucket algorithm testing device, which is applied to a host side, and the device comprises:
[0081] A first generating module, used for generating a token bucket sample acquisition command and a data processing command according to a pre-tested token bucket algorithm type;
[0082] A first sending module is used to send the token bucket sample acquisition command and the data processing command to the storage device, so that the storage device executes the token bucket sample acquisition command and the data processing command, obtains the actual bandwidth value corresponding to each token bucket sample, and sends the actual bandwidth value corresponding to each token bucket sample to the host end;
[0083] A first determination module, configured to determine an average bandwidth value corresponding to each token bucket sample based on an actual bandwidth value corresponding to each token bucket sample;
[0084] A second determination module, configured to determine a theoretical bandwidth value corresponding to the token bucket sample based on the token bucket sample acquisition command;
[0085] A third determination module, configured to determine an actual token bucket linear function based on a theoretical bandwidth value and an average bandwidth value corresponding to the token bucket sample;
[0086] A first judgment module is used to judge whether the error between the actual token bucket linear function and the theoretical token bucket linear function is within a preset error range;
[0087] The fourth determination module is used to determine whether the token bucket algorithm test has passed when the error between the actual token bucket linear function and the theoretical token bucket linear function is within a preset error range.
[0088] In a fourth aspect, the present invention provides a token bucket algorithm testing device, which is applied to a storage device, and the device comprises:
[0089] A first receiving module, used for receiving a token bucket sample acquisition command and a data processing command sent by a host end, wherein the host end generates a token bucket sample acquisition command and a data processing command according to a pre-tested token bucket algorithm type;
[0090] The first execution module is used to execute the token bucket sample acquisition command and the data processing command, obtain the actual bandwidth value corresponding to each token bucket sample, and send the actual bandwidth value corresponding to each token bucket sample to the host end, so that the host end determines the average bandwidth value corresponding to the token bucket sample based on the actual bandwidth value corresponding to each token bucket sample, determines the theoretical bandwidth value corresponding to the token bucket sample based on the token bucket sample acquisition command, determines the actual token bucket linear function based on the theoretical bandwidth value and the average bandwidth value corresponding to the token bucket sample, determines whether the error between the actual token bucket linear function and the theoretical token bucket linear function is within a preset error range, and determines that the token bucket algorithm test is passed when the error between the actual token bucket linear function and the theoretical token bucket linear function is within the preset error range.
[0091] In a fifth aspect, the present invention provides a token bucket algorithm testing system, which includes a host end and a storage device end, wherein the host end is used to execute the token bucket algorithm testing method of the above-mentioned first aspect or any corresponding embodiment thereof, and the storage device end is used to execute the token bucket algorithm testing method of the above-mentioned second aspect or any corresponding embodiment thereof.
[0092] In a sixth aspect, the present invention provides a computer device, comprising: a memory and a processor, the memory and the processor are communicatively connected to each other, computer instructions are stored in the memory, and the processor executes the token bucket algorithm testing method of the above-mentioned first aspect or any corresponding embodiment thereof or the token bucket algorithm testing method of the above-mentioned second aspect or any corresponding embodiment thereof by executing the computer instructions.
[0093] In the seventh aspect, the present invention provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the token bucket algorithm testing method of the above-mentioned first aspect or any corresponding embodiment thereof or the token bucket algorithm testing method of the above-mentioned second aspect or any corresponding embodiment thereof.
[0094] In an eighth aspect, the present invention provides a computer program product, comprising computer instructions, wherein the computer instructions are used to enable a computer to execute the token bucket algorithm testing method of the above-mentioned first aspect or any corresponding embodiment thereof or the token bucket algorithm testing method of the above-mentioned second aspect or any corresponding embodiment thereof. BRIEF DESCRIPTION OF THE DRAWINGS
[0095] In order to more clearly illustrate the specific embodiments of the present invention or the technical solutions in the related technologies, the drawings required for use in the specific embodiments or the related technical descriptions will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0096] Figure 1 It is a flowchart of a method for testing a hardware token bucket algorithm of a multi-functional NVMe device in the related art;
[0097] Figure 2 It is a flowchart of a token bucket algorithm testing method according to an embodiment of the present invention;
[0098] Figure 3 is a flow chart of another token bucket algorithm testing method according to an embodiment of the present invention;
[0099] Figure 4 is a schematic diagram of a token bucket sample acquisition command according to an embodiment of the present invention;
[0100] Figure 5 is a schematic diagram of an actual token bucket linear function and a theoretical token bucket linear function in the same plane according to an embodiment of the present invention;
[0101] Figure 6 is a flow chart of another token bucket algorithm testing method according to an embodiment of the present invention;
[0102] Figure 7 is a flow chart of another token bucket algorithm testing method according to an embodiment of the present invention;
[0103] Figure 8 is a structural block diagram of a token bucket algorithm testing device according to an embodiment of the present invention;
[0104] Fig. 9 is a structural block diagram of another token bucket algorithm testing device according to an embodiment of the present invention;
[0105] Fig.10 is a structural block diagram of a token bucket algorithm testing system according to an embodiment of the present invention;
[0106] Fig.11 It is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0107] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0108] With the development of information technologies such as artificial intelligence, the Internet of Things, and cloud computing, the amount of data in various application systems has increased exponentially, and the storage bandwidth requirements for data center servers have become increasingly higher. At the same time, in order to meet the bandwidth requirements of different users, such as providing different bandwidth quotas according to payment standards, researchers have designed many multi-channel-based current limiting algorithms, such as the development of multi-physical function (Physical Function) non-volatile memory host controller interface specification (Non-Volatile Memory Express, referred to as: NVMe) devices, each function (Function) is based on the hardware token bucket algorithm for current limiting. Accordingly, testers are required to test the functional correctness of the multi-channel-based current limiting algorithm, that is, the hardware current limiting algorithm.
[0109] Figure 1 1 is a flow chart of a method for testing a hardware token bucket algorithm of a multifunctional NVMe device in the related art. Figure 1 As shown, the testing method for the hardware token bucket algorithm of the multi-function NVMe device includes the following steps:
[0110] 1) The host constructs different token bucket parameters and inputs the token bucket parameters into the token bucket linear function designed by the hardware. The token bucket linear function designed by the hardware can be y=M×4K / T, where y is the theoretical bandwidth, M is the number of newly added tokens at a time, T is the token increase interval in us, and K is 1024. It should be noted that the token bucket parameters include the number of newly added tokens at a time, i.e., the number of tokens replenished at a time, and the token increase interval, i.e., the token replenishment interval.
[0111] 2) The host side obtains the theoretical bandwidth value. It can be understood that the theoretical bandwidth value is obtained by inputting the token bucket parameters into the token bucket linear function designed by the hardware.
[0112] 3) The host sends the constructed different token bucket parameters to the hardware registers of each Function in the NVMe device, so that each Function in the NVMe device executes the token bucket algorithm according to the corresponding token bucket parameters.
[0113] 4) Use the input / output (IO) transmission tool on the host side to continuously send IO commands to the specific function of the NVMe device.
[0114] 5)NVMe device specific function performs IO data transmission according to the IO command issued by the host.
[0115] 6) The host software counts the IO data length of a specific function within a period of time, calculates the actual bandwidth of the specific function based on the data transmission length and transmission time, and compares the actual bandwidth with the theoretical bandwidth to determine whether the hardware effectively executes the function current limiting function according to the designed token bucket linear function.
[0116] It should be noted that the token bucket algorithm is usually used in computer network transmission systems. It is a method to limit the data transmission rate of a specific channel on a multi-channel system. For example, to limit the data transmission rate of a specific function on a multi-function NVMe device, the algorithm works by setting a token bucket with a fixed capacity, and then adding a specific number of tokens (the number of tokens added at a time) to the token bucket at a certain interval (token increase interval). Each IO data transmission consumes 1 token, and data transmission is not allowed when there is no token. Therefore, by adjusting the token increase interval and the number of tokens added at a time, the channel bandwidth can be limited.
[0117] However, the testing method of the token bucket algorithm of the multi-functional NVMe device in the related art is insufficient in test samples because the product developers do not understand the user scenarios and the constructed token bucket parameters are limited, resulting in low accuracy of the test results of the token bucket algorithm.
[0118] Furthermore, since the test method used is to compare the theoretical bandwidth with the typical value of the actual bandwidth under given token parameters, it cannot rise to the mathematical theoretical level to compare the trend difference between the actual performance curve and the theoretical performance curve, resulting in the test level not being deep enough.
[0119] In addition, the test method of comparing theoretical bandwidth values with actual bandwidth values requires testers to have certain professional qualities, including understanding the working principle of the token bucket algorithm, the differences between different bandwidth values, and manual analysis of actual performance change trends. As a result, the test results cannot be displayed vividly and require certain manual analysis work, resulting in unfriendly test results.
[0120] In addition, the performance statistics process requires the host software to calculate the actual bandwidth of a specific function based on the data transmission length and transmission time. This process will occupy the CPU resources of the test host, which may cause IO command sending delays and affect the actual bandwidth.
[0121] Moreover, the performance statistics process is completed by each tester writing test code individually, and each person uses a different programming style, resulting in the non-standardization of the performance statistics process and poor code readability and portability.
[0122] The embodiment of the present invention provides a token bucket algorithm testing method, which determines whether the token bucket algorithm test is passed by comparing whether the error between the actual token bucket linear function and the theoretical token bucket linear function is within a preset error range. More token bucket parameters can be covered by the change trend of the actual linear function, so that the test sample is more sufficient, and by comparing the error between the actual token bucket linear function and the theoretical token bucket linear function, the trend difference between the actual token bucket linear function and the theoretical token bucket linear function can be compared at the data theory level, and the test level is deeper to achieve the effect of improving the accuracy of the test results of the token bucket algorithm obtained.
[0123] According to an embodiment of the present invention, a token bucket algorithm testing method embodiment is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0124] In this embodiment, a token bucket algorithm testing method is provided, which can be used on a server host. Figure 2 : is a flowchart of a token bucket algorithm testing method according to an embodiment of the present invention. Figure 2 As shown, the process includes the following steps:
[0125] Step S201: Generate a token bucket sample acquisition command and a data processing command according to a pre-tested token bucket algorithm type.
[0126] It is understandable that, if the pre-tested token bucket algorithm type is different, the generated token bucket sample acquisition command and data processing command will be different.
[0127] Step S202, sending a token bucket sample acquisition command and a data processing command to a storage device, so that the storage device executes the token bucket sample acquisition command and the data processing command, obtains an actual bandwidth value corresponding to each token bucket sample, and sends the actual bandwidth value corresponding to each token bucket sample to the host end.
[0128] After generating the token bucket sample acquisition command and the data processing command, the host sends the token bucket sample acquisition command and the data processing command to the storage device. It should be noted that the storage device is a multi-Function NVMe device.
[0129] This embodiment is described by sending a token bucket sample acquisition command and a data processing command to a specific function of a storage device.
[0130] The storage device specific Function executes a token bucket sample acquisition command and a data processing command to obtain an actual bandwidth value corresponding to each token bucket sample in multiple token bucket samples obtained by executing the token bucket sample acquisition command, and sends the actual bandwidth value corresponding to each token bucket sample to the host end.
[0131] Step S203: determining an average bandwidth value corresponding to the token bucket sample based on the actual bandwidth value corresponding to each token bucket sample.
[0132] It can be understood that, for any token bucket sample acquisition command, the average bandwidth value corresponding to the token bucket sample is determined based on the actual bandwidth value corresponding to each token bucket sample corresponding to the token bucket sample acquisition command.
[0133] It should be noted that each token bucket sample corresponding to the token bucket sample acquisition command is each token bucket sample in the multiple token bucket samples obtained by executing the token bucket sample acquisition command.
[0134] Furthermore, the sum of actual bandwidth values corresponding to multiple token bucket samples corresponding to the token bucket sample acquisition command is calculated, and the sum is divided by the number of token bucket samples corresponding to the token bucket sample acquisition command to obtain an average bandwidth value corresponding to the token bucket samples.
[0135] Step S204: determining a theoretical bandwidth value corresponding to the token bucket sample based on the token bucket sample acquisition command.
[0136] After the token bucket sample acquisition command is generated, the theoretical bandwidth value of the token bucket sample corresponding to the token bucket sample acquisition command is determined according to the generated token bucket sample acquisition command.
[0137] Step S205 , determining an actual token bucket linear function based on the theoretical bandwidth value and the average bandwidth value corresponding to the token bucket sample.
[0138] After obtaining the theoretical bandwidth value and the average bandwidth value of the token bucket sample corresponding to the token bucket sample acquisition command, the actual token bucket linear function is determined according to the theoretical bandwidth value and the average bandwidth value corresponding to the token bucket sample.
[0139] Step S206, determining whether the error between the actual token bucket linear function and the theoretical token bucket linear function is within a preset error range.
[0140] After obtaining the actual token bucket linear function, it is determined whether the error between the actual token bucket linear function and the theoretical token bucket linear function is within a preset error range. It should be noted that the theoretical token bucket linear function can be the token bucket linear function y=M×4K / T of the hardware design as described above, that is, y=M×4096 / T.
[0141] The preset error range is set by the technician and is not specifically limited here.
[0142] Step S207: When the error between the actual token bucket linear function and the theoretical token bucket linear function is within a preset error range, it is determined that the token bucket algorithm test has passed.
[0143] Among them, the error between the actual token bucket linear function and the theoretical token bucket linear function is within the preset error range, which determines that the hardware effectively executes the Function current limiting function according to the designed token bucket linear function, and the token bucket algorithm test passes.
[0144] It can be understood that the token bucket algorithm test passes, that is, the token bucket parameter test corresponding to the generated token bucket sample acquisition command passes.
[0145] The token bucket algorithm testing method provided in this embodiment determines whether the token bucket algorithm test is passed, that is, tests the correctness of the hardware token bucket current limiting algorithm function, by comparing whether the error between the actual token bucket linear function and the theoretical token bucket linear function is within a preset error range. More token bucket parameters can be covered through the change trend of the actual linear function, making the test sample more sufficient, and by comparing the error between the actual token bucket linear function and the theoretical token bucket linear function, the trend difference between the actual token bucket linear function and the theoretical token bucket linear function can be compared at the data theory level, and the test level is deeper, which improves the accuracy of the test results of the token bucket algorithm obtained.
[0146] In this embodiment, a token bucket algorithm testing method is provided, which can be used on a storage device side. Figure 3 : is a flowchart of a token bucket algorithm testing method according to an embodiment of the present invention. Figure 3 As shown, the process includes the following steps:
[0147] Step S301: Generate a token bucket sample acquisition command and a data processing command according to the pre-tested token bucket algorithm type.
[0148] Specifically, the above step S301 includes:
[0149] Step S3011, when the pre-tested token bucket algorithm type is a token bucket algorithm for reading data, a token bucket sample acquisition command and a read command are generated.
[0150] It is understandable that if the pre-tested token bucket algorithm type is different, the token bucket sample acquisition command and data processing command generated by the host side will be different.
[0151] The host application layer software sends a token bucket sample acquisition command and a data processing command to the NVMe device specific function. If the pre-tested token bucket algorithm type is a token bucket algorithm for reading data, a read token bucket sample acquisition command and a read command are generated. In other words, the pre-tested token bucket algorithm type is a token bucket algorithm for reading data, the generated data processing command is a read command, and the generated token bucket sample acquisition command is a read token sample acquisition command.
[0152] Step S3012: When the token bucket algorithm type pre-tested is a token bucket algorithm for writing data, a token bucket sample acquisition command and a write command are generated.
[0153] If the token bucket algorithm type of the pre-test is the token bucket algorithm when writing data, a write token bucket sample acquisition command and a write command are generated. That is, if the token bucket algorithm type of the pre-test is the token bucket algorithm when writing data, the generated data processing command is a write command, and the generated token bucket sample acquisition command is a write token sample acquisition command.
[0154] Step S302: Send the token bucket sample acquisition command and the data processing command to the storage device, so that the storage device executes the token bucket sample acquisition command and the data processing command, obtains the actual bandwidth value corresponding to each token bucket sample, and sends the actual bandwidth value corresponding to each token bucket sample to the host. For details, please refer to Figure 2 Step S202 of the illustrated embodiment will not be described in detail here.
[0155] Step S303: Based on the actual bandwidth value corresponding to each token bucket sample, determine the average bandwidth value corresponding to the token bucket sample. Figure 2 Step S203 of the illustrated embodiment will not be described in detail here.
[0156] Step S304: Determine the theoretical bandwidth value corresponding to the token bucket sample based on the token bucket sample acquisition command. Figure 2 Step S204 of the illustrated embodiment will not be described in detail here.
[0157] Step S305 : determining an actual token bucket linear function based on the theoretical bandwidth value and the average bandwidth value corresponding to the token bucket sample.
[0158] Specifically, the above step S305 includes:
[0159] Step S3051, determining a loss function based on a theoretical token bucket linear function and an average bandwidth value.
[0160] It should be noted that this embodiment uses a linear regression model to infer the actual token bucket linear function that represents the conversion relationship between the token bucket parameter and the bandwidth value. The linear regression model is used to solve the prediction problem that conforms to the linear characteristics. The input of the model is a sample data set containing feature attributes and real results. The model can train a linear prediction function suitable for the sample data based on the sample data set, and then input the new sample feature attributes into the linear prediction function, and the linear prediction function can output the corresponding prediction result.
[0161] The inference process of the linear regression model is as follows:
[0162] First, the theoretical token bucket linear function that represents the conversion relationship between token bucket parameters and bandwidth values defined in the hardware design phase is introduced, such as: Where M represents the number of tokens replenished at a time, i.e., the number of newly added tokens three times; T represents the token replenishment interval in us, i.e., the token increase interval.
[0163] The prediction function is defined as: h(x)=kx+b, where k represents the slope, b represents the intercept, and h represents the predicted bandwidth. The initial values of x, k, and b of the prediction function are consistent with the theoretical token bucket performance linear function, that is, x=M / T, k=4096, and b=0.
[0164] Then the loss function l(x)=h(x)-y′(x), where y′(x) is the average bandwidth value corresponding to the token bucket sample.
[0165] Step S3052: Determine the deviation between the theoretical bandwidth value and the average bandwidth value based on the theoretical bandwidth value and the average bandwidth value corresponding to the token bucket sample.
[0166] Secondly, after obtaining the theoretical bandwidth value and the average bandwidth value corresponding to the token bucket sample, the deviation between the theoretical bandwidth value and the average bandwidth value is determined according to the theoretical bandwidth value and the average bandwidth value corresponding to the token bucket sample, that is, the difference between the theoretical bandwidth value and the average bandwidth value is determined.
[0167] Step S3053, based on the deviation between the theoretical bandwidth value and the average bandwidth value, the first variable and the second variable in the loss function are adjusted until the deviation between the theoretical bandwidth value and the average bandwidth value is reduced to within a preset deviation range, thereby obtaining an actual token bucket linear function.
[0168] Among them, the first variable is k and the second variable is b.
[0169] Finally, when the deviation between the theoretical bandwidth value and the average bandwidth value is not within the preset deviation range, the first variable and the second variable in the loss function are continuously adjusted and optimized.
[0170] The deviation between the theoretical bandwidth value and the average bandwidth value is within the preset deviation range, indicating that the loss function is reduced to the minimum. There is no need to further adjust the first variable and the second variable in the loss function. The final h(x) is the actual token bucket linear function.
[0171] Step S306, determine whether the error between the actual token bucket linear function and the theoretical token bucket linear function is within a preset error range. Figure 2 Step S206 of the illustrated embodiment will not be described in detail here.
[0172] Step S307: If the error between the actual token bucket linear function and the theoretical token bucket linear function is within a preset error range, it is determined that the token bucket algorithm test has passed. Figure 2 Step S207 of the illustrated embodiment will not be described in detail here.
[0173] The token bucket algorithm testing method provided in this embodiment automatically generates corresponding token bucket sample acquisition commands and data processing commands according to different types of token bucket algorithm types, thereby ensuring the matching of test instructions with actual application scenarios and improving the accuracy and efficiency of the test.
[0174] Through the introduction and optimization of the loss function, the theoretical token bucket linear function can be dynamically adjusted to approximate the bandwidth performance during actual runtime, so as to obtain the actual token bucket linear function. Then, based on the difference between the actual token bucket linear function and the theoretical token bucket linear function, the test result of the token bucket algorithm is determined, thereby ensuring the accuracy of the test result of the token bucket algorithm.
[0175] In some optional implementations, the above step S301 includes:
[0176] Step a1, generating a token bucket sample acquisition command and a data processing command that conform to the protocol corresponding to the storage device according to the pre-tested token bucket algorithm type and the protocol corresponding to the storage device.
[0177] It should be noted that the protocol corresponding to the storage device is the NVMe protocol. The NVMe protocol defines a set of management IO request / response queue interfaces, which can realize high concurrency and asynchronous submission of IO request commands to the device and processing of IO responses by the host.
[0178] The token bucket algorithm testing method provided in this embodiment ensures the perfect connection between the test command and the storage device by customizing the token bucket sample acquisition command and the data processing command according to the specific protocol of the storage device, avoids test errors or failures caused by protocol mismatch, and improves the wide applicability and accuracy of the test.
[0179] In some optional implementations, the above step S302 includes:
[0180] Step b1, sending the token bucket sample acquisition command to the token bucket sample acquisition command queue, and sending the data processing command to the data processing command queue, so that the storage device obtains the token bucket sample acquisition command from the token bucket sample acquisition command queue based on the token bucket sample acquisition command queue address, and obtains the data processing command from the data processing command queue based on the data processing command queue address.
[0181] The host driver layer software configures the token bucket sample acquisition command queue address to the token bucket sample acquisition command queue address register of the NVMe device specific function, and configures the data processing command queue address to the data processing command queue address register of the NVMe device specific function. The host application layer software sends the token bucket sample acquisition command to the token bucket sample acquisition command queue, and sends the data processing command to the data processing command queue.
[0182] The NVMe device reads the data processing command queue address from the data processing command queue address register, and obtains the data processing command from the data processing command queue based on the data processing command queue address. The data processing command is the IO command, which is the command used by the NVMe protocol to read and write device memory, including read, write, format, check, etc.
[0183] The NVMe device reads the token bucket sample acquisition command queue address from the token bucket sample acquisition command queue address register, and acquires the token bucket sample acquisition command from the token bucket sample acquisition command queue based on the token bucket sample acquisition command queue address.
[0184] The token bucket algorithm testing method provided in this embodiment can realize asynchronous processing of commands by placing token bucket sample acquisition commands and data processing commands into independent queues. The storage device can obtain and execute commands from two queues in parallel, which significantly improves processing efficiency and reduces the time delay of command waiting and execution.
[0185] In some optional implementations, the above step S304 includes:
[0186] Step c1, obtaining token bucket parameters in a token bucket sample obtaining command, where the token bucket parameters include a token replenishment interval and a single token replenishment number.
[0187] in, Figure 4 Schematic diagram of a token bucket sample acquisition command according to an embodiment of the present invention. The token bucket sample acquisition command is as follows: Figure 4 The NVMe protocol custom admin extension command in the format shown. The admin command is the command used by the NVMe protocol to manage devices, including creating queues, deleting queues, and configuring features.
[0188] like Figure 4 As shown, the fields related to the command format in the token bucket sample acquisition command include T001, T002, and T003.
[0189] The T001 command includes 16 dwords, and each dword contains 4 bytes.
[0190] T002 1st byte represents the first byte from low address to high address in dword. 2st byte represents the second byte from low address to high address in dword. 3st byte represents the third byte from low address to high address in dword. 4th byte represents the fourth byte from low address to high address in dword.
[0191] The T003 reserved field indicates a field not used by the NVMe protocol and is used for future extension of the protocol.
[0192] The command valid data fields in the token bucket sample acquisition command include S001, S002, S003, S004, S005, S006, S007, S008, and S009.
[0193] Among them, S001: Operation code = 0xda. Indicates the command type, used to distinguish other types of NVMe commands.
[0194] S002: DMA address format. Indicates the memory block address organization format when the command uses multiple memory blocks of the host. The NVMe protocol has multiple address formats. This command uses the PRP List type address format.
[0195] S003: Command ID. Indicates the command sequence number in the same admin command queue, that is, the token bucket sample obtains the command sequence number in the command queue, which is used to distinguish other commands in the same admin command queue, such as multiple commands of the same type.
[0196] S004: Host Direct Memory Access (DMA) address, indicating the first address of the host PRPList (memory block list).
[0197] S005: Token type. 0 indicates the token parameter of the read command, and 1 indicates the token parameter of the write command.
[0198] S006: Number of tokens replenished at a time. Indicates the number of tokens replenished when the token replenishment interval expires.
[0199] S007: Token replenishment interval. Indicates the token replenishment interval in us.
[0200] S008: Number of samples. Indicates the number of samples that this command needs to collect from the storage device. Each sample is a read bandwidth value or a write bandwidth value, such as 1500MB / s.
[0201] S009: Sample collection interval. Indicates the collection delay between n samples collected by this command, in seconds (s). For example, 10s means reading 1 read bandwidth value or 1 write bandwidth value from the NVMe device every 10 seconds.
[0202] It should be noted that Figure 4 The values corresponding to the various fields contained therein are set by the technicians according to the pre-tested token bucket algorithm type.
[0203] Step c2: Based on the token bucket parameters, the theoretical bandwidth value corresponding to the token bucket sample is determined by the following formula:
[0204]
[0205] Among them, y(x) is the theoretical bandwidth value corresponding to the token bucket sample, M is the number of tokens replenished at a time, and T is the token replenishment interval.
[0206] The token bucket algorithm testing method provided in this embodiment quantifies the token bucket mechanism through a mathematical formula, and can accurately calculate the theoretical bandwidth value corresponding to the token bucket sample, thereby ensuring the accuracy of the token bucket algorithm test.
[0207] In some optional implementations, the above step S3053 includes:
[0208] Step d1, based on the deviation between the theoretical bandwidth value and the average bandwidth value, the first variable and the second variable in the loss function are adjusted by the following formula:
[0209] k 新 =k 旧 -weight×l k (x)
[0210] b 新 =b 旧 -weight×l b (x)
[0211] Among them, k 新 is the first variable after adjustment, k 旧 is the first variable before adjustment, weight is the learning rate, l k (x) is the partial derivative of the loss function with respect to the first variable, b 新 is the adjusted second variable, b 旧 is the second variable before adjustment, l b(x) is the partial derivative of the loss function with respect to the second variable.
[0212] It should be noted that when the deviation between the theoretical bandwidth value and the average bandwidth value is not within the preset deviation range, the optimization method min k,b l(x), that is, adjusting the values of k and b so that the loss function l(x) is minimized to adjust the first variable and the second variable.
[0213] This embodiment uses the gradient descent method to adjust the first variable and the second variable. Among them, the partial derivative of the loss function with respect to the first variable, that is, the partial derivative of the loss function with respect to the slope k, that is, the rate of change of the loss function along the k direction when k is taken as the only independent variable. The partial derivative of the loss function with respect to the second variable, that is, the partial derivative of the loss function with respect to the intercept b, that is, the rate of change of the loss function along the b direction when b is taken as the only independent variable. The learning rate indicates how much is learned from an error. The larger the learning rate, the faster the optimization speed, but it may cause the algorithm to oscillate near the optimal value. The smaller the learning rate, the slower the optimization speed. The learning rate for a single adjustment of the first variable and the second variable is set by a technician.
[0214] The token bucket algorithm testing method provided in this embodiment realizes the automation of the optimization process by introducing the gradient descent method to automatically adjust the variables in the loss function. This method can efficiently explore the parameter space and find the optimal solution that minimizes the loss function, greatly reducing the workload and time cost of manual parameter adjustment.
[0215] In some optional implementations, the above step S306 includes:
[0216] Step e1, determining whether an error between a first variable in an actual token bucket linear function and a first variable in a theoretical token bucket linear function is within an error range of a preset first variable.
[0217] Step e2, determining whether the error between the second variable in the actual token bucket linear function and the second variable in the theoretical token bucket linear function is within the error range of the preset second variable.
[0218] Among them, comparing the actual token bucket linear function with the theoretical token bucket linear function is essentially comparing whether the error between the first variable in the actual token bucket linear function and the first variable of the theoretical token bucket linear function is within the error range of the preset first variable, and comparing whether the error between the second variable in the actual token bucket linear function and the second variable of the theoretical token bucket linear function is within the error range of the preset second variable.
[0219] Step e3, when the error between the first variable in the actual token bucket linear function and the first variable in the theoretical token bucket linear function is within the error range of the preset first variable, and the error between the second variable in the actual token bucket linear function and the second variable in the theoretical token bucket linear function is within the error range of the preset second variable, it is determined that the token bucket algorithm test has passed.
[0220] It can be understood that the error between the first variable in the actual token bucket linear function and the first variable in the theoretical token bucket linear function is within the error range of the preset first variable, and the error between the second variable in the actual token bucket linear function and the second variable in the theoretical token bucket linear function is within the error range of the preset second variable, which determines that the hardware effectively executes the Function current limiting function according to the designed token bucket linear function, and the token bucket algorithm test passes.
[0221] The token bucket algorithm testing method provided in this embodiment can ensure the accuracy of the test results of the token bucket algorithm by respectively determining whether the error between the first variable in the actual token bucket linear function and the second variable in the theoretical token bucket linear function is within a preset error range, and then determining whether the token bucket algorithm test passes.
[0222] In some optional implementations, the token bucket algorithm testing method further includes:
[0223] Step f1, when the error between the first variable in the actual token bucket linear function and the first variable in the theoretical token bucket linear function is not within the error range of the preset first variable, or the error between the second variable in the actual token bucket linear function and the second variable in the theoretical token bucket linear function is not within the error range of the preset second variable, it is determined that the token bucket algorithm test has failed.
[0224] It can be understood that the error between the first variable in the actual token bucket linear function and the first variable in the theoretical token bucket linear function is not within the error range of the preset first variable, or the error between the second variable in the actual token bucket linear function and the second variable in the theoretical token bucket linear function is not within the error range of the preset second variable, and it is determined that the hardware does not effectively execute the Function current limiting function according to the designed token bucket linear function, and the token bucket algorithm test fails.
[0225] It should be noted that the error range of the preset first variable and the error range of the preset second variable are set by technical personnel.
[0226] The token bucket algorithm testing method provided in this embodiment can ensure the accuracy of the test results of the token bucket algorithm by respectively determining whether the error between the first variable in the actual token bucket linear function and the second variable in the theoretical token bucket linear function is within a preset error range, and then determining whether the token bucket algorithm test passes.
[0227] In some optional implementations, after determining the actual token bucket linear function, the token bucket algorithm testing method further includes:
[0228] Step g1, displaying the actual token bucket linear function and the theoretical token bucket linear function in the same plane.
[0229] Figure 5 is a schematic diagram of an actual token bucket linear function and a theoretical token bucket linear function in the same plane according to an embodiment of the present invention. Figure 5 As shown, the actual linear function, i.e., the actual token bucket linear function, may be y=M / T×k+b, and the theoretical linear function, i.e., the theoretical token bucket linear function, may be y=M / T×4096. In which, the abscissa x is the ratio of M to T, and the ordinate y is the bandwidth value in MB / s.
[0230] The token bucket algorithm testing method provided in this embodiment uses a graphical form to display the actual token bucket linear function and the theoretical token bucket linear function, so that the tester can clearly see the difference between the actual token bucket linear function and the theoretical token bucket linear function, and vividly display the test results. There is no need for the tester to manually analyze the changing trend of the bandwidth performance data, and the test results are more user-friendly.
[0231] In this embodiment, a token bucket algorithm testing method is provided, which can be used on a storage device side. Figure 6 : is a flowchart of a token bucket algorithm testing method according to an embodiment of the present invention. Figure 6 As shown, the process includes the following steps:
[0232] Step S601, receiving a token bucket sample acquisition command and a data processing command sent by the host end, wherein the host end generates a token bucket sample acquisition command and a data processing command according to a pre-tested token bucket algorithm type. Figure 2 Steps S201 and S202 of the illustrated embodiment are not described in detail here.
[0233] Step S602, execute the token bucket sample acquisition command and the data processing command, obtain the actual bandwidth value corresponding to each token bucket sample, send the actual bandwidth value corresponding to each token bucket sample to the host side, so that the host side determines the average bandwidth value corresponding to the token bucket sample based on the actual bandwidth value corresponding to each token bucket sample, determines the theoretical bandwidth value corresponding to the token bucket sample based on the token bucket sample acquisition command, determines the actual token bucket linear function based on the theoretical bandwidth value and the average bandwidth value corresponding to the token bucket sample, and determines whether the error between the actual token bucket linear function and the theoretical token bucket linear function is within the preset error range. If the error between the actual token bucket linear function and the theoretical token bucket linear function is within the preset error range, it is determined that the token bucket algorithm test has passed. For details, please refer to Figure 2 Step S202, step S203, step S204, step S205, step S206, and step S207 of the illustrated embodiment are not described in detail here.
[0234] The token bucket algorithm testing method provided in this embodiment determines whether the token bucket algorithm test passes by comparing the error between the actual token bucket linear function and the theoretical token bucket linear function to see whether it is within a preset error range. More token bucket parameters can be covered by the change trend of the actual linear function, making the test sample more sufficient, and by comparing the error between the actual token bucket linear function and the theoretical token bucket linear function, the trend difference between the actual token bucket linear function and the theoretical token bucket linear function can be compared at the data theory level, and the test level is deeper, thereby improving the accuracy of the test results of the token bucket algorithm obtained.
[0235] In some optional implementations, the above step S601 includes:
[0236] Step h1, reading a data processing command queue address from a first address register, and acquiring a data processing command from a data processing command queue based on the data processing command queue address.
[0237] It can be understood that the first address register is the aforementioned data processing command queue address register.
[0238] Step h2: read the token bucket sample acquisition command queue address from the second address register, and acquire the token bucket sample acquisition command from the token bucket sample acquisition command queue based on the token bucket sample acquisition command queue address.
[0239] It can be understood that the second address register is the aforementioned token bucket sample acquisition command queue address register.
[0240] The token bucket algorithm testing method provided in this embodiment reduces the intermediate processing links by directly reading the command queue address from the address register, accelerates the process of obtaining data processing commands from the queue and obtaining commands from token bucket samples, improves the system response speed, and ensures the efficiency of command processing.
[0241] In some optional implementations, executing the data processing command includes:
[0242] Step i1, parsing the data processing command to determine the type of the data processing command and the data processing parameters of the data processing command.
[0243] The storage device parses the data processing command according to the command operation code to determine the type of the data processing command and the data processing parameters of the data processing command.
[0244] It should be noted that the data processing parameters include slba (NVMe device memory starting address), nlb (number of memory blocks), etc.
[0245] Step i2: when the type of the data processing command is a read command, execute the read command based on the data processing parameters.
[0246] It is understandable that the storage device executes the corresponding command according to the type of data processing command and the data processing parameters. If the type of data processing command is a read command, the storage device executes the read command based on the data processing parameters, that is, performs an operation of reading data from the device memory.
[0247] It should be noted that the storage device includes two IO command execution modules, one of which is used to execute a read command based on a data processing parameter when the type of the data processing command is a read command.
[0248] Step i3: when the type of the data processing command is a write command, execute the write command based on the data processing parameters.
[0249] If the data processing command type is a write command, the storage device executes the write command based on the data processing parameters, that is, executes the operation of writing data from the device memory. Another IO command execution module is used to execute the write command based on the data processing parameters when the data processing command type is a write command.
[0250] The token bucket algorithm testing method provided in this embodiment dynamically executes read operations or write operations according to the type of data processing commands. This flexibility can cope with diverse data processing requirements and enable the system to support more complex business logic.
[0251] In some optional implementations, executing a token bucket sample acquisition command includes:
[0252] Step j1, parse the token bucket sample acquisition command to obtain token bucket parameters.
[0253] The token sample acquisition command is parsed according to the command operation code to determine whether the token bucket sample acquisition command is a read token bucket sample acquisition command or a write token bucket sample acquisition command.
[0254] The token bucket parameters such as token type, number of tokens replenished at a time, and token replenishment interval are parsed from the token bucket sample acquisition command. It should be noted that the token bucket parameters in this embodiment also include sample parameters, which include the number of samples, sample collection interval, host DMA address, etc.
[0255] Step j2, determining the token type based on the token bucket parameters.
[0256] Wherein, if the token type is 0, the token type is determined to be a read token type, and if the token type is 1, the token type is determined to be a write token type.
[0257] Step j3, when the token type is a read token type, write the token bucket parameters into the read token parameter register.
[0258] Among them, the token type is a read token type, and the parsed token bucket parameters are written into the hardware's read token bucket parameter register.
[0259] Step j4, when the token type is a write token type, write the token bucket parameters into the write token parameter register.
[0260] Among them, the token type is a write token type, and the parsed token bucket parameters are written into the hardware write token bucket parameter register.
[0261] Step j5, performing data transmission control and sample collection control based on the token bucket parameters in the read token parameter register or the token bucket parameters in the write token parameter register.
[0262] It should be noted that the NVMe device includes two hardware token bucket algorithm execution modules, one of which is used to perform data transmission control and sample collection control according to the token bucket parameters in the read token parameter register. The other token bucket algorithm execution module is used to perform data transmission control and sample collection control according to the token bucket parameters in the write token parameter register.
[0263] The token bucket algorithm testing method provided in this embodiment realizes more precise data transmission control and sample collection control strategy by distinguishing between read token and write token types and writing corresponding token bucket parameters into corresponding registers, thereby improving the testing efficiency of the token bucket algorithm and the accuracy of the test results.
[0264] In some optional implementations, the above step j5 includes:
[0265] Step j51, data transmission control is performed based on the token replenishment interval and the number of tokens replenished at a time in the token bucket parameters.
[0266] The token bucket algorithm execution module performs data transmission control, namely, data transmission current limiting, according to the token bucket replenishment interval and the number of tokens replenished at a time in the token bucket parameters.
[0267] Step j52, performing sample collection control based on the sample collection interval and the number of sample collection in the token bucket parameters.
[0268] The token bucket algorithm execution module controls sample collection according to the sample collection interval and the number of sample collection in the token bucket parameters.
[0269] It should be noted that the NVMe device includes two hardware IO performance statistics modules, wherein one IO performance statistics module is used to count the actual bandwidth value corresponding to each token bucket sample corresponding to the read token sample acquisition command, and write it into the first performance statistics register. The other IO performance statistics module is used to count the actual bandwidth value corresponding to each token bucket sample corresponding to the write token sample acquisition command, and write it into the second performance statistics register.
[0270] The storage device firmware obtains the actual bandwidth value corresponding to each token bucket sample corresponding to the read token sample acquisition command from the first performance statistics register after a delay according to the sample collection interval parameter in the read token sample acquisition command, and writes it as a sample to the host DMA address.
[0271] The storage device firmware obtains the actual bandwidth value corresponding to each token bucket sample corresponding to the write token sample acquisition command from the second performance statistics register after a delay according to the sample collection interval parameter in the write token sample acquisition command, and writes it as a sample to the host DMA address.
[0272] It can be understood that the step of obtaining the actual bandwidth value corresponding to each token bucket sample corresponding to the token sample acquisition command from the performance statistics register is executed cyclically until the number of samples obtained reaches the number of samples in the token sample acquisition command.
[0273] It should be noted that this embodiment obtains samples in a serial execution manner, and the actual hardware digital logic circuit has a parallel execution feature. The performance can be improved by reasonably arranging the instruction pipelines of hardware modules such as the IO command execution module, the token bucket algorithm execution module, the IO performance statistics module, etc., so that the hardware steps can be executed in parallel.
[0274] The token bucket algorithm testing method provided in this embodiment realizes intelligent regulation of network traffic by dynamically adjusting the data transmission rate according to the token replenishment interval and the number of single replenishments in the token bucket parameters, and controls sample collection according to the sample collection interval and the number of collections, thereby ensuring that the required samples can be collected on time and in quantity during network monitoring, thereby improving the testing efficiency of the token bucket algorithm and the accuracy of the test results.
[0275] The token bucket algorithm testing method provided in this embodiment calculates the actual bandwidth through hardware rather than host software. This process can release the CPU resources of the host and save CPU resources, thereby avoiding the impact of data processing command sending delay on the actual bandwidth.
[0276] In some optional implementations, the token bucket algorithm testing method further includes:
[0277] Step k1, generate a first command status code according to the execution status of the data processing command, and write the first command status code into the first response queue, so that the host side obtains the first command status code from the first response queue, and determines the execution status of the data processing command based on the first command status code. When the execution status of the data processing command is that the data processing command is successfully executed, continue to send the data processing command; when the execution status of the data processing command is that the data processing command fails to execute, exit the test process.
[0278] The first command status code is used to indicate whether the data processing command is executed successfully, that is, whether the reading and writing of the device memory is successful.
[0279] The storage device takes out the data processing command response queue address from the data processing command response queue address register, converts the first command status code into a first command status code that complies with the NVMe protocol, and writes the first command status code that complies with the NVMe protocol into the first response queue based on the data processing command response queue address. The first response queue is the data processing command response queue.
[0280] The host-side driver layer software takes out the first command status code from the data processing command response queue.
[0281] The host application layer software parses the first command status code to determine the execution status of the data processing command, that is, to determine whether the data processing command is executed successfully. It should be noted that during the token bucket algorithm test, the host continuously sends the data processing command to the storage device. If the execution status of the data processing command is that the data processing command is executed successfully, the data processing command continues to be sent cyclically, that is, the data processing command continues to be sent continuously to the storage device.
[0282] If the execution status of the data processing command is that the data processing command execution fails, the test process is exited, that is, the execution of the token bucket sample acquisition command and the data processing command is stopped, and the testing of the token bucket algorithm is stopped.
[0283] The token bucket algorithm testing method provided in this embodiment automatically determines whether the data processing command is executed successfully according to the first command status code, and can respond quickly when the execution fails and exit the test process in time. When the data processing command is executed successfully, the system can seamlessly continue to send subsequent data processing commands without waiting for manual confirmation, thereby maintaining the continuity of the processing flow and improving the overall execution efficiency.
[0284] In some optional implementations, the token bucket algorithm testing method further includes:
[0285] Step 11, based on the execution status of the token bucket sample acquisition command, generate a second command status code, and write the second command status code into the second response queue, so that the host side obtains the second command status code from the second response queue, and determines the execution status of the token bucket sample acquisition command based on the second command status code. When the execution status of the token bucket sample acquisition command is that the token bucket sample acquisition command is successfully executed, execute the step of sending the actual bandwidth value corresponding to each token bucket sample to the host side. When the execution status of the data processing command is that the token bucket sample acquisition command fails to execute, exit the test process.
[0286] The second command status code is used to indicate whether the token bucket sample acquisition command is executed successfully, that is, whether the sample is collected successfully.
[0287] The storage device takes out the token bucket sample acquisition command response queue address from the token bucket sample acquisition command response queue address register, converts the second command status code into a second command status code that complies with the NVMe protocol, and writes the second command status code that complies with the NVMe protocol into the second response queue based on the token bucket sample acquisition command response queue address. The second response queue is the token bucket sample acquisition command response queue.
[0288] The host-side driver layer software takes out the second command status code from the token bucket sample acquisition command response queue.
[0289] The host application layer software parses the second command status code to determine the execution status of the token bucket sample acquisition command, that is, to determine whether the token bucket sample acquisition command is executed successfully. If the execution status of the token bucket sample acquisition command is that the token bucket sample acquisition command is executed successfully, the step of sending the actual bandwidth value corresponding to each token bucket sample to the host and the steps after this step are executed, that is, determining whether the token bucket algorithm is tested according to the actual bandwidth value corresponding to the sample.
[0290] If the execution status of the token bucket sample acquisition command is that the token bucket sample acquisition command execution fails, the test process is exited, that is, the execution of the token bucket sample acquisition command and the data processing command is stopped, and the testing of the token bucket algorithm is stopped.
[0291] The token bucket algorithm testing method provided in this embodiment automatically determines the execution result of the token bucket sample acquisition command based on the second command status code, can respond quickly when an execution failure occurs, and immediately exit the test process. When the token bucket sample acquisition command is executed successfully, it continues to send the actual bandwidth value to the host side to determine the actual token bucket linear function, and then determine the test result of the token bucket algorithm.
[0292] In this embodiment, a token bucket algorithm testing method is also provided. Figure 7: is a flowchart of a token bucket algorithm testing method provided according to an embodiment of the present invention. Figure 7 As shown, the token bucket algorithm testing method includes: 1) test preparation phase, 2) sample acquisition process and 3) linear function reasoning process.
[0293] Among them, 1) the test preparation stage includes:
[0294] Step 1) a, the host application layer software sends an IO read / write command, i.e., a data transmission command, to the host driver layer. It is understandable that, when the pre-tested token bucket algorithm type is a token bucket algorithm for reading data, the data transmission command is a read command. When the pre-tested token bucket algorithm type is a token bucket algorithm for writing data, the data transmission command is a write command.
[0295] Step 1) b, the host-side driver layer software constructs an IO command request.
[0296] The IO command request is constructed as the host driver layer software configures the IO command request queue address to the IO command request queue address register of the NVMe device specific function, configures the IO command response queue address to the IO command response queue address register of the NVMe device specific function, and then constructs a data processing command that complies with the NVMe protocol according to the IO parameters such as data processing parameters in the data transmission command passed in by the application layer software, and writes the data processing command into the data processing command queue. For details, please refer to the description of step b1, which will not be repeated here.
[0297] Step 1) c, the NVMe device hardware reads the IO command queue address from the IO command request queue address register, then reads the IO command from the IO command queue address, and parses the IO command. For details, refer to the description of step h1 and step i1, which will not be repeated here.
[0298] Step 1) d, the NVMe device hardware executes the IO read / write command based on the parsing result of the IO command. Please refer to the description of step i2 and step i3 for details, which will not be repeated here.
[0299] Step 1) e, the NVMe device hardware generates a command status code based on whether the read and write device memory is successful.
[0300] Step 1) f, the NVMe device hardware takes out the IO command response queue address from the IO command response queue address register, converts the command status code into an IO command response that complies with the NVMe protocol, and writes the IO command response into the IO command response queue.
[0301] Step 1) g, the host driver layer software takes out the IO command response from the IO command response queue.
[0302] Step 1) h, the host application layer software parses the IO command response and determines whether the command is executed successfully. If the command is executed successfully, the IO command is continuously executed cyclically, otherwise the test process is exited and a failure report is issued. Please refer to the description of step k1 for details, which will not be repeated here.
[0303] 2) The sample acquisition process includes:
[0304] Step 2) a, the host application layer software sends a token bucket sample acquisition command to the driver layer.
[0305] Step 2) b, the host driver layer software configures the admin command request queue address to the admin command request queue address register of the NVMe device-specific Function, and configures the admin command response queue address to the admin command response queue address register of the NVMe device-specific Function, and then constructs an admin command that complies with the NVMe protocol according to the admin command parameters passed in by the application layer software, such as token bucket type, number of tokens replenished at a time, token replenishment interval, number of samples, and sample collection interval, and writes the admin command to the admin command request queue. See the description of step b1 for details, which will not be repeated here.
[0306] Step 2) c, the NVMe device firmware (representing the software program running in the NVMe device) reads the admin command request queue address from the admin command request queue address register, then takes out the admin command from the queue and parses it according to the opcode. For details, see the description of step h2 and step j1, step j2, which will not be repeated here.
[0307] Step 2) d, the NVMe device firmware executes the token bucket sample command.
[0308] The step 2)d comprises:
[0309] Step 2) d.1, parse the token parameters such as token type, number of tokens replenished at a time, token replenishment interval, and sample parameters such as number of samples, sample collection interval, host DMA address, etc. from the command. When the token type is 0, write the token parameters to the hardware read token bucket parameter register. When the token type is 1, write the token parameters to the hardware write token bucket parameter register. See the description of step j3 and step j4 for details, which will not be repeated here.
[0310] Step 2) d.2, the hardware token bucket algorithm execution module executes the token bucket algorithm according to the new token bucket parameters. Please refer to the description of step j5 for details, which will not be repeated here.
[0311] Step 2) d.3, the hardware IO performance statistics module counts the bandwidth value and writes it into the performance statistics register.
[0312] Step 2) d.4, after a delay of a period of time according to the sample collection interval parameter, obtain the read / write bandwidth value from the performance statistics register and write it as a sample to the host DMA address, and execute this step repeatedly until the number of samples specified by the sample number parameter is obtained. For details, please refer to the description of step j51 and step j52, which will not be repeated here.
[0313] Step 2) e, the NVMe device firmware generates a command status code based on whether the sample collection is successful.
[0314] Step 2) f, the NVMe device firmware takes out the admin command response queue address from the admin command response queue address register, converts the command status code into an admin command response that complies with the NVMe protocol, and writes the admin command response into the admin command response queue.
[0315] Step 2) g, the host driver layer software takes out the admin command response from the admin command response queue.
[0316] Step 2) h, the host application layer software parses the admin command response to determine whether the command is executed successfully. If it is executed successfully, the sample is sent to the subsequent linear function reasoning process, otherwise the test fails. Please refer to the description of step l1 for details, which will not be repeated here.
[0317] 3) The linear function reasoning process includes:
[0318] Step 3) a, obtaining a token bucket sample set from step 2), each sample including token bucket parameters (token replenishment interval, number of tokens replenished at a time) and bandwidth value.
[0319] Step 3) b, use the linear regression model to infer the actual token bucket linear function representing the conversion relationship between the token bucket parameter and the bandwidth value. For details, refer to the description of step S303, step S304, and step S305, which will not be repeated here.
[0320] Step 3) c, compare the k and b differences between the actual token bucket linear function and the theoretical token bucket linear function, and determine whether they are within the allowable error range. If the error is reasonable, the test is considered to have passed, otherwise it is considered to have failed. For details, refer to the description of step S306, which will not be repeated here.
[0321] Step 3) d, output the performance curve. Draw the actual token bucket linear function and the theoretical token bucket linear function on the same plane. Please refer to the description of step g1 for details, which will not be repeated here.
[0322] It should be noted that the host and NVMe devices transmit data through a high-speed serial computer expansion bus standard (Peripheral Component Interconnect Express, referred to as: PCIe) link. The PCIe bus protocol implemented inside the PCIe hardware link enables the host and peripherals to exchange data based on the PCIe interface, with features such as high-speed transmission, abnormal recovery, and power consumption management.
[0323] Furthermore, the host, NVMe device multi-function, hardware token bucket algorithm execution module, hardware IO performance statistics module, IO command and admin command processing, etc. defined in the token bucket algorithm test method provided in the embodiment of the present invention are only for understanding the specific implementation mode of the present invention, and are not used to limit the present invention. Any optimization made without departing from the spirit and scope of the present invention, especially the optimization of the execution process of the token bucket sample acquisition command and the reasoning process of the actual token bucket linear function, are within the protection scope of the present invention.
[0324] The token bucket algorithm testing method provided in this embodiment uses standard NVMe commands to obtain hardware performance statistics and standard PCIe link transmission NVMe commands, so the code has good readability and portability. And the token bucket sample acquisition command designed based on the NVMeadmin extension command can obtain a token bucket sample set from the NVMe device at one time, which is convenient for subsequent execution of linear function reasoning.
[0325] In the present embodiment, a token bucket algorithm testing device is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0326] This embodiment provides a token bucket algorithm testing device, such as Figure 8 As shown, it is applied to the host side, including:
[0327] The first generating module 801 is used to generate a token bucket sample acquisition command and a data processing command according to a pre-tested token bucket algorithm type;
[0328] The first sending module 802 is used to send a token bucket sample acquisition command and a data processing command to the storage device, so that the storage device executes the token bucket sample acquisition command and the data processing command, obtains the actual bandwidth value corresponding to each token bucket sample, and sends the actual bandwidth value corresponding to each token bucket sample to the host end;
[0329] The first determination module 803 is configured to determine an average bandwidth value corresponding to the token bucket sample based on the actual bandwidth value corresponding to each token bucket sample.
[0330] The second determination module 804 is configured to determine a theoretical bandwidth value corresponding to the token bucket sample based on the token bucket sample acquisition command.
[0331] The third determination module 805 is used to determine the actual token bucket linear function based on the theoretical bandwidth value and the average bandwidth value corresponding to the token bucket sample.
[0332] The first judgment module 806 is used to judge whether the error between the actual token bucket linear function and the theoretical token bucket linear function is within a preset error range.
[0333] The fourth determination module 807 is used to determine whether the token bucket algorithm test has passed when the error between the actual token bucket linear function and the theoretical token bucket linear function is within a preset error range.
[0334] In some optional implementations, the first generating module 801 includes:
[0335] The first generating subunit is used to generate a token bucket sample acquisition command and a read command when the pre-tested token bucket algorithm type is a token bucket algorithm for reading data.
[0336] The second generating subunit is used to generate a token bucket sample acquisition command and a write command when the pre-tested token bucket algorithm type is a token bucket algorithm for writing data.
[0337] In some optional implementations, the first generating module 801 includes:
[0338] The third generating subunit is used to generate a token bucket sample acquisition command and a data processing command that conform to the protocol corresponding to the storage device according to the pre-tested token bucket algorithm type and the protocol corresponding to the storage device.
[0339] In some optional implementations, the first sending module 802 includes:
[0340] The first sending sub-unit is used to send the token bucket sample acquisition command to the token bucket sample acquisition command queue, and send the data processing command to the data processing command queue, so that the storage device obtains the token bucket sample acquisition command from the token bucket sample acquisition command queue based on the token bucket sample acquisition command queue address, and obtains the data processing command from the data processing command queue based on the data processing command queue address.
[0341] In some optional implementations, the second determining module 804 includes:
[0342] The first acquisition unit is used to acquire token bucket parameters in the token bucket sample acquisition command, where the token bucket parameters include a token replenishment interval and a single token replenishment number.
[0343] The first determining unit is used to determine the theoretical bandwidth value corresponding to the token bucket sample based on the token bucket parameter by using the following formula:
[0344]
[0345] Among them, y(x) is the theoretical bandwidth value corresponding to the token bucket sample, M is the number of tokens replenished at a time, and T is the token replenishment interval.
[0346] In some optional implementations, the third determining module 805 includes:
[0347] The second determining unit is used to determine the loss function based on the theoretical token bucket linear function and the average bandwidth value.
[0348] The third determining unit is configured to determine a deviation between the theoretical bandwidth value and the average bandwidth value based on the theoretical bandwidth value and the average bandwidth value corresponding to the token bucket sample.
[0349] The first adjustment unit is used to adjust the first variable and the second variable in the loss function based on the deviation between the theoretical bandwidth value and the average bandwidth value until the deviation between the theoretical bandwidth value and the average bandwidth value is reduced to a preset deviation range to obtain an actual token bucket linear function.
[0350] In some optional implementations, the first adjustment unit includes:
[0351] The first adjustment subunit is used to adjust the first variable and the second variable in the loss function according to the following formula based on the deviation between the theoretical bandwidth value and the average bandwidth value:
[0352] k 新 =k 旧 -weight×l k (x)
[0353] b 新 =b 旧 -weight×l b (x)
[0354] Among them, k 新 is the first variable after adjustment, k 旧 is the first variable before adjustment, weight is the learning rate, l k (x) is the partial derivative of the loss function with respect to the first variable, b 新 is the adjusted second variable, b 旧 is the second variable before adjustment, l b(x) is the partial derivative of the loss function with respect to the second variable.
[0355] In some optional implementations, the first determination module 806 includes:
[0356] The first judging unit is used to judge whether an error between a first variable in an actual token bucket linear function and a first variable in a theoretical token bucket linear function is within an error range of a preset first variable.
[0357] The second judging unit is used to judge whether the error between the second variable in the actual token bucket linear function and the second variable in the theoretical token bucket linear function is within the error range of the preset second variable.
[0358] The fourth determination unit is used to determine that the token bucket algorithm test has passed when the error between the first variable in the actual token bucket linear function and the first variable in the theoretical token bucket linear function is within the error range of the preset first variable, and the error between the second variable in the actual token bucket linear function and the second variable in the theoretical token bucket linear function is within the error range of the preset second variable.
[0359] In some optional implementations, the token bucket algorithm testing device further includes:
[0360] The fifth determination module is used to determine that the token bucket algorithm test has failed when the error between the first variable in the actual token bucket linear function and the first variable in the theoretical token bucket linear function is not within the error range of the preset first variable, or the error between the second variable in the actual token bucket linear function and the second variable in the theoretical token bucket linear function is not within the error range of the preset second variable.
[0361] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.
[0362] The token bucket algorithm testing device in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.
[0363] The embodiment of the present invention also provides a token bucket algorithm testing device, such as Fig. 9 As shown, it is applied to the storage device side, including:
[0364] The first receiving module 901 is used to receive a token bucket sample acquisition command and a data processing command sent by a host end, wherein the host end generates a token bucket sample acquisition command and a data processing command according to a pre-tested token bucket algorithm type.
[0365] The first execution module 902 is used to execute the token bucket sample acquisition command and the data processing command, obtain the actual bandwidth value corresponding to each token bucket sample, and send the actual bandwidth value corresponding to each token bucket sample to the host side, so that the host side determines the average bandwidth value corresponding to the token bucket sample based on the actual bandwidth value corresponding to each token bucket sample, determines the theoretical bandwidth value corresponding to the token bucket sample based on the token bucket sample acquisition command, determines the actual token bucket linear function based on the theoretical bandwidth value and the average bandwidth value corresponding to the token bucket sample, and determines whether the error between the actual token bucket linear function and the theoretical token bucket linear function is within a preset error range. If the error between the actual token bucket linear function and the theoretical token bucket linear function is within the preset error range, it is determined that the token bucket algorithm test has passed.
[0366] In some optional implementations, the first receiving module 901 includes:
[0367] The second acquisition unit is used to read the data processing command queue address from the first address register, and acquire the data processing command from the data processing command queue based on the data processing command queue address.
[0368] The third acquisition unit is used to read the token bucket sample acquisition command queue address from the second address register, and acquire the token bucket sample acquisition command from the token bucket sample acquisition command queue based on the token bucket sample acquisition command queue address.
[0369] In some optional implementations, the first execution module 902 includes:
[0370] The fifth determining unit is used to parse the data processing command to determine the type of the data processing command and the data processing parameters of the data processing command.
[0371] The first execution unit is configured to execute the read command based on the data processing parameter when the type of the data processing command is a read command.
[0372] The second execution unit is used to execute the write command based on the data processing parameter when the type of the data processing command is a write command.
[0373] In some optional implementations, the first execution module 902 includes:
[0374] The fourth acquisition unit is used to parse the token bucket sample acquisition command to obtain token bucket parameters.
[0375] The sixth determining unit is configured to determine a token type based on a token bucket parameter.
[0376] The first writing unit is used to write the token bucket parameter into the read token parameter register when the token type is a read token type.
[0377] The second writing unit is used to write the token bucket parameters into the write token parameter register when the token type is a write token type.
[0378] The first control unit is used to perform data transmission control and sample collection control based on the token bucket parameters in the read token parameter register or the token bucket parameters in the write token parameter register.
[0379] In some optional embodiments, the first control unit includes:
[0380] The second control unit is used to control data transmission based on the token replenishment interval and the number of tokens replenished at a time in the token bucket parameters.
[0381] The third control unit is used to control sample collection based on the sample collection interval and the number of sample collection in the token bucket parameters.
[0382] In some optional implementations, the token bucket algorithm testing device further includes:
[0383] The first writing module is used to generate a first command status code according to the execution status of the data processing command, and write the first command status code into the first response queue, so that the host side obtains the first command status code from the first response queue, determines the execution status of the data processing command based on the first command status code, and continues to send the data processing command when the execution status of the data processing command is that the data processing command is successfully executed; when the execution status of the data processing command is that the data processing command fails to execute, exits the test process.
[0384] In some optional implementations, the token bucket algorithm testing device further includes:
[0385] The second writing module is used to generate a second command status code according to the execution status of the token bucket sample acquisition command, and write the second command status code into the second response queue, so that the host end obtains the second command status code from the second response queue, determines the execution status of the token bucket sample acquisition command based on the second command status code, and when the execution status of the token bucket sample acquisition command is that the token bucket sample acquisition command is successfully executed, executes the step of sending the actual bandwidth value corresponding to each token bucket sample to the host end; when the execution status of the data processing command is that the token bucket sample acquisition command fails to execute, exits the test process.
[0386] The embodiment of the present invention also provides a token bucket algorithm testing system. Fig.10 is a structural block diagram of a token bucket algorithm testing system according to an embodiment of the present invention. Fig.10 As shown, the token bucket algorithm testing system includes a host side and a storage device side.
[0387] Among them, the host side is used to provide host-side test software for configuring token bucket parameters and IO commands to NVMe devices.
[0388] The NVMe device is used to execute the token bucket current limiting algorithm and IO commands according to the token bucket parameters configured on the host side, and to count the actual bandwidth performance and send the actual bandwidth performance to the host side.
[0389] The host side is also used to calculate the actual token bucket linear function through the actual bandwidth performance and the linear regression model, and to determine whether the token bucket algorithm has passed the test by comparing it with the theoretical token bucket linear function of the hardware device.
[0390] It should be noted that the host side is used to execute the token bucket algorithm testing method applied to the host side, and the storage device side is used to execute the token bucket algorithm testing method applied to the storage device side.
[0391] The token bucket algorithm test system provided in this embodiment determines whether the token bucket algorithm test passes by comparing whether the error between the actual token bucket linear function and the theoretical token bucket linear function is within a preset error range. More token bucket parameters can be covered by the change trend of the actual linear function, making the test sample more sufficient, and by comparing the error test method between the actual token bucket linear function and the theoretical token bucket linear function, the trend difference between the actual token bucket linear function and the theoretical token bucket linear function can be compared at the data theory level, and the test level is deeper, thereby improving the accuracy of the test results of the token bucket algorithm obtained.
[0392] The embodiment of the present invention also provides a computer device having the above Figure 8 The token bucket algorithm test device shown or the above Fig. 9 The token bucket algorithm test setup is shown.
[0393] See also Fig.11 , Fig.11 is a schematic diagram of the structure of a computer device provided by an optional embodiment of the present invention, such as Fig.11As shown, the computer device includes: one or more processors 1101, memory 1102, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. Each component utilizes different buses to communicate with each other, and can be installed on a common mainboard or installed in other ways as required. The processor can process the instructions executed in the computer device, including instructions stored in the memory or on the memory to display the graphical information of the GUI on an external input / output device (such as, a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple computer devices can be connected, and each device provides part of the necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Fig.11 A processor 1101 is taken as an example.
[0394] The processor 1101 may be a central processing unit, a network processor or a combination thereof. The processor 1101 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable logic gate array, a general purpose array logic or any combination thereof.
[0395] The memory 1102 stores instructions executable by at least one processor 1101, so as to enable at least one processor 1101 to implement the method shown in the above embodiment.
[0396] The memory 1102 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 1102 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 1102 may optionally include a memory remotely arranged relative to the processor 1101, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0397] The memory 1102 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 1102 may also include a combination of the above types of memory.
[0398] The computer device also includes a communication interface 1103, which is used for the computer device to communicate with other devices or a communication network.
[0399] The embodiment of the present invention also provides a computer-readable storage medium. The method according to the embodiment of the present invention can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium through a network download, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state hard disk, etc.; further, the storage medium can also include a combination of the above types of memories. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor, or hardware, the method shown in the above embodiment is implemented.
[0400] A part of the present invention may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present invention through the operation of the computer. Those skilled in the art should understand that the existence of the computer program instruction in a computer-readable medium includes, but is not limited to, a source file, an executable file, an installation package file, etc., and accordingly, the way in which the computer program instruction is executed by the computer includes, but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium may be any available computer-readable storage medium or communication medium accessible to the computer.
[0401] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the scope defined by the appended claims.
Claims
1. A token bucket algorithm testing method, characterized in that: Applied to the host side, the method includes: Generate a token bucket sample acquisition command and a data processing command according to the pre-tested token bucket algorithm type; Sending the token bucket sample acquisition command and the data processing command to the storage device, so that the storage device executes the token bucket sample acquisition command and the data processing command, obtains the actual bandwidth value corresponding to each token bucket sample, and sends the actual bandwidth value corresponding to each token bucket sample to the host end; Based on the actual bandwidth value corresponding to each token bucket sample, determine the average bandwidth value corresponding to the token bucket sample; Based on the token bucket sample acquisition command, determine a theoretical bandwidth value corresponding to the token bucket sample; Determine an actual token bucket linear function based on a theoretical bandwidth value and an average bandwidth value corresponding to the token bucket sample; Determine whether the error between the actual token bucket linear function and the theoretical token bucket linear function is within a preset error range; When the error between the actual token bucket linear function and the theoretical token bucket linear function is within a preset error range, it is determined that the token bucket algorithm test has passed.
2. The method according to claim 1, characterized in that The generating of a token bucket sample acquisition command and a data processing command according to the pre-tested token bucket algorithm type includes: When the token bucket algorithm type of the pre-test is the token bucket algorithm for reading data, a token bucket sample acquisition command and a read command are generated; When the token bucket algorithm type of the pre-test is the token bucket algorithm for writing data, a token bucket sample acquisition command and a write command are generated.
3. The method according to claim 1, characterized in that The generating of a token bucket sample acquisition command and a data processing command according to the pre-tested token bucket algorithm type includes: According to the pre-tested token bucket algorithm type and the protocol corresponding to the storage device, a token bucket sample acquisition command and a data processing command that conform to the protocol corresponding to the storage device are generated.
4. The method according to claim 1, characterized in that: The sending of the token bucket sample acquisition command and the data processing command to the storage device includes: A token bucket sample acquisition command is sent to a token bucket sample acquisition command queue, and a data processing command is sent to a data processing command queue, so that the storage device obtains the token bucket sample acquisition command from the token bucket sample acquisition command queue based on the token bucket sample acquisition command queue address, and obtains the data processing command from the data processing command queue based on the data processing command queue address.
5. The method according to claim 1, characterized in that The determining, based on the token bucket sample acquisition command, a theoretical bandwidth value corresponding to the token bucket sample, comprises: Obtaining token bucket parameters in the token bucket sample acquisition command, wherein the token bucket parameters include a token replenishment interval and a single token replenishment number; Based on the token bucket parameters, the theoretical bandwidth value corresponding to the token bucket sample is determined by the following formula: Wherein, y(x) is the theoretical bandwidth value corresponding to the token bucket sample, M is the number of tokens replenished at a time, and T is the token replenishment interval.
6. The method according to claim 1, characterized in that The determining of the actual token bucket linear function based on the theoretical bandwidth value and the average bandwidth value corresponding to the token bucket sample includes: Determine the loss function based on the theoretical token bucket linear function and the average bandwidth value; Determine a deviation between the theoretical bandwidth value and the average bandwidth value based on the theoretical bandwidth value and the average bandwidth value corresponding to the token bucket sample; Based on the deviation between the theoretical bandwidth value and the average bandwidth value, the first variable and the second variable in the loss function are adjusted until the deviation between the theoretical bandwidth value and the average bandwidth value is reduced to a preset deviation range to obtain an actual token bucket linear function.
7. The method according to claim 6, characterized in that The adjusting the first variable and the second variable in the loss function based on the deviation between the theoretical bandwidth value and the average bandwidth value includes: Based on the deviation between the theoretical bandwidth value and the average bandwidth value, the first variable and the second variable in the loss function are adjusted by the following formula: k 新 =k 旧 -weight×l k (x) b 新 =b 旧 -weight×l b (x) Among them, k 新 is the first variable after adjustment, k 旧 is the first variable before adjustment, weight is the learning rate, l k (x) is the partial derivative of the loss function with respect to the first variable, b 新 is the adjusted second variable, b 旧 is the second variable before adjustment, l b (x) is the partial derivative of the loss function with respect to the second variable.
8. The method according to claim 1, characterized in that The determining whether the error between the actual token bucket linear function and the theoretical token bucket linear function is within a preset error range includes: Determine whether an error between a first variable in an actual token bucket linear function and a first variable in a theoretical token bucket linear function is within an error range of a preset first variable; Determine whether an error between a second variable in an actual token bucket linear function and a second variable in a theoretical token bucket linear function is within an error range of a preset second variable; When the error between the first variable in the actual token bucket linear function and the first variable in the theoretical token bucket linear function is within the error range of the preset first variable, and the error between the second variable in the actual token bucket linear function and the second variable in the theoretical token bucket linear function is within the error range of the preset second variable, it is determined that the token bucket algorithm test has passed.
9. The method according to claim 8, characterized in that The method further comprises: If the error between the first variable in the actual token bucket linear function and the first variable in the theoretical token bucket linear function is not within the error range of the preset first variable, or the error between the second variable in the actual token bucket linear function and the second variable in the theoretical token bucket linear function is not within the error range of the preset second variable, it is determined that the token bucket algorithm test has failed.
10. A token bucket algorithm testing method, characterized in that: Applied to a storage device, the method includes: Receiving a token bucket sample acquisition command and a data processing command sent by a host end, wherein the host end generates a token bucket sample acquisition command and a data processing command according to a pre-tested token bucket algorithm type; Execute the token bucket sample acquisition command and the data processing command to obtain the actual bandwidth value corresponding to each token bucket sample, and send the actual bandwidth value corresponding to each token bucket sample to the host end, so that the host end determines the average bandwidth value corresponding to the token bucket sample based on the actual bandwidth value corresponding to each token bucket sample, determines the theoretical bandwidth value corresponding to the token bucket sample based on the token bucket sample acquisition command, determines the actual token bucket linear function based on the theoretical bandwidth value and the average bandwidth value corresponding to the token bucket sample, and determines whether the error between the actual token bucket linear function and the theoretical token bucket linear function is within a preset error range. If the error between the actual token bucket linear function and the theoretical token bucket linear function is within the preset error range, determine that the token bucket algorithm test is passed.
11. The method according to claim 10, characterized in that The receiving host sends a token bucket sample acquisition command and a data processing command, including: Reading a data processing command queue address from a first address register, and acquiring a data processing command from the data processing command queue based on the data processing command queue address; The token bucket sample acquisition command queue address is read from the second address register, and the token bucket sample acquisition command is acquired from the token bucket sample acquisition command queue based on the token bucket sample acquisition command queue address.
12. The method according to claim 10, characterized in that Executing the data processing command includes: Parsing the data processing command to determine the type of the data processing command and data processing parameters of the data processing command; In a case where the type of the data processing command is a read command, executing the read command based on the data processing parameter; In a case where the type of the data processing command is a write command, the write command is executed based on the data processing parameter.
13. The method according to claim 10, characterized in that Executing the token bucket sample acquisition command includes: Parsing the token bucket sample acquisition command to obtain token bucket parameters; Determining a token type based on the token bucket parameters; When the token type is a read token type, writing the token bucket parameter into a read token parameter register; When the token type is a write token type, writing the token bucket parameter into a write token parameter register; Data transmission control and sample collection control are performed based on the token bucket parameters in the read token parameter register or the token bucket parameters in the write token parameter register.
14. The method according to claim 13, characterized in that The data transmission control and sample collection control based on the token bucket parameters in the read token parameter register or the token bucket parameters in the write token parameter register include: Performing data transmission control based on the token replenishment interval and the number of tokens replenished at a time in the token bucket parameters; The sample collection control is performed based on the sample collection interval and the number of sample collection in the token bucket parameters.
15. The method according to claim 10, characterized in that The method further comprises: A first command status code is generated according to the execution status of the data processing command, and the first command status code is written into a first response queue, so that the host side obtains the first command status code from the first response queue, and determines the execution status of the data processing command based on the first command status code. When the execution status of the data processing command is that the data processing command is successfully executed, the data processing command continues to be sent. When the execution status of the data processing command is that the data processing command is failed to execute, the test process is exited.
16. The method according to claim 10, characterized in that The method further comprises: A second command status code is generated according to the execution status of the token bucket sample acquisition command, and the second command status code is written into the second response queue, so that the host end obtains the second command status code from the second response queue, and the execution status of the token bucket sample acquisition command is determined based on the second command status code. When the execution status of the token bucket sample acquisition command is that the token bucket sample acquisition command is successfully executed, the step of sending the actual bandwidth value corresponding to each token bucket sample to the host end is performed. When the execution status of the data processing command is that the token bucket sample acquisition command fails to execute, the test process is exited.
17. A token bucket algorithm testing device, characterized in that: Applied to the host side, the device comprises: A first generating module, used for generating a token bucket sample acquisition command and a data processing command according to a pre-tested token bucket algorithm type; A first sending module is used to send the token bucket sample acquisition command and the data processing command to the storage device, so that the storage device executes the token bucket sample acquisition command and the data processing command, obtains the actual bandwidth value corresponding to each token bucket sample, and sends the actual bandwidth value corresponding to each token bucket sample to the host end; A first determination module, configured to determine an average bandwidth value corresponding to each token bucket sample based on an actual bandwidth value corresponding to each token bucket sample; A second determination module, configured to determine a theoretical bandwidth value corresponding to the token bucket sample based on the token bucket sample acquisition command; A third determination module, configured to determine an actual token bucket linear function based on a theoretical bandwidth value and an average bandwidth value corresponding to the token bucket sample; A first judgment module is used to judge whether the error between the actual token bucket linear function and the theoretical token bucket linear function is within a preset error range; The fourth determination module is used to determine whether the token bucket algorithm test has passed when the error between the actual token bucket linear function and the theoretical token bucket linear function is within a preset error range.
18. A token bucket algorithm testing device, characterized in that: Applied to a storage device, the device comprises: A first receiving module, used for receiving a token bucket sample acquisition command and a data processing command sent by a host end, wherein the host end generates a token bucket sample acquisition command and a data processing command according to a pre-tested token bucket algorithm type; The first execution module is used to execute the token bucket sample acquisition command and the data processing command, obtain the actual bandwidth value corresponding to each token bucket sample, and send the actual bandwidth value corresponding to each token bucket sample to the host end, so that the host end determines the average bandwidth value corresponding to the token bucket sample based on the actual bandwidth value corresponding to each token bucket sample, determines the theoretical bandwidth value corresponding to the token bucket sample based on the token bucket sample acquisition command, determines the actual token bucket linear function based on the theoretical bandwidth value and the average bandwidth value corresponding to the token bucket sample, determines whether the error between the actual token bucket linear function and the theoretical token bucket linear function is within a preset error range, and determines that the token bucket algorithm test is passed when the error between the actual token bucket linear function and the theoretical token bucket linear function is within the preset error range.
19. A token bucket algorithm testing system, characterized in that: The system includes a host end and a storage device end, wherein the host end is used to execute the token bucket algorithm testing method described in any one of claims 1-9, and the storage device end is used to execute the token bucket algorithm testing method described in any one of claims 10-16.
20. A computer device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the token bucket algorithm testing method described in any one of claims 1 to 9 or the token bucket algorithm testing method described in any one of claims 10 to 16 by executing the computer instructions.
21. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the token bucket algorithm testing method described in any one of claims 1 to 9 or the token bucket algorithm testing method described in any one of claims 10 to 16.
22. A computer program product, characterized in that It comprises computer instructions, and the computer instructions are used to make a computer execute the token bucket algorithm testing method described in any one of claims 1 to 9 or the token bucket algorithm testing method described in any one of claims 10-16.
Citation Information
Cited By
Heterogeneous acceleration system, method and device, computing equipment and storage medium
CN119537304A
Token bucket verification method and system, electronic equipment and medium
CN120389986A
