Memory management method and electronic device

By obtaining the current memory management parameters of BMC, running preset test cases, and updating the parameters based on the fitness function value, the problem of low memory utilization in BMC memory resource management is solved, dynamic management and cluster-level load balancing are realized, and the real-time performance and efficiency of memory allocation are improved.

CN122285462APending Publication Date: 2026-06-26INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
INSPUR SUZHOU INTELLIGENT TECH CO LTD
Filing Date
2026-05-28
Publication Date
2026-06-26

AI Technical Summary

Technical Problem

The memory resource management method of BMC in the existing technology results in low memory utilization, cannot dynamically adjust memory management parameters, cannot meet the high-performance memory management needs of large-scale data centers, and lacks cluster-level collaborative optimization methods, leading to memory resource fragmentation and load imbalance.

Method used

By obtaining the controller's current memory management parameters, running preset test cases to obtain performance indicators, updating memory management parameters based on fitness function values ​​to achieve dynamic management, optimizing by combining BMC kernel state and hardware characteristics, and using particle swarm optimization algorithm for iterative optimization to achieve cluster-level load balancing.

Benefits of technology

It improves memory utilization, reduces memory resource fragmentation, enhances the real-time performance and efficiency of memory allocation, and meets the needs of large-scale data centers for high-performance memory management by BMC.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122285462A_ABST
    Figure CN122285462A_ABST
Patent Text Reader

Abstract

This application discloses a memory management method and electronic device, relating to the field of computer technology. The method includes configuring the memory of any controller in a target cluster based on its current memory management parameters, running preset test cases on the controller to obtain performance indicators under the current memory configuration, determining the fitness function value of the controller under the current memory configuration, and then determining the controller's historically optimal memory management parameters. If the current iteration count has not reached an iteration count threshold, the memory management parameters are updated based on the target update speed, and iteration continues based on the updated memory management parameters. If the current iteration count reaches the iteration count threshold, the controller is configured with appropriate memory based on its historically optimal memory management parameters. This achieves dynamic memory management of the controller, resulting in improved memory utilization.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to memory management methods and electronic devices. Background Technology

[0002] With the rapid development of technologies such as artificial intelligence and cloud computing, the scale of data center servers is expanding rapidly. As a core component of server management, the Baseboard Management Controller (BMC) faces severe challenges in memory resource management. Related technologies typically employ static parameter configuration strategies for BMC memory resource management.

[0003] This memory resource management method results in low memory utilization. Summary of the Invention

[0004] This application provides a memory management method and an electronic device to at least solve the problem of low memory utilization caused by memory resource management methods in related technologies.

[0005] This application provides a memory management method, including: For any controller in the target cluster, obtain the current memory management parameters of that controller; Based on the current memory management parameters, configure the controller accordingly and run preset test cases on the controller to obtain the controller's performance indicators under the current memory configuration; Based on the performance metrics of the controller under the current memory configuration, determine the fitness function value of the controller under the current memory configuration; Based on the fitness function value of the controller under the current memory configuration, determine the controller's own historical best memory management parameters; If the current iteration count has not reached the iteration count threshold, the memory management parameters are updated based on the target update rate of the memory management parameters, and the process returns to the step of obtaining the current memory management parameters of the controller. If the current iteration count reaches the iteration count threshold, then the controller will be configured with appropriate memory based on its historical best memory management parameters.

[0006] This application also provides an electronic device, including: a memory for storing a computer program; and a processor for implementing any of the above-described memory management methods when executing the computer program.

[0007] This application also provides a computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the steps of any of the above-described memory management methods.

[0008] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of any of the above-described memory management methods.

[0009] This application achieves dynamic management of the controller's memory resources by: acquiring the current memory management parameters of any controller in the target cluster; configuring the controller's memory accordingly based on these parameters; running preset test cases on the controller to obtain its performance metrics under the current memory configuration; determining the controller's fitness function value under the current memory configuration based on these performance metrics; determining the controller's historical best memory management parameters based on the fitness function value; if the current iteration count has not reached the iteration count threshold, updating the memory management parameters based on the target update rate, and returning to the step of acquiring the controller's current memory management parameters; if the current iteration count has reached the iteration count threshold, configuring the controller's memory accordingly based on its historical best memory management parameters. This solves the technical problem of low memory utilization caused by memory resource management methods in related technologies, thus improving memory utilization. Attached Figure Description

[0010] To more clearly illustrate the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0011] Figure 1 This is a schematic diagram of the structure of a memory management system provided in an embodiment of this application; Figure 2 This is a schematic diagram of the structure of the BMC provided in the embodiments of this application; Figure 3 A flowchart illustrating a memory management method provided in an embodiment of this application; Figure 4 A flowchart illustrating yet another memory management method provided in an embodiment of this application; Figure 5 A flowchart illustrating another memory management method provided in an embodiment of this application; Figure 6 A schematic diagram of a sub-process of the particle swarm optimization algorithm provided in an embodiment of this application; Figure 7 This is a schematic diagram of the structure of a memory management device provided in an embodiment of this application; Figure 8 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0012] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the protection scope of this application.

[0013] It should be noted that, in the description of this application, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. The terms "first," "second," etc., in this application are used to distinguish similar objects and are not used to describe a specific order or sequence.

[0014] To enable those skilled in the art to better understand the present application, the present application will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0015] With the rapid development of technologies such as artificial intelligence, cloud computing, and robotics, the scale of data center servers is expanding rapidly. As a core component of server management, the memory resource management capabilities of the BMC (Browser Controller) face severe challenges. Related technologies typically employ static parameter configuration and independent optimization strategies. This means that the memory management parameters of each BMC in a server are configured independently and statically. Administrators can set the same set of memory management parameters for all BMCs based on experience, or pre-set memory management parameters by simply grouping the BMCs according to their hardware models.

[0016] The memory resource management method of BMC in related technologies cannot dynamically adjust memory management parameters, making it difficult to adapt to complex and ever-changing workload scenarios, resulting in low memory utilization and high response latency.

[0017] Furthermore, the memory management methods of BMC in related technologies cannot effectively combine the BMC kernel state and hardware characteristics for dynamic optimization, resulting in low real-time performance and efficiency of memory allocation, which cannot meet the needs of large-scale data centers for high-performance memory management of BMC.

[0018] Furthermore, the memory resource management methods in these technologies typically operate independently within each Business Control Center (BMC), lacking cluster-level collaborative optimization methods. This leads to problems such as low memory utilization, severe memory resource fragmentation, and uneven cluster load. Moreover, the memory resource management methods in these technologies fail to adaptively adjust according to real-time load conditions, easily triggering resource contention in high-concurrency scenarios and affecting the overall stability of the system.

