Optimization method for discarding timeout tasks with delayed response of multi-control linkage

By setting operation indexes and delay queues for controls and combining them with adaptive algorithms to optimize task processing, we solved the problems of UI lag and resource waste caused by multi-control linkage, achieving more efficient system performance and user experience.

CN120407129BActive Publication Date: 2025-09-09GUANGZHOU CHUANGHUI INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510903670.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-07-01
Publication Date
2025-09-09
Estimated Expiration
2045-07-01

AI Technical Summary

Technical Problem

In program development, the linkage of multiple controls causes UI refresh jams and increased server pressure. Although the traditional delayed loading method avoids user input jams, it still leads to waste of CPU resources and increased server burden.

Method used

An operation index is set for each basic control, and tasks are stored in a delay queue. The execution or discard of tasks is determined by comparing the index values. The delay time is dynamically adjusted by combining an adaptive algorithm and CPU idle detection to optimize task processing.

Benefits of technology

It reduces the client CPU pressure, reduces the server API call burden, improves user operation fluency, and optimizes system performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120407129B_ABST
    Figure CN120407129B_ABST
Patent Text Reader

Abstract

The present application relates to the field of computer technology and discloses a method for optimizing the discarding of timeout tasks with delayed responses to multiple controls, including: S1-setting the corresponding latest operation index for each basic control, and updating the index value MaxActionIndex of the operation index each time the basic control is operated; S2-storing the operation tasks of the basic controls into a delay queue, where each task includes the operation content and the current index value; S3-setting the execution delay time of the task; S4-when the CPU is idle, obtaining the expired task M from the delay queue and extracting its index value ActionIndexM; S5-determining whether to discard the task based on the comparison between ActionIndexM and the largest MaxActionIndex in the current delay queue. The use of this application can reduce the pressure on the server's concurrency and network bandwidth, optimize the performance of the client and server, and improve the user's smoothness of use.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a method for optimizing the discarding of timeout tasks with delayed responses of multiple controls in linkage. Background Art

[0002] During application development and use, both B / S and C / S applications often involve multiple front-end controls and require fast editing, with each edit requiring interaction with the server. Fast editing and multi-control linkage require frequent UI refreshes, while real-time server interaction requires frequent calls to back-end API services. These two scenarios can cause UI refresh lags and, secondly, increased back-end pressure due to frequent server calls. Frequent requests and responses can significantly increase CPU usage on both the client and server. Traditionally, delayed loading is used to mitigate this lag. Instead of responding immediately to user actions on controls, the response is delayed for 30-50 milliseconds. This prevents choppy operation, but delayed loading tasks continue to execute in the next cycle. While the user's current input is not lag-free, the execution of delayed tasks in the next cycle still increases CPU usage. This impact is particularly pronounced when multiple controls are linked, where the operation of one control affects the display of others. Furthermore, when each action requires server-side back-end computation and verification, the lag is even more pronounced. The faster the operation and the more frequent the response, the greater the burden on the server API calls.

[0003] Therefore, an interactive optimization technology is urgently needed to ensure program development efficiency. Summary of the Invention

[0004] The purpose of this application is to provide a timeout task discard optimization method for multi-control linkage delayed response to solve the technical problems raised in the above background technology.

[0005] To achieve the above objectives, the present application discloses the following technical solution: a method for optimizing timeout task discarding with delayed response of multiple controls, comprising the following steps:

[0006] S1-Set the corresponding latest operation index for each basic control, and update the index value MaxActionIndex of the operation index each time the basic control is operated;

[0007] S2-Store the basic control's operation tasks into the delay queue. Each task in the delay queue includes the operation content and the current index value MaxActionIndex when it is pushed into the queue;

[0008] S3-Set the execution delay time of tasks in the delay queue;

[0009] S4-When the CPU is idle, get the due task M from the delay queue and extract the index value ActionIndexM of the operation index carried by the due task M;

[0010] S5-Compare ActionIndexM with the largest MaxActionIndex in the current delay queue;

[0011] S51-If ActionIndexM is equal to the maximum MaxActionIndex, perform the following operations:

[0012] S511-call the backend API to perform data verification on the basic control content;

[0013] S512-notify the linked control to perform synchronous refresh based on the latest basic control value;

