Software component hot upgrade method and system based on dynamic switching of execution context
By preprocessing and risk assessment of thread switching monitoring data, safe switching opportunities in a multi-threaded environment are identified, solving the problems of illegal addresses and segmentation faults after thread switching, and achieving safe and stable upgrades in a multi-threaded environment.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-18
- Publication Date
- 2026-03-10
AI Technical Summary
Existing technologies cannot accurately identify the safe switching timing of threads in I/O blocking or lock waiting states in a multi-threaded service component runtime environment, resulting in illegal new code segment addresses and segmentation faults after thread switching.
By collecting context switching monitoring data, performing time base correction, noise suppression, anomaly removal, and feature dimensionality reduction, a thread-level data sequence is constructed to assess switching risks. At a safe time, the scheduling queue is frozen, thread switching is executed, and the stability of the switching process is evaluated to achieve closed-loop control.
Automatically identify switching risks in a multi-threaded environment to avoid execution flow interruptions or resource access conflicts caused by incorrect switching timing, improve thread scheduling safety, and ensure the continuous and stable operation of the system under complex load conditions.
Smart Images

Figure CN121636253A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of thread switching technology, specifically to a method and system for hot-upgrading software components based on dynamic switching of execution context. Background Technology
[0002] With the continuous development of artificial intelligence technology, application software systems are showing a trend towards high modularity and intelligence. To adapt to the continuous evolution of complex business scenarios, software systems need to have the ability to respond quickly and expand flexibly during operation, thus placing higher demands on the real-time optimization and upgrading of components. Existing research is gradually introducing artificial intelligence decision-making mechanisms into software operation management to achieve intelligent perception and dynamic adjustment of system status, thereby improving the operating efficiency and resource utilization of application software in multi-threaded environments.
[0003] For example, invention publication number CN106598682A discloses a component upgrade method and apparatus, belonging to the field of computer technology. The method includes: sending an upgrade package for the component to be upgraded to M test users; obtaining component operation data from N upgraded test users; when it is determined, based on the component operation data from the N upgraded test users, that the upgrade package for the component to be upgraded can run stably, gradually increasing the number of test users until component operation data from S upgraded test users is obtained, and based on the component operation data from the S upgraded test users, it is determined that the upgrade package for the component to be upgraded can run stably, and then sending the upgrade package for the component to be upgraded to each un-upgraded user. This invention adopts a step-by-step upgrade method for upgrading the component to be upgraded. During each upgrade process, by monitoring the component operation data of the upgraded test users, it automatically determines whether to continue the upgrade or stop the upgrade, thereby achieving the purpose of real-time monitoring of upgrade risks, thus making the upgrade method more reasonable.
[0004] For example, the invention disclosed in CN104866341A discloses a component upgrade method, including: determining a target component among the loaded components that can be upgraded based on component information corresponding to components already loaded in the target software and the latest version component information of the loaded components from the network side, wherein the target component is a component whose component information is not the latest version; obtaining an upgrade package file of the target component from the network side; and using the obtained upgrade package file to upgrade the target component in the target software. This invention embodiment also discloses a component upgrade device and terminal. Using this invention embodiment can improve the efficiency of component upgrades.
[0005] However, in a multi-threaded service component runtime environment, complex synchronization and lock contention relationships exist between threads, and some threads may be in an I / O blocking or lock waiting state during execution. Existing technical solutions often cannot accurately identify the safe switching time for these threads without affecting system operation. If component replacement is performed at an inappropriate time, it may cause the thread to be woken up and point to an invalid new code segment address, thereby causing a segmentation fault or system crash.
[0006] Therefore, in order to address the above problems, there is an urgent need for a method and system for hot-upgrading software components based on dynamic switching of execution context. Summary of the Invention
[0007] Technical problems to be solved To address the shortcomings of existing technologies, this invention provides a method and system for hot upgrading of software components based on dynamic switching of execution context. This solves the problem that existing technologies cannot identify the safe switching timing of threads that are in I / O blocking and lock waiting states, which leads to illegal new code segment addresses and segmentation faults after thread switching.
[0008] Technical solution To achieve the above objectives, the present invention provides the following technical solution: a software component hot upgrade method and system based on dynamic execution context switching, comprising: S1, collecting context switching monitoring data, and performing time base correction, noise suppression, anomaly removal, feature dimensionality reduction and standardization processing on the context switching monitoring data to obtain preprocessed context switching monitoring data; S2, constructing a thread-level data sequence and marking switchable threads based on the preprocessed context switching monitoring data, assessing the current switching risk of each switchable thread, and outputting a switchable window sequence based on the assessment results; S3, comprehensively assessing the switching safety of each switchable thread within the corresponding switchable window, and determining a safe switching timing point based on the assessment results; S4, freezing the scheduling queue of the target thread at the safe switching timing point, performing thread switching, extracting context switching monitoring data before and after the switching, assessing the stability of the switching process, determining whether to unfreeze the scheduling queue, and completing the closed-loop control of component hot upgrade.
[0009] Further, context switching monitoring data is collected, and time-base correction, noise suppression, anomaly removal, feature dimensionality reduction, and standardization are performed on the context switching monitoring data to obtain preprocessed context switching monitoring data. The specific steps are as follows: Real-time collection of context switching monitoring data for running threads, including thread number, thread CPU time, CPU execution cycles, thread switching count, context capture time, context recovery time, I / O blocking duration, I / O in-transit data volume, I / O throughput rate, lock wait time, and CPU utilization; the collected context switching monitoring data is resampled using timestamps. The algorithm performs unified time base correction to ensure that the sampled data is aligned on the time axis; it uses a sliding median filter algorithm to suppress noise in the context switching monitoring data, reducing scheduling jitter and transient spike interference; it uses a linear interpolation algorithm to compensate for missing sampling points in the context switching monitoring data; it uses a local anomaly factor algorithm to identify and remove abnormal data in the context switching monitoring data; it uses principal component analysis to perform feature dimensionality reduction and multi-index correlation analysis on the context switching monitoring data, removing redundant data; and it combines the Z-Score standardization algorithm to standardize the context switching monitoring data, unifying the numerical scale and eliminating dimensional differences.
[0010] Furthermore, based on the preprocessed context switching monitoring data, the specific steps for constructing a thread-level data sequence and marking switchable threads are as follows: For threads in I / O blocking and lock waiting states, the preprocessed context switching monitoring data is grouped by thread number as index, and a thread-level data sequence is established in chronological order; a fixed-width sliding time window is set as an evaluation period, and the remaining I / O blocking time, remaining lock waiting time, and CPU execution cycle variance of each thread are periodically calculated; the remaining I / O blocking time and remaining lock waiting time of adjacent evaluation periods are differentiated to generate corresponding time change rate sequences; when both are detected to be monotonically decreasing and the time change rate is less than the corresponding threshold, the thread is marked as a switchable thread.
[0011] Further, the specific steps for assessing the current switching risk of each switchable thread and outputting a switchable window sequence based on the assessment results are as follows: For all switchable threads, divide the thread's CPU usage time by the sum of the remaining I / O blocking time and the remaining lock waiting time to obtain the resource usage ratio; take the negative of the ratio of the CPU execution cycle variance to the standard CPU execution cycle variance as the exponent, and take the power function value with base e to obtain the execution stability decay term; add one to the ratio of CPU utilization to the rated CPU utilization and take the reciprocal to obtain the system load constraint term; multiply the resource usage ratio term, the execution stability decay term, and the system load constraint term in sequence to obtain the switching risk assessment value; compare the switching risk assessment value and the risk threshold in real time; when the switching risk assessment value is less than the risk threshold for N consecutive assessment cycles, mark the corresponding time window as a switchable window; merge adjacent switchable windows within the same thread and output a switchable window sequence organized by thread number.
[0012] Furthermore, for each switchable thread, the specific steps for comprehensively evaluating switching safety within the corresponding switchable window are as follows: Extract the switchable window for each switchable thread, obtain the switchable window duration for each switchable window, and calculate the CPU utilization change rate and I / O in-transit data change rate in real time within the switchable window; within the switchable window, calculate in real time the ratio of CPU execution cycle variance to standard CPU execution cycle variance to obtain the execution fluctuation suppression term; subtract the sum of context capture time and context recovery time from the switchable window duration, and then divide by the switchable window duration. The following steps are performed: First, calculate the time utilization ratio. Second, multiply the execution fluctuation suppression ratio by the time utilization ratio to obtain the overall execution stability. Third, add one to the ratio of the current CPU utilization to the rated CPU utilization to obtain the system load coefficient. Fourth, add one to the ratio of the current I / O data in transit to the rated I / O data in transit to obtain the data flow coefficient. Fifth, average the absolute values of the CPU utilization change rate and the I / O data in transit change rate and add one to obtain the system dynamic adjustment coefficient. Sixth, divide the overall execution stability by the product of the system load coefficient, the data flow coefficient, and the system dynamic adjustment coefficient to obtain the switching safety assessment value.
[0013] Furthermore, the specific steps for determining the safe handover timing based on the assessment results are as follows: monitor the handover safety assessment value within the switchable window in real time. If the handover safety assessment value is greater than the safety threshold for K consecutive times, then the current moment is determined as the safe handover timing point; if the handover safety assessment value is always lower than the adaptation threshold within the switchable window, then the last moment of the switchable window is determined as the safe handover timing point.
[0014] Furthermore, at the safe switching point, the target thread's scheduling queue is frozen, and the specific steps for thread switching are as follows: After determining the safe switching point, the target thread's scheduling queue is frozen, the thread's context state data is stored in the thread context buffer, and the program counter, register set, stack pointer, and lock holding information are read to generate and store a context integrity check code; the new version of the target component's code segment is loaded, and instruction base address relocation is performed according to the address mapping relationship between the thread number and the old version; the function entry mapping tables of the new and old versions are compared, and when a difference in return address offset is detected, the stack frame layout is dynamically adjusted and register remapping is performed based on the register set and stack pointer information in the thread context buffer; the context restoration operation is performed, and the cached context data is written to the new version's execution space.
[0015] Furthermore, the specific steps for extracting context switching monitoring data before and after the switch and evaluating the stability of the switch process are as follows: Add one to the ratio of the number of CPU execution cycles of the thread before and after the switch, and take the natural logarithm; square the ratio of the number of thread switches before and after the switch, and add the two together to obtain the performance response term; normalize and square the differences in CPU utilization, I / O throughput, and lock wait time before and after the switch, sum the results, and take the mean; multiply the square root of the mean by the time decay coefficient to obtain the dynamic perturbation term; divide the performance response term by one and add the dynamic perturbation term to obtain the switch convergence evaluation value.
[0016] Furthermore, the specific steps for determining whether to unfreeze the scheduling queue and complete the closed-loop control of component hot upgrade are as follows: Real-time monitoring of the changing trend of the switching convergence evaluation value, and calculation of the mean and variance of the switching convergence evaluation value. When the mean of the switching convergence evaluation value continues to rise for M consecutive times and the variance is less than or equal to the stability threshold, it is determined that the system has entered a convergence and stability state, the thread scheduling queue is unfrozen, and normal task allocation is restored; otherwise, it is determined that there is a risk of performance oscillation, the adaptive rollback mechanism is triggered, thread execution is paused, the old version of the component is restored and the thread context buffer data is reloaded, and the switching is performed again after re-determining the safe switching time point to complete the component hot upgrade.
[0017] The second aspect of this invention provides a software component hot upgrade system based on dynamic execution context switching, comprising: a data acquisition and preprocessing module, a switching risk assessment module, a switching safety determination module, and a switching convergence control module, wherein: the data acquisition and preprocessing module is used to acquire context switching monitoring data and perform time base correction, noise suppression, anomaly removal, feature dimensionality reduction, and standardization processing on the context switching monitoring data to obtain preprocessed context switching monitoring data; the switching risk assessment module is used to construct a thread-level data sequence and mark switchable threads based on the preprocessed context switching monitoring data, assess the current switching risk of each switchable thread, and output a switchable window sequence based on the assessment results; the switching safety determination module is used to comprehensively assess the switching safety of each switchable thread within the corresponding switchable window, and determine the safe switching timing point based on the assessment results; the switching convergence control module is used to freeze the scheduling queue of the target thread at the safe switching timing point, execute thread switching, extract context switching monitoring data before and after the switching, assess the stability of the switching process, determine whether to unfreeze the scheduling queue, and complete the closed-loop control of component hot upgrade.
[0018] Beneficial effects The present invention has the following beneficial effects: (1) The software component hot upgrade method and system based on dynamic switching of execution context constructs a thread-level data sequence and quantifies the switchability of thread operation, and proposes a dynamic judgment mechanism for switching risk assessment value. It can automatically identify the switching risk of threads in a blocked or waiting state in a multi-threaded concurrent environment, effectively avoid the problem of execution flow interruption or resource access conflict caused by incorrect selection of switching time, and significantly improve the thread scheduling security of the hot upgrade process.
[0019] (2) The software component hot upgrade method and system based on dynamic switching of execution context, by comprehensively introducing multi-dimensional constraint factors such as CPU execution cycle variance, context capture and recovery time, CPU utilization and I / O in-transit data volume within the switchable window, calculates the switching safety assessment value, quantifies the thread switching safety, realizes dynamic prediction and safety decision of switching behavior in multi-threaded environment, and ensures that thread switching is completed within the system's tolerance range.
[0020] (3) The software component hot upgrade method and system based on dynamic switching of execution context normalizes the changes in CPU execution cycle number, thread switching number, I / O throughput rate and lock waiting time before and after switching, and combines the time decay coefficient for dynamic weighting to quantitatively evaluate the stability of the switching process. This effectively makes up for the shortcomings of traditional switching evaluation methods that cannot dynamically capture performance disturbances and response delays, and provides an accurate basis for adaptive judgment of system performance after switching.
[0021] (4) The software component hot upgrade method and system based on dynamic switching of execution context automatically determines whether it has entered a stable state or experienced performance oscillation by monitoring the changing trend of convergence mean and variance, and constructs a two-way feedback mechanism to realize the self-awareness and self-correction of thread switching state during hot upgrade, ensuring the continuous and stable operation of the system under complex load conditions. Attached Figure Description
[0022] Figure 1 A flowchart illustrating a method for hot-upgrading software components based on dynamic switching of execution context; Figure 2 This is a system architecture diagram for hot upgrades of software components based on dynamic switching of execution context. Figure 3 This is a diagram showing the results of the switchable window determination based on the switching risk assessment value; Figure 4 This is a flowchart of the closed-loop control for component hot upgrade based on switching convergence evaluation. Detailed Implementation
[0023] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0024] Please see Figures 1-4 This invention provides a technical solution: a method and system for hot upgrading of software components based on dynamic switching of execution context, comprising: S1, collecting context switching monitoring data, and performing time base correction, noise suppression, anomaly removal, feature dimensionality reduction and standardization processing on the context switching monitoring data to obtain preprocessed context switching monitoring data; S2, constructing a thread-level data sequence and marking switchable threads based on the preprocessed context switching monitoring data, assessing the current switching risk of each switchable thread, and outputting a switchable window sequence based on the assessment results; S3, comprehensively assessing the switching safety of each switchable thread within the corresponding switchable window, and determining a safe switching timing point based on the assessment results; S4, freezing the scheduling queue of the target thread at the safe switching timing point, performing thread switching, extracting context switching monitoring data before and after the switching, assessing the stability of the switching process, determining whether to unfreeze the scheduling queue, and completing the closed-loop control of component hot upgrading.
[0025] Specifically, the following steps are taken to collect context switching monitoring data and perform time base correction, noise suppression, anomaly removal, feature dimensionality reduction and standardization on the context switching monitoring data to obtain preprocessed context switching monitoring data: Real-time collection of context switching monitoring data of running threads. Context switching monitoring data includes thread number, thread CPU time, number of CPU execution cycles, number of thread switches, context capture time, context recovery time, I / O blocking duration, I / O in-transit data volume, I / O throughput rate, lock wait time and CPU utilization. The thread ID is directly extracted from the scheduler's assigned identifier; the thread's CPU usage time is read using a high-precision performance counter; the number of CPU execution cycles is obtained from the processor's internal performance counter register; the number of thread switches is accumulated from the switching events recorded by the system scheduler; the context capture time and context recovery time are calculated by the time difference during context saving and recovery, respectively; the I / O blocking duration is obtained from the time difference between the start and end of blocking recorded by the system I / O scheduler; the amount of I / O data in transit is obtained in real time based on the number of bytes to be processed in the transmission queue; the I / O throughput rate is calculated as the total amount of I / O data transmitted per unit time; the lock wait time is determined by the difference between the duration of thread lock holding and the waiting state; and the CPU utilization rate is calculated as the ratio of processor activity cycles to the total number of cycles. During data acquisition, a combination of periodic sampling and event-triggered sampling mechanisms is used for different thread running states to ensure dynamic consistency in the monitoring accuracy of high-frequency and low-frequency switching threads. All collected data is accompanied by a high-precision timestamp for subsequent timeline alignment and multi-threaded data correlation analysis. For the collected context switching monitoring data, a unified time base correction is performed using a timestamp resampling algorithm to ensure that the sampled data is aligned on the time axis. During the time base correction process, interpolation correction is performed on context switching monitoring data collected at different times, based on a unified sampling period, to maintain data continuity at the same time scale, thereby eliminating time offsets caused by differences in sampling periods. A sliding median filtering algorithm is used to suppress noise in the context switching monitoring data, reducing scheduling jitter and transient spike interference, and improving signal stability. A linear interpolation algorithm is used to compensate for missing sampling points in the context switching monitoring data. During compensation, interpolation calculations are performed based on the difference between the number of CPU execution cycles and the amount of I / O data in transit at adjacent times, ensuring that the compensation result is consistent with the original trend and guaranteeing the integrity of the time series data. A local anomaly factor algorithm is used to identify and remove abnormal data in the context switching monitoring data to avoid interference from subsequent analysis. Principal component analysis is used to perform feature dimensionality reduction and multi-indicator correlation analysis on the context switching monitoring data, removing redundant information and retaining core features reflecting thread running status, improving analysis efficiency and computational accuracy. The Z-Score standardization algorithm is used to standardize the context switching monitoring data, unify the numerical scale, and eliminate dimensional differences.During standardization, the mean and standard deviation of each context switching monitoring data are used as the benchmark to perform normalization calculations on each context switching monitoring data, so that the characteristics of different dimensions are within a unified range, thereby ensuring the numerical stability and comparability of subsequent risk assessment and trend analysis.
[0026] In this implementation scheme, high-fidelity restoration and high-consistency characterization of thread runtime state data are achieved through refined collection and multi-level preprocessing of context switching monitoring data. This method effectively reduces interference from sampling jitter, measurement drift, and abrupt noise during data time-series alignment, anomaly removal, and numerical normalization. This ensures that thread CPU usage time, CPU execution cycles, I / O blocking duration, I / O throughput, lock wait time, and CPU utilization maintain a stable correlation in both time dimension and statistical characteristics. This improves the reliability of thread behavior data and the computational accuracy in dynamic switching scenarios, providing a verifiable, high-quality data foundation for subsequent switching risk quantification and security assessment.
[0027] Specifically, based on the preprocessed context switching monitoring data, the steps for constructing thread-level data sequences and marking switchable threads are as follows: For threads in I / O blocking and lock waiting states, the preprocessed context switching monitoring data is grouped using thread IDs as indices, and thread-level data sequences are established in chronological order. During the construction of the thread-level data sequences, a timestamp sorting mechanism is used to sequentially arrange the I / O blocking duration, lock waiting duration, CPU execution cycles, thread switching counts, thread CPU usage time, and CPU utilization collected at different time periods, ensuring that the running state of each thread has complete temporal continuity and traceability. After the data sequences are established, a fixed-width sliding time window is set as an evaluation period, and the remaining I / O blocking time, remaining lock waiting time, and CPU execution cycle variance are periodically calculated within each evaluation period. The width of the sliding time window is set according to the scheduling sampling interval, ensuring that the sampling frequency of thread state change characteristics remains stable and consistent under different operating loads. The remaining I / O blocking time is estimated based on the decreasing trend of I / O blocking duration within the current sampling period; the remaining lock waiting time is calculated based on the difference in lock waiting time between consecutive sampling points; the CPU execution cycle variance is obtained based on the dispersion of the number of CPU execution cycles of the same thread within the current evaluation period to reflect the computational stability during thread execution. Subsequently, the remaining I / O blocking time and remaining lock waiting time of adjacent evaluation periods are differentially calculated to generate corresponding time change rate sequences. The time change rate sequences are used to characterize the dynamic fluctuation characteristics of thread resource occupancy. A sliding two-cycle calculation method is used during differential calculation to reduce the interference of transient scheduling jitter on the change trend and improve the stability of time change rate determination. When the time change rates of I / O blocking time and remaining lock waiting time are detected to show a monotonically decreasing trend in multiple consecutive evaluation periods, and the decrease is less than the corresponding threshold, the thread is determined to have entered a stable migration stage and is marked as a switchable thread, providing dynamic, continuous, and highly consistent data support for subsequent switching risk quantification analysis and comprehensive security assessment.
[0028] In this implementation scheme, a thread-level data sequence is constructed based on preprocessed context switching monitoring data, and switchable threads are marked, enabling dynamic identification and fine-grained differentiation of thread running states. This method utilizes the time variation patterns of I / O blocking remaining time, lock waiting remaining time, and CPU execution cycle variance to accurately identify the stable running phase of a thread in a multi-threaded concurrent environment, effectively avoiding context recovery anomalies and execution interruptions caused by incorrect switching timing. Through trend analysis of the rate of change over continuous periods, the temporal continuity of switchable thread determination and the stability of the determination results are ensured, improving the adaptability to resource state fluctuations during thread migration and providing a reliable dynamic basis for determining safe switching points.
[0029] Specifically, the steps for assessing the current switching risk of each switchable thread and outputting a switchable window sequence based on the assessment results are as follows: For all marked switchable threads, firstly, three core parameters are extracted based on the running data of continuous sampling periods: thread CPU usage time, remaining I / O blocking time, and remaining lock waiting time. The thread CPU usage time is divided by the sum of the remaining I / O blocking time and the remaining lock waiting time to obtain a resource usage ratio, which reflects the thread's resource usage intensity under constrained resource conditions. Normalization is used in the calculation of the resource usage ratio to ensure the comparability of numerical scales between different threads and to suppress transient anomalies caused by load fluctuations. Subsequently, the CPU execution cycle variance of the thread in the current assessment period and the standard CPU execution cycle variance are obtained, and their ratio is calculated. The negative of this ratio is used as the exponent, and the result is a power function value with base e, yielding an execution stability decay term, used to quantify the thread's sensitivity to fluctuations in execution state. Furthermore, the current CPU utilization and the rated CPU utilization are extracted, and the ratio of the two is increased by one and the reciprocal is taken to obtain the system load constraint term, which is used to characterize the degree of dependence of the thread on the overall CPU load during thread execution. The resource occupancy ratio term, the execution stability decay term, and the system load constraint term are multiplied in sequence to obtain the switching risk assessment value. This assessment value comprehensively reflects the interaction between thread resource occupancy intensity, execution stability, and system load state, and is the core basis for determining the switchable window. The calculation of the switching risk assessment value is updated with a sliding time window as the base period to ensure its real-time response to changes in thread running state. After obtaining the switching risk assessment value, it is compared with the risk threshold in real time. When the switching risk assessment value is less than the risk threshold for N consecutive assessment periods, it is determined that the thread running state is stable within that time interval, and the corresponding time window is marked as a switchable window, where N is a positive integer value. For adjacent switchable windows within the same thread, if the time interval is less than the spacing threshold, the windows are merged to form a switchable interval for a continuous time period. The final output is a sequence of switchable windows organized by thread number, providing a clear timing reference and status basis for subsequent security assessment and determination of switching timing.
[0030] The specific formula for calculating the switching risk assessment value is as follows: ; In the formula, This indicates a switch to the risk assessment value. Indicates the remaining I / O blocking time. Indicates the remaining time the lock is waiting. This indicates the CPU time used by the thread. This represents the variance of CPU execution cycles. This represents the variance of standard CPU execution cycles. Indicates CPU utilization. This indicates the rated CPU utilization.
[0031] In this embodiment, Table 1 is a data table of switching risk assessment values, listing the key monitoring parameters and corresponding switching risk assessment values for five assessment periods. The key parameters used include: remaining I / O blocking time, remaining lock wait time, thread CPU usage time, CPU execution cycle variance, standard CPU execution cycle variance, CPU utilization, and rated CPU utilization. The specific data is as follows: In evaluation period 1, the remaining I / O blocking time was 38.2 seconds, the remaining lock wait time was 25.6 seconds, the thread CPU usage time was 9.4 seconds, the CPU execution cycle variance was 1.05 seconds, the standard CPU execution cycle variance was 2.00 seconds, the CPU utilization was 65%, the rated CPU utilization was 90%, and the corresponding switching risk assessment value was 0.178. In evaluation period 2, the remaining I / O blocking time was 30.7 seconds, the remaining lock wait time was 22.1 seconds, the thread CPU usage time was 10.2 seconds, the CPU execution cycle variance was 0.96 seconds, the standard CPU execution cycle variance was 2.00 seconds, the CPU utilization was 60%, the rated CPU utilization was 90%, and the corresponding switching risk assessment value was 0.135. In evaluation period 3, the remaining I / O blocking time was 26.5 seconds, the remaining lock wait time was 18.9 seconds, the thread CPU usage time was 11.6 seconds, and the CPU execution cycle variance was 1.05 seconds, the standard CPU execution cycle variance was 2.00 seconds, the CPU utilization was 60%, the rated CPU utilization was 90%, and the corresponding switching risk assessment value was 0.135. The variance is 0.87, the standard CPU execution cycle variance is 2.00, the CPU utilization is 58, the rated CPU utilization is 90, and the corresponding switching risk assessment value is 0.101. In assessment cycle 4, the remaining I / O blocking time is 21.3, the remaining lock waiting time is 16.7, the thread CPU usage time is 12.4, the CPU execution cycle variance is 0.81, the standard CPU execution cycle variance is 2.00, the CPU utilization is 55, the rated CPU utilization is 90, and the corresponding switching risk assessment value is 0.072. In assessment cycle 5, the remaining I / O blocking time is 18.4, the remaining lock waiting time is 14.2, the thread CPU usage time is 13.3, the CPU execution cycle variance is 0.75, the standard CPU execution cycle variance is 2.00, the CPU utilization is 52, the rated CPU utilization is 90, and the corresponding switching risk assessment value is 0.051.
[0032] Table 1 Switching Risk Assessment Values Data Table
[0033] like Figure 3The figure shows the trend of the switching risk assessment value of a single switchable thread over five consecutive assessment periods, reflecting the switching safety and risk status of the thread at different operational stages. The figure depicts the risk assessment results for each assessment period in a line graph, with the vertical axis representing the switching risk assessment value S and the horizontal axis representing the assessment period. A blue dashed line is set as the risk threshold to distinguish whether a thread is in a safe and switchable state within the current period. As can be seen from the figure, the switching risk assessment value gradually decreases as the period progresses. The line points for assessment periods 3, 4, and 5 are marked in red, indicating that the risk assessment value in these periods has fallen below the risk threshold, and the corresponding thread has entered the switchable window. Figure 3 It intuitively displays the evolution trend of thread switching risks during operation, effectively identifies the time window for safe switching, and provides quantitative basis and visual decision support for dynamic hot upgrades of multi-threaded components, thereby ensuring smooth transition and stable switching of the system during operation.
[0034] In this implementation, by quantifying the switching risk of switchable threads and outputting a switchable window sequence, the precise identification and dynamic filtering of thread-level safe switching conditions are achieved. This method establishes a dynamic balance mechanism between risk and stability by comprehensively considering multi-dimensional characteristics such as thread CPU usage time, remaining I / O blocking time, remaining lock wait time, CPU execution cycle variance, and CPU utilization. Through trend determination over continuous evaluation periods, it can effectively identify the sustained stable intervals of thread running states, thereby avoiding unsafe switching during periods of high system load or thread execution fluctuations. This design improves the accuracy and robustness of thread switchable window determination, providing reliable preliminary data support for subsequent safe switching assessments and stability control.
[0035] Specifically, the steps for comprehensively evaluating the switching safety of each switchable thread within its corresponding switchable window are as follows: First, extract the switchable window for each switchable thread and obtain the switchable window duration based on time-series records. Then, calculate the CPU utilization rate change rate and the I / O data in transit rate change rate in real time within the switchable window. Extract the dynamic trends of these two parameters using a sliding time difference method to quantify the fluctuations in thread load and I / O data flow. Within the switchable window, the ratio of the CPU execution cycle variance to the standard CPU execution cycle variance is calculated in real time to obtain the execution fluctuation suppression term, which describes the stability of the thread before switching. Next, the sum of context capture and context recovery times is subtracted from the switchable window duration, and then divided by the switchable window duration to obtain the time utilization ratio, which reflects the proportion of time the thread can use to execute effective tasks during the switchable window. Subsequently, the execution fluctuation suppression term is multiplied by the time utilization ratio to obtain the overall execution stability, which measures the combined performance of thread stability and operability. Finally, the current CPU utilization and the rated CPU utilization are extracted, and the ratio of the two is added to obtain the system negative value. The load factor reflects the real-time load level of the thread's execution environment. Next, the ratio of the current I / O data in transit to the rated I / O data in transit is extracted and incremented by one to obtain the data flow factor, used to evaluate the thread's data processing status during I / O operations. The absolute values of the CPU utilization change rate and the I / O data in transit change rate are averaged and incremented by one to obtain the system dynamic adjustment factor, used to measure the dynamic fluctuations of the thread's execution environment. Finally, the overall execution stability is divided by the product of the system load factor, data flow factor, and system dynamic adjustment factor to obtain the switching safety assessment value, used to quantitatively reflect the overall safety status of the thread within the switchable window; the larger the value, the more stable and lower-risk the thread is in the switching environment.
[0036] The specific calculation formula for switching security assessment values is as follows: ; In the formula, This indicates a switch to the security assessment value. This represents the variance of CPU execution cycles. This represents the variance of standard CPU execution cycles. Indicates the duration of the switchable window. Indicates the time spent capturing the context. Indicates the time taken for context recovery. This indicates the current CPU utilization. Indicates the rated CPU utilization. This indicates the amount of data currently in transit for I / O. Indicates the rated amount of data in transit for I / O. This indicates the rate of change in CPU utilization. This indicates the rate of change of the amount of I / O data in transit.
[0037] This implementation scheme achieves quantitative judgment and dynamic optimization of switching safety by comprehensively evaluating the thread running state within a switchable window from multiple dimensions. During the calculation process, this method correlates and analyzes core parameters such as CPU utilization change rate, I / O in-transit data change rate, CPU execution cycle variance, context capture time, context recovery time, and switchable window duration, forming a safety assessment system that considers both time and execution characteristics. By comprehensively constraining execution stability with system load coefficient, data flow coefficient, and system dynamic adjustment coefficient, it can effectively identify safe switching intervals for threads during execution, avoiding potential anomalies caused by resource contention or execution fluctuations. This design improves the accuracy of thread switching timing determination, making thread migration in dynamic environments smoother and more stable, and providing a solid safety guarantee for context recovery and performance convergence in subsequent execution phases.
[0038] Specifically, the steps for determining the safe switching timing point based on the evaluation results are as follows: Within the switchable window, the changing trend of the switching safety evaluation value is monitored in real time, and the numerical sequence of continuous sampling periods is smoothed to reduce interference caused by transient fluctuations. During continuous monitoring, if the switching safety evaluation value is detected to be greater than the safety threshold for K consecutive times, it indicates that the current thread is in a stable switchable state, and the current moment is determined as the safe switching timing point; where K is a positive integer value. If the switching safety evaluation value is always lower than the safety threshold throughout the entire duration of the switchable window, the last moment of the switchable window is determined as the safe switching timing point to implement a delayed triggering mechanism. The delayed triggering mechanism ensures that the thread re-enters a stable state in the next evaluation period before performing the switching operation, thereby avoiding context recovery anomalies caused by premature execution.
[0039] In this implementation scheme, by introducing a continuity judgment mechanism and a delayed triggering strategy, the determination of the safe switching timing point has higher stability and adaptability. This method comprehensively considers the continuous change characteristics of the time series during real-time monitoring of the switching safety assessment value, so that the switching judgment no longer relies on a single instantaneous value, but rather forms a stable criterion based on the dynamic trend of continuous multi-periods. By constraining the fluctuation range and time delay of the assessment value, false triggering caused by short-term jitter or periodic load fluctuations is effectively avoided. This design ensures that the selection of the safe switching timing is more in line with the actual running state of the thread, significantly improving the accuracy of timing determination within the switchable window, thereby enhancing the timing coordination and execution reliability of context switching operations during thread migration.
[0040] Specifically, at the safe switching point, the target thread's scheduling queue is frozen. The specific steps for thread switching are as follows: After determining the safe switching point, the target thread's scheduling queue is immediately frozen to prevent new scheduling requests from entering the execution queue, ensuring state consistency during thread switching. During the freezing process, the thread priority and execution sequence number information of the current scheduling queue are recorded to maintain the original scheduling order during subsequent recovery and avoid scheduling disorder caused by resource contention. After freezing, the thread's context state data is completely stored in the thread context buffer. The stored data includes the current value of the program counter, the contents of general-purpose registers and status registers in the register set, the stack top address information indicated by the stack pointer, and the lock identifier and lock-holding thread number in the lock holding information. To ensure the integrity and consistency of data during cross-version migration, double verification is performed on the stored context state data. A context integrity check code is generated based on the field hash and byte-level verification results and written to the secure storage area. Subsequently, the new version code segment of the target component is loaded, and during the loading process, the thread number index table and the address mapping information of the old version component are read, and instruction base address relocation is performed. This process ensures that the new version of the code correctly interfaces with the call paths in the original thread context, thus avoiding incorrect instruction jump addresses. After code relocation is complete, the function entry mapping tables of the old and new versions are compared. When a difference in return address offset is detected, the stack frame layout is dynamically adjusted based on the register set and stack pointer information in the thread context buffer, stack space offset addresses are reallocated, and the register mapping table is reconstructed to ensure that the execution space of the new version maintains a logical correspondence with the running state of the old version. Finally, a context recovery operation is performed, writing the verified context data item by item into the execution space of the new version, and verifying the state of key registers and the position of the stack pointer to ensure that the thread can correctly resume its execution flow at the instruction entry point after the switch. This process achieves safe migration of context during version switching, providing a reliable operational foundation for subsequent performance evaluation and convergence judgment.
[0041] In this implementation, by freezing the thread scheduling process and performing a complete context state migration at the safe switching point, the thread switching operation achieves higher atomicity and data consistency. This method establishes a precise mapping relationship from the register set to the stack pointer throughout the entire process of context capture, storage, verification, and restoration, ensuring instruction continuity and logical consistency of the thread in the new version's execution space. By introducing a context integrity check code and a dual mapping relocation mechanism, execution interruptions caused by instruction entry errors and return address offsets are effectively prevented, significantly reducing the probability of exceptions during thread switching. This design enables smooth context transitions during dynamic component upgrades, improving the safety and execution stability of thread switching, and fundamentally guaranteeing the operational reliability of multi-threaded tasks during hot upgrades.
[0042] Specifically, the steps for extracting context switching monitoring data before and after the switch and evaluating the stability of the switch process are as follows: First, extract context switching monitoring data before and after the switch, and align the timestamps of the sampled data at different time points to ensure consistent sampling timing of thread states. Then, calculate the ratio of the number of CPU execution cycles of the thread before and after the switch to reflect the trend of thread execution efficiency changes before and after version migration. Add one to the obtained ratio and take the natural logarithm. The logarithmic function compresses the impact of abnormal fluctuations, making the evaluation results insensitive to transient jitter, thus more accurately reflecting the true response of thread execution performance. Based on this, calculate the ratio of the number of thread switches before and after the switch to quantify the difference in thread scheduling activity before and after migration. To enhance the weighted expression of the changing trend, square the ratio of the number of thread switches to increase the sensitivity of the evaluation by amplifying the impact of high-difference intervals. Add the obtained natural logarithm term to the squared term to form a performance response term that comprehensively reflects the CPU load response and thread scheduling changes, used to characterize the overall degree of change in thread performance characteristics during the switch process. Next, the differences in CPU utilization, I / O throughput, and lock wait time before and after the switchover are normalized item by item to eliminate dimensional differences. The squares of the three normalized differences are then summed to balance the contribution of different performance metrics to the overall disturbance. The mean of the sum of squares is taken, and then the square root of the mean is calculated to obtain the overall amplitude of the performance fluctuation. A time decay coefficient is then introduced to give higher weight to short-term fluctuations and to adjust for long-term stable differences, resulting in a dynamic disturbance term used to quantify the degree of external interference affecting the system during the switchover. The time decay coefficient is calculated using time-series data of CPU utilization, I / O throughput, and lock wait time before and after the switchover, using an exponentially weighted moving average algorithm, with a value ranging from 0 to 1. Finally, the performance response term is divided by the dynamic disturbance term to calculate the switchover convergence evaluation value, which comprehensively measures the system's performance recovery speed and operational stability after the switchover.
[0043] The specific formula for calculating the switching convergence evaluation value is as follows: ; In the formula, This indicates switching the convergence evaluation value. This indicates the number of CPU execution cycles before the switch. This indicates the number of CPU execution cycles after the switch. Indicates the number of thread switches before the switch. Indicates the number of thread switches after the switch. This indicates the CPU utilization rate before the switch. This indicates the CPU utilization rate after the switch. Indicates the I / O throughput rate before the switch. Indicates the I / O throughput rate after the switch. Indicates the lock wait time before switching. Indicates the lock wait time after switching. This represents the time decay coefficient.
[0044] This implementation scheme achieves a quantitative assessment of the stability of the thread switching process through multi-dimensional comparative analysis of CPU execution cycles, thread switching counts, CPU utilization, I / O throughput, and lock wait time before and after the switching. This method establishes a dynamic correlation between thread execution performance and external system disturbances, with performance response and dynamic disturbance terms at its core. This ensures that the evaluation results not only reflect the immediate performance recovery after the switch but also the convergence trend of the thread in the temporal dimension. By introducing a time decay coefficient to weight short-term fluctuations, the evaluation process better reflects the true dynamic characteristics of the thread switching process, avoiding misjudgments caused by transient changes. This design achieves dynamic observability and continuous stability tracking of switching behavior, improving the convergence accuracy and operational reliability of hot thread switching, and providing a stable guarantee for safe upgrades in multi-threaded environments.
[0045] Specifically, the steps for determining whether to unfreeze the scheduling queue and complete the closed-loop control of component hot upgrade are as follows: Monitor the changing trend of the switching convergence evaluation value in real time, and calculate the mean and variance of the switching convergence evaluation value. When the mean of the switching convergence evaluation value continuously increases for M consecutive times and the variance is less than or equal to the stability threshold, it is determined that the system has entered a convergence stable state, the thread scheduling queue is unfrozen, and normal task allocation is restored; otherwise, ... Figure 4 As shown, if a performance fluctuation risk is detected, an adaptive rollback mechanism is triggered, pausing thread execution, restoring the old version of the component and reloading the thread context buffer data, and then re-determining the safe switching point before re-performing the switch to complete the component hot upgrade. Here, M is a positive integer value. To improve accuracy, the handover convergence evaluation value is continuously collected using a fixed sampling interval and a sliding statistical window. Outliers within the window are replaced with median values, and the mean and variance are calculated using unbiased estimation. For a continuously rising mean, a minimum slope constraint and a monotonicity tolerance band are introduced. Variance determination is performed by simultaneously setting entry and exit thresholds to form a hysteresis zone, reducing frequent round trips caused by critical jitter. The minimum slope constraint refers to the minimum allowable growth slope of the mean sequence within the sliding window. When the scheduling queue is unfrozen, the scheduling order is restored according to the thread priority and execution sequence number recorded before freezing, the cumulative count of the handover convergence evaluation value is reset, and a timestamp and verification record are written for traceability. After entering the adaptive rollback mechanism, a cooldown period is set. During the cooldown period, only the handover convergence evaluation value is recorded without triggering new handover actions. After the cooldown period, a safe handover timing point is identified. The cooldown period refers to the shortest time interval after rollback that prevents the handover determination from being triggered again.
[0046] In this implementation, the method dynamically monitors and analyzes the mean and variance of the switching convergence evaluation value to achieve adaptive determination of the system's operating state after thread switching. Through continuous sampling and sliding window calculation, it can capture the continuous changes in performance fluctuations over time, making the stability judgment of the thread state no longer dependent on a single result but based on a continuous trend. The introduction of minimum slope constraints and hysteresis region determination mechanisms effectively suppresses frequent switching caused by critical fluctuations, improving the robustness of the determination. Overall, this method achieves closed-loop control based on the switching convergence evaluation value, significantly improving the safety, controllability, and adaptability of the hot upgrade process.
[0047] like Figure 2 As shown, the second aspect of the present invention provides a software component hot upgrade system based on dynamic switching of execution context, including: a data acquisition and preprocessing module, a switching risk assessment module, a switching safety determination module, and a switching convergence control module, wherein: the data acquisition and preprocessing module is used to acquire context switching monitoring data and perform time base correction, noise suppression, anomaly removal, feature dimensionality reduction and standardization processing on the context switching monitoring data to obtain preprocessed context switching monitoring data; the switching risk assessment module is used to construct a thread-level data sequence and mark switchable threads based on the preprocessed context switching monitoring data, assess the current switching risk of each switchable thread, and output a switchable window sequence based on the assessment results; the switching safety determination module is used to comprehensively assess the switching safety of each switchable thread within the corresponding switchable window, and determine the safe switching timing point based on the assessment results; the switching convergence control module is used to freeze the scheduling queue of the target thread at the safe switching timing point, execute thread switching, extract context switching monitoring data before and after the switching, assess the stability of the switching process, determine whether to unfreeze the scheduling queue, and complete the closed-loop control of component hot upgrade.
[0048] This implementation scheme introduces a hot-upgrade mechanism based on dynamic execution context switching, achieving precise thread-level identification, dynamic evaluation, and security control. Its core lies in combining the multi-dimensional characteristics and temporal evolution characteristics of context switching monitoring data. Through dynamic analysis of switching risk and security assessment values, thread switching behavior can adaptively proceed while maintaining predictable performance. This design forms a complete closed-loop logic between data acquisition, risk assessment, security determination, and convergence control, ensuring the continuity and stability of the hot-upgrade process and avoiding address offset errors and execution anomalies caused by uncertain switching timing in traditional methods. By coupling and dynamically adjusting multiple indicators of thread states, the system's adaptability under varying operating loads is improved, enabling stable updates of software components without interrupting operation, thereby significantly enhancing system reliability and maintainability.
[0049] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus.
[0050] The preferred embodiments of the present invention disclosed above are merely illustrative of the invention. These preferred embodiments do not exhaustively describe all details, nor do they limit the invention to the specific implementations described. Clearly, many modifications and variations can be made based on the content of this specification. This specification selects and specifically describes these embodiments to better explain the principles and practical applications of the invention, thereby enabling those skilled in the art to better understand and utilize the invention. The invention is limited only by the claims and their full scope and equivalents.
Claims
1. A method for hot upgrade of software components based on dynamic switching of execution context, characterized in that, The method comprises the following steps: S1, collecting context switching monitoring data, and performing time base correction, noise suppression, abnormality elimination, feature dimension reduction and standardization processing on the context switching monitoring data to obtain preprocessed context switching monitoring data; S2, based on the preprocessed context switching monitoring data, constructing a thread-level data sequence and marking switchable threads, evaluating the current switching risk of each switchable thread, and outputting a switchable window sequence based on the evaluation result; S3, for each switchable thread, comprehensively evaluating the switching safety within the corresponding switchable window, and determining a safe switching time point based on the evaluation result; S4, freezing the scheduling queue of the target thread at the safe switching time point, performing thread switching, extracting the context switching monitoring data before and after switching, evaluating the stability of the switching process, determining whether to unfreeze the scheduling queue, and completing the closed-loop control of component hot upgrade.
2. The method of claim 1, wherein: The specific steps of collecting context switching monitoring data and performing time base correction, noise suppression, abnormality elimination, feature dimension reduction and standardization processing on the context switching monitoring data to obtain preprocessed context switching monitoring data are as follows: Real-time collection of context switching monitoring data of running threads, wherein the context switching monitoring data includes thread number, thread CPU occupation time, CPU execution cycle number, thread switching number, context capture time consumption, context recovery time consumption, I / O blocking time length, I / O in-transit data volume, I / O throughput rate, lock waiting time length and CPU utilization rate; Uniform time base correction of the collected context switching monitoring data through a timestamp resampling algorithm to ensure that the sampling data is aligned on the time axis; noise suppression of the context switching monitoring data through a sliding median filtering algorithm to reduce scheduling jitter and transient peak interference; compensation of missing sampling points in the context switching monitoring data through a linear interpolation algorithm; identification and elimination of abnormal data in the context switching monitoring data through a local outlier factor algorithm; feature dimension reduction and multi-index correlation analysis of the context switching monitoring data through a principal component analysis algorithm to eliminate redundant data; and standardization processing of the context switching monitoring data through a Z-Score standardization algorithm to unify the numerical scale and eliminate the dimension difference.
3. The method of claim 1, wherein: The specific steps of constructing a thread-level data sequence and marking switchable threads based on the preprocessed context switching monitoring data are as follows: Grouping the preprocessed context switching monitoring data of threads in I / O blocking and lock waiting states by thread number, and establishing a thread-level data sequence in chronological order; and setting a fixed-width sliding time window as an evaluation period, and periodically calculating the I / O blocking remaining time, lock waiting remaining time and CPU execution cycle variance of each thread; Differencing the I / O blocking remaining time and the lock waiting remaining time of adjacent evaluation periods to generate a corresponding time change rate sequence, and marking the thread as a switchable thread when it is detected that both are monotonically decreasing and the time change rates are less than the corresponding threshold values.
4. The method of claim 1, wherein: The specific steps of outputting the switchable window sequence based on the evaluation results are as follows: For all switchable threads, the resource occupation ratio item is obtained by dividing the thread CPU occupation time by the sum of the I / O blocking residual time and the lock waiting residual time; the execution stability decay item is obtained by taking the negative of the ratio of the CPU execution cycle variance to the standard CPU execution cycle variance and taking the e-based power function value; the system load constraint item is obtained by taking the reciprocal of the ratio of the CPU utilization rate to the rated CPU utilization rate plus one; and the switch risk evaluation value is obtained by multiplying the resource occupation ratio item, the execution stability decay item and the system load constraint item in sequence; The switch risk evaluation value and the risk threshold value are compared in real time, and when the switch risk evaluation value is less than the risk threshold value for N consecutive evaluation periods, the corresponding time window is marked as a switchable window; adjacent switchable windows in the same thread are merged, and a switchable window sequence organized according to thread numbers is output.
5. The method of claim 1, wherein: The specific steps of comprehensively evaluating the switch safety in the corresponding switchable window for each switchable thread are as follows: The switchable window of each switchable thread is extracted, the switchable window duration of each switchable window is obtained, and the CPU utilization rate change rate and the I / O in-transit data volume change rate are calculated in real time within the switchable window; the execution fluctuation suppression item is obtained by calculating, in real time within the switchable window, one minus the ratio of the CPU execution cycle variance to the standard CPU execution cycle variance; the time utilization ratio item is obtained by subtracting the sum of the context capture time consumption and the context recovery time consumption from the switchable window duration and then dividing the result by the switchable window duration; the comprehensive execution stability is obtained by multiplying the execution fluctuation suppression item by the time utilization ratio item; the system load coefficient is obtained by adding one to the ratio of the current CPU utilization rate to the rated CPU utilization rate; the data flow coefficient is obtained by adding one to the ratio of the current I / O in-transit data volume to the rated I / O in-transit data volume; the system dynamic adjustment coefficient is obtained by adding one to the average of the absolute values of the CPU utilization rate change rate and the I / O in-transit data volume change rate; and the switch safety evaluation value is obtained by dividing the comprehensive execution stability by the product of the system load coefficient, the data flow coefficient and the system dynamic adjustment coefficient.
6. The method of claim 1, wherein: The specific steps of determining the safe switch timing point based on the evaluation results are as follows: The switch safety evaluation value within the switchable window is monitored in real time, and if the switch safety evaluation value is greater than the safety threshold value for K consecutive times, the current time is determined as the safe switch timing point; If the switch safety evaluation value within the switchable window is always lower than the adaptive threshold value, the last time of the switchable window is determined as the safe switch timing point.
7. The method of claim 1, wherein: The specific steps of freezing the scheduling queue of the target thread at the safe switch timing point and performing thread switching are as follows: After the safe switch timing point is determined, the scheduling queue of the target thread is frozen, the context state data of the thread is stored in the thread context buffer, the program counter, the register group, the stack pointer and the lock holding information are read, the context integrity check code is generated and stored. Load the new version code segment of the target component, perform instruction base address relocation according to the address mapping relationship corresponding to the old version of the thread number, compare the new and old version function entry mapping tables, when detecting that there is a difference in the return address offset, dynamically adjust the stack frame layout and perform register remapping according to the register group and stack pointer information in the thread context buffer, and perform context recovery operation to write the cached context data into the new version execution space.
8. The method of claim 1, wherein: The specific steps for extracting the context switching monitoring data before and after the switching and evaluating the stability of the switching process are as follows: Taking the ratio of the CPU execution cycle numbers of the threads before and after the switching plus one and taking the natural logarithm, taking the square of the ratio of the thread switching times before and after the switching, and adding the two to obtain a performance response term; the difference values of the CPU utilization, I / O throughput rate and lock waiting time before and after the switching are normalized and squared, and then averaged, and the square root of the obtained average value is multiplied by a time decay coefficient to obtain a dynamic disturbance term; the performance response term is divided by one plus the dynamic disturbance term to obtain a switching convergence evaluation value.
9. The method of claim 1, wherein: The specific steps for determining whether to release the scheduling queue freezing and completing the closed-loop control of the component hot upgrade are as follows: Real-time monitoring of the switching convergence evaluation value change trend, and calculation of the mean and variance of the switching convergence evaluation value, when the mean of the switching convergence evaluation value continuously rises for M consecutive times and the variance is less than or equal to a stable threshold, it is determined that the system is in a convergent and stable state, the thread scheduling queue is unfreezed, and normal task allocation is restored; Otherwise, it is determined that there is a risk of performance shock, a self-adaptive rollback mechanism is triggered, the thread execution is suspended, the old version component is restored and the thread context buffer data is reloaded, and the safe switching time point is determined again to execute the switching again to complete the component hot upgrade.
10. A system for hot upgrade of software components based on dynamic switching of execution context, characterized in that: It comprises: a data acquisition and preprocessing module, a switching risk evaluation module, a switching safety determination module and a switching convergence control module, wherein: The data acquisition and preprocessing module is configured to acquire context switching monitoring data, and perform time base correction, noise suppression, abnormality rejection, feature dimension reduction and standardization processing on the context switching monitoring data to obtain preprocessed context switching monitoring data; The switching risk evaluation module is configured to construct thread-level data sequences and mark switchable threads based on the preprocessed context switching monitoring data, evaluate the current switching risk of each switchable thread, and output a switchable window sequence based on the evaluation result; The switching safety determination module is configured to comprehensively evaluate the switching safety in the corresponding switchable window for each switchable thread, and determine a safe switching time point based on the evaluation result; The switching convergence control module is configured to freeze the scheduling queue of the target thread at the safe switching time point, perform thread switching, extract the context switching monitoring data before and after the switching, evaluate the stability of the switching process, determine whether to release the scheduling queue freezing, and complete the closed-loop control of the component hot upgrade.
Citation Information
Patent Citations
Component upgrade method, apparatus and terminal
CN104866341A
Component upgrading method and device
CN106598682A