Frequency modulation method, device and equipment and readable storage medium
Patent Information
- Application Number
- CN202411038004.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-31
- Publication Date
- 2024-10-22
Smart Images

Figure CN118819860A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer application technology, and in particular to a frequency modulation method, device, equipment and readable storage medium. Background Art
[0002] Server CPU (Central Processing Unit) frequency adjustment is a technology that manages the balance between CPU performance and energy consumption. As the core component of the data center, the server consumes a lot of energy. By adjusting the CPU frequency, the frequency can be reduced during low-load periods to reduce power consumption, thereby reducing operating costs and helping to protect the environment. At the same time, different application scenarios have different performance requirements for servers. Dynamically adjusting the CPU frequency can allocate appropriate computing resources according to the needs of the current task, which not only avoids resource waste but also ensures the efficient execution of key tasks.
[0003] In Linux servers, the cpufreq (CPU frequency, cpufreq is a module for CPU frequency adjustment provided by the Linux system kernel) subsystem is part of its power management framework, focusing on dynamic voltage and frequency adjustment. Users can use the command line tool cpupower (processor power) provided by the cpufreq subsystem to view and modify the CPU frequency adjustment strategy and specific frequency settings through frequency-set (frequency setting) and frequency-info (frequency information). CPU manufacturers will provide drivers for cpufreq to control CPU frequency, and different manufacturers have different CPU frequency adjustment strategies.
[0004] Usually, the manufacturer's driver will provide several regulators, such as performance mode, on-demand mode, energy-saving mode, etc., which will adjust automatically at the hardware level according to the current load of the server. Usually, the regulator will not change after it is set, and it cannot effectively fit the actual application scenario, and cannot effectively improve performance or reduce power consumption. For example, in actual use, it is often encountered that the frequency is extremely high or extremely low jitter, and it cannot provide the CPU frequency that is most suitable for the current task.
[0005] In summary, how to effectively solve problems such as frequency modulation of processors in servers is a technical problem that technical personnel in this field urgently need to solve. Summary of the invention
[0006] The purpose of the present application is to provide a frequency modulation method, apparatus, device and readable storage medium, which can adjust the frequency of a processor in a server to adapt to the load.
[0007] In order to solve the above technical problems, this application provides the following technical solutions:
[0008] A frequency modulation method, comprising:
[0009] Get the load data of the target server;
[0010] Inputting the load data into a trained prediction model to perform load adaptation frequency prediction to obtain a predicted frequency;
[0011] Using the predicted frequency, performing frequency modulation processing on a processor in the target server;
[0012] Wherein, training the prediction model comprises:
[0013] In a production scenario, during a frequency adjustment process of a processor in a server using an on-demand regulator, first load data and a first processor frequency are collected;
[0014] In a simulated target carrier service scenario, during a frequency adjustment process of a processor in the server based on a customized frequency scheduling strategy, collecting second load data and a second processor frequency;
[0015] constructing a training sample based on the first load data, the first processor frequency, the second load data, and the second processor frequency;
[0016] The prediction model is trained for frequency prediction using the training samples, and after the training is completed, the prediction model is obtained.
[0017] Preferably, obtaining the load data of the target server includes:
[0018] Using command line tools, collect the processor ratio, memory ratio, and disk ratio of the target server;
[0019] The processor proportion, the memory proportion and the disk proportion are determined as the load data.
[0020] Preferably, constructing a training sample based on the first load data, the first processor frequency, the second load data and the second processor frequency includes:
[0021] The first load data and the first processor frequency are stored in an array to obtain a first training sample;
[0022] The second load data and the second processor frequency are stored in an array format to obtain a second training sample.
[0023] Preferably, using the training samples to perform frequency prediction training on the prediction model includes:
[0024] Obtaining the highest frequency of the server;
[0025] Calculating a ratio of a processor frequency in the training sample to the highest frequency;
[0026] replacing the processor frequency in the training sample with the ratio;
[0027] Accordingly, the load data is input into the trained prediction model to predict the load adaptation frequency, and the predicted frequency is obtained, including:
[0028] Inputting the load data into a trained prediction model to predict the load adaptation frequency and obtain a prediction ratio;
[0029] The predicted frequency is obtained by multiplying the predicted ratio by the highest frequency of the processor in the target server.
[0030] Preferably, the prediction model includes a long short-term memory network, an attention layer, and a fully connected layer;
[0031] Accordingly, the load data is input into the trained prediction model to predict the load adaptation frequency, and the predicted frequency is obtained, including:
[0032] inputting the load data into the prediction model;
[0033] Extracting input features from the load data using the long short-term memory network;
[0034] Using the attention layer, based on the dot product of the input feature and the weight matrix, the matching degree is calculated, and an unnormalized attention score is generated by conversion through an activation function and adding a bias term; using a number theory function, the attention score is converted; after conversion, normalization is performed to obtain an attention weight for each time step; using the attention weight to perform weighted summation on the input feature to obtain a predicted load;
[0035] Using the fully connected layer, a prediction frequency adapted to the predicted load is determined.
[0036] Preferably, the prediction model includes a long short-term memory network, an attention layer, and a fully connected layer;
[0037] Accordingly, the prediction model is trained for frequency prediction using the training samples, including:
[0038] Inputting the training sample into the prediction model;
[0039] Extracting input features from the load data of the training sample using the long short-term memory network;
[0040] Using the attention layer, based on the dot product of the input feature and the weight matrix, the matching degree is calculated, and an unnormalized attention score is generated by conversion through an activation function and adding a bias term; using a number theory function, the attention score is converted; after conversion, normalization is performed to obtain an attention weight for each time step; using the attention weight to perform weighted summation on the input feature to obtain a predicted load;
[0041] Calculate a first error between the predicted load and the target load in the training sample using a loss function;
[0042] Adjusting parameters of the long short-term memory network and / or the attention layer through neural network back propagation to reduce the first error;
[0043] After the long short-term memory network and the attention layer have converged in training, inputting the prediction load into the fully connected layer;
[0044] Using the fully connected layer to perform frequency adaptation prediction on the predicted load to obtain a predicted frequency;
[0045] Calculating a second error between the predicted frequency and the processor frequency in the input sample using a loss function;
[0046] The parameters of the prediction model are adjusted through neural network back propagation to reduce the second error.
[0047] Preferably, the load data is input into a trained prediction model to predict the load adaptation frequency to obtain the predicted frequency, including:
[0048] Inputting the load data into a trained first prediction model to perform load adaptation frequency prediction to obtain a first prediction frequency;
[0049] Inputting the load data into a trained second prediction model to perform load adaptation frequency prediction to obtain a second prediction frequency;
[0050] The first predicted frequency is weightedly modified based on the second predicted frequency to obtain the predicted frequency.
[0051] A frequency modulation device, comprising:
[0052] A load acquisition module is used to obtain the load data of the target server;
[0053] A frequency prediction module, used for inputting the load data into a trained prediction model to perform load adaptation frequency prediction and obtain a predicted frequency;
[0054] A frequency modulation processing module, used to perform frequency modulation processing on the processor in the target server using the predicted frequency;
[0055] A data collection module is used to collect first load data and a first processor frequency during a frequency adjustment process of a processor in a server using an on-demand regulator in a production scenario; and to collect second load data and a second processor frequency during a frequency adjustment process of a processor in the server based on a customized frequency scheduling strategy in a simulated carrier target business scenario;
[0056] a sample construction module, configured to construct a training sample based on the first load data, the first processor frequency, the second load data, and the second processor frequency;
[0057] The model training module is used to perform frequency prediction training on the prediction model using the training samples, and obtain the prediction model after the training is completed.
[0058] An electronic device, comprising:
[0059] Memory for storing computer programs;
[0060] A processor is used to implement the steps of the above-mentioned frequency modulation method when executing the computer program.
[0061] A readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above-mentioned frequency modulation method are implemented.
[0062] A computer program product comprises a computer program / instruction, which implements the steps of the above frequency modulation method when executed by a processor.
[0063] Apply the method provided in the embodiment of the present application to obtain the load data of the target server; input the load data into the trained prediction model to predict the load adaptation frequency and obtain the predicted frequency; use the predicted frequency to perform frequency modulation processing on the processor in the target server; wherein, training the prediction model includes: in a production scenario, using an on-demand regulator to perform frequency modulation processing on the processor in the server, collecting first load data and a first processor frequency; in a simulated target business scenario, based on a customized frequency scheduling strategy, collecting second load data and a second processor frequency; constructing a training sample based on the first load data, the first processor frequency, the second load data and the second processor frequency; using the training sample to perform frequency prediction training on the prediction model, and obtaining the prediction model after the training is completed.
[0064] Data is collected for production scenarios and simulation scenarios to obtain load data and processor frequencies in different scenarios, and then training samples for different scenarios are constructed. The prediction model is trained based on the training samples corresponding to different scenarios to obtain a prediction model that can predict the frequency of the input load data. When it is necessary to perform frequency modulation on the processor of the target server, the load data of the server can be collected and input into the prediction model for frequency prediction to obtain the predicted frequency. Finally, the processor in the target server can be frequency modulated based on the predicted frequency. In this way, the future frequency can be predicted based on the current load data, so that the frequency modulation of the server can be adapted to the load, and is no longer limited to a few preset fixed thresholds.
[0065] Technical effect: It is possible to predict future frequencies based on the server's load data, and adjust the frequency of the processor in the server based on the predicted frequency, so that the frequency of the processor in the server is adapted to the load.
[0066] Correspondingly, the embodiments of the present application also provide frequency modulation devices, equipment, readable storage media and computer program products corresponding to the above-mentioned frequency modulation method, which have the above-mentioned technical effects and are not described in detail here. BRIEF DESCRIPTION OF THE DRAWINGS
[0067] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the drawings required for use in the embodiments or the related technical descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0068] Figure 1 This is a flow chart of an implementation of a frequency modulation method in an embodiment of the present application;
[0069] Figure 2 A schematic diagram of a prediction model in an embodiment of the present application;
[0070] Figure 3 A schematic diagram of load prediction in an embodiment of the present application;
[0071] Figure 4 This is a frequency prediction schematic diagram in an embodiment of the present application;
[0072] Figure 5 This is a schematic diagram of a model merging training in an embodiment of the present application;
[0073] Figure 6 This is a schematic diagram of a model deployment in an embodiment of the present application;
[0074] Figure 7 This is a schematic diagram of the structure of a frequency modulation device in an embodiment of the present application;
[0075] Figure 8 This is a schematic diagram of the structure of an electronic device in an embodiment of the present application;
[0076] Fig. 9 This is a schematic diagram of the specific structure of an electronic device in an embodiment of the present application. DETAILED DESCRIPTION
[0077] In order to enable those skilled in the art to better understand the present application, the present application is further described in detail below in conjunction with the accompanying drawings and specific implementation methods. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.
[0078] Please refer to Figure 1 , Figure 1 This is a flow chart of a frequency modulation method in an embodiment of the present application, the method comprising the following steps:
[0079] S101. Obtain load data of a target server.
[0080] The target server can be any server that needs to perform frequency modulation on the processor. The load data is data that can represent the load status of the target server, such as the processor ratio, memory ratio and disk ratio, where the ratio is the occupancy ratio.
[0081] In one embodiment of the present application, obtaining load data of a target server includes:
[0082] Use command line tools to collect the processor share, memory share, and disk share of the target server;
[0083] The processor ratio, memory ratio, and disk ratio are determined as load data.
[0084] Use top (top is a command line tool provided by the Linux software procps-ng, which can be used to view information about the processes currently running in the system) to obtain the CPU usage and memory usage of the server; use iotop (iotop is a command line tool provided by the Linux software iotop, which can be used to view the output and input operations of the processes currently running in the system and display the disk read and write speed) to obtain the disk usage of the server.
[0085] After collecting the processor percentage, memory percentage, and disk percentage, these percentage data are determined as load data.
[0086] S102: Input the load data into the trained prediction model to perform load adaptation frequency prediction to obtain a predicted frequency.
[0087] In an embodiment of the present application, a model can be pre-trained that can perform predictive processing on input load data and output a predicted frequency that is adapted to the load.
[0088] Among them, training the prediction model includes:
[0089] Step 1: In a production scenario, during a frequency adjustment process of a processor in a server using an on-demand regulator, first load data and a first processor frequency are collected.
[0090] Step 2: In a simulated target carrier business scenario, during the frequency adjustment process of the processor in the server based on the customized frequency scheduling strategy, the second load data and the second processor frequency are collected.
[0091] Step three: construct a training sample based on the first load data, the first processor frequency, the second load data and the second processor frequency.
[0092] Step 4: Use the training samples to perform frequency prediction training on the prediction model. After the training is completed, the prediction model is obtained.
[0093] For ease of description, the above steps are combined for explanation below.
[0094] In production scenarios, use the ondemand regulator of the cpufreq tool in the server operating system to allow the server to adjust the frequency according to the business load and continuously collect the first load data and the first processor frequency;
[0095] In the simulation scenario, the server is used to run a variety of business scenarios, such as database business and website hosting business, which can be specially customized according to the user's usage scenario. At this time, the CPU scheduling strategy can also be customized according to user needs, generating user-customized CPU frequency adjustment tendencies during training, and more matching the scenario in subsequent frequency prediction. Continuously collect the second load data and the second processor frequency.
[0096] To avoid affecting the server's own business, the server's current time, load, and CPU frequency are collected every 5 minutes.
[0097] In addition, the more data you collect, the better. If you only consider predictions in minutes or hours, you can collect data for a few days. If you need to consider predictions in days or months, you need to collect data for one or more months.
[0098] Then, a training sample is constructed based on the first load data, the first processor frequency, the second load data, and the second processor frequency.
[0099] It should be noted that the first and second of the first load data, the first processor frequency, the second load data and the second processor frequency are only used to distinguish the different data source scenarios, and have no other limiting meanings such as priority, order, etc.
[0100] In one embodiment of the present application, constructing a training sample based on first load data, a first processor frequency, second load data, and a second processor frequency includes:
[0101] The first load data and the first processor frequency are stored in an array to obtain a first training sample;
[0102] The second load data and the second processor frequency are stored in an array format to obtain a second training sample.
[0103] Specifically, for each load data collected by the server and the processing frequency corresponding to the load data, the collected data is stored in an array. For example, the collected data is saved in an array, and the array members are time, CPU usage, memory usage, disk usage, and CPU frequency. The stored array is the training sample.
[0104] After obtaining the training samples, the prediction model can be trained. It should be noted that in this application, the goal of training is to perform reasoning analysis on the input load data to determine the adaptive processor frequency at the future moment. Therefore, in this embodiment, the training of the prediction model can be divided into two steps, namely, determining the future load data based on the current input load data, and predicting the adaptive processor frequency based on the future load data.
[0105] In one embodiment of the present application, the prediction model includes a long short-term memory network, an attention layer, and a fully connected layer;
[0106] Accordingly, the prediction model is trained for frequency prediction using training samples, including:
[0107] Input the training samples into the prediction model;
[0108] Using long short-term memory networks, input features are extracted from the load data of training samples;
[0109] Using the attention layer, the matching degree is calculated based on the dot product of the input features and the weight matrix, and the unnormalized attention score is generated by conversion through the activation function and adding the bias term; the attention score is converted using the number theory function; after the conversion, it is normalized to obtain the attention weight of each time step; the input features are weighted summed using the attention weight to obtain the predicted load;
[0110] Using the loss function, calculate the first error between the predicted load and the target load in the training sample;
[0111] Adjusting the parameters of the LSTM network and / or the attention layer through neural network back propagation to reduce the first error;
[0112] After the LSTM and attention layer training converges, the prediction load is input to the fully connected layer;
[0113] Use the fully connected layer to perform frequency adaptation prediction on the predicted load to obtain the predicted frequency;
[0114] Calculate a second error between the predicted frequency and the processor frequency in the input sample using the loss function;
[0115] The parameters of the prediction model are adjusted through neural network back propagation to reduce the second error.
[0116] For ease of description, the above steps are combined for explanation below.
[0117] Please refer to Figure 2 , the prediction model consists of two parts:
[0118] First, predict the load in the future based on the historical CPU load. Here is a load prediction model that uses LSTM (Long Short-Term Memory) units combined with an attention layer to predict time series load data.
[0119] Second, the CPU frequency is determined based on the user load in the future obtained by the load prediction model. There are fewer elements here, so a fully connected model can be used to implement it.
[0120] Within the prediction model, a prediction result for the CPU frequency at the next moment is generated based on the recorded historical load.
[0121] The long short-term memory network performs load forecasting, that is, predicting the future load of the server. LSTM (Long Short-Term Memory Network) is a special recurrent neural network structure that achieves efficient capture and retention of long-term dependencies through a gating mechanism, further enhancing the ability to understand sequence context. Here, the model can use 20 LSTM units and 1 attention layer to build a time series network model. The three values of the load correspond to the three features of the LSTM unit input and the three results of the attention layer output.
[0122] The attention layer calculates the initial matching degree using the dot product of the input features and the weight matrix, and then converts it through the tanh activation function and adds a bias term to generate an unnormalized attention score; the exp function (exp-function, number theory function) is applied to the above-obtained attention score and normalized to obtain the attention weight of each time step, which reflects the relative importance of different parts after passing through the LSTM unit; the input features are weighted and summed according to the calculated attention weights to obtain the final prediction result.
[0123] The fully connected layer is used to generate the corresponding CPU frequency according to the business load such as CPU usage, memory usage, disk usage, etc. The input content is 3 and the output result is 1. In terms of structure, a fully connected network of input layer-hidden layer-output layer is selected, where the units of the hidden layer can be set to 8. If more load indicators are needed, the units of the input layer and hidden layer can be increased, or an additional hidden layer can be added.
[0124] Considering the cyclical regularity of time scale, that is, the server load changes regularly every minute on a day scale and every day on a month scale, the prediction time interval can be customized, such as every 10 minutes, every 30 minutes, every hour, every day, etc., depending on the specific needs of the user. The data set for model training can be modified to achieve CPU frequency prediction at different time intervals. The CPU frequency prediction results of multiple time steps can also be used for weighted calculation to obtain a comprehensive prediction of the CPU frequency. Among them, the weight setting can be the average of the prediction values of each time scale.
[0125] Since the prediction model in the embodiment of the present application includes two parts: load prediction and frequency prediction, the two parts of the model are trained separately, the model pre-training weights are determined, and then the two networks are merged to perform model training and fine-tuning.
[0126] Please refer to Figure 3 , you can choose to use the data of the first 10 time steps to predict the situation of the next time step, then the shape of the input data will be (number of samples, number of time steps, number of features), where the number of features is 3 (memory usage, hard disk usage, and CPU usage), the number of samples is the number of data used in one training, and the time step is set to 10.
[0127] If the time step is set to 10 minutes, data needs to be taken at intervals of ten minutes from the collected original data. A set of data consists of 11 data, of which the first 10 are input data and the last one is the target data for comparison with the predicted value. Assuming that 30 sets of data are taken here, the training input is an array of 30*10*3, the target data is an array of 30*1*3, and the output predicted value is an array of 30*1*3. The error between the output predicted data and the target data is calculated through the loss function, and the parameters are adjusted through the back propagation of the neural network to make the error (i.e., the first error) between the predicted value (i.e., the predicted load data) and the target value (the load data in the training sample) smaller and smaller.
[0128] On this basis, different data processing methods need to be set according to different time steps. If the time step is short, you can directly take data at intervals of time steps; if the time step is long, such as one day, there will be a large error in replacing the overall data with data at a certain moment, so you can choose to calculate the average value of the data in half of the range of the nearby time step (such as half a day) as the input data.
[0129] Please refer to Figure 4 , frequency prediction is not time-series related, so during training, all collected data can be directly divided into training set and test set, of which the training set accounts for 70% and the test set accounts for 30%. The input content of the fully connected network model is three types of loads: CPU occupancy, memory occupancy, and disk occupancy, and the output content is CPU frequency. During training, the predicted CPU frequency is obtained based on the input load, and the error between the predicted CPU frequency and the actual collected CPU frequency is calculated through the loss function. The parameters are adjusted through the back propagation of the neural network to make the error (i.e., the second error) between the predicted value (i.e., the predicted frequency) and the actual collected value (i.e., the processor frequency in the training sample) smaller and smaller.
[0130] Considering that there are data from different business scenarios during data collection, training can be carried out on data for a specific scenario, and targeted models for different business scenarios can be trained based on the model.
[0131] Please refer to Figure 5 , load prediction and frequency prediction are combined and trained together. The input data is the same as the load prediction model, and the target data is the same as the fully connected network model. The error between the prediction result and the target data is calculated and back-propagated to complete the model fine-tuning.
[0132] By training the models separately, different pre-trained models can be established for different scenarios. The user can match the appropriate pre-trained model weights according to the needs of timing prediction and frequency modulation strategy, and then fine-tune them according to the user's actual scenario, thereby reducing usage complexity and training costs.
[0133] After the model training is completed, the trained prediction model can be deployed to predict the processor frequency based on the prediction model.
[0134] In this application, the deployment of the prediction model may include but is not limited to the following two methods:
[0135] Method 1: Local general model deployment: The general model needs to be trained using load data collected from various types of services. During training, the CPU frequency needs to be switched to the ratio of the CPU frequency to the maximum frequency to avoid hardware differences between different CPUs. After training, it is published in the form of a pre-trained model, which does not require additional training and is directly distributed to the server, which performs inference locally.
[0136] The performance of general-purpose servers usually does not support local model training. You can also use customized data to train models externally based on business preferences and then distribute them to the server.
[0137] The current prediction model is relatively small. In order to avoid occupying local hardware resources, a dedicated inference hardware module can be customized based on FPGA to perform intelligent frequency modulation inference.
[0138] Method 2: Customized deployment in LAN mode, please refer to Figure 6 , deployment on a single machine may affect the performance of the server itself, so the intelligent frequency modulation model can be deployed separately in the local area network according to business needs.
[0139] A machine with reasoning capabilities, called an inference machine, is used within the local area network. The model and appropriate pre-trained weights are loaded into the inference machine according to user needs.
[0140] Classify the devices that are ready to access the model. The inference engine can load different models at the same time and connect servers with similar services to the same model.
[0141] Use the syslog service to collect the load data of the servers in the LAN every 5 minutes and aggregate the data connected to the same model.
[0142] When sufficient data is collected, the model is fine-tuned based on the collected user data on the inference engine.
[0143] After the model fine-tuning training is completed, the predicted CPU frequency data is generated based on the current load data passed into the inference engine and sent to the server for automatic frequency adjustment, or the inference engine remotely controls the server CPU frequency without occupying the server's own resources.
[0144] The trained model will be regularly verified with the actual collected data. If the error is large, the model will be fine-tuned using the recently collected data.
[0145] On this basis, a visual server management platform can be developed and deployed on the inference machine to provide cluster management functions such as visual load status display, load forecast display, batch frequency adjustment, etc.
[0146] After the model is trained and deployed, the load adaptation frequency can be predicted based on the prediction model to obtain the predicted frequency.
[0147] In this embodiment, the prediction link within the prediction model includes: performing timing prediction based on the input load data to obtain predicted load data; and then predicting the processor frequency that matches the predicted load data.
[0148] In one embodiment of the present application, the prediction model includes a long short-term memory network, an attention layer, and a fully connected layer;
[0149] Accordingly, the load data is input into the trained prediction model to predict the load adaptation frequency and obtain the predicted frequency, including:
[0150] Input load data into the forecasting model;
[0151] Using long short-term memory networks, input features are extracted from load data;
[0152] Using the attention layer, the matching degree is calculated based on the dot product of the input features and the weight matrix, and the unnormalized attention score is generated by conversion through the activation function and adding the bias term; the attention score is converted using the number theory function; after the conversion, it is normalized to obtain the attention weight of each time step; the input features are weighted summed using the attention weight to obtain the predicted load;
[0153] Using the fully connected layer, the prediction frequency adapted to the predicted load is determined.
[0154] It can be seen that in the embodiment of the present application, the process of predicting the predicted frequency based on the input load data prediction and load adaptation is similar to the training process of the prediction model. Compared with the training process, obtaining the predicted frequency requires parameter tuning. In the actual prediction processing, the prediction processing is completed when the predicted frequency is obtained.
[0155] Therefore, the prediction process of the model can refer to the training process described above and will not be described in detail here.
[0156] S103: Using the predicted frequency, frequency modulation is performed on the processor in the target server.
[0157] The predicted frequency is a frequency that is adapted to the load of the target server in the future, and thus the processor in the target server can be directly adjusted to the predicted frequency, so that the frequency of the processor is adapted to the load.
[0158] In one embodiment of the present application, the load data is input into a trained prediction model to predict the load adaptation frequency to obtain the predicted frequency, including:
[0159] Inputting the load data into the trained first prediction model to perform load adaptation frequency prediction to obtain a first prediction frequency;
[0160] Inputting the load data into the trained second prediction model to perform load adaptation frequency prediction to obtain a second prediction frequency;
[0161] The first predicted frequency is weighted and modified based on the second predicted frequency to obtain a predicted frequency.
[0162] For ease of description, the above steps are combined for explanation below.
[0163] In the embodiment of the present application, a prediction model can be trained to predict the frequency of different future time periods, for example, every 10 minutes, every 30 minutes, every hour, and every day.
[0164] In actual application, different prediction models can be used to predict the frequencies in different time periods in the future. The model with a shorter time period is the first prediction model, and the model with a longer time period is the second prediction model. For the first prediction frequency output by the first prediction model, in order to avoid its jitter range being too large, the first prediction frequency can be weighted and corrected based on the second prediction frequency, thereby obtaining a prediction frequency for adjusting the processing frequency in the server. For example, the frequency output by one prediction model corresponds to the next 10 minutes, and the frequency output by another model corresponds to the next 1 hour. The frequency corresponding to the next 10 minutes and the frequency corresponding to the next 1 hour can be averaged, and the average value can be used as the prediction frequency for frequency modulation processing of the processor in the server.
[0165] Apply the method provided in the embodiment of the present application to obtain the load data of the target server; input the load data into the trained prediction model to predict the load adaptation frequency and obtain the predicted frequency; use the predicted frequency to perform frequency modulation processing on the processor in the target server; wherein, training the prediction model includes: in a production scenario, using an on-demand regulator to perform frequency modulation processing on the processor in the server, collecting first load data and a first processor frequency; in a simulated target business scenario, based on a customized frequency scheduling strategy, collecting second load data and a second processor frequency; constructing a training sample based on the first load data, the first processor frequency, the second load data and the second processor frequency; using the training sample to perform frequency prediction training on the prediction model, and obtaining the prediction model after the training is completed.
[0166] Data is collected for production scenarios and simulation scenarios to obtain load data and processor frequencies in different scenarios, and then training samples for different scenarios are constructed. The prediction model is trained based on the training samples corresponding to different scenarios to obtain a prediction model that can predict the frequency of the input load data. When it is necessary to perform frequency modulation on the processor of the target server, the load data of the server can be collected and input into the prediction model for frequency prediction to obtain the predicted frequency. Finally, the processor in the target server can be frequency modulated based on the predicted frequency. In this way, the future frequency can be predicted based on the current load data, so that the frequency modulation of the server can be adapted to the load, and is no longer limited to a few preset fixed thresholds.
[0167] Technical effect: It is possible to predict future frequencies based on the server's load data, and adjust the frequency of the processor in the server based on the predicted frequency, so that the frequency of the processor in the server is adapted to the load.
[0168] It should be noted that, based on the above embodiments, the embodiments of the present application also provide corresponding improved solutions. In the preferred / improved embodiments, the same steps or corresponding steps as those in the above embodiments can be referenced to each other, and the corresponding beneficial effects can also be referenced to each other, which will not be described one by one in the preferred / improved embodiments of this article.
[0169] In one embodiment of the present application, frequency prediction training of a prediction model is performed using training samples, including:
[0170] Get the highest frequency of the server;
[0171] Calculate the ratio of the processor frequency in the training sample to the highest frequency;
[0172] Replace the processor frequencies in the training samples with ratios;
[0173] Accordingly, the load data is input into the trained prediction model to predict the load adaptation frequency and obtain the predicted frequency, including:
[0174] Input the load data into the trained prediction model to predict the load adaptation frequency and obtain the prediction ratio;
[0175] Multiply the predicted ratio by the highest frequency of the processor in the target server to obtain the predicted frequency.
[0176] For ease of description, the above steps are combined for explanation below.
[0177] When training a model, you need to use the load data collected by carrying various types of business for training. At this time, the CPU frequency can be switched to the ratio of the CPU frequency to the maximum frequency during training to avoid hardware differences between different CPUs. After training, it is published in the form of a pre-trained model, which does not require additional training and is directly distributed to the server, which performs inference locally.
[0178] When using the trained prediction model for reasoning, the following can be done specifically: input the load data into the trained prediction model to predict the load adaptation frequency and obtain the prediction ratio; then, multiply the prediction ratio by the highest frequency of the processor in the target server to obtain the prediction frequency. In this way, the model adaptation can be achieved.
[0179] Corresponding to the above method embodiment, the embodiment of the present application further provides a frequency modulation device. The frequency modulation device described below and the frequency modulation method described above can refer to each other.
[0180] See also Figure 7 As shown, the device includes the following modules:
[0181] The load acquisition module 101 is used to acquire the load data of the target server;
[0182] The frequency prediction module 102 is used to input the load data into the trained prediction model to perform load adaptation frequency prediction and obtain the predicted frequency;
[0183] The frequency modulation processing module 103 is used to perform frequency modulation processing on the processor in the target server using the predicted frequency;
[0184] The data collection module 104 is used to collect first load data and a first processor frequency during a frequency adjustment process of a processor in a server using an on-demand regulator in a production scenario; and collect second load data and a second processor frequency during a frequency adjustment process of a processor in a server based on a customized frequency scheduling strategy in a simulated carrier target service scenario;
[0185] A sample construction module 105, configured to construct a training sample based on the first load data, the first processor frequency, the second load data, and the second processor frequency;
[0186] The model training module 106 is used to perform frequency prediction training on the prediction model using training samples, and obtain the prediction model after the training is completed.
[0187] The device provided in the embodiment of the present application is used to obtain the load data of the target server; the load data is input into the trained prediction model to predict the load adaptation frequency and obtain the predicted frequency; the processor in the target server is frequency-adjusted using the predicted frequency; wherein the training of the prediction model comprises: in a production scenario, during the frequency adjustment process of the processor in the server using an on-demand regulator, first load data and a first processor frequency are collected; in a simulated target business scenario, during the frequency adjustment process of the processor in the server based on a customized frequency scheduling strategy, second load data and a second processor frequency are collected; based on the first load data, the first processor frequency, the second load data and the second processor frequency, a training sample is constructed; the prediction model is trained for frequency prediction using the training sample, and after the training is completed, a prediction model is obtained.
[0188] Data is collected for production scenarios and simulation scenarios to obtain load data and processor frequencies in different scenarios, and then training samples for different scenarios are constructed. The prediction model is trained based on the training samples corresponding to different scenarios to obtain a prediction model that can predict the frequency of the input load data. When it is necessary to perform frequency modulation on the processor of the target server, the load data of the server can be collected and input into the prediction model for frequency prediction to obtain the predicted frequency. Finally, the processor in the target server can be frequency modulated based on the predicted frequency. In this way, the future frequency can be predicted based on the current load data, so that the frequency modulation of the server can be adapted to the load, and is no longer limited to a few preset fixed thresholds.
[0189] Technical effect: It is possible to predict future frequencies based on the server's load data, and adjust the frequency of the processor in the server based on the predicted frequency, so that the frequency of the processor in the server is adapted to the load.
[0190] In a specific implementation of the present application, the load acquisition module is specifically used to collect the processor share, memory share, and disk share of the target server using a command line tool;
[0191] The processor ratio, memory ratio, and disk ratio are determined as load data.
[0192] In a specific implementation of the present application, the sample construction module is specifically used to save the first load data and the first processor frequency in an array manner to obtain a first training sample;
[0193] The second load data and the second processor frequency are stored in an array format to obtain a second training sample.
[0194] In a specific implementation of the present application, the model training module is specifically used to obtain the highest frequency of the server;
[0195] Calculate the ratio of the processor frequency in the training sample to the highest frequency;
[0196] Replace the processor frequencies in the training samples with ratios;
[0197] Accordingly, the frequency prediction module is specifically used to input the load data into the trained prediction model to perform load adaptation frequency prediction and obtain a prediction ratio;
[0198] Multiply the predicted ratio by the highest frequency of the processor in the target server to obtain the predicted frequency.
[0199] In a specific embodiment of the present application, the prediction model includes a long short-term memory network, an attention layer, and a fully connected layer;
[0200] Accordingly, the frequency prediction module is specifically used to input the load data into the prediction model;
[0201] Using long short-term memory networks, input features are extracted from load data;
[0202] Using the attention layer, the matching degree is calculated based on the dot product of the input features and the weight matrix, and the unnormalized attention score is generated by conversion through the activation function and adding the bias term; the attention score is converted using the number theory function; after the conversion, it is normalized to obtain the attention weight of each time step; the input features are weighted summed using the attention weight to obtain the predicted load;
[0203] Using the fully connected layer, the prediction frequency adapted to the predicted load is determined.
[0204] In a specific embodiment of the present application, the prediction model includes a long short-term memory network, an attention layer, and a fully connected layer;
[0205] Accordingly, the model training module is specifically used to input the training samples into the prediction model;
[0206] Using long short-term memory networks, input features are extracted from the load data of training samples;
[0207] Using the attention layer, the matching degree is calculated based on the dot product of the input features and the weight matrix, and the unnormalized attention score is generated by conversion through the activation function and adding the bias term; the attention score is converted using the number theory function; after the conversion, it is normalized to obtain the attention weight of each time step; the input features are weighted summed using the attention weight to obtain the predicted load;
[0208] Using the loss function, calculate the first error between the predicted load and the target load in the training sample;
[0209] Adjusting the parameters of the LSTM network and / or the attention layer through neural network back propagation to reduce the first error;
[0210] After the LSTM and attention layer training converges, the prediction load is input to the fully connected layer;
[0211] Use the fully connected layer to perform frequency adaptation prediction on the predicted load to obtain the predicted frequency;
[0212] Calculate a second error between the predicted frequency and the processor frequency in the input sample using the loss function;
[0213] The parameters of the prediction model are adjusted through neural network back propagation to reduce the second error.
[0214] In a specific implementation of the present application, the frequency prediction module is specifically used to input the load data into the trained first prediction model to perform load adaptation frequency prediction to obtain a first predicted frequency;
[0215] Inputting the load data into the trained second prediction model to perform load adaptation frequency prediction to obtain a second prediction frequency;
[0216] The first predicted frequency is weighted and modified based on the second predicted frequency to obtain a predicted frequency.
[0217] Corresponding to the above method embodiment, an embodiment of the present application further provides an electronic device. The electronic device described below and the frequency modulation method described above can refer to each other.
[0218] See also Figure 8 As shown, the electronic device includes:
[0219] A memory 332, for storing computer programs;
[0220] The processor 322 is used to implement the steps of the frequency modulation method of the above method embodiment when executing the computer program.
[0221] For details, please refer to Fig. 9 , Fig. 9A schematic diagram of the specific structure of an electronic device provided for this embodiment, which may have relatively large differences due to different configurations or performances, may include one or more processors (central processing units, CPU) (for example, one or more processors) and a memory 332, and the memory 332 stores one or more computer programs 342 or data 344. Among them, the memory 332 can be a temporary storage or a permanent storage. The program stored in the memory 332 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations in the data processing device. Furthermore, the processor 322 can be configured to communicate with the memory 332 to execute a series of instruction operations in the memory 332 on the electronic device 301.
[0222] The electronic device 301 may further include one or more power supplies 326 , one or more wired or wireless network interfaces 350 , one or more input and output interfaces 358 , and / or one or more operating systems 341 .
[0223] The steps in the frequency modulation method described above can be implemented by the structure of an electronic device.
[0224] Corresponding to the above method embodiment, the embodiment of the present application further provides a readable storage medium. The readable storage medium described below and the frequency modulation method described above can refer to each other.
[0225] A readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the frequency modulation method of the above method embodiment are implemented.
[0226] The readable storage medium may specifically be a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, or other readable storage medium that can store program codes.
[0227] Corresponding to the above method embodiment, the embodiment of the present application further provides a computer program product. The computer program product described below and the frequency modulation method described above can refer to each other.
[0228] A computer program product includes a computer program / instruction. When the computer program / instruction is executed by a processor, the steps of the above-mentioned frequency modulation method are implemented.
[0229] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0230] Those skilled in the art may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented with electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0231] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0232] Finally, it should be noted that, in this article, relationships such as first and second, etc. are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms include, include or any other variations are intended to cover non-exclusive inclusion, so that a process, method, article or device that includes a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device.
[0233] Specific examples are used herein to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for those skilled in the art, according to the idea of the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A frequency modulation method, characterized in that: include: Get the load data of the target server; Inputting the load data into a trained prediction model to perform load adaptation frequency prediction to obtain a predicted frequency; Using the predicted frequency, performing frequency modulation processing on a processor in the target server; Wherein, training the prediction model comprises: In a production scenario, during a frequency adjustment process of a processor in a server using an on-demand regulator, first load data and a first processor frequency are collected; In a simulated target carrier service scenario, during a frequency adjustment process of a processor in the server based on a customized frequency scheduling strategy, collecting second load data and a second processor frequency; constructing a training sample based on the first load data, the first processor frequency, the second load data, and the second processor frequency; The prediction model is trained for frequency prediction using the training samples, and after the training is completed, the prediction model is obtained.
2. The method according to claim 1, characterized in that: Obtain the target server's load data, including: Using command line tools, collect the processor ratio, memory ratio, and disk ratio of the target server; The processor proportion, the memory proportion and the disk proportion are determined as the load data.
3. The method according to claim 1, characterized in that Constructing a training sample based on the first load data, the first processor frequency, the second load data, and the second processor frequency, including: The first load data and the first processor frequency are stored in an array to obtain a first training sample; The second load data and the second processor frequency are stored in an array format to obtain a second training sample.
4. The method according to claim 1, characterized in that: Using the training samples to perform frequency prediction training on the prediction model includes: Obtaining the highest frequency of the server; Calculating a ratio of a processor frequency in the training sample to the highest frequency; replacing the processor frequency in the training sample with the ratio; Accordingly, the load data is input into the trained prediction model to predict the load adaptation frequency, and the predicted frequency is obtained, including: Inputting the load data into a trained prediction model to predict the load adaptation frequency and obtain a prediction ratio; The predicted frequency is obtained by multiplying the predicted ratio by the highest frequency of the processor in the target server.
5. The method according to claim 1, characterized in that The prediction model includes a long short-term memory network, an attention layer, and a fully connected layer; Accordingly, the load data is input into the trained prediction model to predict the load adaptation frequency, and the predicted frequency is obtained, including: inputting the load data into the prediction model; Extracting input features from the load data using the long short-term memory network; Using the attention layer, based on the dot product of the input feature and the weight matrix, the matching degree is calculated, and an unnormalized attention score is generated by conversion through an activation function and adding a bias term; using a number theory function, the attention score is converted; after conversion, normalization is performed to obtain an attention weight for each time step; using the attention weight to perform weighted summation on the input feature to obtain a predicted load; Using the fully connected layer, a predicted frequency adapted to the predicted load is determined.
6. The method according to claim 1, characterized in that The prediction model includes a long short-term memory network, an attention layer, and a fully connected layer; Accordingly, the prediction model is trained for frequency prediction using the training samples, including: Inputting the training sample into the prediction model; Extracting input features from the load data of the training sample using the long short-term memory network; Using the attention layer, based on the dot product of the input feature and the weight matrix, the matching degree is calculated, and an unnormalized attention score is generated by conversion through an activation function and adding a bias term; using a number theory function, the attention score is converted; after conversion, normalization is performed to obtain an attention weight for each time step; using the attention weight to perform weighted summation on the input feature to obtain a predicted load; Calculate a first error between the predicted load and the target load in the training sample using a loss function; Adjusting parameters of the long short-term memory network and / or the attention layer through neural network back propagation to reduce the first error; After the long short-term memory network and the attention layer have converged in training, inputting the prediction load into the fully connected layer; Using the fully connected layer to perform frequency adaptation prediction on the predicted load to obtain a predicted frequency; Calculating a second error between the predicted frequency and the processor frequency in the input sample using a loss function; The parameters of the prediction model are adjusted through neural network back propagation to reduce the second error.
7. The method according to any one of claims 1 to 6, characterized in that: The load data is input into the trained prediction model to predict the load adaptation frequency, and the predicted frequency is obtained, including: Inputting the load data into a trained first prediction model to perform load adaptation frequency prediction to obtain a first prediction frequency; Inputting the load data into a trained second prediction model to perform load adaptation frequency prediction to obtain a second prediction frequency; The first predicted frequency is weightedly modified based on the second predicted frequency to obtain the predicted frequency.
8. A frequency modulation device, characterized in that: include: A load acquisition module is used to obtain the load data of the target server; A frequency prediction module, used for inputting the load data into a trained prediction model to perform load adaptation frequency prediction and obtain a predicted frequency; A frequency modulation processing module, used to perform frequency modulation processing on the processor in the target server using the predicted frequency; A data collection module is used to collect first load data and a first processor frequency during a frequency adjustment process of a processor in a server using an on-demand regulator in a production scenario; and to collect second load data and a second processor frequency during a frequency adjustment process of a processor in the server based on a customized frequency scheduling strategy in a simulated carrier target business scenario; a sample construction module, configured to construct a training sample based on the first load data, the first processor frequency, the second load data and the second processor frequency; The model training module is used to perform frequency prediction training on the prediction model using the training samples, and obtain the prediction model after the training is completed.
9. An electronic device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the frequency modulation method according to any one of claims 1 to 7 when executing the computer program.
10. A readable storage medium, characterized in that: The readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the frequency modulation method according to any one of claims 1 to 7 are implemented.
Citation Information
Cited By
Model training method and device, storage medium and computer equipment
CN120086025A
Model Training Method, Device, Storage Medium and Computer Equipment
CN120086025B
Energy-saving method and device for terminal equipment
CN121262639A
Constant-temperature crystal oscillator time keeping method and system based on LSTM neural network
CN121995725A
Cluster CPU cooperative frequency regulation method and system, computer equipment and medium
CN122019189A