[0014] S52-If ActionIndexM is less than the maximum MaxActionIndex, the due task is discarded, and S4-S5 are repeated until the index value ActionIndexm corresponding to an due task m is equal to the maximum MaxActionIndex in the delay queue during this comparison.

[0015] Preferably, when S4 is executed, it supports continuously receiving new operations and pushing tasks corresponding to the new operations into the delay queue.

[0016] Preferably, in S3, the setting of the execution delay time is based on a dynamic balance principle of avoiding UI freezes and CPU resource waste.

[0017] Preferably, the execution delay time is 30-50 milliseconds.

[0018] Preferably, the index value MaxActionIndex is a globally unique increasing integer, and is automatically increased by 1 in chronological order to generate a new index value each time a basic control is operated; the delay queue is a priority queue, and the tasks in the queue are arranged in descending or ascending order according to the index value.

[0019] Preferably, the execution delay time is dynamically adjusted by an adaptive algorithm, and the adaptive algorithm is: when the basic control operation frequency per unit time exceeds a threshold, the delay time is automatically shortened; when the system CPU load is higher than a set threshold, the delay time is automatically extended.

[0020] Preferably, the mechanism for determining whether the CPU is idle is: real-time monitoring of the system CPU utilization, and when the CPU utilization is lower than a preset threshold for N consecutive milliseconds, triggering the task execution process in the delay queue, where N is a configurable time parameter.

[0021] Preferably, the synchronous refresh of the linkage control adopts a difference cache mechanism, and the difference cache mechanism is: only when there is a difference between the latest value of the basic control and the cached value, the UI update of the linkage control is triggered.

[0022] Preferably, the S52 further comprises: generating a performance analysis log for the discarded task, wherein the performance analysis log comprises: a recorded discard reason and context information.

[0023] Preferably, the method also includes: performing a timing analysis on the index value sequence of the discarded tasks based on the performance analysis log, establishing a task discard trend prediction model, and dynamically adjusting the capacity threshold of the delay queue and the CPU idle detection sensitivity based on the prediction model.

[0024] Beneficial effect: The timeout task discarding optimization method for delayed response of multiple control linkage of the present application, based on delayed execution, uses the delayed task timeout discarding mechanism to discard unnecessary timeout tasks such as responses of client basic controls, calls of server APIs, responses of linkage controls, etc. after timeout, which means they no longer need to be executed, thereby reducing the pressure on the client's CPU, while reducing unnecessary API calls, and also reducing the pressure on server concurrency and network bandwidth. It can solve the problem of discontinuous UI experience of users' fast operations, optimize the performance of the client and server, and improve the user's usage fluency. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without paying any creative work.

[0026] Figure 1 This is a flowchart of a method for optimizing the discarding of timeout tasks with delayed responses to multiple controls linked together, as provided in an embodiment of the present application. DETAILED DESCRIPTION

[0027] The following is a clear and complete description of the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of them. Based on the embodiments of this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.

[0028] In this document, the term "comprising" is intended to encompass non-exclusive inclusion, such that a process, method, article, or apparatus that includes a list of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising..." does not preclude the presence of additional identical elements in the process, method, article, or apparatus that includes the element.

[0029] During application development and use, both B / S and C / S applications often involve multiple front-end controls and require fast editing, with each edit requiring interaction with the server. Fast editing and multi-control linkage require frequent UI refreshes, while real-time server interaction requires frequent calls to back-end API services. These two scenarios can cause UI refresh lags and, secondly, increased back-end pressure due to frequent server calls. Frequent requests and responses can significantly increase CPU usage on both the client and server. Traditionally, delayed loading is used to mitigate this lag. Instead of responding immediately to user actions on controls, the response is delayed by 30-50 milliseconds. This prevents choppy operation, but delayed loading tasks continue to execute in the next cycle. While the user's current input is not lag-free, the execution of delayed tasks in the next cycle still increases CPU usage. This impact is particularly pronounced when multiple controls are linked, where the operation of one control affects the display of others. Furthermore, when each operation requires server-side back-end computation and verification, the lag is even more pronounced. The faster the operation and the more frequent the response, the greater the burden on the server API calls.

[0030] Based on this, this embodiment provides a Figure 1 The timeout task discarding optimization method for delayed response of multi-control linkage shown is an optimization method for front-end multi-control linkage, fast editing, and frequent interaction with the server, including the following steps:

