Optimal sorting algorithm dual screening system, electronic equipment and readable storage medium
Through a dual screening system that monitors the system resource status in real time and dynamically selects the optimal sorting algorithm, the performance problems of embedded devices under high load conditions are solved, and memory footprint reduction, throughput improvement and development efficiency are achieved.
Patent Information
- Application Number
- CN202510661012.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-22
- Publication Date
- 2025-07-25
AI Technical Summary
The existing software systems lack real-time perception of environmental status on resource-constrained embedded devices, resulting in poor system performance under high load conditions, and even frequent GC triggers, affecting order processing efficiency, and high adaptation and testing costs for different customer needs.
A dual filtering system for optimal sorting algorithms is designed, including environment perception module, algorithm warehouse module, decision rules module and emergency module. By monitoring the system resource status in real time, filtering and calling the optimal sorting algorithm, and enabling a guaranteed strategy when resource overload is enabled to ensure the stability of the system.
Significantly reduce the memory usage of embedded devices, improve throughput in high-load scenarios, shorten algorithm adaptation time, improve development efficiency and system availability, and reduce labor costs.
Smart Images

Figure CN120371529A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and particularly to a dual screening system for an optimal sorting algorithm, an electronic device, and a readable storage medium. Background Art
[0002] When current software systems process sorting requirements, they often adopt fixed algorithms or simple conditional judgments. For example, insertion sort is used when the data volume is small. However, this approach has many deficiencies: On resource-constrained embedded devices, quicksort with deep recursion may still be used, resulting in stack overflow; in high-concurrency scenarios, merge sort may exacerbate resource competition due to excessive CPU resource consumption; at the same time, different customers have different requirements. For example, real-time systems require millisecond-level response, and Internet of Things devices have strict restrictions on memory usage. It requires developers to manually adjust, consuming a large amount of adaptation and testing costs; in addition, traditional solutions lack real-time perception of the environmental state (such as CPU load, memory usage, etc.), resulting in poor system performance under specific high-load conditions, and even triggering frequent GCs due to excessive memory occupancy, seriously affecting the order processing efficiency. Summary of the Invention
[0003] In view of the above problems, the present invention is proposed to provide a dual screening system for an optimal sorting algorithm, an electronic device, and a readable storage medium that overcome the above problems or at least partially solve the above problems.
[0004] The present invention provides a dual screening system for an optimal sorting algorithm, including:
[0005] An environment perception module, configured to monitor system resource status data in real time according to different computer system environments; the system resource status data includes CPU occupancy rate, memory margin, data volume, data orderliness, and fragmentation index;
[0006] An algorithm repository module, configured to screen and match sorting algorithms through an algorithm matching model according to the system resource status data and technical parameters of the stored sorting algorithms to obtain candidate sorting algorithms; the stored sorting algorithms include pre-built-in sorting algorithms and newly added sorting algorithms by users;
[0007] A decision rule module, configured to select an optimal sorting algorithm from the candidate sorting algorithms according to the optimal sorting algorithm selection rule and cost matrix scoring; the optimal sorting algorithm selection rule includes system preset rules and user-defined rules;
[0008] An automatic execution module, configured to call the selected optimal sorting algorithm;
[0009] An emergency module is used to determine whether the system resource status data after invoking the optimal sorting algorithm triggers a multi-level fusing protection system. If so, it executes the fallback sorting strategy corresponding to the triggered protection level.
[0010] Optionally, the environment perception module is further configured to trigger multi-level resource response processing based on the remaining memory, and when the last-level resource response processing is triggered, push resource warning information to the user side.
[0011] Optionally, the algorithm repository module is further configured to store the ontology algorithm logic code, metadata file, and algorithm matching model of the sorting algorithm; the metadata component records the technical parameters of the sorting algorithm, including time complexity, space complexity, and stability; the algorithm matching model is the screening logic for candidate sorting algorithms.
[0012] Optionally, the decision rule module is further configured to:
[0013] When a relatively optimal sorting algorithm is screened from the candidate sorting algorithms according to the optimal sorting algorithm selection rule, then the relatively optimal sorting algorithm is the optimal sorting algorithm;
[0014] When multiple relatively optimal sorting algorithms are screened from the candidate sorting algorithms according to the optimal sorting algorithm selection rule, then calculate the cost matrix scores of each relatively optimal sorting algorithm respectively, and take the relatively optimal sorting algorithm with the highest cost matrix score as the optimal sorting algorithm;
[0015] When zero relatively optimal sorting algorithms are screened from the candidate sorting algorithms according to the optimal sorting algorithm selection rule, then calculate the cost matrix scores of each candidate sorting algorithm respectively, and take the candidate sorting algorithm with the highest cost matrix score as the optimal sorting algorithm.
[0016] Optionally, the automatic execution module is further configured to output the type and performance report of the invoked optimal sorting algorithm;
[0017] The optimal sorting algorithm double screening system further includes a performance report receiving module at the user side, and the performance report receiving module is configured to receive the type and performance report of the optimal sorting algorithm adopted by the system provided by the automatic execution module.
[0018] Optionally, the multi-level fusing protection system includes:
[0019] If the CPU occupancy rate exceeds the first preset CPU occupancy rate threshold, or the remaining memory is lower than the first preset remaining memory threshold, then start the resource limit mode to compress the resources of non-core processes;
[0020] If the CPU occupancy rate exceeds the second preset CPU occupancy rate threshold, or the remaining memory is lower than the second preset remaining memory threshold, then switch to a sorting algorithm with low technical parameters and perform memory fragmentation reorganization in parallel; wherein, the second preset CPU occupancy rate threshold is greater than the first preset CPU occupancy rate threshold, and the second preset remaining memory threshold is less than the first preset remaining memory threshold;
[0021] If, within the first preset time period, the CPU occupancy rate continuously exceeds the second preset CPU occupancy rate threshold, or the remaining memory continuously is lower than the second preset remaining memory threshold, then forcibly release the sorting cache and enable disk-assisted sorting.
[0022] Optionally, the optimal sorting algorithm dual screening system further includes a user-defined configuration module at the user end, and the user-defined configuration module is used to convert the optimal sorting algorithm selection rule configured by the user from the condition-action rule form into a feature vector rule form recognizable by the decision rule module.
[0023] Optionally, the remaining memory includes physical remaining memory and virtual remaining memory.
[0024] The multi-level resource response processing includes:
[0025] If the physical remaining memory continuously is lower than the first preset physical remaining memory threshold within the second preset time period, then set the system status flag bit to mark the low memory mode.
[0026] If, within the third preset time period after setting the system status flag bit to mark the low memory mode, the physical remaining memory continuously is lower than the first preset physical remaining memory threshold, then compress the system cache.
[0027] If, after compressing the system cache, the physical remaining memory is lower than the second preset physical remaining memory threshold, then push a resource warning message to the user end; the second preset physical remaining memory threshold is less than the first preset physical remaining memory threshold.
[0028] The present invention further provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the electronic device executes the computer program, it loads the optimal sorting algorithm dual screening system according to any one of the embodiments of the present invention.
[0029] The present invention further provides a readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, it loads the optimal sorting algorithm dual screening system according to any one of the embodiments of the present invention.
[0030] The present invention includes the following advantages:
[0031] The optimal sorting algorithm double - screening system of the present invention includes middleware modules such as environment perception, algorithm repository, decision rules, automatic execution, and emergency. The environment perception module can monitor the server CPU, memory, and data scale in real - time according to different system environments. The algorithm repository module has commonly used sorting algorithms built - in and initially screens suitable algorithms based on the perceived data, and also supports adding new algorithms through user configuration files. The decision rules module makes a secondary selection of the optimal algorithm based on the condition - action rule and the cost matrix evaluation formula. The automatic execution module calls the corresponding algorithm and outputs a performance report. The emergency module enables a fallback strategy when the CPU is highly loaded or the memory is insufficient to ensure the stability of the system. This system solution not only significantly reduces the memory occupancy of embedded devices, improves the throughput in high - load scenarios, but also greatly shortens the algorithm adaptation time and enables extension configuration to be completed without professional algorithm knowledge, significantly improving the development efficiency and system availability compared with the traditional development mode. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Figure 1 FIG. is a structural block diagram of an optimal sorting algorithm double - screening system provided by an embodiment of the present invention;
[0033] Figure 2 FIG. is a processing flow chart of the optimal sorting algorithm double - screening provided by an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0034] To make the above - mentioned objects, features, and advantages of the present invention more obvious and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0035] Refer to Figure 1 , which shows a structural block diagram of an optimal sorting algorithm double - screening system provided by an embodiment of the present invention, and specifically may include the following modules:
[0036] An environment perception module, configured to monitor system resource status data in real - time according to different computer system environments; the system resource status data includes CPU occupancy rate, memory margin, data volume, data orderliness, and fragmentation index;
[0037] An algorithm repository module, configured to screen and match sorting algorithms through an algorithm matching model according to the system resource status data and the technical parameters of the stored sorting algorithms to obtain candidate sorting algorithms; the stored sorting algorithms include pre - built - in sorting algorithms and newly added sorting algorithms by users;
[0038] A decision rules module, configured to select an optimal sorting algorithm from the candidate sorting algorithms according to the optimal sorting algorithm selection rules and cost matrix scoring; the optimal sorting algorithm selection rules include system - preset rules and user - defined rules;
[0039] An automatic execution module, configured to call the selected optimal sorting algorithm;
[0040] The emergency module is used to determine whether the system resource status data after calling the optimal sorting algorithm triggers the multi-level fuse protection system. If so, the minimum sorting strategy corresponding to the triggered protection level is executed.
[0041] In this embodiment, the environment perception module serves as the system resource monitoring center. First, the operating system interface obtains the CPU occupancy rate, memory margin (distinguishing between physical memory and virtual memory), data volume, data order, and memory fragmentation index to perceive the system resource status, supports resource monitoring of multiple platforms (such as Linux, Windows, etc.), and provides real-time data perception for the decision rule module. Perform 100 high-precision samplings per second, and then retain 60 seconds of historical data through the sliding window algorithm to build a dynamic environment matrix (the matrix obtains data fields such as CPU, memory, data volume, order, etc. and rolls over every 60 seconds), fragmentation index:
[0042]
[0043] If the procfs file system interface is used in the Linux system, the CPU usage can be obtained by reading the / proc / stat file, the physical memory information can be obtained from / proc / meminfo, and the virtual memory information can be obtained through / proc / [pid] / status or / proc / [pid] / statm.
[0044] If it is in Windows system, call GlobalMemoryStatusEx function to read the total physical memory and available memory through ullTotalPhys and ullAvailPhys fields, and use GetProcessMemoryInfo to obtain the virtual memory usage of the process.
[0045] The algorithm repository module has built-in common sorting algorithms, including 9 types of sorting algorithms (bubble sort, selection sort, insertion sort, merge sort, quick sort, heap sort, shell sort, counting sort, and radix sort). Metadata is registered for each type of algorithm such as quick sort (speed - first, suitable for regular data), heap sort (memory - saving, suitable for resource - constrained scenarios), and insertion sort (efficient for small amounts of data below 1000 or when part of the data is ordered). Each algorithm is encapsulated as an independent execution unit, and a plug - in - based algorithm container system is constructed. To add a new sorting strategy, only the JSON configuration needs to be extended. Each algorithm contains the ontology algorithm logic code, a metadata file (defining three parameters such as time and space complexity), and an algorithm matching model. Through this plug - in design and hot - loading ability, dynamic extension and version management of algorithms are achieved. Metadata description file: defines three technical parameters, namely time complexity (O(n log n)), space complexity (O(1)), and stability (true / false); new algorithms are specified with the execution path, dependent library versions, and applicable scenario tags such as "memory - sensitive" and "real - time response" through a JSON configuration file. When a new algorithm is declared through JSON configuration, it is automatically registered in the repository, supporting hot - loading and version rollback for multi - language implementations. A custom class loader dependent on Java is created by inheriting ClassLoader to dynamically load algorithm packages, achieving zero - downtime updates and cross - platform adaptation capabilities.
[0046] List of sorting algorithms:
[0047] Table 1 List of sorting algorithms
[0048]
[0049]
[0050] The screening logic for candidate sorting algorithms in the algorithm matching model is as follows:
[0051] First, obtain data such as CPU, memory, data volume, and orderliness provided by the environment perception module. ① If the remaining memory < algorithm space complexity × data volume, then exclude this algorithm. ② If the data volume < 1000, the candidate algorithms are insertion sort, bubble sort, and selection sort. ③ If the data volume > 10^6, the candidate algorithms are quick sort, heap sort, and radix sort. ④ If the data orderliness > 90%, give priority to insertion sort or bubble sort. ⑤ Finally, filter out inapplicable algorithms based on these conditions: Is the memory resource < 20%? Yes, heap sort; Is the data orderliness > 90%? Yes, bubble sort; Is the data orderliness > 70%? Yes, selection sort; Is the data volume > 10^6? Yes, shell sort; Is the memory resource <= 50? Yes, merge sort; Is the data volume >= 1000? Yes, quick sort; Are all data volumes integers? Yes, radix sort; Is the data range small? Yes, counting sort; No, selection sort. If resource over - limit (such as CPU > 90%) triggers the emergency strategy module.
[0052] Example: Data volume = 10^7, memory margin = 4GB, data order = 30%, user strategy = speed first.
[0053] Preliminary screening: merge sort (insufficient space) and radix sort (large data range and non-integer) are excluded.
[0054] Candidate algorithms: quick sort, heap sort, shell sort.
[0055] The decision rule module obtains the perception module data and the feature vector rules configured by the user. The rule engine uses the "condition-action" simple rule judgment (such as: Rule 1: data volume <1000→insertion sort, Rule 2: memory <30%→heap sort, Rule 3: user checks "speed priority"→quick sort, Rule 4: data order >70%→insertion sort). When multiple rules are triggered, multiple algorithms are selected and the cost matrix score is used for dynamic selection to eliminate policy conflicts, calculate the expected overhead of each algorithm, and select the optimal algorithm.
[0056] Cost matrix scoring formula: Score = α*1 / T(n)+β*1 / S(n)+γ□Stability (stable: 1, unstable: 0)
[0057] Speed weight (α=0.6): The lower the time complexity, the higher the score.
[0058] Memory weight (β=0.3): The lower the space complexity, the higher the score.
[0059] Stability weight (γ = 0.1): If the user requires a stable sort, algorithms with high stability will score higher.
[0060] The automatic execution module calls the corresponding algorithm according to the results of the decision module, and outputs the type of sorting algorithm and performance report (time consumption, memory usage). The emergency module automatically records the system recovery speed after the execution of each strategy, realizes a three-level fuse protection system, and dynamically optimizes the bottom-line algorithm selection strategy.
[0061] It can be seen that the optimal sorting algorithm dual screening system of the present invention realizes accurate monitoring of system resource status through 60-second sliding window modeling of the environment perception module, combines the plug-in hot loading architecture of the algorithm warehouse and the conflict resolution model of the decision rule engine (dynamic weight calculation based on the cost matrix), autonomously optimizes algorithm selection within the millisecond response cycle, and relies on the three-level fuse system of the emergency module to ensure service stability in extreme scenarios, and realizes zero-coding business adaptation through the user rule parser (DSL). Compared with traditional solutions, the core effects of reducing the memory usage of embedded devices by 65%, increasing the high concurrency throughput by 2 times, and compressing the algorithm expansion cycle to 2 hours are finally achieved, and the labor cost is reduced by 90%, effectively improving development efficiency and system availability.
[0062] In an alternative embodiment of the present invention, the environment perception module is further configured to trigger multi-level resource response processing based on the remaining memory, and when triggering the last-level resource response processing, push resource warning information to the user side.
[0063] In an alternative embodiment of the present invention, the remaining memory includes physical memory remaining and virtual memory remaining.
[0064] The multi-level resource response processing includes:
[0065] If the physical memory remaining is continuously lower than the first preset physical memory remaining threshold within the second preset time period, set the system status flag bit to mark the low memory mode.
[0066] If the physical memory remaining is continuously lower than the first preset physical memory remaining threshold within the third preset time period after setting the system status flag bit to mark the low memory mode, compress the system cache.
[0067] If the physical memory remaining is lower than the second preset physical memory remaining threshold after compressing the system cache, push resource warning information to the user side; the second preset physical memory remaining threshold is less than the first preset physical memory remaining threshold.
[0068] It can be seen that in the above embodiment, the environment perception module continuously monitors the physical memory remaining and triggers a multi-level resource response processing mechanism according to the memory usage situation, so as to realize the dynamic management of system resources. Specifically, not only gradually cope with the memory pressure by setting the low memory mode flag bit and compressing the system cache, but also actively push resource warning information to the user side when the remaining memory further deteriorates to the second preset threshold, so as to improve the stability of the system and the user experience.
[0069] As an example of this embodiment, when the remaining memory is lower than 20%, a three-level response is triggered: if the physical memory < 20% lasts for 3 seconds, set the system status flag bit LOW_MEM_MODE to mark the low memory mode; when the marked low memory mode does not recover for 5 seconds, the system calls the ioctl(ZRAM_CREATE) method to enable zRAM compressed cache; if the memory compression is still < 15%, record it in the log and push resource warning information to the client.
[0070] In an alternative embodiment of the present invention, the decision rule module is further configured to:
[0071] When a relatively optimal sorting algorithm is selected from the candidate sorting algorithms according to the optimal sorting algorithm selection rule, the relatively optimal sorting algorithm is the optimal sorting algorithm.
[0072] When multiple relatively optimal sorting algorithms are screened from the candidate sorting algorithms according to the optimal sorting algorithm selection rule, the cost matrix scores of each relatively optimal sorting algorithm are calculated respectively, and the relatively optimal sorting algorithm with the highest cost matrix score is used as the optimal sorting algorithm;
[0073] When zero relatively optimal sorting algorithms are screened from the candidate sorting algorithms according to the optimal sorting algorithm selection rule, the cost matrix scores of each candidate sorting algorithm are calculated respectively, and the candidate sorting algorithm with the highest cost matrix score is used as the optimal sorting algorithm.
[0074] It can be seen that in the above embodiments, the decision rule module uses a hierarchical screening mechanism to determine the optimal sorting algorithm: first, relatively optimal algorithms are preliminarily screened from the candidate algorithms according to the preset selection rule. If a unique result is obtained, it is directly determined as the optimal algorithm; if there are multiple candidates, secondary screening is performed through the cost matrix score, and the one with the highest score is selected; when there is no result in the preliminary screening, the cost matrix scores of all candidate algorithms are compared. This multi-level decision-making mechanism not only ensures the efficiency of algorithm selection by quickly screening through rules first, but also ensures the selection accuracy in complex situations through quantitative scoring, achieving a balance between efficiency and accuracy.
[0075] As an execution example of this embodiment: If it is detected that the user inputs the rule "memory < 40% → heap sort" (meeting the user-defined rule), the heap sort is triggered; if the data volume = 10^5, the remaining memory = 4GB, the data order degree = 30%, and the user policy = speed priority (not meeting any preset rule and if there is no suitable user-defined configuration condition-action rule), then calculate the scores of the candidate algorithms:
[0076] Quick sort: T(n) = O(n log n), S(n) = O(log n), Score = 0.6 / 1 + 0.3 / 0.5 + 0 = 1.8 Heap sort: T(n) = O(n log n), S(n) = O(1), Score = 0.6 / 1 + 0.3 / 1 + 0 = 0.9
[0077] Shell sort: T(n) = O(n log n), S(n) = O(1), Score = 0.6 / 1 + 0.3 / 1 + 0 = 0.9
[0078] Selection result: Quick sort (the highest comprehensive score).
[0079] In an alternative embodiment of the present invention, the multi-level fusing protection system includes:
[0080] If the CPU occupancy rate exceeds the first preset CPU occupancy rate threshold, or the remaining memory is lower than the first preset remaining memory threshold, the resource limit mode is started to compress the resources of non-core processes;
[0081] If the CPU occupancy rate exceeds the second preset CPU occupancy rate threshold, or the remaining memory is lower than the second preset remaining memory threshold, switch to a sorting algorithm with low technical parameters and perform memory fragmentation reorganization in parallel; where the second preset CPU occupancy rate threshold is greater than the first preset CPU occupancy rate threshold, and the second preset remaining memory threshold is less than the first preset remaining memory threshold;
[0082] If within the first preset time period, the CPU occupancy rate continuously exceeds the second preset CPU occupancy rate threshold, or the remaining memory continuously is lower than the second preset remaining memory threshold, forcibly release the sorting cache and enable disk-assisted sorting.
[0083] It can be seen that in the above embodiments, the multi-level fuse protection system of the emergency module adopts a progressive resource management strategy, triggering a differential response mechanism through three-level thresholds: the primary threshold triggers the resource limit mode to optimize resource allocation; the intermediate threshold triggers dual measures of algorithm degradation and memory reorganization; continuous over-threshold enables the highest-level protection, forcibly releasing the cache and starting disk sorting. The emergency module combines real-time monitoring and continuous status judgment through this system, dynamically adjusts the protection intensity, and realizes a stepped response in case of resource overload, avoiding the impact of excessive fusing on system performance and ensuring system stability in extreme cases.
[0084] As an execution example of this embodiment, the three-level system fuse protection includes:
[0085] Primary warning (CPU > 80% or memory < 25%): Start the resource limit mode and compress the resources of non-core processes.
[0086] Intermediate emergency (CPU > 90% or memory < 10%): Switch to a simplified algorithm such as selection sort and perform memory fragmentation reorganization in parallel.
[0087] Advanced fuse (continuously exceeding the intermediate emergency threshold for 15 seconds): Forcibly release the sorting cache and enable disk-assisted sorting.
[0088] In an alternative embodiment of the present invention, the automatic execution module is further configured to output the type and performance report of the optimal sorting algorithm called;
[0089] The optimal sorting algorithm dual screening system further includes a performance report receiving module at the user end, and the performance report receiving module is configured to receive the type and performance report of the optimal sorting algorithm adopted by the system provided by the automatic execution module.
[0090] In an alternative embodiment of the present invention, the optimal sorting algorithm double screening system further includes a user-defined configuration module at the client side, which is used to convert the optimal sorting algorithm selection rules configured by the user from the condition-action rule form into the feature vector rule form recognizable by the decision rule module.
[0091] In the optimal sorting algorithm double screening system of the present invention, the main functions of the client side communicating with the above-mentioned optimal sorting algorithm double screening middleware are as follows:
[0092] 1. User-defined configuration module: This module can convert the condition-action configured by the user into a feature vector rule recognizable by the rule engine. First, use a parser (DSL) to disassemble the user input rule (such as "memory < 40% → heap sort") into a Token stream: [condition subject: data volume][operator: <][threshold: 1000][action operator: →][algorithm: insertion sort], and then operate on the semantic layer to bind "memory → METRIC_002", "30% → 0.3 (float)", and facilitate the decision rule module to recognize through the system-preset feature vectorization data: set the corresponding bit of METRIC_002 to 1, variable name [METRIC_002] = 0.3, op_codes[0] = 0x01 (indicating the < operator encoding).
[0093] 2. Performance report receiving module: Receive the type of sorting algorithm adopted by the system provided by the automatic execution module and the performance report.
[0094] 3. Log recording module: Record data such as CPU, memory, data volume, orderliness, etc. and resource warning information.
[0095] Refer to Figure 2 , the processing flow of the optimal sorting algorithm double screening of the present invention is as follows:
[0096] ①First, the user-side personnel can choose whether to customize the data that the rule engine can identify, and then use the internal http communication protocol to communicate with the algorithm middleware. ②After obtaining the information, the middleware calls the environment perception to obtain the CPU usage and memory margin. When the memory margin is less than 20%, the three-level resource response mechanism is triggered: 1. If the physical memory is <20% for 3 seconds, the system status flag LOW_MEM_MODE is set to mark the low memory mode; 2. When the low memory mode is marked for 5 seconds without recovery, the system calls the ioctl (ZRAM_CREATE) method to enable the zRAM compression cache; 3. If the memory compression is turned on and it is still <15%, the log is recorded and the resource warning information is pushed to the client to provide real-time data perception for the decision rule module. ③The algorithm warehouse module initially selects the appropriate algorithm based on the perception module data; ④The decision rule module further obtains the custom configuration rules, and selects the optimal algorithm among the appropriate algorithms based on whether there are custom rules, system preset rules and cost matrix scores. ⑤After the decision rule is executed, the system recovery speed after each strategy is executed is automatically recorded, and the normal operation of the system is maintained through the three-level system fuse.
[0097] The present invention has the following technical effects:
[0098] 1. Real-time: Through real-time monitoring of system resources and combining 60-second sliding window modeling to build a dynamic environment matrix, accurate prediction of resource status can be achieved. When resources are tight, a three-level response mechanism is triggered to ensure stable operation of the system.
[0099] 2. Convenience and economy: It has built-in commonly used sorting algorithms (such as quick sort, heap sort, insertion sort, etc.), and supports dynamic addition of new algorithms through configuration files. It adopts a hot loading architecture and supports user-defined configuration converted into dynamic registration and rollback of algorithms without modifying the core code, reducing maintenance costs.
[0100] 3. Efficiency: The decision engine based on condition-action rules combines the cost matrix to dynamically select the algorithm, eliminates policy conflicts, ensures the selection of the optimal algorithm under different conditions, and users can further optimize the algorithm selection through custom rules to improve system efficiency.
[0101] 4. Stability: When system resources are overloaded, the bottom-line strategies are gradually enabled, including resource restriction mode, simplified algorithm switching, disk-assisted sorting, etc., to ensure that the system can still run stably under extreme conditions and avoid service interruptions.
[0102] 5. Flexible adaptability: Through the DSL parser, users can customize rules and complete configuration without coding, which lowers the usage threshold.
[0103] Based on the same inventive concept, another embodiment of the present invention provides an electronic device, including a memory, a processor, and a computer program stored on the memory. The processor executes the computer program to load the optimal sorting algorithm dual screening system according to any one of the embodiments of the present invention.
[0104] Specifically, the electronic device includes: a memory and a processor. The memory is communicatively connected to the processor via a bus. A computer program is stored in the memory and can run on the processor, thereby loading the optimal sorting algorithm dual screening system according to any one of the first aspects of the embodiments of the present invention.
[0105] The memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located far from the aforementioned processor.
[0106] The above-mentioned processor may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0107] Based on the same inventive concept, another embodiment of the present invention provides a computer-readable storage medium, on which a computer program / instructions are stored. When the computer program / instructions are executed by a processor, the optimal sorting algorithm dual screening system according to any one of the first aspects of the embodiments of the present invention is loaded.
[0108] Each embodiment in this specification is described in a progressive manner. The key point of each embodiment is to illustrate the differences from other embodiments. For the same or similar parts among the embodiments, reference can be made to each other.
[0109] Those skilled in the art should understand that the embodiments of the present invention can be provided as a method, a device, an electronic device, a storage medium, or a computer program product. Therefore, the embodiments of the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Moreover, the embodiments of the present invention can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CDROM, optical storage, etc.) that contain computer-usable program code.
[0110] Although the embodiments of the present invention have been shown and described, those of ordinary skill in the art can understand that various changes, modifications, substitutions, and variations can be made to these embodiments without departing from the principles and spirit of the present invention. The scope of the present invention is defined by the claims and their equivalents.
[0111] Finally, it should also be noted that in this document, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including", or any other variation thereof is intended to cover non-exclusive inclusion, so that a process, method, article, or terminal device comprising a series of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or terminal device. Without further limitation, an element defined by the statement "comprising an..." does not exclude the presence of additional identical elements in the process, method, article, or terminal device comprising the element.
[0112] The above has introduced in detail an optimal sorting algorithm double screening system, an electronic device, and a readable storage medium provided by the present invention. Specific examples are used in this article to elaborate on the principles and implementation manners of the present application. The description of the above embodiments is only used to help understand the method and its core idea of the present application; at the same time, for those of ordinary skill in the art, according to the idea of the present application, there will be changes in the specific implementation manners and application scopes. In summary, the content of this specification should not be construed as a limitation to the present application. The above embodiments are only preferred embodiments given to fully illustrate the present invention, and the protection scope of the present invention is not limited thereto. Equivalent substitutions or transformations made by those skilled in the art on the basis of the present invention are within the protection scope of the present invention.
Claims
1. An optimal sorting algorithm double screening system, characterized in that including: An environment perception module, which is used to monitor the system resource status data in real time according to different computer system environments; the system resource status data includes CPU occupancy rate, memory margin, data volume, data orderliness, and fragmentation index; An algorithm repository module, which is used to screen and match sorting algorithms according to the system resource status data and the technical parameters of the stored sorting algorithms through an algorithm matching model to obtain candidate sorting algorithms; the stored sorting algorithms include pre-built sorting algorithms and newly added sorting algorithms by users; A decision rule module, which is used to select the optimal sorting algorithm from the candidate sorting algorithms according to the optimal sorting algorithm selection rule and the cost matrix score; the optimal sorting algorithm selection rule includes system preset rules and user-defined rules; An automatic execution module, which is used to call the selected optimal sorting algorithm; An emergency module, which is used to determine whether the system resource status data after calling the optimal sorting algorithm triggers a multi-level fusing protection system. If so, it executes the guaranteed sorting strategy corresponding to the triggered protection level.
2. The optimal sorting algorithm double-selection system according to claim 1, characterized in that the environment perception module is further used to trigger multi-level resource response processing according to the memory margin, and when the last-level resource response processing is triggered, push resource warning information to the user side.
3. The optimal sorting algorithm double-selection system according to claim 1, characterized in that the algorithm repository module is further used to store the ontology algorithm logic code, metadata file and algorithm matching model of the sorting algorithm; the metadata component records the technical parameters of the sorting algorithm, including time complexity, space complexity, and stability; the algorithm matching model is the screening logic of the candidate sorting algorithm.
4. The optimal sorting algorithm double-selection system according to claim 1, characterized in that the decision rule module is further used for: when a relatively optimal sorting algorithm is screened from the candidate sorting algorithms according to the optimal sorting algorithm selection rule, then the relatively optimal sorting algorithm is the optimal sorting algorithm; when multiple relatively optimal sorting algorithms are screened from the candidate sorting algorithms according to the optimal sorting algorithm selection rule, then calculate the cost matrix score of each relatively optimal sorting algorithm, and use the relatively optimal sorting algorithm with the highest cost matrix score as the optimal sorting algorithm; when zero relatively optimal sorting algorithms are screened from the candidate sorting algorithms according to the optimal sorting algorithm selection rule, then calculate the cost matrix score of each candidate sorting algorithm, and use the candidate sorting algorithm with the highest cost matrix score as the optimal sorting algorithm.
5. The optimal sorting algorithm double-selection system according to claim 1, characterized in that the automatic execution module is further used to output the type and performance report of the called optimal sorting algorithm; the optimal sorting algorithm double-selection system further includes a performance report receiving module at the user side, and the performance report receiving module is used to receive the type and performance report of the optimal sorting algorithm adopted by the system provided by the automatic execution module.
6. The optimal sorting algorithm double-selection system according to claim 1, characterized in that the multi-level fusing protection system includes: If the CPU occupancy rate exceeds the first preset CPU occupancy rate threshold, or the remaining memory is lower than the first preset remaining memory threshold, the resource limit mode is started to compress the resources of non-core processes; If the CPU occupancy rate exceeds the second preset CPU occupancy rate threshold, or the remaining memory is lower than the second preset remaining memory threshold, switch to the sorting algorithm with lower technical parameters and perform memory fragmentation sorting in parallel; wherein, the second preset CPU occupancy rate threshold is greater than the first preset CPU occupancy rate threshold, and the second preset remaining memory threshold is less than the first preset remaining memory threshold; If the CPU occupancy rate continuously exceeds the second preset CPU occupancy rate threshold, or the remaining memory continuously is lower than the second preset remaining memory threshold within the first preset time period, forcefully release the sorting cache and enable disk-assisted sorting.
7. The optimal sorting algorithm dual-screening system according to claim 1, wherein the optimal sorting algorithm dual-screening system further includes a user-defined configuration module at the user end, and the user-defined configuration module is used to convert the optimal sorting algorithm selection rule configured by the user from the condition-action rule form into the feature vector rule form recognizable by the decision rule module.
8. The optimal sorting algorithm double screening system according to claim 2, characterized in that The remaining memory includes the remaining physical memory and the remaining virtual memory. The multi-level resource response processing includes: If the remaining physical memory continuously is lower than the first preset remaining physical memory threshold within the second preset time period, set the system status flag bit to mark the low memory mode; If the remaining physical memory continuously is lower than the first preset remaining physical memory threshold within the third preset time period after setting the system status flag bit to mark the low memory mode, compress the system cache; If the remaining physical memory is lower than the second preset remaining physical memory threshold after compressing the system cache, push a resource warning message to the user end; the second preset remaining physical memory threshold is less than the first preset remaining physical memory threshold.
9. An electronic device, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, When the electronic device executes the computer program, load the optimal sorting algorithm dual-screening system according to any one of claims 1 to 8.
10. A readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, load the optimal sorting algorithm dual-screening system according to any one of claims 1 to 8.
Citation Information
Cited By
Display device and video static frame detection method
CN121262357A