[0019] To address the aforementioned technical problems, embodiments of this application provide a memory management method and an electronic device. The memory management method includes: for any controller in a target cluster, obtaining the current memory management parameters of the controller; based on the current memory management parameters, configuring the controller accordingly, and running preset test cases on the controller to obtain the controller's performance indicators under the current memory configuration; based on the controller's performance indicators under the current memory configuration, determining the fitness function value of the controller under the current memory configuration; based on the fitness function value of the controller under the current memory configuration, determining the controller's own historical best memory management parameters; if the current iteration count has not reached an iteration count threshold, updating the memory management parameters based on the target update rate of the memory management parameters, and returning to the step of obtaining the controller's current memory management parameters; if the current iteration count has reached an iteration count threshold, configuring the controller accordingly based on the controller's own historical best memory management parameters. The method provided by the above scheme determines the fitness function value based on the controller's performance indicators under the current memory configuration, and then determines the controller's own historical optimal memory management parameters. If the current iteration number has not reached the iteration number threshold, the memory management parameters are updated to continue iteration based on the updated memory management parameters. If the current iteration number has reached the iteration number threshold, the controller's memory is configured accordingly based on the controller's own historical optimal memory management parameters. This achieves dynamic management of the controller's memory resources, thus solving the technical problem of low memory utilization caused by memory resource management methods in related technologies, and achieving the technical effect of improving memory utilization.

[0020] The specific application environment architecture or specific hardware architecture on which the execution of the memory management method depends is described here.

[0021] The memory management method and electronic device provided in this application are applicable to managing the memory of a controller. For example... Figure 1The diagram shows the structure of the memory management system upon which this application is based. This system includes a system control module, a server cluster, and a knowledge base module. The system control module collects the historical best memory management parameters of each BMC (Browser Management Center), calculates and distributes the optimal management parameters for the cluster, and achieves collaborative optimization across the cluster. The knowledge base module stores the optimized memory management parameters, the results of applying these optimized parameters, and performance data, providing data support and trend prediction for optimization decisions. The server cluster consists of multiple servers that execute actual business logic and provide operational data for optimization analysis. Each server contains a BMC. Figure 2 This is a schematic diagram of the structure of the BMC provided in the embodiments of this application, such as... Figure 2 As shown, BMC includes a particle swarm optimizer, a performance monitor, a memory management interface, a Linux operating system, and a real-time operating system. The particle swarm optimizer executes the particle swarm optimization algorithm, manages local memory management parameter configurations, and calculates fitness function values ​​for memory optimization. The performance monitor collects performance metrics in real time, providing a data foundation for memory optimization. The memory management interface provides a secure and reliable channel for reading and writing memory parameters and can perform automatic rollback in case of memory configuration anomalies. The Linux operating system is primarily responsible for the main server monitoring functions of BMC, while the real-time operating system mainly assists with functions such as thermal configuration during rapid boot.

[0022] Embodiments of this application provide a memory management method applied to the aforementioned memory management system. Figure 3 A flowchart of the memory management method provided in the embodiments of this application is shown below. Figure 3 As shown, this memory management method includes the following steps: Step S301: For any controller in the target cluster, obtain the current memory management parameters of that controller.

[0023] The memory management parameters are multidimensional and are represented by the position vector used in the particle swarm optimization algorithm. The expression for this position vector is: x i = (x i1 x i2 x i3 x i4 x i5 x i6) Position vector x i This represents an n-dimensional real vector, indicating the memory configuration of the i-th BMC. A controller can be a BMC.

[0024] x ij : Represents an adjustable memory management parameter, that is, the value of the i-th particle in the j-th dimension of the memory management parameter. In other words, it represents the j-th dimension of the memory management parameter of the i-th BMC.

[0025] Based on the characteristics of BMC's dual operating system and cluster management, the location vector can be divided into the following parts: Part 1: Kernel Memory Allocator Parameters (Reducing Memory Fragmentation Rate) x i1 Parameter name: buddy_max_order, physical meaning: the maximum search order of the buddy allocator, value range: [5, 10]. With a system page size of 4KB, the corresponding maximum contiguous physical memory block size is 128KB to 4MB. Function: controls the maximum size of the allocatable contiguous physical memory block, affecting external fragmentation.

[0026] x i2 Parameter name: slab_cache_size, physical meaning: the cache size set in the SLAB allocator for frequently used objects (such as task_struct), value range: [10, 50] (unit: objects), function: affects the kernel object allocation speed and memory reuse rate.

[0027] Part Two: Dual-System Memory Allocation Parameters (Providing Real-Time Performance) x i3 Parameter name: rtos_mem_ratio; Physical meaning: The percentage of total memory reserved for the Real-Time Operating System (RTOS); Value range: [0.15, 0.35] (15% - 35%); Function: A key parameter. Ensures low latency and determinism in real-time systems.

[0028] x i4 Parameter name: linux_watermark_scale_factor, physical meaning: Linux memory watermark scaling factor, value range: [10, 200], function: controls how aggressively the kernel starts reclaiming memory, affecting responsiveness.

[0029] Part Three: Cluster Coordination Parameters (Load Balancing Factor) x i5 Parameter name: free_memory_threshold_high, physical meaning: free memory high watermark threshold. When the free memory of this BMC is higher than this threshold, it indicates that it has sufficient memory and is willing to lend memory to other BMCs. Value range: [0.65, 0.85] (65% - 85%), function: to achieve cluster load balancing.

[0030] x i6Parameter name: free_memory_threshold_low, physical meaning: low watermark threshold for free memory. When the free memory of this BMC is lower than this threshold, it indicates that it is under pressure and is willing to borrow memory from other nodes. Value range: [0.3, 0.6] (30% - 60%). Function: to achieve cluster load balancing.

[0031] Understandably, memory management parameters can include kernel memory allocator parameters, dual-system memory partitioning parameters, and cluster coordination parameters. Kernel memory allocator parameters include the maximum search order of the buddy allocator and the cache size set in the SLAB allocator for the target object, i.e., frequently used objects. Dual-system memory partitioning parameters include the percentage of total memory reserved for the real-time operating system and the Linux memory watermark scaling factor. Cluster coordination parameters include the high-watermark threshold for free memory and the low-watermark threshold for free memory.

[0032] The commonly used objects in the SLAB allocator are mainly predefined by the kernel during initialization based on the system type and configuration.

[0033] It should be noted that during initialization, initial memory management parameters for each controller in the target cluster are randomly generated. Subsequently, during iterations, these memory management parameters are updated according to the target update rate.

[0034] Step S302: Based on the current memory management parameters, configure the controller accordingly and run preset test cases on the controller to obtain the controller's performance indicators under the current memory configuration.

[0035] After obtaining the current memory management parameters of the controller, the controller is configured with corresponding memory based on the current memory management parameters, and preset test cases are run on the controller to obtain the performance indicators of the controller under the current memory configuration.

[0036] Running preset test cases on the controller includes running preset test cases for a fixed duration or a fixed number of times. The fixed duration or fixed number of times is set by the technician. For example, the fixed duration can be 30 seconds, and the fixed number of times can be 10,000. It is understood that running preset test cases for a fixed duration means executing preset test cases multiple times within the fixed duration.

[0037] The pre-set test cases are set up by technical personnel and include key RTOS tasks that need to be monitored (such as sensor polling). The key RTOS tasks that need to be monitored are the target tasks in the RTOS.

[0038] Step S303: Based on the performance indicators of the controller under the current memory configuration, determine the fitness function value of the controller under the current memory configuration.

[0039] The performance metrics include average external fragmentation rate, worst-case execution time of the target task in the real-time operating system, and memory utilization.

[0040] Step S304: Based on the fitness function value of the controller under the current memory configuration, update the controller's own historical best memory management parameters.

