An AI-based memory optimization method for scheduling tasks
By implementing real-time monitoring and adaptive memory management, the problem of low memory utilization efficiency in existing technologies has been solved, achieving efficient utilization of memory resources and improved system performance.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-01
- Publication Date
- 2026-04-10
AI Technical Summary
Existing memory management methods are ill-suited to handle dynamically changing task requirements, resulting in inefficient memory usage, increased response latency, and a lack of timely response and handling for abnormal memory usage.
The memory monitoring system monitors task memory usage data in real time, performs real-time memory demand prediction and adaptive allocation, builds a priority scheduling queue, marks and identifies active and unused objects, monitors memory block anomaly indices in real time, and generates optimization signals for memory re-optimization.
It achieves accurate memory demand prediction and adaptive optimization, improves the rationality and efficiency of memory use, reduces memory waste and performance bottlenecks, and enhances the overall system performance.
Smart Images

Figure CN119065856B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer memory management, in particular to a memory optimization method based on AI task scheduling. BACKGROUND
[0002] In modern computer systems, memory management and optimization play a crucial role in the efficiency of task execution. Existing memory management methods usually rely on static allocation strategies, which are difficult to cope with dynamic changes in task demand and memory usage. These traditional methods are prone to low memory usage efficiency, increased response delay, and even system crash risk when facing high load or frequent task switching. In addition, existing memory optimization schemes mostly focus on memory allocation and recycling, ignoring the dynamic demand of real-time tasks for memory, which makes memory resources unable to be efficiently utilized.
[0003] With the rapid development of artificial intelligence (AI) technology, AI applications in task scheduling and resource management have gradually attracted attention. However, current methods of applying AI for memory optimization are still relatively preliminary, usually only adjusting based on historical data or rules, lacking accurate prediction and dynamic adjustment capabilities for real-time memory usage. In addition, existing AI memory optimization schemes lack timely response and processing mechanisms for abnormal memory usage, when abnormal memory usage occurs, the system often cannot quickly make optimization adjustments, leading to memory waste or task failure. SUMMARY
[0004] Based on the above-mentioned shortcomings of the prior art, the purpose of the present application is to provide a memory optimization method based on AI task scheduling to solve the above technical problems.
[0005] To achieve the above-mentioned purpose, the present application provides the following technical solution: a memory optimization method based on AI task scheduling, comprising:
[0006] S1: collecting and preprocessing the memory usage data of the tasks being executed by the memory monitoring system, and performing real-time memory demand prediction;
[0007] S2: based on the predicted memory demand, integrating the state parameter data of the tasks and the memory usage trend, and performing adaptive memory pre-allocation;
[0008] S3: performing memory demand analysis on the concurrent tasks to be executed, constructing a priority scheduling queue to sort the tasks, and executing the tasks in the priority scheduling queue through a pre-set preemption scheduling algorithm;
[0009] S4: Mark and identify active objects and objects no longer in use in memory, clear objects no longer in use, monitor memory blocks in use in real time, obtain memory rising abnormality index and memory optimization performance index;
[0010] S5: When the memory rising abnormality index and / or the memory optimization performance index is greater than a preset threshold value, a memory optimization signal is generated, and memory re-optimization is performed.
[0011] The application further provides that step S1 specifically comprises:
[0012] The memory usage data of the tasks being executed is collected and preprocessed by the memory monitoring system, and the memory usage data includes memory allocation, release and usage;
[0013] The memory usage data is preprocessed, and the preprocessing includes cleaning, standardization and feature extraction, and eliminates noise and outliers;
[0014] According to the preprocessed memory usage data, real-time memory demand prediction is performed based on a time series convolution network.
[0015] The application further provides that in step S2, the state parameters include priority and urgency; based on the predicted memory demand, the state parameter data and the memory usage trend of the task are comprehensively considered to perform adaptive memory allocation, specifically: wherein, is the adaptive memory allocation, is the predicted memory demand, is the current actual memory consumption, is the memory usage trend, specifically the slope of the current actual memory consumption, and is a weight coefficient, and , is the priority score, is the urgency score, and the value range is (0, 1].
[0016] The application further provides that step S3 specifically comprises:
[0017] S31: Memory demand analysis is performed on the current concurrent task to be executed to obtain memory consumption, priority, urgency and task waiting time;
[0018] S32: The priority scheduling index of the task is calculated according to the priority, urgency and task waiting time, a priority scheduling queue is constructed in descending order of the priority scheduling index, and a priority scheduling pointer is set to point to the concurrent task to be executed at the head of the priority scheduling queue;
[0019] S33: obtaining a running task whose memory allocation is greater than or equal to the memory consumption of the concurrent task to be executed pointed by the priority scheduling pointer and whose priority scheduling index is the minimum;
[0020] S34: when the priority scheduling index of the running task is less than the priority scheduling index of the concurrent task to be executed pointed by the priority scheduling pointer, preemptively scheduling the concurrent task to be executed pointed by the priority scheduling pointer;
[0021] S35: when the priority scheduling index of the running task is greater than or equal to the priority scheduling index of the concurrent task to be executed pointed by the priority scheduling pointer, moving the priority scheduling pointer by one bit, and executing step S33.
[0022] The application is further configured that, in step S32, the priority scheduling index of the task is calculated according to the priority, the urgency and the task waiting time, specifically: wherein, is the priority scheduling index of the task, is the score of the priority, is the score of the urgency, and the value range is (0, 1], is the weight coefficient, and is greater than 0, is the task waiting time, and the value of the task waiting time of the running task is 0.
[0023] The application is further configured that, in step S4, the active objects and the objects no longer in use in the memory are marked and identified, and the objects no longer in use are cleared, specifically including:
[0024] When the memory is allocated, a unique identifier is allocated to each object, and the reference count is recorded;
[0025] The object reference relationship graph is maintained, the reference and dependency relationship between the objects are recorded, and the memory reference model is constructed;
[0026] Starting from the root set, the object reference graph is recursively traversed;
[0027] The unvisited objects are first marked, the objects that have been found but have not traversed all the child nodes are second marked, and the objects that have traversed all the child nodes are third marked, wherein the marked objects are the reachable active objects, and the unmarked objects are the unreachable objects, indicating that the objects are no longer in use.
[0028] The application is further configured that, in step S4, the memory blocks in use are monitored in real time, and the memory rising abnormality index and the memory optimization efficiency index are obtained, including:
[0029] obtaining a memory growth rate, an allocation-deallocation imbalance rate, a garbage collection efficiency and a memory fragmentation degree of the memory block being used, and normalizing;
[0030] calculating a memory rise abnormality index according to the memory growth rate and the allocation-deallocation imbalance rate;
[0031] calculating a memory optimization performance index according to the garbage collection efficiency and the memory fragmentation degree.
[0032] The application is further provided that the memory growth rate is a change value of the memory usage in a time interval; the allocation-deallocation imbalance rate is a ratio between a difference value between the number of memory allocation operations and the number of release operations in the time interval and the number of memory allocation operations; and the calculation logic of the memory rise abnormality index is: wherein, is the memory rise abnormality index, is the memory growth rate, is the allocation-deallocation imbalance rate, and is a weight coefficient, and .
[0033] The application is further provided that the garbage collection efficiency is a total amount of memory recovered by garbage collection operations in a time interval; the memory fragmentation degree is a ratio of a size of the largest continuous free block in the current memory to a total size of all free spaces in the current memory; and the calculation logic of the memory optimization performance index is: wherein, is the memory optimization performance index, is the garbage collection efficiency, is the memory fragmentation degree, and is a weight coefficient, and .
[0034] The application is further provided that the step S5 specifically includes:
[0035] When the memory rise abnormality index is greater than a preset memory rise abnormality threshold value, a memory abnormality alarm signal is generated, a high memory consumption task is located, and a memory leak check is performed;
[0036] When the memory optimization performance index is greater than a preset memory optimization performance threshold value, a memory optimization alarm signal is generated, a recovery parameter is optimized, and a memory compression is performed.
[0037] The application provides a memory optimization method based on AI scheduling tasks, which collects and pre-processes the memory usage data of the tasks in execution through a memory monitoring system, and performs real-time memory demand prediction; based on the predicted memory demand, the state parameter data and memory usage trend of the tasks are comprehensively considered to perform adaptive memory pre-allocation; the memory demand of the current concurrent tasks to be executed is analyzed, a priority scheduling queue is constructed to sort the tasks, and the tasks in the priority scheduling queue are executed through a preset preemption scheduling algorithm; the active objects and no longer used objects in the memory are marked and identified, the no longer used objects are cleared, the memory blocks in use are monitored in real time, and the memory rising abnormality index and memory optimization efficiency index are obtained; when the memory rising abnormality index and / or the memory optimization efficiency index is greater than a preset threshold, a memory optimization signal is generated, and memory re-optimization is performed, and the beneficial effects include:
[0038] 1. Precise memory demand prediction: through the AI model, the memory usage data during task execution is monitored and analyzed in real time, the memory demand of the tasks to be executed can be accurately predicted, the changes during task execution can be dynamically adapted, the rationality and efficiency of memory usage can be significantly improved, and memory waste or performance bottleneck caused by insufficient or excessive allocation can be avoided;
[0039] 2. Adaptive memory optimization: according to the predicted memory demand, the state parameters and memory usage trend of the tasks, the memory allocation and recovery strategy can be automatically adjusted during task execution. Compared with the existing fixed rule allocation method, the application provides a more flexible memory scheduling mechanism, which can optimize memory resource allocation at different task execution stages, thereby improving the overall system performance;
[0040] 3. Efficient memory allocation and recovery mechanism: through the optimized memory allocation and recovery algorithm, the application can maximize the utilization of memory resources. Especially in the case of multi-task parallel execution, the application can intelligently adjust the memory allocation order according to the task priority, memory demand and execution time, reduce the task waiting time, and improve the overall running efficiency of the system.
[0041] The above description is only a summary of the technical scheme of the application, in order to more clearly understand the technical means of the application, the application can be implemented according to the content of the specification, and in order to make the above and other purposes, characteristics and advantages of the application more obvious and easy to understand, the following specific embodiments of the application are described. BRIEF DESCRIPTION OF DRAWINGS
[0042] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the embodiments will be briefly introduced. Obviously, the drawings in the following description only constitute some embodiments of the present application. Based on these drawings, other drawings can be obtained by those skilled in the art without any creative effort. In the drawings:
[0043] Figure 1 A flow chart of a memory optimization method based on AI scheduling tasks is shown for an exemplary embodiment of the present application. DETAILED DESCRIPTION
[0044] The embodiments of the present application will be described below with reference to the drawings and preferred embodiments. Those skilled in the art can easily understand other advantages and effects of the present application from the content disclosed in the present specification. The present application can also be implemented or applied by other different specific embodiments, and the details in the present specification can be modified or changed based on different views and applications without departing from the spirit of the present application. It should be understood that the preferred embodiments are only for illustrating the present application, but not for limiting the protection scope of the present application.
[0045] It should be noted that the diagrams provided in the following embodiments only schematically illustrate the basic concept of the present application, and only the components related to the present application are shown in the diagrams, but not the number, shape and size of the components when actually implemented. The type, number and proportion of each component can be arbitrarily changed when actually implemented, and the layout type of the components can also be more complex.
[0046] In the following description, a large number of details are discussed to provide a more thorough explanation of the embodiments of the present application. However, it is obvious to those skilled in the art that the embodiments of the present application can be implemented without these specific details, and in other embodiments, the known structures and devices are shown in the form of block diagrams instead of details, so as not to make the embodiments of the present application difficult to understand.
[0047] A memory optimization method based on AI scheduling tasks, as shown in Figure 1 , includes:
[0048] S1: Collect and preprocess the memory usage data of the tasks in execution by the memory monitoring system, and perform real-time memory demand prediction;
[0049] S2: Based on the predicted memory demand, comprehensively consider the state parameter data and memory usage trend of the tasks, and perform adaptive memory pre-allocation;
[0050] S3: memory requirement analysis is performed on the current concurrent task to be executed, a priority scheduling queue is constructed to sort the tasks, and a preset preemption scheduling algorithm is used to execute the tasks in the priority scheduling queue;
[0051] S4: active objects and objects no longer in use in the memory are marked and identified, the objects no longer in use are cleared, the memory blocks in use are monitored in real time, and a memory rising abnormality index and a memory optimization performance index are obtained;
[0052] S5: when the memory rising abnormality index and / or the memory optimization performance index is greater than a preset threshold, a memory optimization signal is generated, and memory re-optimization is performed.
[0053] The application further provides that step S1 specifically comprises:
[0054] The memory usage data of the tasks being executed is collected and preprocessed by the memory monitoring system, and the memory usage data includes memory allocation, release and usage; specifically, the memory usage data of the tasks being executed is collected in real time by the memory monitoring system, and the memory usage data includes memory allocation, release and usage;
[0055] The memory usage data is preprocessed, and the preprocessing includes cleaning, normalization and feature extraction to eliminate noise and abnormal values; specifically, the original memory usage data collected is cleaned to eliminate noise and abnormal values, and the data quality is ensured; different sources and different formats of data are converted into a unified format and unit to eliminate dimensional differences and facilitate model processing; key features are extracted from the cleaned and normalized data to provide high-quality input for the model and improve the prediction performance.
[0056] Based on the time series convolution network, real-time memory requirement prediction is performed according to the preprocessed memory usage data; specifically, a time series convolution network (TCN) is selected as the prediction model, which is suitable for processing sequence data and capturing long-term time dependence; the TCN model is trained using the preprocessed memory usage data, so that it learns the time pattern and trend of task memory usage; the data collected and preprocessed in real time is input into the trained TCN model to perform real-time prediction of memory requirement, thereby providing a basis for memory allocation.
[0057] The application further provides that in step S2, the state parameters include priority and urgency; based on the predicted memory requirement, the state parameter data and memory usage trend of the task are comprehensively considered to perform adaptive memory allocation, specifically: wherein, is the adaptive memory allocation, is the predicted memory requirement, a current actual memory consumption, a memory usage trend, specifically a slope of the current actual memory consumption, and is a weight coefficient, and , is a score of the priority, is a score of the urgency, and the value ranges are both (0, 1]. In a feasible embodiment of the present application, is 0.6, is 0.4. The closer the scores of the priority and the urgency are to 1, the higher the priority and the urgency of the task are.
[0058] The present application further provides that step S3 specifically comprises:
[0059] S31: performing memory demand analysis on the current concurrent task to be executed to obtain the memory consumption, the priority, the urgency and the task waiting time; specifically, the memory consumption refers to the memory amount required by each task to be executed in the execution process; the priority refers to the importance level of the task determined according to the business demand or the strategy; the urgency refers to how fast the task needs to be completed, and the more urgent the task is, the faster it needs to be executed; and the task waiting time refers to the length of time the task has been waiting in the waiting queue;
[0060] S32: calculating the priority scheduling index of the task according to the priority, the urgency and the task waiting time, constructing a priority scheduling queue in descending order of the priority scheduling index, and setting a priority scheduling pointer pointing to the concurrent task to be executed at the head of the priority scheduling queue; the present application further provides that in step S32, the priority scheduling index of the task is calculated according to the priority, the urgency and the task waiting time, and specifically: wherein, is the priority scheduling index of the task, is the score of the priority, is the score of the urgency, and the value ranges are both (0, 1], is a weight coefficient, and is greater than 0, is the task waiting time, and the value of the task waiting time of the task in execution is 0.
[0061] S33: obtaining the task in execution whose memory allocation is greater than or equal to the memory consumption of the concurrent task to be executed pointed to by the priority scheduling pointer and whose priority scheduling index is the smallest;
[0062] S34: when the priority scheduling index of the task in execution is smaller than the priority scheduling index of the concurrent task to be executed pointed to by the priority scheduling pointer, preemptively scheduling and executing the concurrent task to be executed pointed to by the priority scheduling pointer;
[0063] S35: When the priority scheduling index of the task being executed is greater than or equal to the priority scheduling index of the concurrent task to be executed pointed by the priority scheduling pointer, the priority scheduling pointer is moved one bit, and step S33 is executed. Through preemption scheduling, high-priority, urgent tasks can obtain resources for execution in time to meet business needs; memory resources released by tasks being executed are fully utilized to avoid resource idling or waste, improve memory utilization, dynamically adjust scheduling strategies according to task priorities and resource conditions, and adapt to load changes; while considering task priorities, the introduction of task waiting time prevents low-priority tasks from being executed for a long time and improves system fairness.
[0064] The application further provides that in step S4, active objects and objects no longer in use in the memory are marked and identified, and the objects no longer in use are cleared, specifically including:
[0065] In memory allocation, a unique identifier is allocated to each object, and a reference count is recorded; specifically, a unique identifier (ID) is allocated to each object when the object is created, so that the object can be accurately positioned and identified in the memory management process; each object maintains a reference counter to record the number of references to the object, and when the reference count drops to zero, it indicates that no other object references it, and it can become a candidate object for garbage collection;
[0066] An object reference graph is maintained to record the reference and dependency relationship between objects and build a memory reference model; specifically, the reference and dependency relationship between objects is recorded to form a directed graph, with nodes representing objects and edges representing reference relationships.
[0067] Starting from the root set, the object reference graph is recursively traversed; specifically, the root set (Root Set) contains all objects directly referenced by the program execution environment, such as global variables, references on the stack, and references in CPU registers; recursive traversal means that the object reference graph is traversed in depth-first or breadth-first order from the root set to find all reachable objects.
[0068] Unvisited objects are marked with a first mark, objects that have been discovered but have not yet traversed their child nodes are marked with a second mark, and objects that have traversed their child nodes are marked with a third mark, wherein the objects marked are reachable active objects, and the objects not marked are unreachable objects, indicating that they are no longer in use.
[0069] The application further provides that in step S4, the memory blocks in use are monitored in real time to obtain a memory increase abnormality index and a memory optimization performance index, including:
[0070] The memory growth rate, allocation-release imbalance rate, garbage collection efficiency, and memory fragmentation degree of the memory blocks in use are obtained and normalized.
[0071] The memory rising abnormality index is calculated according to a memory growth rate and an allocation-release imbalance rate; the application further provides that the memory growth rate is obtained by the change value of the memory usage in a time interval; the allocation-release imbalance rate is obtained by the ratio of the difference between the number of memory allocation operations and the number of release operations in a time interval to the number of memory allocation operations; and the calculation logic of the memory rising abnormality index is: wherein, is the memory rising abnormality index, is the memory growth rate, is the allocation-release imbalance rate, and is a weight coefficient, and .
[0072] The memory optimization performance index is calculated according to a garbage collection efficiency and a memory fragmentation degree; the application further provides that the garbage collection efficiency is obtained by the total amount of memory recovered by the garbage collection operation in a time interval; the memory fragmentation degree is obtained by subtracting the ratio of the size of the largest continuous free block in the current memory to the total size of all free spaces in the current memory; and the calculation logic of the memory optimization performance index is: wherein, is the memory optimization performance index, is the garbage collection efficiency, is the memory fragmentation degree, and is a weight coefficient, and .
[0073] The application further provides that step S5 specifically includes:
[0074] When the memory rising abnormality index is greater than a preset memory rising abnormality threshold, a memory abnormality alarm signal is generated, a high memory consumption task is located, and a memory leakage check is performed; specifically, the method for locating the high memory consumption task is: memory usage sorting, the tasks currently running are sorted according to the memory occupation, and the task with the highest memory consumption is found; memory growth analysis, the memory usage growth rate of the task is monitored, and the task with abnormal memory growth is identified; memory leakage indicates that the program does not correctly release the memory no longer used, resulting in the phenomenon of continuous growth of memory occupation, and the memory allocation and release of the task are analyzed by using a memory leakage detection tool.
[0075] When the memory optimization performance index is greater than the preset memory optimization performance threshold, a memory optimization alarm signal is generated, garbage collection parameters are optimized, and memory compression is performed. Specifically, the garbage collection parameters include a collection frequency and a heap size; the memory compression means eliminating memory fragmentation by moving active objects in the memory, merging free memory areas, and forming continuous available memory space. By monitoring the memory rise anomaly index, abnormal growth of memory usage can be detected in a timely manner to prevent memory exhaustion caused by memory leaks. Locating high memory consumption tasks and performing memory leak checks can quickly locate the source of the problem, take timely measures, and avoid system crashes; by monitoring the memory optimization performance index, the system can identify a decrease in the efficiency of the memory optimization mechanism; optimizing garbage collection parameters and performing memory compression can improve memory recovery efficiency, reduce memory fragmentation, improve memory utilization, and thus improve system performance.
[0076] The above embodiments can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented by software, the above embodiments can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions or computer programs. When the computer instructions or computer programs are loaded or executed on a computer, the processes or functions described in the embodiments of the present application are generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another, for example, the computer instructions can be transmitted from one website, computer, server or data center to another website, computer, server or data center by wired (such as infrared, wireless, microwave, etc.) mode. The computer-readable storage medium can be any available medium accessible by a computer or a data storage device such as a server, data center, etc. containing one or more available medium collections. The available medium can be a magnetic medium (such as a floppy disk, a hard disk, a magnetic tape), an optical medium (such as a DVD), or a semiconductor medium. The semiconductor medium can be a solid state disk.
[0077] It should be understood that the term "and / or" herein merely describes the association relationship of the associated objects, and means that there can be three relationships, for example, A and / or B can mean that A exists alone, A and B exist together, and B exists alone, where A and B can be singular or plural. In addition, the character " / " herein generally represents that the associated objects before and after it are in an "or" relationship, but it can also represent an "and / or" relationship, which can be understood according to the context before and after it.
[0078] In this application, "at least one" means one or more, and "more than one" means two or more. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of single or multiple items. For example, at least one of a, b, or c can mean: a, b, c, ab, ac, bc, or abc, where a, b, and c can be single or multiple.
[0079] It should be understood that in the various embodiments of this application, the order of the above-mentioned processes does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0080] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0081] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0082] In the several embodiments provided in this application, it should be understood that the disclosed system can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.
[0083] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0084] In addition, each function unit in each embodiment of the present application can be integrated in one processing unit, or each unit can be physically present separately, or two or more units can be integrated in one unit.
[0085] The functions, if implemented in the form of software function units and sold or used as independent products, can be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the present application, essentially or in part, or parts of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium, and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), magnetic disk or optical disk, and various other media that can store program codes.
[0086] The above is merely specific embodiments of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art can easily think of changes or replacements within the technical scope disclosed in the present application, which shall be covered within the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.
Claims
1. A memory optimization method based on AI-scheduled tasks, characterized in that, include: S1: Collect and preprocess memory usage data of executing tasks through a memory monitoring system to perform real-time memory demand prediction; S2: Based on the predicted memory requirements, and by combining the task's state parameter data and memory usage trends, adaptive memory pre-allocation is performed; S3: Analyze the memory requirements of the concurrent tasks to be executed, build a priority scheduling queue to sort the tasks, and execute the tasks in the priority scheduling queue through a preset preemptive scheduling algorithm; S4: Mark and identify active and unused objects in memory, clear unused objects, monitor memory blocks in use in real time, and obtain memory rise anomaly index and memory optimization performance index; S5: When the memory rise anomaly index and / or memory optimization performance index exceed the preset threshold, a memory optimization signal is generated to perform memory re-optimization; In step S4, the memory blocks in use are monitored in real time to obtain the memory rise anomaly index and memory optimization performance index, including: Obtain the memory growth rate, allocation-release imbalance rate, garbage collection efficiency, and memory fragmentation level of the memory blocks currently in use, and normalize them; Calculate the memory rise anomaly index based on memory growth rate and allocation-release imbalance rate; Memory optimization performance index is calculated based on garbage collection efficiency and memory fragmentation level; The logic for obtaining the memory growth rate is the change in memory usage within a time interval; the logic for obtaining the allocation-release imbalance rate is the ratio of the difference between the number of memory allocation operations and the number of memory release operations within a time interval to the number of memory allocation operations; the logic for calculating the memory increase anomaly index is as follows: ,in, This is an abnormal index indicating a rise in memory usage. For memory growth rate, To allocate and release the imbalance rate, and These are the weighting coefficients, and ; The logic for obtaining garbage collection efficiency is the total amount of memory reclaimed by garbage collection operations within a time interval; the logic for obtaining memory fragmentation level is a ratio of the size of the largest contiguous free block in current memory to the total size of all free space in current memory; the logic for calculating the memory optimization performance index is: ,in, Optimize memory performance index. To improve waste recycling efficiency, For the degree of memory fragmentation, and These are the weighting coefficients, and .
2. The memory optimization method based on AI-scheduled tasks according to claim 1, characterized in that, Step S1 specifically includes: The memory usage data of the tasks in execution is collected and preprocessed through a memory monitoring system. The memory usage data includes memory allocation, release, and usage. The memory usage data is preprocessed, including cleaning, normalization, and feature extraction to remove noise and outliers. Real-time memory demand prediction is performed based on a temporal convolutional network using preprocessed memory usage data.
3. The memory optimization method based on AI-scheduled tasks according to claim 1, characterized in that, In step S2, the state parameters include priority and urgency; based on the predicted memory requirements, and considering both the task's state parameter data and memory usage trends, adaptive memory allocation is performed, specifically as follows: ,in, For the predicted memory requirements, This represents the current actual memory consumption. This represents the memory usage trend, specifically the slope of the current actual memory consumption. and These are the weighting coefficients, and , As a priority rating, The score represents the urgency level, and the values range from (0,1).
4. The memory optimization method based on AI-scheduled tasks according to claim 1, characterized in that, Step S3 specifically includes: S31: Analyze the memory requirements of the concurrent tasks to be executed, and obtain the memory consumption, priority, urgency and task waiting time; S32: Calculate the priority scheduling index of the task based on priority, urgency and task waiting time, construct a priority scheduling queue in descending order of priority scheduling index, and set a priority scheduling pointer to point to the concurrent task waiting to be executed at the first position of the priority scheduling queue. S33: Get the running task whose memory allocation is greater than or equal to the memory consumption of the concurrent task to be executed pointed to by the priority scheduling pointer and has the smallest priority scheduling index. S34: When the priority scheduling index of the executing task is less than the priority scheduling index of the concurrent task to be executed pointed to by the priority scheduling pointer, the concurrent task to be executed pointed to by the priority scheduling pointer will be preemptively scheduled and executed. S35: When the priority scheduling index of the executing task is greater than or equal to the priority scheduling index of the concurrent task to be executed pointed to by the priority scheduling pointer, the priority scheduling pointer is moved one position to the right, and step S33 is executed.
5. The memory optimization method based on AI-scheduled tasks according to claim 4, characterized in that, In step S32, the priority scheduling index of the task is calculated based on priority, urgency, and task waiting time, specifically as follows: ,in, This is the priority scheduling index for tasks. As a priority rating, The score represents the urgency level, and all values are in the range (0,1]. This is the weighting coefficient, and it is greater than 0. This represents the task waiting time; for tasks that are currently executing, the task waiting time is 0.
6. The memory optimization method based on AI-scheduled tasks according to claim 1, characterized in that, In step S4, active objects and unused objects in memory are marked and identified, and unused objects are cleared, specifically including: During memory allocation, a unique identifier is assigned to each object, and a reference count is recorded. Maintain an object reference graph to record the references and dependencies between objects and build a memory reference model; Starting from the root set, recursively traverse the object reference graph; Unvisited objects are marked as first objects, objects that have been found but whose child nodes have not been traversed are marked as second objects, and objects whose child nodes have been traversed are marked as third objects. Among them, the marked objects are reachable active objects, and the unmarked objects are unreachable objects, indicating that they are no longer used.
7. The memory optimization method based on AI-scheduled tasks according to claim 1, characterized in that, Step S5 specifically includes: When the memory rise anomaly index exceeds the preset memory rise anomaly threshold, a memory anomaly alarm signal is generated to locate the high memory consumption task and perform a memory leak check. When the memory optimization performance index exceeds the preset memory optimization performance threshold, a memory optimization alarm signal is generated, optimization and recovery parameters are optimized, and memory compression is performed.
Citation Information
Patent Citations
Memory optimization method and system
CN117520039A
Task processing method and system for comprehensive resource management of intelligent monitoring system
CN117608840A
Heterogeneous hardware computing power scheduling method and device, equipment and medium
CN118626263A