[0031] S1-Set the latest operation index for each basic control. Update the index value MaxActionIndex of the operation index each time the basic control is operated. Each control maintains MaxActionIndex independently without interfering with each other.

[0032] S2-Store the basic control's operation tasks into the delay queue. Each task in the delay queue includes the operation content and the current index value MaxActionIndex when it is pushed into the queue;

[0033] S3-Set the execution delay time of tasks in the delay queue;

[0034] S4-When the CPU is idle, get the due task M from the delay queue and extract the index value ActionIndexM of the operation index carried by the due task M; due tasks refer to tasks such as the response of the client-side basic control, the call of the server-side API, the response of the linkage control, etc. that should be executed immediately according to the schedule or have timed out;

[0035] S5-Compare ActionIndexM with the largest MaxActionIndex in the current delay queue;

[0036] S51-If ActionIndexM is equal to the maximum MaxActionIndex, perform the following operations:

[0037] S511-Call the backend API to perform data verification on the basic control content (including legitimacy, value range, and logical conflict verification);

[0038] S512-notify the linked control to perform synchronous refresh based on the latest basic control value;

[0039] S52-If ActionIndexM is less than the maximum MaxActionIndex, the due task is discarded, and S4-S5 are repeated until the index value ActionIndexm corresponding to an due task m is equal to the maximum MaxActionIndex in the delay queue during this comparison.

[0040] In this embodiment, when executed, S4 supports continuously receiving new operations and pushing the tasks corresponding to the new operations into the deferred queue, forming a dynamic task processing loop. That is, when the CPU is idle, it obtains deferred tasks. Regardless of whether the result is to execute or not, the user can continue to operate the basic controls while pushing new deferred tasks, and this cycle repeats.

[0041] In this embodiment, the execution delay time is set based on the principle of dynamic balance between avoiding UI freezes and wasting CPU resources. It is feasible that the execution delay time can be 30-50 milliseconds.

[0042] Furthermore, in order to improve the CPU operating efficiency and quality, as a preferred implementation method of this embodiment, the execution delay time is dynamically adjusted through an adaptive algorithm. The adaptive algorithm is: when the basic control operation frequency per unit time exceeds a threshold, the delay time is automatically shortened to improve the response speed; when the system CPU load is higher than the set threshold, the delay time is automatically extended to avoid resource competition.

[0043] Specifically, the calculation formula for the execution delay time is:

[0044]

[0045] in, is the initial delay time (30-50ms); The operation frequency of the basic control per unit time (times / second), which counts the number of operations in the last second through a sliding window; is the CPU load rate (0-1), taking the exponential moving average (EMA) over the past 5 seconds; and is the adjustment coefficient, , , dynamically optimized through machine learning models.