[0041] Specifically, after obtaining the fitness function value of the controller under the current memory configuration, the fitness function value of the controller under the current memory configuration is compared with the fitness function value corresponding to the current historical best memory management parameter of the controller. If the fitness function value of the controller under the current memory configuration is not greater than the fitness function value corresponding to the current historical best memory management parameter of the controller, then the current historical best memory management parameter of the controller is kept unchanged.

[0042] If the fitness function value of the controller under the current memory configuration is greater than the fitness function value corresponding to the current historical best memory management parameter of the controller, then the controller's own historical best memory management parameter is updated based on the current memory configuration of the controller.

[0043] Step S305: If the current iteration count has not reached the iteration count threshold, then update the memory management parameters based on the target update speed of the memory management parameters, and return to the step of obtaining the current memory management parameters of the controller.

[0044] The iteration count threshold is set by technical personnel and is not specifically limited here. If the current iteration count has not reached the iteration count threshold, the memory management parameters of the controller are updated based on the target update rate of the controller's memory management parameters, and the process returns to the step of obtaining the current memory management parameters of the controller and subsequent steps.

[0045] Step S306: If the current iteration count reaches the iteration count threshold, then the controller is configured with corresponding memory based on its own historical best memory management parameters.

[0046] The memory management method provided in this application determines the fitness function value based on the controller's performance indicators under the current memory configuration, and then determines the controller's own historical optimal memory management parameters. If the current iteration count has not reached the iteration count threshold, the memory management parameters are updated to continue iteration based on the updated memory management parameters. If the current iteration count reaches the iteration count threshold, the controller's memory is configured accordingly based on the controller's own historical optimal memory management parameters. This achieves dynamic management of the controller's memory resources, thus solving the technical problem of low memory utilization caused by memory resource management methods in related technologies, and achieving the technical effect of improving memory utilization and reducing memory resource fragmentation.

[0047] The memory management method provided in this application effectively combines the BMC kernel state and hardware characteristics for dynamic optimization, improving the real-time performance and efficiency of memory allocation, and meeting the needs of large-scale data centers for high-performance memory management of BMC.

[0048] By dynamically adjusting the memory water level, SLAB allocator parameters, and RTOS reservation ratio of each BMC through an iterative update mechanism, and by designing borrow / borrow thresholds, memory load balancing across BMC nodes is achieved. This significantly improves the efficiency of cluster-level memory resource utilization while reducing fragmentation rate and ensuring real-time performance.

[0049] Embodiments of this application provide a memory management method applied to the aforementioned memory management system. Figure 4 A flowchart of the memory management method provided in the embodiments of this application is shown below. Figure 4 As shown, this memory management method includes the following steps: Step S401: For any controller in the target cluster, obtain the current memory management parameters of that controller. See details in [link to relevant documentation]. Figure 3 Step S301 of the illustrated embodiment will not be described again here.

[0050] Step S402: Based on the current memory management parameters, configure the controller accordingly and run preset test cases on the controller to obtain the controller's performance indicators under the current memory configuration.

[0051] Specifically, performance metrics include the average external fragmentation rate. Step S402 above includes: Step S4021: Run a preset test case on the controller to obtain the size of the free block in each of all levels in the partner allocator.

[0052] Step S4022: Based on the size of the free block in each of all orders, determine the total free block size and the size of the free block in the highest order.

[0053] The maximum size of a contiguous free memory block for this controller corresponds to the size of the highest-order free block in the buddy allocator. For example, if the buddy allocator can allocate a maximum of a 4MB (order=10) contiguous free memory block, then the size of the highest-order free block is 4MB.

[0054] It is understandable that the sum of the sizes of the free blocks in each of all levels is the total free block size, i.e., the total free memory size.

[0055] Step S4023: Based on the total free block size and the size of the highest-order free block, determine the average external fragmentation rate of the controller under the current memory configuration.

[0056] Step S403: Based on the performance indicators of the controller under the current memory configuration, determine the fitness function value of the controller under the current memory configuration.

[0057] Specifically, performance metrics include average external fragmentation rate, worst-case execution time of the target task in the real-time operating system, and memory utilization. The preset test cases include the target task in the real-time operating system. Step S403 above includes: Step S4031: Based on the average external fragmentation rate of the controller under the current memory configuration, determine the memory fragmentation sub-function value of the controller under the current memory configuration.

[0058] Among them, the lower the average fragmentation rate, the higher the value of the memory fragmentation sub-function.

[0059] Step S4032: Based on the worst-case execution time of the target task in the real-time operating system under the current memory configuration, determine the real-time performance sub-function value of the controller under the current memory configuration.

[0060] It should be noted that preset test cases of fixed duration or preset test cases of fixed number of times are run on the controller to obtain the execution time of the target task in the real-time operating system each time the preset test cases are run. Based on the execution time of the target task in the real-time operating system each time the preset test cases are run, the maximum execution time of the target task in the real-time operating system is determined as the worst execution time of the target task in the real-time operation of the controller under the current memory configuration.

[0061] Step S4033: Obtain the memory utilization of other controllers in the target cluster, excluding this controller, under their corresponding current memory configuration.

[0062] The controller periodically collects memory utilization data from other controllers in the cluster besides itself, that is, it obtains the memory utilization of other controllers in the target cluster besides itself under their corresponding current memory configuration.

[0063] Step S4034: Based on the memory utilization of the controller under the current memory configuration and the memory utilization of other controllers in the target cluster under their corresponding current memory configurations, determine the variance of the memory utilization of all controllers in the target cluster.

[0064] Step S4035: Based on the variance of memory utilization of all controllers in the target cluster, determine the cluster balance subfunction value of the controller under the current memory configuration.

[0065] Step S4036: Based on the memory fragmentation sub-function value, real-time performance sub-function value, and cluster balancing sub-function value of the controller under the current memory configuration, determine the fitness function value of the controller under the current memory configuration.

[0066] Step S404: Based on the fitness function value of the controller under the current memory configuration, update the controller's own historical best memory management parameters. For details, please refer to [link to relevant documentation]. Figure 3 Step S304 of the illustrated embodiment will not be described again here.

[0067] Step S405: If the current iteration count has not reached the iteration count threshold, then update the memory management parameters based on the target update rate, and return to the step of obtaining the current memory management parameters of the controller. For details, please refer to [link to relevant documentation]. Figure 3 Step S305 of the illustrated embodiment will not be described again here.

[0068] Step S406: If the current iteration count reaches the iteration count threshold, then based on the controller's historical best memory management parameters, perform corresponding memory configuration for the controller. For details, please refer to [link to relevant documentation]. Figure 3 Step S306 of the illustrated embodiment will not be described again here.

[0069] The memory management method provided in this application embodiment obtains the free block size of each order in the partner allocator by running preset test cases, and calculates the average external fragmentation rate based on the total free block size and the highest order free block size, which can more accurately reflect the degree of fragmentation under the current memory configuration.

[0070] By introducing a memory fragmentation sub-function value (based on the average external fragmentation rate), a real-time performance sub-function value (based on the worst-case execution time of the target task), and a cluster balancing sub-function value (based on memory utilization variance), system performance is modeled from three key dimensions: memory management efficiency, task responsiveness, and resource distribution balance. This multi-objective comprehensive evaluation mechanism avoids the one-sidedness of single-index evaluation and significantly improves the scientificity and accuracy of memory configuration optimization decisions.

