Memory optimization method based on AI scheduling task
Through real-time monitoring and preprocessing of memory usage data, adaptive memory allocation and recycling, and tagging objects that are no longer in use, the problem of inefficient memory management in the existing technology is solved, and efficient memory resource utilization and system performance improvement is achieved.
Patent Information
- Application Number
- CN202411548200.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-01
- Publication Date
- 2024-12-03
- Estimated Expiration
- 2044-11-01
AI Technical Summary
Existing memory management methods are difficult to cope with dynamically changing task requirements and high load conditions, resulting in inefficient memory usage and increased response delays, and lack timely response and handling mechanisms for abnormal memory usage.
Through the memory monitoring system, collect and preprocess the memory usage data of tasks, conduct real-time demand prediction, adaptive memory preallocation, and build a priority scheduling queue, mark and identify objects that are no longer used, monitor memory usage in real time, and generate optimization signals for Memory optimization.
Accurate memory demand forecasting and adaptive optimization are achieved, memory usage efficiency is improved, memory waste and performance bottlenecks are avoided, and overall system performance is improved.
Smart Images

Figure CN119065856A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer memory management, and in particular to a memory optimization method based on AI scheduling tasks. Background Art
[0002] In modern computer systems, memory management and optimization play a vital role in the efficiency of task execution. Existing memory management methods usually rely on static allocation strategies, which are difficult to cope with dynamically changing task requirements and memory usage. These traditional methods are prone to inefficient memory usage, increased response delays, and even the risk of system crashes when faced with high loads or frequent task switching. In addition, most existing memory optimization solutions only focus on memory allocation and recycling, ignoring the dynamic memory requirements of real-time tasks, which makes it impossible to efficiently use memory resources.
[0003] With the rapid development of artificial intelligence (AI) technology, the application of AI in task scheduling and resource management has gradually gained attention. However, the current methods of applying AI to memory optimization are still relatively preliminary, usually simply adjusting based on historical data or rules, and lack the ability to accurately predict and dynamically adjust real-time memory usage. In addition, the existing AI memory optimization solutions lack a timely response and processing mechanism for abnormal memory usage. When abnormal memory usage behavior occurs, the system often cannot quickly make optimization adjustments, resulting in memory waste or task failure. Summary of the invention
[0004] Based on the above-mentioned shortcomings of the prior art, the purpose of the present invention is to provide a memory optimization method based on AI scheduling tasks to solve the above-mentioned technical problems.
[0005] To achieve the above object, the present invention provides the following technical solution: a memory optimization method based on AI scheduling tasks, comprising:
[0006] S1: The memory monitoring system collects and preprocesses the memory usage data of the executing tasks to make real-time memory demand predictions.
[0007] S2: Adaptive memory pre-allocation based on predicted memory demand, integrated task status parameter data and memory usage trends;
[0008] S3: Analyze the memory requirements of 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;
[0009] S4: Mark and identify active objects and unused objects in memory, clear unused objects, monitor the memory blocks in use in real time, and obtain the memory increase abnormality index and memory optimization efficiency index;
[0010] S5: When the memory increase abnormality index and / or the memory optimization efficiency index is greater than a preset threshold, a memory optimization signal is generated to perform memory re-optimization.
[0011] The present invention is further configured that step S1 specifically includes:
[0012] Collect and pre-process memory usage data of the executing tasks through a memory monitoring system, wherein the memory usage data includes memory allocation, release and usage;
[0013] Preprocessing the memory usage data, wherein the preprocessing includes cleaning, normalization and feature extraction, and eliminating noise and outliers;
[0014] Real-time memory demand prediction is performed based on the preprocessed memory usage data and the temporal convolutional network.
[0015] The present invention is further configured that, in step S2, the state parameter includes priority and urgency; based on the predicted memory demand, the state parameter data of the comprehensive task and the memory usage trend, adaptive memory allocation is performed, specifically: ,in, For adaptive memory allocation, To predict memory requirements, is the current actual memory consumption, is the memory usage trend, specifically the slope of the current actual memory consumption, and is the weight coefficient, and , is the priority score, is the urgency score, and its value range is (0,1).
[0016] The present invention is further configured that step S3 specifically includes:
[0017] S31: Analyze the memory requirements of the concurrent tasks to be executed, and obtain the memory consumption, priority, urgency and task waiting time;
[0018] S32: Calculate the priority scheduling index of the task according to the priority, urgency and task waiting time, construct a priority scheduling queue according to the descending order of the priority scheduling index, and set a priority scheduling pointer to point to the concurrent task to be executed at the first position in the priority scheduling queue;
[0019] S33: Obtaining the executing 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 whose priority scheduling index is the smallest;
[0020] S34: when the priority scheduling index of the task being executed is less than the priority scheduling index of the concurrent task to be executed pointed to by the priority scheduling pointer, preemptively schedule the concurrent task to be executed pointed to by the priority scheduling pointer;
[0021] 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 to by the priority scheduling pointer, the priority scheduling pointer moves back one position and executes step S33.
[0022] The present invention is further configured to calculate the priority scheduling index of the task according to the priority, urgency and task waiting time in step S32, specifically: ,in, is the priority scheduling index of the task, is the priority score, is the urgency score, and its value range is (0,1). is the weight coefficient and is greater than 0. The task waiting time is 0 for the task being executed.
[0023] The present invention is further configured to, in step S4, mark and identify active objects and no longer used objects in the memory, and clear the no longer used objects, specifically including:
[0024] When allocating memory, a unique identifier is assigned to each object and a reference count is recorded;
[0025] Maintain object reference relationship graph, record references and dependencies between objects, and build memory reference model;
[0026] Starting from the root collection, recursively traverse the object reference graph;
[0027] The unvisited objects are marked first, the objects that have been found but whose child nodes have not been traversed are marked second, and the objects whose child nodes have been traversed are marked third. Among them, the marked objects are reachable active objects, and the unmarked objects are unreachable objects, which means they are no longer used.
[0028] The present invention is further configured to monitor the memory blocks in use in real time in step S4 to obtain a memory increase abnormality index and a memory optimization efficiency index, including:
[0029] Obtain the memory growth rate, allocation-release imbalance rate, garbage collection efficiency, and memory fragmentation degree of the memory blocks in use, and normalize them;
[0030] Calculate the memory increase abnormality index based on the memory growth rate and allocation-release imbalance rate;
[0031] Calculates the memory optimization performance index based on garbage collection efficiency and memory fragmentation level.
[0032] The present invention is further configured such that the acquisition logic of the memory growth rate is the change value of the memory usage within the time interval; the acquisition logic of the allocation-release imbalance rate is the ratio of the difference between the number of memory allocation operations and the number of release operations within the time interval to the number of memory allocation operations; the calculation logic of the memory increase abnormality index is: ,in, The memory increase abnormality index. is the memory growth rate, is the allocation-release imbalance ratio, and is the weight coefficient, and .
[0033] The present invention is further configured such that the garbage collection efficiency is obtained by the total amount of memory recovered by the garbage collection operation within the 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 memory optimization performance index is calculated by: ,in, Optimize memory performance index. For garbage collection efficiency, is the degree of memory fragmentation, and is the weight coefficient, and .
[0034] The present invention is further configured that step S5 specifically includes:
[0035] When the memory increase abnormality index is greater than the preset memory increase abnormality threshold, a memory abnormality alarm signal is generated to locate high memory consumption tasks and perform memory leak checks;
[0036] When the memory optimization performance index is greater than the preset memory optimization performance threshold, a memory optimization alarm signal is generated, recycling parameters are optimized, and memory compression is performed.
[0037] The present invention provides a memory optimization method based on AI scheduling tasks. The method collects and preprocesses memory usage data of tasks in execution through a memory monitoring system to perform real-time memory demand prediction; based on the predicted memory demand, the state parameter data of the task and the memory usage trend are integrated to perform adaptive memory pre-allocation; memory demand analysis is performed on concurrent tasks to be executed, a priority scheduling queue is constructed to sort the tasks, and the tasks in the priority scheduling queue are executed through a preset preemptive scheduling algorithm; active objects and objects no longer in use in the memory are marked and identified, objects no longer in use are cleared, and the memory blocks in use are monitored in real time to obtain a memory increase abnormality index and a memory optimization efficiency index; when the memory increase abnormality index and / or the memory optimization efficiency index are greater than a preset threshold, a memory optimization signal is generated to perform memory re-optimization, and the beneficial effects produced include:
[0038] 1. Accurate memory demand prediction: The AI model monitors and analyzes memory usage data in real time during task execution, accurately predicts the memory demand of tasks to be executed, and dynamically adapts to changes during task execution, significantly improving the rationality and efficiency of memory usage, and avoiding memory waste or performance bottlenecks caused by insufficient or excessive allocation.
[0039] 2. Adaptive memory optimization: The present invention can automatically adjust the memory allocation and recycling strategy during task execution based on the predicted memory demand, combined with the task status parameters and memory usage trends. Compared with the existing fixed rule allocation method, the present invention 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 recycling mechanism: Through the optimized memory allocation and recycling algorithm, the present invention can maximize the utilization of memory resources. In particular, when multiple tasks are executed in parallel, the present invention can intelligently adjust the memory allocation order according to task priority, memory requirements and execution time, reduce task waiting time, and improve the overall operation efficiency of the system.
[0041] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for describing the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. In the drawings:
[0043] Figure 1 The present invention is a flowchart of a memory optimization method based on AI scheduling tasks, showing an exemplary embodiment of the present invention. DETAILED DESCRIPTION
[0044] The following will describe the embodiments of the present invention with reference to the accompanying drawings and preferred embodiments. Those skilled in the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present invention. It should be understood that the preferred embodiments are only for illustrating the present invention, not for limiting the scope of protection of the present invention.
[0045] It should be noted that the illustrations provided in the following embodiments are only schematic illustrations of the basic concept of the present invention, and thus the drawings only show components related to the present invention rather than being drawn according to the number, shape and size of components in actual implementation. In actual implementation, the type, quantity and proportion of each component may be changed arbitrarily, and the component layout may also be more complicated.
[0046] In the following description, numerous details are discussed to provide a more thorough explanation of the embodiments of the present invention. However, it is obvious to those skilled in the art that the embodiments of the present invention can be implemented without these specific details. In other embodiments, well-known structures and devices are shown in the form of block diagrams rather than in detail to avoid making the embodiments of the present invention difficult to understand.
[0047] A memory optimization method based on AI scheduling tasks, such as Figure 1 As shown, including:
[0048] S1: The memory monitoring system collects and preprocesses the memory usage data of the executing tasks to make real-time memory demand predictions.
[0049] S2: Adaptive memory pre-allocation based on predicted memory demand, integrated task status parameter data and memory usage trends;
[0050] S3: Analyze the memory requirements of 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;
[0051] S4: Mark and identify active objects and unused objects in memory, clear unused objects, monitor the memory blocks in use in real time, and obtain the memory increase abnormality index and memory optimization efficiency index;
[0052] S5: When the memory increase abnormality index and / or the memory optimization efficiency index is greater than a preset threshold, a memory optimization signal is generated to perform memory re-optimization.
[0053] The present invention is further configured that step S1 specifically includes:
[0054] Collect and pre-process memory usage data of the executing tasks through the memory monitoring system, wherein the memory usage data includes memory allocation, release and usage; specifically, collect the memory usage data of the executing tasks in real time through the memory monitoring system, wherein 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 outliers. Specifically, the collected raw memory usage data is cleaned to eliminate noise and outliers to ensure data quality. Data from different sources and formats are converted into a unified format and unit to eliminate dimensional differences for easy model processing. Key features are extracted from the cleaned and normalized data to provide high-quality input for the model and improve prediction performance.
[0056] According to the preprocessed memory usage data, based on the temporal convolutional network, real-time memory demand prediction is performed; specifically, the temporal convolutional network (TCN) is selected as the prediction model, which is suitable for processing sequence data and capturing long-term time dependencies; the preprocessed memory usage data is used to train the TCN model to enable it to learn the time pattern and trend of task memory usage; the real-time collected and preprocessed data is input into the trained TCN model to perform real-time prediction of memory demand and provide a basis for memory allocation.
[0057] The present invention is further configured that, in step S2, the state parameter includes priority and urgency; based on the predicted memory demand, the state parameter data of the comprehensive task and the memory usage trend, adaptive memory allocation is performed, specifically: ,in, For adaptive memory allocation, To predict memory requirements, is the current actual memory consumption, is the memory usage trend, specifically the slope of the current actual memory consumption, and is the weight coefficient, and , is the priority score, is the score of urgency, and its value range is (0,1). In a feasible embodiment of the present invention, is 0.6, The closer the priority and urgency scores are to 1, the higher the priority and urgency of the task.
[0058] The present invention is further configured that step S3 specifically includes:
[0059] S31: Analyze the memory requirements of the concurrent tasks to be executed, and obtain the memory consumption, priority, urgency and task waiting time. Specifically, the memory consumption refers to the amount of memory required by each task to be executed during the execution process; the priority refers to the importance level of the task determined according to business needs or policies; the urgency refers to how quickly the task needs to be completed, and the more urgent the task, the faster it needs to be executed; the task waiting time refers to the length of time the task has been waiting in the waiting queue;
[0060] S32: Calculate the priority scheduling index of the task according to the priority, urgency and task waiting time, construct a priority scheduling queue according to the descending order of the priority scheduling index, and set the priority scheduling pointer to point to the concurrent task to be executed at the first position in the priority scheduling queue; the present invention is further configured that, in step S32, the priority scheduling index of the task is calculated according to the priority, urgency and task waiting time, specifically: ,in, is the priority scheduling index of the task, is the priority score, is the urgency score, and its value range is (0,1). is the weight coefficient and is greater than 0. The task waiting time is 0 for the task being executed.
[0061] S33: Obtaining the executing 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 whose priority scheduling index is the smallest;
[0062] S34: when the priority scheduling index of the task being executed is less than the priority scheduling index of the concurrent task to be executed pointed to by the priority scheduling pointer, preemptively schedule 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 to by the priority scheduling pointer, the priority scheduling pointer moves back one position and executes step S33. Through preemptive scheduling, high-priority and urgent tasks can obtain resources for execution in a timely manner to meet business needs; make full use of the memory resources released by the executing tasks to avoid idle or wasted resources, improve memory utilization, and dynamically adjust the scheduling strategy according to the priority and resource status of the task to adapt to load changes; while considering the task priority, the introduction of task waiting time can prevent low-priority tasks from being executed for a long time, thereby improving system fairness.
[0064] The present invention is further configured to, in step S4, mark and identify active objects and no longer used objects in the memory, and clear the no longer used objects, specifically including:
[0065] When allocating memory, a unique identifier is assigned to each object and the reference count is recorded. Specifically, when an object is created, a unique identifier (ID) is assigned to each object to ensure that the object can be accurately located and identified during memory management. Each object maintains a reference counter to record the number of references to the object. When the reference count drops to zero, it means that no other object references it and it may become a candidate for garbage collection.
[0066] Maintain an object reference relationship graph, record references and dependencies between objects, and build a memory reference model; specifically, record references and dependencies between objects to form a directed graph, where nodes represent objects and edges represent reference relationships.
[0067] Starting from the root set, recursively traverse the object reference graph; specifically, the root set (Root Set) contains all objects directly referenced by the program execution environment, such as global variables, references on the stack, references in CPU registers, etc.; recursive traversal means starting from the root set, traversing the object reference graph depth-first or breadth-first to find all reachable objects.
[0068] The unvisited objects are marked first, the objects that have been found but whose child nodes have not been traversed are marked second, and the objects whose child nodes have been traversed are marked third. Among them, the marked objects are reachable active objects, and the unmarked objects are unreachable objects, which means they are no longer used.
[0069] The present invention is further configured to monitor the memory blocks in use in real time in step S4 to obtain a memory increase abnormality index and a memory optimization efficiency index, including:
[0070] Obtain the memory growth rate, allocation-release imbalance rate, garbage collection efficiency, and memory fragmentation degree of the memory blocks in use, and normalize them;
[0071] The memory increase abnormality index is calculated according to the memory growth rate and the allocation-release imbalance rate; the present invention is further configured that the acquisition logic of the memory growth rate is the change value of the memory usage within the time interval; the acquisition logic of the allocation-release imbalance rate is the ratio of the difference between the number of memory allocation operations and the number of release operations within the time interval to the number of memory allocation operations; the calculation logic of the memory increase abnormality index is: ,in, The memory increase abnormality index. is the memory growth rate, is the allocation-release imbalance ratio, and is the weight coefficient, and .
[0072] The memory optimization performance index is calculated based on the garbage collection efficiency and the degree of memory fragmentation. The present invention is further configured such that the logic for obtaining the garbage collection efficiency is the total amount of memory recovered by the garbage collection operation within the time interval; the logic for obtaining the degree of memory fragmentation is the ratio of one minus the size of the largest continuous free block in the current memory to the total size of all free spaces in the current memory; the calculation logic of the memory optimization performance index is: ,in, Optimize memory performance index. For garbage collection efficiency, is the degree of memory fragmentation, and is the weight coefficient, and .
[0073] The present invention is further configured that step S5 specifically includes:
[0074] When the memory increase abnormality index is greater than the preset memory increase abnormality threshold, a memory abnormality alarm signal is generated, high memory consumption tasks are located, and memory leak checks are performed; specifically, the method for locating high memory consumption tasks is as follows: memory usage sorting, sorting currently running tasks by memory usage, and finding the tasks with the highest memory consumption; memory growth analysis, monitoring the memory usage growth rate of tasks, and identifying tasks with abnormal memory growth; memory leaks indicate that the program has not correctly released memory that is no longer in use, resulting in a continuous increase in memory usage, and memory leak detection tools are used to analyze the memory allocation and release of tasks.
[0075] When the memory optimization performance index is greater than the preset memory optimization performance threshold, a memory optimization alarm signal is generated, the recycling parameters are optimized, and memory compression is performed. Specifically, garbage collection parameters include recycling frequency and heap size; memory compression means eliminating memory fragmentation by moving active objects in memory, merging free memory areas, and forming a continuous available memory space. By monitoring the memory rising abnormality index, abnormal growth in memory usage can be discovered in a timely manner to prevent memory exhaustion caused by problems such as memory leaks. Locating high memory consumption tasks and performing memory leak checks can quickly locate the source of the problem and take timely measures to avoid system crashes; by monitoring the memory optimization performance index, the system can identify the decline in the efficiency of the memory optimization mechanism; optimizing garbage collection parameters and performing memory compression can improve memory recycling efficiency, reduce memory fragmentation, and improve memory utilization, thereby improving system performance.
[0076] The above embodiments can be implemented in whole or in part by software, hardware, firmware or any other combination. 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 process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from one website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that contains one or more available media sets. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium. The semiconductor medium can be a solid-state hard disk.
[0077] It should be understood that the term "and / or" in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. A and B can be singular or plural. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship, but it may also indicate an "and / or" relationship. Please refer to the context for specific understanding.
[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 refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can be represented by: a, b, c, ab, ac, bc, or abc, where a, b, c can be single or multiple.
[0079] It should be understood that in the various embodiments of the present application, the size of the serial numbers of the above-mentioned processes does not mean 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 the present application.
[0080] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example 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 performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0081] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0082] In the several embodiments provided in the present application, it should be understood that the disclosed system can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0083] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0084] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0085] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage media include: various media that can store program codes, such as USB flash drives, mobile hard disks, read-only memories (ROM), random access memories (RAM), magnetic disks or optical disks.
[0086] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A memory optimization method based on AI scheduling tasks, characterized in that: include: S1: The memory monitoring system collects and preprocesses the memory usage data of the executing tasks to make real-time memory demand predictions. S2: Adaptive memory pre-allocation based on predicted memory demand, integrated task state parameter data and memory usage trends; S3: Analyze the memory requirements of 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 objects and unused objects in memory, clear unused objects, monitor the memory blocks in use in real time, and obtain the memory increase abnormality index and memory optimization efficiency index; S5: When the memory increase abnormality index and / or the memory optimization efficiency index is greater than a preset threshold, a memory optimization signal is generated to perform memory re-optimization.
2. According to the memory optimization method based on AI scheduling tasks according to claim 1, it is characterized in that: Step S1 specifically includes: Collect and pre-process memory usage data of the executing tasks through a memory monitoring system, wherein the memory usage data includes memory allocation, release and usage; Preprocessing the memory usage data, wherein the preprocessing includes cleaning, normalization and feature extraction, and eliminating noise and outliers; Real-time memory demand prediction is performed based on the preprocessed memory usage data and the temporal convolutional network.
3. The memory optimization method based on AI scheduling tasks according to claim 1 is characterized in that: In step S2, the state parameters include priority and urgency; based on the predicted memory demand, the state parameter data of the comprehensive task and the memory usage trend, adaptive memory allocation is performed, specifically: ,in, For adaptive memory allocation, For the predicted memory requirements, is the current actual memory consumption, is the memory usage trend, specifically the slope of the current actual memory consumption, and is the weight coefficient, and , is the priority score, is the urgency score, and its value range is (0,1).
4. The memory optimization method based on AI scheduling tasks according to claim 1 is 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 according to the priority, urgency and task waiting time, construct a priority scheduling queue according to the descending order of the priority scheduling index, and set a priority scheduling pointer to point to the concurrent task to be executed at the first position in the priority scheduling queue; S33: Obtaining the executing 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 whose priority scheduling index is the smallest; S34: when the priority scheduling index of the task being executed is less than the priority scheduling index of the concurrent task to be executed pointed to by the priority scheduling pointer, preemptively schedule the concurrent task to be executed pointed to by the priority scheduling pointer; 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 to by the priority scheduling pointer, the priority scheduling pointer moves back one position and executes step S33.
5. The memory optimization method based on AI scheduling tasks according to claim 4 is characterized in that: In step S32, the priority scheduling index of the task is calculated according to the priority, urgency and task waiting time, specifically: ,in, is the priority scheduling index of the task, is the priority score, is the urgency score, and its value range is (0,1). is the weight coefficient and is greater than 0. The task waiting time is 0 for the task being executed.
6. The memory optimization method based on AI scheduling tasks according to claim 1, characterized in 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, which specifically includes: When allocating memory, a unique identifier is assigned to each object and a reference count is recorded; Maintain object reference relationship graph, record references and dependencies between objects, and build memory reference model; Starting from the root collection, recursively traverse the object reference graph; The unvisited objects are marked first, the objects that have been found but whose child nodes have not been traversed are marked second, and the objects whose child nodes have been traversed are marked third. Among them, the marked objects are reachable active objects, and the unmarked objects are unreachable objects, which means they are no longer used.
7. The memory optimization method based on AI scheduling tasks according to claim 1, characterized in that: In step S4, the memory blocks in use are monitored in real time to obtain the memory increase abnormality index and the memory optimization efficiency index, including: Obtain the memory growth rate, allocation-release imbalance rate, garbage collection efficiency, and memory fragmentation degree of the memory blocks in use, and normalize them; Calculate the memory increase abnormality index based on the memory growth rate and allocation-release imbalance rate; Calculates the memory optimization performance index based on garbage collection efficiency and memory fragmentation level.
8. The memory optimization method based on AI scheduling tasks according to claim 7 is characterized in that: The acquisition logic of the memory growth rate is the change value of the memory usage within the time interval; the acquisition logic of the allocation-release imbalance rate is the ratio of the difference between the number of memory allocation operations and the number of release operations within the time interval to the number of memory allocation operations;The calculation logic of the memory increase abnormal index is: ,in, The memory increase abnormality index. is the memory growth rate, is the allocation-release imbalance ratio, and is the weight coefficient, and .
9. The memory optimization method based on AI scheduling tasks according to claim 7, characterized in that: The logic for obtaining the garbage collection efficiency is the total amount of memory recovered by the garbage collection operation within the time interval; the logic for obtaining the degree of memory fragmentation is the ratio of one minus the size of the largest continuous free block in the current memory to the total size of all free spaces in the current memory; The calculation logic of the memory optimization performance index is: ,in, Optimize memory performance index. For garbage collection efficiency, is the degree of memory fragmentation, and is the weight coefficient, and .
10. The memory optimization method based on AI scheduling tasks according to claim 1, characterized in that: Step S5 specifically includes: When the memory increase abnormality index is greater than the preset memory increase abnormality threshold, a memory abnormality alarm signal is generated to locate high memory consumption tasks and perform memory leak checks; When the memory optimization performance index is greater than the preset memory optimization performance threshold, a memory optimization alarm signal is generated, recycling parameters are optimized, and memory compression is performed.
Citation Information
Patent Citations
Message task scheduling method and device and electronic equipment
CN111782362A
Working platform task workload prediction method based on deep learning
CN111784073A
Method and device for eliminating hotspot data
CN115442382A
Task scheduling method, device and equipment
CN115454602A
Memory optimization method and system
CN117520039A
Cited By
Memory management method and system for large language model training
CN119883642A
A memory management method and system for large language model training
CN119883642B
Memory dynamic adjustment method and system, electronic equipment and storage medium
CN121187767A
A memory dynamic adjustment method and system, electronic equipment and storage medium
CN121187767B