[0046] The calculation logic is that the higher the operating frequency ( The larger the exponential term The smaller the value, the shorter the delay time; the higher the CPU load ( The larger the exponential term The smaller (because ), the delay time is extended, and dynamic balance is achieved through nonlinear transformation.

[0047] It is feasible that the task queue can be polled according to the CPU time slice. As a preference, in order to improve the task response efficiency, in this embodiment, the index value MaxActionIndex is a globally unique increasing integer, and each time a basic control is operated, 1 is automatically added to generate a new index value in chronological order; the delay queue is a priority queue, and the tasks in the queue are arranged in descending or ascending order according to the index value, so that expired tasks with lower index values ​​can be retrieved and processed first when the CPU is idle, thereby improving the efficiency of the sequential execution of "timed tasks" and avoiding missed task responses.

[0048] Furthermore, in order to ensure the efficient operation of the CPU and accurately control whether it is idle, as a preferred implementation method of this embodiment, the judgment mechanism of whether the CPU is idle is: real-time monitoring of the system CPU utilization, when the CPU utilization is lower than the preset threshold for N consecutive milliseconds, triggering the task execution process in the delay queue, where N is a configurable time parameter.

[0049] Specifically, the judgment mechanism is:

[0050]

[0051] in, The CPU utilization rate within N consecutive milliseconds; The preset threshold for CPU utilization, such as 30%; For the moment CPU utilization (value ranges from 0 to 100%).

[0052] The calculation logic uses a sliding integral window to calculate the average utilization over N consecutive milliseconds. When the average value falls below a threshold, the CPU is considered idle. Using an integral window instead of a simple average calculation avoids interference from transient fluctuations. By accumulating data over consecutive time periods, the CPU idle state is determined, improving stability.

[0053] Furthermore, in order to avoid repeated invalid refresh operations, as an optimal implementation method of this embodiment, the synchronous refresh of the linkage control adopts a differential cache mechanism, and the differential cache mechanism is: the UI update of the linkage control is triggered only when there is a difference between the latest value of the basic control and the cached value.

[0054] Specifically, the differential caching mechanism is:

[0055]

[0056] in, The latest value of the underlying control, that is, the real-time value currently entered or modified by the user (such as the content of a text box, the selected value of a drop-down box, etc.); The cache value of the underlying control, that is, the value stored after the last valid operation (stored in client memory or cache); As the hash function, a polynomial rolling hash is used, such as:

[0057]

[0058] is a large prime number, such as wait; is the modulus, such as Or a custom positive integer.

[0059] Compare the hash values ​​of the new value and the cached value, and trigger a refresh if they are inconsistent ( ).

[0060] The calculation logic uses hash value comparison instead of field-by-field comparison to reduce data comparison overhead. Polynomial rolling hash supports incremental updates and improves difference detection efficiency.

[0061] It is feasible that the S52 further includes: generating a performance analysis log for the discarded task, wherein the performance analysis log includes: a recorded discard reason and context information.

[0062] Furthermore, to ensure efficient operation of the CPU, it is feasible that the method also includes: performing a timing analysis on the index value sequence of the discarded tasks based on the performance analysis log, establishing a task discard trend prediction model, and dynamically adjusting the capacity threshold of the delay queue and the CPU idle detection sensitivity based on the prediction model.

[0063] Specifically, the logic of dynamic adjustment is:

[0064] Calculate the task discard trend prediction value representing the task discard rate trend predicted in the future unit time at time t (A larger value indicates a higher risk of discarding). The calculation formula is:

[0065] in, The latest operation index. The index value of the i-th discarded task (the most recent n tasks are taken in reverse chronological order); 、 and are the weights, slope parameters, and bias terms obtained through LSTM neural network training; It is a linear rectification function that filters invalid samples with index differences less than 0. Since the index values ​​increase monotonically, the differences must be non-negative, which serves as a robustness check.

[0066] The LSTM network learns the index difference distribution of historically discarded tasks and predicts the trend of task discard rates per unit time in the future. When the predicted discard rate exceeds a threshold, the system automatically increases the capacity of the delay queue or lowers the CPU idle detection threshold (for example, from 30% to 25%), triggering task processing in advance to reduce discards.

[0067] To sum up, the timeout task discarding optimization method for delayed response of multiple controls linkage in this embodiment, through the three-dimensional technical solution of index identification timing - queue buffering tasks - dynamic discarding of old tasks - adaptive resource scheduling - intelligent UI refresh - log-driven optimization, breaks through the limitation of traditional delayed loading that only solves UI jams, and realizes full-chain optimization from client operation, server interaction to system resource scheduling.

[0068] In the embodiments provided herein, it should be understood that the embodiments described herein can be implemented using hardware, software, firmware, middleware, code, or any appropriate combination thereof. For hardware implementation, the processor may be implemented in one or more of the following: an application-specific integrated circuit (ASIC), a digital signal processor (DSP), a digital signal processing device (DSPD), a programmable logic device (PLD), a field-programmable gate array (FPGA), a processor, a controller, a microcontroller, a microprocessor, or other electronic units designed to implement the functionality described herein, or any combination thereof. For software implementation, some or all of the processes of the embodiments may be performed by a computer program instructing the relevant hardware. During implementation, the program may be stored in a computer-readable storage medium or transmitted as one or more instructions or codes on a computer-readable storage medium. Computer-readable storage media include computer storage media and communication media, wherein communication media includes any medium that facilitates the transmission of a computer program from one location to another. The storage medium may be any available medium that can be accessed by a computer. Computer-readable storage media may include, but are not limited to, RAM, ROM, EEPROM, CD-ROM or other optical disk storage, magnetic disk storage media or other magnetic storage devices, or any other medium capable of carrying or storing the desired program code in the form of instructions or data structures and accessible by a computer.

[0069] Finally, it should be noted that the above is only a preferred embodiment of the present application and is not intended to limit the present application. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art can still modify the technical solutions described in the aforementioned embodiments or make equivalent replacements for some of the technical features therein. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application should be included in the scope of protection of the present application.

Claims

1. A method for optimizing timeout task discarding with delayed response of multiple controls, characterized in that: The method comprises the following steps: S1-Set the corresponding latest operation index for each basic control, and update the index value MaxActionIndex of the operation index each time the basic control is operated; S2-Store the basic control's operation tasks into the delay queue. Each task in the delay queue includes the operation content and the current index value MaxActionIndex when it is pushed into the queue; S3-Set the execution delay time of tasks in the delay queue; S4-When the CPU is idle, get the due task M from the delay queue and extract the index value ActionIndexM of the operation index carried by the due task M; S5-Compare ActionIndexM with the largest MaxActionIndex in the current delay queue; S51-If ActionIndexM is equal to the maximum MaxActionIndex, perform the following operations: S511-call the backend API to perform data verification on the basic control content; S512-notify the linked control to perform synchronous refresh based on the latest basic control value; S52-If ActionIndexM is less than the maximum MaxActionIndex, the due task is discarded, and S4-S5 are repeated until the index value ActionIndexm corresponding to an due task m is equal to the maximum MaxActionIndex in the delay queue during this comparison.

2. The method for optimizing the discarding of timeout tasks with delayed response of multiple controls linkage according to claim 1 is characterized in that: When S4 is executed, it supports continuously receiving new operations and pushing tasks corresponding to the new operations into the delay queue.

3. The method for optimizing the discarding of timeout tasks with delayed response of multiple controls linkage according to claim 1 is characterized in that: In S3, the setting of the execution delay time is based on a dynamic balance principle of avoiding UI freezes and CPU resource waste.

4. The method for optimizing the discarding of timeout tasks with delayed response of multiple controls according to claim 3 is characterized in that: The execution delay time is 30-50 milliseconds.

5. The method for optimizing discarding timeout tasks with delayed response of multiple controls linkage according to claim 1 is characterized in that: The index value MaxActionIndex is a globally unique increasing integer, and is automatically increased by 1 to generate a new index value in chronological order each time a basic control is operated; the delay queue is a priority queue, and the tasks in the queue are arranged in descending or ascending order according to the index value.

6. The method for optimizing the discarding of timeout tasks with delayed response of multiple controls linked together according to claim 3 or 4, characterized in that: The execution delay time is dynamically adjusted through an adaptive algorithm, which is: when the basic control operation frequency per unit time exceeds a threshold, the delay time is automatically shortened; when the system CPU load is higher than a set threshold, the delay time is automatically extended.

7. The method for optimizing discarding timeout tasks with delayed response of multiple controls linkage according to claim 1 is characterized in that: The CPU idleness determination mechanism is as follows: real-time monitoring of the system CPU utilization, when the CPU utilization is lower than a preset threshold for N consecutive milliseconds, triggering the task execution process in the delay queue, where N is a configurable time parameter.

8. The method for optimizing discarding timeout tasks with delayed response of multiple controls linkage according to claim 1 is characterized in that: The synchronous refresh of the linkage control adopts a difference cache mechanism, which is: only when there is a difference between the latest value of the basic control and the cached value, the UI update of the linkage control is triggered.

9. The method for optimizing discarding timeout tasks with delayed response of multiple controls linkage according to claim 1 is characterized in that: The S52 further includes: generating a performance analysis log for the discarded task, wherein the performance analysis log includes: a recorded discard reason and context information.

10. The method for optimizing discarding timeout tasks with delayed response of multiple controls linkage according to claim 9 is characterized in that: The method also includes: performing a time series analysis on the index value sequence of the discarded tasks based on the performance analysis log, establishing a task discard trend prediction model, and dynamically adjusting the capacity threshold of the delay queue and the CPU idle detection sensitivity based on the prediction model.

Citation Information

Patent Citations

  • Page event processing method and device, computer device and storage medium

    CN109634756A

  • Control operation method, mobile terminal and computer readable storage medium

    CN110109723A