[0071] In some optional implementations, step S4023 above includes: Step a1: Based on the first formula, determine the average external fragmentation rate of the controller under the current memory configuration. The first formula is:

[0072] in, This represents the average external fragmentation rate of the controller under the current memory configuration.

[0073] In some optional implementations, step S4031 above includes: Step b1: Based on the second formula, determine the memory fragmentation sub-function value of the controller under the current memory configuration. The second formula is:

[0074] in, This represents the average external fragmentation rate of the controller under the current memory configuration. This is the memory fragmentation sub-function value for the controller under the current memory configuration.

[0075] It is understandable that the second formula above is a memory fragmentation sub-function expression.

[0076] The relationship between the value of the memory fragmentation subfunction and the location vector, i.e., the memory management parameters, is as follows: x i1 (buddy_max_order): Strong impact. This parameter determines whether the kernel can retain large contiguous blocks. If set too low, the system will prematurely split large memory blocks, resulting in smaller maximum contiguous blocks and increased FragRate. reduce.

[0077] x i4 (linux_watermark_scale_factor): Significant impact. This parameter controls how aggressively the kernel merges fragments. A higher value means the kernel more actively reclaims and merges memory pages, making it easier to form large contiguous blocks (larger maximum contiguous block size), thus reducing FragRate and increasing... .

[0078] x i2 (slab_cache_size): Indirect impact. Optimizing this parameter can reduce the "trouble" that small memory allocations cause to the Buddy system, help maintain the integrity of large memory blocks, and have a positive effect on reducing FragRate.

[0079] Step S4032 above includes: Step c1: Based on the third formula, determine the real-time performance sub-function value of the controller under the current memory configuration. The third formula is:

[0080] in, This is the real-time performance sub-function value for the controller under the current memory configuration. This represents the worst-case execution time of the target task in a real-time operating system with the current memory configuration for this controller. This is a preset execution time threshold.

[0081] It is understandable that the third formula above is the expression for the real-time sub-function. The goal of this real-time sub-function is to reward low latency and high task hit rate. If Less than Then the real-time sub-function value is close to 1, if Greater than Then, fitness will be penalized based on the degree of timeout.

[0082] Deadlines are pre-analyzed and set based on hardware characteristics and mission criticality before deployment. This is a clear and fixed design constraint.

[0083] The relationship between the real-time sub-function value and the location vector, i.e., the memory management parameter, is as follows: x i3 (rtos_mem_ratio): Crucial. This is the most direct and strongest influencing factor. Increasing x i3 Allocating more memory for the RTOS will significantly reduce latency caused by insufficient memory, and WCET will decrease. Increase.

[0084] x i4 (linux_watermark_scale_factor): Indirect impact. Lower x i4 This may cause Linux to reclaim memory in a timely manner, competing with the RTOS for resources when memory needs to be allocated, resulting in latency jitter.

[0085] x i1 x i2 Indirect impact. An efficient memory allocator (Buddy / SLAB) can also reduce allocation latency, which positively contributes to the responsiveness of the RTOS.

[0086] Step S4035 above includes: Step d1: Based on the fourth formula, determine the cluster load balancing subfunction value of the controller under the current memory configuration. The fourth formula is:

[0087] in, This is the cluster load balancing subfunction value for the controller under the current memory configuration. This represents the variance of memory utilization across all controllers in the target cluster.

[0088] It is understandable that the fourth formula above is the expression for the cluster load balancing sub-function. The goal of this cluster load balancing sub-function is to penalize memory load imbalances among the BMCs in the cluster.

[0089] The relationship between the cluster load balancer function value and the location vector, i.e., the memory management parameters, is as follows: x i5 (free_memory_threshold_high): Direct driver. This parameter determines when the BMC considers itself "free" enough to lend out memory. Lowering x i5 This will encourage BMC to be more proactive in becoming a lender.

[0090] x i6 (rtos_mem_ratio): Direct driver. This parameter determines when the BMC considers itself "stressed" enough to need to borrow memory. (Increase x) i6 This will allow BMC to become a borrower earlier.

[0091] These two parameters together determine when cluster memory borrowing behavior is triggered, and are crucial for influencing cluster load variance. The most important factor. The Particle Swarm Optimization (PSO) algorithm adjusts x... i5 and x i6 To minimize variance, thereby maximizing the value of the cluster equilibrium subfunction.

[0092] The memory management method provided in this application uses a second formula to map the average external fragmentation rate to a memory fragmentation sub-function value, transforming the fragmentation level from a non-linear actual observation value into a normalized, monotonically decreasing scoring function. A higher fragmentation rate results in a lower sub-function value, facilitating comprehensive evaluation. A third formula compares the worst-case execution time with a preset execution time threshold to generate a real-time sub-function value, ensuring that critical tasks do not time out. When the execution time approaches or exceeds the threshold, the score drops rapidly or even reaches zero, reflecting the sensitivity to hard real-time constraints. A fourth formula calculates the cluster balancing sub-function value based on the memory utilization variance; a larger variance indicates a more uneven load and a lower score, thereby incentivizing the system to optimize towards a more balanced resource distribution.

[0093] In some optional implementations, step S4036 above includes: Step e1: Based on the fifth formula, determine the fitness function value of the controller under the current memory configuration. The fifth formula is: F = α × F fragmentation +β×F rtos +γ×F cluster Where F is the fitness function value of the controller under the current memory configuration, F fragmentation F is the memory fragmentation subfunction value for this controller under the current memory configuration. rtos F represents the real-time performance sub-function value of the controller under the current memory configuration. cluster This is the cluster balancing subfunction for the controller under the current memory configuration, where α, β, and γ are preset weight coefficients, and α+β+γ=1.

[0094] It is understandable that the fifth formula above is the fitness function expression. α, β, and γ reflect the priority of the optimization objective.

[0095] The memory management method provided in this application constructs a composite fitness function that integrates fragmentation rate, real-time task latency, and load balancing. It evaluates the BMC memory status in real time based on real-time monitoring data to optimize the BMC memory, thereby achieving cluster-wide collaborative optimization of fragmentation rate, real-time performance, and load balancing.

[0096] In some optional implementations, step S405 above includes: Step f1: Update the cluster's optimal memory management parameters based on the historical optimal memory management parameters of each controller in the target cluster.

[0097] Specifically, based on the historical best memory management parameters of each controller in the target cluster, the fitness function value corresponding to the historical best memory management parameters of each controller in the target cluster is determined, and based on the fitness function value corresponding to the historical best memory management parameters of each controller in the target cluster, the maximum fitness function value is determined.

[0098] The maximum fitness function value is compared with the fitness function value corresponding to the current optimal memory management parameter of the cluster. If the maximum fitness function value is greater than the fitness function value corresponding to the current optimal memory management parameter of the cluster, the optimal memory management parameter of the cluster is updated to the historical optimal memory management parameter corresponding to the maximum fitness function value.

[0099] If the maximum fitness function value is not greater than the fitness function value corresponding to the current cluster's optimal memory management parameters, then the current cluster's optimal memory management parameters will remain unchanged.

[0100] Step f2: If the current iteration count has not reached the iteration count threshold, then the target update rate of the controller's memory management parameters is determined based on the controller's own historical best memory management parameters, the cluster's best memory management parameters, and the current update rate of the memory management parameters.

[0101] As mentioned earlier, since memory management parameters are multidimensional, their update speeds are also multidimensional. The update speed for any given memory management parameter is represented by a velocity vector used in the particle swarm optimization algorithm. The expression for this velocity vector is: v i = (v i1 v i2 v i3 v i4 v i5 v i6 v ij : Represents the update rate of the i-th particle in the j-th dimension parameter, that is, the update rate of the j-th dimension memory management parameter of the i-th BMC, corresponding to x ij The amount and trend of change.

[0102] Positive update speed (v) ij >0): This means that the parameter x ij There is an increasing trend.

[0103] Negative update rate (v) ij <0): This means that the parameter x ij There is a decreasing trend.

[0104] Speed ​​magnitude (| v ij |): Represents the step size or magnitude of parameter change. A larger value means a larger parameter change in the next iteration, indicating stronger exploratory behavior; a smaller value means fine-tuning, which is beneficial for local fine-grained search.

[0105] At the start of the algorithm, the velocity vector of each particle is typically initialized randomly in each dimension, with a range usually proportional to the range of the position vector, but a maximum update rate V is set. max This limits the step size to prevent particles from flying over the optimal solution region. In other words, during initialization, the update rate of the memory management parameters for each BMC is randomly initialized. The initial update rate of the memory management parameters is usually proportional to the corresponding value range, but a maximum update rate V is set. max To limit the step size.

[0106] The initial update rate of the memory management parameters for each BMC is determined using the following formula: v ij (t = 0) = rand(-V maxj V maxj ) v ij (t = 0) represents the initial update rate of the j-th dimension memory management parameter of the i-th BMC; V maxj This represents the maximum update speed limit for the j-th dimension memory management parameters, i.e., the maximum update speed. `rand` indicates the update speed from (-V) maxj V maxj A number is generated uniformly and randomly within a range. V maxj Typically set to the range of values ​​for the j-th dimension memory management parameter (max). j min j A proportion, for example, 0.2 × (max) j min j ).

[0107] For example, x i1 The range of values ​​for x is [5, 10]. i1 V max1 It can be set to 0.2 × (10-5) = 1.

[0108] Step f3: Update the memory management parameters based on the target update speed, and return to the step of obtaining the current memory management parameters of the controller.

[0109] The memory management method provided in this application continuously tries new memory configuration combinations through multiple iterations, enabling the system to gradually approach parameter settings with better performance or even close to the global optimum, starting from an initial random or empirical configuration. This avoids the subjectivity, inefficiency, and error-proneness associated with manual parameter tuning, thus improving the system's automation and intelligence levels.

[0110] In some optional implementations, the memory management parameters are multidimensional parameters, and step f2 above includes: Step f21: Based on the sixth formula, determine the target update speed of the memory management parameters. The sixth formula is: v ij (t + 1) = w×v ij (t)+c1×r1×(pbest ij x ij (t)) + c2×r2×(gbest j x ij (t)) Among them, v ij (t + 1) represents the target update rate of the j-th dimension memory management parameter of the controller, x ij(t) represents the current j-th dimension memory management parameter of the controller, w is the inertia weight, c1 and c2 are learning factors, r1 and r2 are random numbers in the interval [0, 1], and v ij (t) represents the current update speed of the j-th dimension memory management parameter of the controller, pbest ij This represents the controller's historical best j-th dimension memory management parameters, gbest. j This represents the optimal j-th dimension memory management parameter for the cluster.

[0111] It is understandable that this controller is the i-th BMC. ij (t) controls the step size and direction of memory management parameter adjustments. The inertia weight is typically initially set to a large value (e.g., 0.9), gradually decreasing to a smaller value (e.g., 0.4) with each iteration, thus implementing a strategy of global exploration followed by local development. c1 and c2 adjust the individual and global experience weights respectively, typically set to c1=c2=1.5. r1 and r2 are random numbers within the interval [0, 1], introducing randomness to avoid premature convergence.

[0112] Based on the controller's own historical best memory management parameters, determine the controller's own historical best j-th dimension memory management parameters; based on the cluster's best management parameters, determine the cluster's best j-th dimension memory management parameters.

[0113] In some alternative implementations, step f3 above includes: Step f31, based on Formula 7, determines the updated memory management parameters. Formula 7 includes: x ij (t + 1) = x ij (t) + v ij (t + 1) Where, x ij (t + 1) represents the updated j-th dimension memory management parameter of the controller, x ij (t) represents the current j-th dimension memory management parameter of the controller, v ij (t + 1) represents the target update speed of the j-th dimension memory management parameter of the controller.

[0114] In some optional implementations, the above memory management method further includes: Step g1: After configuring the controller with the appropriate memory based on its own historical best memory management parameters, continuously monitor the status of the controller.

[0115] Step g2: If the controller is in an abnormal state, then re-execute the step of configuring the controller's memory based on its own historical best memory management parameters, and then continuously monitor the controller's state.

[0116] Step g3: If the number of times the step of re-executing the controller based on its own historical best memory management parameters, configuring the controller accordingly, and continuously monitoring the controller's status exceeds a preset threshold, and the controller's status is still abnormal, then update the controller's memory configuration to the memory configuration before applying the controller's own historical best memory management parameters.

[0117] The memory management method provided in this application will not remain in the error state if the controller enters an abnormal state (such as memory overflow, response timeout, process crash, etc.) after applying new or optimized memory management parameters. Instead, it will immediately start the recovery process. By repeatedly executing the configuration operation based on its own historical best parameters, it will attempt to reactivate the stable operation mode, avoid declaring the whole failure with a one-time failure, enhance the tolerance for unstable configuration, and reduce unnecessary shutdowns caused by misjudgment.

[0118] If the number of retries exceeds the preset threshold and the system still cannot recover, it indicates that the current "historical best parameters" may no longer be applicable. In this case, actively rolling back to the original configuration before the application is equivalent to enabling a "security snapshot" to ensure that the system can at least return to a known normal operating state and improve system reliability.

[0119] Embodiments of this application provide a memory management method applied to the aforementioned memory management system. Figure 5 A flowchart of the memory management method provided in the embodiments of this application is shown below. Figure 5 As shown, this memory management method includes the following steps: Perform system initialization and enter continuous monitoring mode.

[0120] The system determines whether the optimization triggering conditions have been met. If not, it remains in continuous monitoring mode. Memory management can be triggered periodically; for example, the memory management method described in the above embodiment can be executed once every preset time interval. Determining whether the optimization triggering conditions have been met means determining whether the periodic triggering time has been reached.

[0121] Memory management can also be triggered conditionally, for example, when the average external fragmentation rate of the controller exceeds a preset fragmentation rate threshold; or when the worst-case execution time of the target task in the controller's real-time operating system exceeds a preset execution time threshold; or when the variance of memory utilization across all controllers in the target cluster exceeds a preset variance threshold.

[0122] Memory management can also be event-driven, for example, triggered by the detection of specific system time or external commands. For instance, operations personnel might manually issue optimization commands, or there might be significant changes to system configuration or workload patterns.

[0123] Memory management can also be triggered opportunistically, for example, when the system is detected to be at a low load time window level.

[0124] If the optimization triggering conditions are met, the particle swarm algorithm subprocess is executed. Figure 6 This is a schematic diagram of a sub-process of the particle swarm optimization algorithm provided in an embodiment of this application, as shown below. Figure 6 As shown, the process includes: Step 1: Initialize the particle swarm and randomly generate multiple sets of parameters, i.e., randomly generate the initial memory management parameters corresponding to each BMC. Step 2: For each particle, apply its parameter configuration, collect performance data, and calculate the fitness function value. See steps S402 to S403 above for details, which will not be repeated here. Step 3: Update the particle's own historical optimal solution and the cluster's global optimal solution. That is, update the BMC's own historical optimal solution and the cluster's global optimal solution. See steps S304 and f1 above for details, which will not be repeated here. Step 4: Determine whether all particles have been evaluated. That is, determine whether all BMCs have completed steps 2 and 3. If there are particles that have not been evaluated, return to step 2 to continue evaluating the next particle. If all particles have been evaluated, proceed to step 5. Step 5: Determine whether the termination condition is met, i.e., determine whether the iteration number threshold has been reached. If the iteration number threshold has been reached, proceed to step 7. If the iteration number threshold has not been reached, proceed to step 6. Step 6: Update the velocity and position of all particles according to the PSO formula, and then return to step 3 for a new round of iteration. For details, please refer to the description of step S405 above, which will not be repeated here. Step 7: Return the historical optimal solution for each particle. That is, return the historical optimal memory management parameters for each particle.

[0125] After obtaining the historical best memory management parameters for each particle, it is determined whether the new configuration is better than the current configuration. That is, for any BMC, it is determined whether the historical best memory management parameters obtained by this memory optimization of the BMC are better than the current memory management parameters of the BMC. Specifically, it can be determined based on the corresponding fitness function value.

[0126] If the new configuration is not better than the current configuration, then return to continuous monitoring status.

[0127] If the new configuration is superior to the current configuration, the new configuration is applied to the system. In other words, if a BMC's new configuration is superior to the current configuration, the BMC optimizes and adjusts its memory management parameters based on the new configuration. The system then enters an enhanced monitoring and protection phase, increasing monitoring frequency and tracking key performance indicators in real time. It determines whether the system is running normally, i.e., whether the BMC is running normally after applying the new configuration. If it is running normally, the memory optimization is marked as successful. If it is not running normally, an automatic rollback operation is performed, restoring the system to the previous stable configuration. The optimization process and results are recorded and used for system learning. Specifically, the memory management parameters obtained from this optimization, the results of this optimization, and the performance data are recorded in the knowledge base module to provide data support for subsequent optimizations. The system returns to continuous monitoring status, forming a closed-loop optimization process.

[0128] The memory management method provided in this application modeles the distributed memory management process as a multi-objective optimization problem. Utilizing the collaborative search and dynamic tuning capabilities of multi-particle swarm optimization, it seeks the globally optimal memory configuration scheme while meeting real-time constraints, effectively improving the continuity of memory allocation. By treating each Business Controller (BMC) as an independent optimization unit, the memory parameters of a single BMC node are optimized through a local fitness function. Simultaneously, a particle swarm optimization algorithm is introduced to dynamically coordinate the search behavior of each node, and global monitoring enables collaboration among multiple BMC nodes. A load balancing factor quantifies the memory usage relationship between BMCs, and dynamic constraint processing controls resource allocation, forming a hierarchical collaborative architecture that balances local performance and global efficiency. Adaptive memory partitioning and dynamic waterline adjustment ensure the efficiency of critical task execution, significantly improving system stability and reliability in heterogeneous environments. Intelligent coordination of BMC memory allocation strategies optimizes resource utilization while ensuring real-time performance, enhancing the automation level of server operation and maintenance.

[0129] A hierarchical collaborative architecture is adopted, with the system control module running the upper-level particle swarm optimization logic and each BMC running its local particle swarm optimization algorithm. The system control module determines the local optimal solution from the particle swarm algorithms running by all BMCs, then calculates the global optimal solution for multi-particle swarm optimization, and broadcasts the global optimal solution to all BMCs, achieving cluster collaborative optimization of fragmentation rate, real-time performance, and load balancing.

[0130] By constructing a composite fitness function that integrates fragmentation rate, real-time task latency, and load balancing, the status of BMC nodes is evaluated in real-time based on real-time monitoring data. A memory collaboration mechanism between BMCs is designed, quantifying memory usage efficiency among multiple BMCs through a load balancing factor, precisely guiding the rational flow of memory resources among BMCs, and reducing resource contention and conflicts. A parameter constraint handling strategy is proposed, introducing a boundary protection mechanism during the optimization process, and achieving multi-objective optimization through weight adjustment. Compared with traditional static memory configuration methods, this application effectively reduces memory fragmentation rate and improves cluster load balancing while effectively reducing real-time task latency, thereby enhancing the efficiency and reliability of BMC memory management in large-scale data center servers.

[0131] It should be noted that the above memory management methods are not only applicable to optimizing the memory of the BMC in servers, but can also be used to optimize the memory of the BMC in computers, switches, and industrial control computers.

[0132] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method.

[0133] Embodiments of this application also provide a memory management device, such as... Figure 7 As shown, the memory management device includes: The acquisition module 701 is used to acquire the current memory management parameters of any controller in the target cluster.

[0134] The first configuration module 702 is used to configure the controller according to the current memory management parameters and run preset test cases on the controller to obtain the performance indicators of the controller under the current memory configuration.

[0135] The determination module 703 is used to determine the fitness function value of the controller under the current memory configuration based on the controller's performance indicators under the current memory configuration.

[0136] The update module 704 is used to update the controller's own historical best memory management parameters based on the fitness function value of the controller under the current memory configuration.

[0137] Return to execution module 705, which is used to update the memory management parameters based on the target update speed of the memory management parameters if the current iteration count has not reached the iteration count threshold, and return to the execution step of obtaining the current memory management parameters of the controller.

[0138] The second configuration module 706 is used to configure the memory of the controller based on its own historical best memory management parameters if the current iteration number reaches the iteration number threshold.

[0139] In some optional implementations, performance metrics include average external fragmentation rate, and the first configuration module includes: The first acquisition unit is used to run preset test cases on the controller to acquire the size of the free block in each of all levels in the partner allocator.

[0140] The first determining unit is used to determine the total free block size and the size of the highest-order free block based on the size of the free block at each of all orders.

[0141] The second determining unit is used to determine the average external fragmentation rate of the controller under the current memory configuration based on the total free block size and the size of the highest-order free block.

[0142] In some optional implementations, the second determining unit includes: The second determining subunit is used to determine the average external fragmentation rate of the controller under the current memory configuration based on the first formula, which is:

[0143] in, This represents the average external fragmentation rate of the controller under the current memory configuration.

[0144] In some optional implementations, performance metrics include average external fragmentation rate, worst-case execution time of the target task in the real-time operating system, and memory utilization; preset test cases include the target task in the real-time operating system. The determination module 703 includes: The third determining unit is used to determine the memory fragmentation sub-function value of the controller under the current memory configuration based on the average external fragmentation rate of the controller under the current memory configuration.

[0145] The fourth determining unit is used to determine the real-time performance sub-function value of the controller under the current memory configuration based on the worst-case execution time of the target task in the real-time operating system under the current memory configuration.

[0146] The second acquisition unit is used to acquire the memory utilization of other controllers in the target cluster, excluding the controller itself, under their corresponding current memory configuration.

[0147] The fifth determining unit is used to determine the variance of the memory utilization of all controllers in the target cluster based on the memory utilization of the controller under the current memory configuration and the memory utilization of other controllers in the target cluster under their corresponding current memory configurations.

[0148] The sixth determining unit is used to determine the cluster balance sub-function value of the controller under the current memory configuration based on the variance of the memory utilization of all controllers in the target cluster.

[0149] The seventh determining unit is used to determine the fitness function value of the controller under the current memory configuration based on the memory fragmentation sub-function value, real-time performance sub-function value, and cluster balancing sub-function value of the controller under the current memory configuration.

[0150] In some optional implementations, the third determining unit includes: The third determining subunit is used to determine the memory fragmentation subfunction value of the controller under the current memory configuration based on the second formula, which is:

[0151] in, This represents the average external fragmentation rate of the controller under the current memory configuration. This is the memory fragmentation sub-function value for the controller under the current memory configuration.

[0152] The fourth determining unit includes: The fourth determining sub-unit is used to determine the real-time sub-function value of the controller under the current memory configuration based on the third formula, which is:

[0153] in, This is the real-time performance sub-function value for the controller under the current memory configuration. This represents the worst-case execution time of the target task in a real-time operating system with the current memory configuration for this controller. This is a preset execution time threshold.

[0154] The sixth determining unit includes: The sixth determining sub-unit is used to determine the cluster load balancing sub-function value of the controller under the current memory configuration based on the fourth formula, which is:

[0155] in, This is the cluster load balancing subfunction value for the controller under the current memory configuration. This represents the variance of memory utilization across all controllers in the target cluster.

[0156] In some optional implementations, the seventh determining unit includes: The seventh determining sub-unit is used to determine the fitness function value of the controller under the current memory configuration based on the fifth formula, which is: F = α × F fragmentation +β×F rtos +γ×F cluster Where F is the fitness function value of the controller under the current memory configuration, F fragmentation F is the memory fragmentation subfunction value for this controller under the current memory configuration. rtos F represents the real-time performance sub-function value of the controller under the current memory configuration. cluster This is the cluster balancing subfunction for the controller under the current memory configuration, where α, β, and γ are preset weight coefficients, and α+β+γ=1.

[0157] In some alternative implementations, the return execution module 705 includes: The first update unit is used to update the cluster's optimal memory management parameters based on the historical optimal memory management parameters of each controller in the target cluster.

[0158] The eighth determining unit is used to determine the target update rate of the controller's memory management parameters based on the controller's own historical best memory management parameters, the cluster's best memory management parameters, and the current update rate of the memory management parameters if the current iteration number has not reached the iteration number threshold.

[0159] Return to the execution subunit, which updates the memory management parameters based on the target update rate, and then returns to the execution step that retrieves the current memory management parameters of the controller.

[0160] In some optional implementations, the memory management parameters are multi-dimensional parameters, based on the controller's own historical best memory management parameters, the cluster's best memory management parameters, and the current update rate of the memory management parameters. The eighth determining unit includes: The eighth determining subunit is used to determine the target update speed of memory management parameters based on the sixth formula, which is: v ij (t + 1) = w×v ij (t)+c1×r1×(pbest ij x ij (t)) + c2×r2×(gbest j x ij (t)) Among them, v ij (t + 1) represents the target update rate of the j-th dimension memory management parameter of the controller, x ij (t) represents the current j-th dimension memory management parameter of the controller, w is the inertia weight, c1 and c2 are learning factors, r1 and r2 are random numbers in the interval [0, 1], and vij (t) represents the current update speed of the j-th dimension memory management parameter of the controller, pbest ij This represents the controller's historical best j-th dimension memory management parameters, gbest. j This represents the optimal j-th dimension memory management parameter for the cluster.

[0161] Based on the controller's own historical best memory management parameters, determine the controller's own historical best j-th dimension memory management parameters; based on the cluster's best management parameters, determine the cluster's best j-th dimension memory management parameters.

[0162] In some alternative implementations, the return execution subunit includes: The ninth determining unit is used to determine the updated memory management parameters based on the seventh formula, which includes: x ij (t + 1) = x ij (t) + v ij (t + 1) Where, x ij (t + 1) represents the updated j-th dimension memory management parameter of the controller, x ij (t) represents the current j-th dimension memory management parameter of the controller, v ij (t + 1) represents the target update speed of the j-th dimension memory management parameter of the controller.

[0163] For a description of the features in the embodiment corresponding to the memory management device, please refer to the relevant description in the embodiment corresponding to the memory management method, which will not be repeated here.

[0164] Embodiments of this application also provide an electronic device, such as... Figure 8 As shown, it includes a processor 801 and a memory 802, in which a computer program is stored, and the processor 801 is configured to run the computer program to perform the steps in any of the above-described memory management method embodiments.

[0165] Embodiments of this application also provide a computer-readable storage medium storing a computer program, wherein the computer program is configured to execute the steps in any of the above-described memory management method embodiments at runtime.

[0166] In one exemplary embodiment, the aforementioned computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard disk, magnetic disk, or optical disk.

[0167] Embodiments of this application also provide a computer program product, which includes a computer program that, when executed by a processor, implements the steps in any of the above-described memory management method embodiments.

[0168] Embodiments of this application also provide another computer program product, including a non-volatile computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps in any of the above-described memory management method embodiments.

[0169] Any of the components, modules, units, parts, methods, and operations described herein can be implemented using software, firmware, hardware (e.g., fixed logic circuitry), manual processing, or any combination thereof. Alternatively or additionally, any functionality described herein can be executed at least in part by one or more hardware logic components, such as, but not limited to, a central processing unit (CPU), a field-programmable gate array (FPGA), an application-specific integrated circuit (ASIC), an application-specific standard product (ASSP), a system-on-a-chip (SoC), a complex programmable logic device (CPLD), a microprocessor (MCU), etc. The terms "system," "computing device," or "apparatus" as used herein encompass various means, devices, and machines for processing data, including, for example, one or more programmable processors, computers, SoCs, or combinations thereof. The apparatus may also include code that creates an execution environment for the computer program in question, such as code constituting processor firmware, a protocol stack, a database management system, an operating system, a cross-platform runtime environment, a virtual machine, or one or more combinations thereof. The aforementioned computer program (also known as a program, software, software application, app, script, or code) can be written in any form of programming language, including compiled or interpreted languages, declarative or procedural languages, and can be deployed in any form, including as a standalone program or as a module, component, subroutine, object, or other unit suitable for a computing environment.

[0170] Those skilled in the art will further 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, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. 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.

[0171] The foregoing has provided a detailed description of a memory management method and electronic device provided in this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the embodiments above are only intended to help understand the method and core ideas of this application. It should be noted that those skilled in the art can make various improvements and modifications to this application without departing from its principles, and these improvements and modifications also fall within the protection scope of the claims of this application.

Claims

1. A memory management method, characterized in that, include: For any controller in the target cluster, obtain the current memory management parameters of that controller; Based on the current memory management parameters, the controller is configured with the corresponding memory settings, and preset test cases are run on the controller to obtain the performance indicators of the controller under the current memory configuration. Based on the performance metrics of the controller under the current memory configuration, determine the fitness function value of the controller under the current memory configuration; Based on the fitness function value of the controller under the current memory configuration, update the controller's own historical best memory management parameters; If the current iteration count has not reached the iteration count threshold, the memory management parameters are updated based on the target update rate of the memory management parameters, and the process returns to the step of obtaining the current memory management parameters of the controller. If the current iteration count reaches the iteration count threshold, then the controller will be configured with appropriate memory based on its historical best memory management parameters.

2. The method according to claim 1, characterized in that, The performance metrics include the average external fragmentation rate. Running preset test cases on the controller to obtain the controller's performance metrics under the current memory configuration includes: Run preset test cases on the controller to obtain the size of the free block in each of all levels of the partner allocator; Based on the size of the free block at each of all orders, determine the total free block size and the size of the free block at the highest order. Based on the total free block size and the size of the highest-order free block, the average external fragmentation rate of the controller under the current memory configuration is determined.

3. The method according to claim 2, characterized in that, The determination of the controller's average external fragmentation rate under the current memory configuration, based on the total free block size and the size of the highest-order free block, includes: Based on the first formula, the average external fragmentation rate of the controller under the current memory configuration is determined. The first formula is: in, This represents the average external fragmentation rate of the controller under the current memory configuration.

4. The method according to claim 1, characterized in that, The performance metrics include average external fragmentation rate, worst-case execution time of the target task in the real-time operating system, and memory utilization; the preset test cases include the target task in the real-time operating system; The process of determining the fitness function value of the controller under the current memory configuration based on the controller's performance metrics includes: Based on the average external fragmentation rate of the controller under the current memory configuration, determine the memory fragmentation sub-function value of the controller under the current memory configuration; Based on the worst-case execution time of the target task in the real-time operating system under the current memory configuration, determine the real-time performance sub-function value of the controller under the current memory configuration; Obtain the memory utilization of other controllers in the target cluster, excluding the controller mentioned above, under their corresponding current memory configurations; Based on the memory utilization of the controller under the current memory configuration and the memory utilization of other controllers in the target cluster under their corresponding current memory configurations, determine the variance of the memory utilization of all controllers in the target cluster. Based on the variance of memory utilization of all controllers in the target cluster, determine the cluster balance sub-function value of the controller under the current memory configuration. Based on the memory fragmentation sub-function value, real-time performance sub-function value, and cluster balancing sub-function value of the controller under the current memory configuration, the fitness function value of the controller under the current memory configuration is determined.

5. The method according to claim 4, characterized in that, The step of determining the memory fragmentation sub-function value of the controller under the current memory configuration based on the average external fragmentation rate of the controller under the current memory configuration includes: Based on the second formula, the memory fragmentation subfunction value of the controller under the current memory configuration is determined. The second formula is: in, This represents the average external fragmentation rate of the controller under the current memory configuration. This is the memory fragmentation sub-function value for the controller under the current memory configuration; The determination of the real-time performance sub-function value of the controller under the current memory configuration, based on the worst-case execution time of the target task in the real-time operating system under the current memory configuration, includes: Based on the third formula, the real-time performance sub-function value of the controller under the current memory configuration is determined. The third formula is: in, This is the real-time performance sub-function value for the controller under the current memory configuration. This represents the worst-case execution time of the target task in a real-time operating system with the current memory configuration for this controller. The preset execution time threshold; The step of determining the cluster balancer sub-function value of a controller under the current memory configuration based on the variance of memory utilization of all controllers in the target cluster includes: Based on the fourth formula, the cluster load balancing subfunction value of the controller under the current memory configuration is determined. The fourth formula is: in, This is the cluster load balancing subfunction value for the controller under the current memory configuration. This is the variance of memory utilization for all controllers in the target cluster.

6. The method according to claim 4, characterized in that, The process of determining the fitness function value of the controller under the current memory configuration based on the memory fragmentation sub-function value, real-time performance sub-function value, and cluster balancing sub-function value of the controller under the current memory configuration includes: Based on the fifth formula, the fitness function value of the controller under the current memory configuration is determined. The fifth formula is: F = α x F fragmentation + β x F rtos + γ x F cluster F = F + F + F + F fragmentation F = F + F + F + F rtos F = F + F + F + F cluster F = F + F + F + F wherein F is a fitness function value of the controller under the current memory configuration, F fragmentation is a memory fragmentation sub-function value of the controller under the current memory configuration, F rtos is a real-time sub-function value of the controller under the current memory configuration, F cluster is a cluster balance sub-function of the controller under the current memory configuration, and α, β and γ are preset weight coefficients, and α+β+γ=1.

7. The method according to claim 1, characterized in that, If the current iteration count has not reached the iteration count threshold, then based on the target update rate of the memory management parameters, the memory management parameters are updated, and the process returns to the step of obtaining the current memory management parameters of the controller, including: Update the cluster's optimal memory management parameters based on the historical best memory management parameters of each controller in the target cluster. If the current iteration count has not reached the iteration count threshold, the target update rate of the controller's memory management parameters is determined based on the controller's own historical best memory management parameters, the cluster's best memory management parameters, and the current update rate of the memory management parameters. Based on the target update speed, the memory management parameters are updated, and the process returns to the step of obtaining the current memory management parameters of the controller.

8. The method according to claim 7, characterized in that, The memory management parameters are multi-dimensional parameters. Determining the target update rate of the controller's memory management parameters based on the controller's own historical best memory management parameters, the cluster's best memory management parameters, and the current update rate of the memory management parameters includes: Based on the sixth formula, the target update speed of memory management parameters is determined. The sixth formula is: v ij (t + 1) = w×v ij (t)+c1×r1×(pbest ij x ij (t)) + c2×r2×(gbest j x ij (t)) where v ij (t + 1) is the target update speed of the jth dimension memory management parameter of the controller, x ij (t) is the current jth dimension memory management parameter of the controller, w is the inertia weight, c1 and c2 are learning factors, r1 and r2 are random numbers in the interval [0, 1], v ij (t) is the current update speed of the jth dimension memory management parameter of the controller, pbest ij represents the self historical optimal jth dimension memory management parameter of the controller, gbest j represents the swarm optimal jth dimension memory management parameter Based on the controller's own historical best memory management parameters, determine the controller's own historical best j-th dimension memory management parameters; based on the cluster's best management parameters, determine the cluster's best j-th dimension memory management parameters.

9. The method according to claim 7, characterized in that, The memory management parameters are multi-dimensional parameters. Updating the memory management parameters based on the target update speed includes: Based on the seventh formula, the updated memory management parameters are determined, wherein the seventh formula includes: x ij (t + 1) = x ij (t) + v ij (t + 1) Where, x ij (t + 1) represents the updated j-th dimension memory management parameter of the controller, x ij (t) represents the current j-th dimension memory management parameter of the controller, v ij (t + 1) represents the target update speed of the j-th dimension memory management parameter of the controller.

10. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for implementing the steps of the memory management method as described in any one of claims 1 to 9 when executing the computer program.