WO2021232386A1 - 动态管理共享内存池的方法和装置 - Google Patents

动态管理共享内存池的方法和装置 Download PDF

Info

Publication number
WO2021232386A1
WO2021232386A1 PCT/CN2020/091686 CN2020091686W WO2021232386A1 WO 2021232386 A1 WO2021232386 A1 WO 2021232386A1 CN 2020091686 W CN2020091686 W CN 2020091686W WO 2021232386 A1 WO2021232386 A1 WO 2021232386A1
Authority
WO
WIPO (PCT)
Prior art keywords
memory pool
shared memory
business scenario
size
shared
Prior art date
Application number
PCT/CN2020/091686
Other languages
English (en)
French (fr)
Inventor
朱国峰
李泉材
唐建生
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Priority to EP20936608.7A priority Critical patent/EP4141671A4/en
Priority to CN202080101088.XA priority patent/CN115668144A/zh
Priority to PCT/CN2020/091686 priority patent/WO2021232386A1/zh
Publication of WO2021232386A1 publication Critical patent/WO2021232386A1/zh
Priority to US17/990,990 priority patent/US20230085979A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/061Improving I/O performance
    • G06F3/0613Improving I/O performance in relation to throughput
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/546Message passing systems or structures, e.g. queues
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/061Improving I/O performance
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0629Configuration or reconfiguration of storage systems
    • G06F3/0631Configuration or reconfiguration of storage systems by allocating resources to storage systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0653Monitoring storage devices or systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0668Interfaces specially adapted for storage systems adopting a particular infrastructure
    • G06F3/067Distributed or networked storage systems, e.g. storage area networks [SAN], network attached storage [NAS]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5016Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/5011Pool
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/5014Reservation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/503Resource availability
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/508Monitor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N20/00Machine learning
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N5/00Computing arrangements using knowledge-based models
    • G06N5/04Inference or reasoning models

Definitions

  • This application relates to the storage field, and more specifically, to a method and device for dynamically managing a shared memory pool.
  • the current industry provides a memory pool sharing mechanism to avoid a large number of applications and releases by reusing memory to improve data transmission efficiency and save memory resources.
  • One is the fixed memory pool mechanism.
  • the memory pool size can be pre-allocated in advance to avoid unnecessary scaling and save a certain amount of memory.
  • the method is not flexible enough to be suitable for scenarios with multi-threading and unfixed data flow; the other is the dynamic memory pool mechanism.
  • this method dynamically expands and shrinks the memory pool and allocates memory on demand , Which can save memory usage to the greatest extent, but frequent expansion and contraction will cause fluctuations in system performance.
  • This application provides a method and device for dynamically managing a shared memory pool, which determines a shared memory pool mechanism suitable for the current business scenario according to different business scenarios, and then dynamically adjusts the memory pool mechanism according to the determined result to improve the performance of the system.
  • a method for dynamically managing a shared memory pool includes: determining a first shared memory pool mechanism, where the first shared memory pool mechanism is a fixed memory pool mechanism or a dynamic memory pool mechanism;
  • the business scenario determines a second shared memory pool mechanism suitable for the second business scenario, and the second shared memory pool mechanism is a fixed memory pool mechanism or a dynamic memory pool mechanism; in the second shared memory pool mechanism and the When the first shared memory pool mechanism is different, the first shared memory pool mechanism is adjusted to the second shared memory pool mechanism.
  • the method for dynamically managing a shared memory pool in the embodiment of the application adopts different shared memory pool mechanisms for different business scenarios, determines a shared memory pool mechanism suitable for the current business scenario according to different business scenarios, and then dynamically adjusts the memory pool according to the determined result Mechanism to give full play to the advantages of different shared memory pool mechanisms to better meet the needs of business scenarios.
  • the first shared memory pool mechanism is a shared memory pool mechanism suitable for the first business scenario; the determining that is suitable for the second business according to the second business scenario Before the second shared memory pool mechanism of the scenario, it further includes: determining that the business scenario has been switched from the first business scenario to the second business scenario.
  • the method for dynamically managing the shared memory pool in the embodiment of the present application can be applied to when the business scenario is switched, if the shared memory pool mechanism applicable to the current business scenario is also changed, the shared memory pool applicable to the current business scenario can be re-determined mechanism.
  • the first shared memory pool mechanism is an initialized shared memory pool mechanism.
  • the method for dynamically managing the shared memory pool in the embodiment of the present application may be suitable for re-determining the shared memory pool mechanism suitable for the current business scenario when the shared memory pool initialized by the system is not suitable for the current business scenario.
  • the determining according to the second business scenario a second shared memory pool mechanism suitable for the second business scenario includes: determining according to the second business scenario The parameters of the second shared memory pool applicable to the second business scenario; and the second shared memory pool mechanism applicable to the second business scenario is determined according to the parameters of the second shared memory pool.
  • the parameters of the second shared memory pool include the maximum value and the minimum value of the size of the second shared memory pool.
  • the maximum and minimum size of the shared memory pool can be determined first, and the mechanism of the shared memory pool can be determined according to the maximum and minimum size of the shared memory pool .
  • the determining the parameters of the second shared memory pool applicable to the second business scenario according to the second business scenario includes: acquiring the second business scenario , The memory usage information of the first time period; the parameters of the second shared memory pool are determined according to the memory usage information.
  • the parameters of the shared memory pool are determined according to the actual memory usage information, and the shared memory pool parameters that are more suitable for the current business scenario can be obtained.
  • the determining the parameters of the second shared memory pool according to the memory usage information includes: acquiring the memory in the second business scenario in the second time Usage value; if the memory usage value is greater than the maximum size of the first shared memory pool, then the memory usage value is taken as the maximum size of the second shared memory pool, or if the memory usage value If it is less than the maximum size of the first shared memory pool, the memory usage value is taken as the maximum size of the second shared memory pool.
  • the memory usage value is taken as the minimum size of the second shared memory pool, or if the memory usage value is less than the If the minimum size of the first shared memory pool is the minimum value, the memory usage value is taken as the minimum size of the second shared memory pool.
  • the method for dynamically managing the shared memory pool in the embodiment of the present application provides a method for determining the parameters of the shared memory pool according to the actual memory usage value.
  • the actual memory usage value is used as the size of the shared memory pool, so that the shared memory pool can be more Suitable for current business scenarios, intuitive and convenient.
  • the determining a second shared memory pool mechanism suitable for the second business scenario according to the parameters of the second shared memory pool includes: if the second shared memory pool is If the difference between the maximum size of the shared memory pool and the minimum size of the second shared memory pool is less than the third threshold, it is determined that the second shared memory pool mechanism is a fixed memory pool mechanism; if the second shared memory If the difference between the maximum value of the pool size and the minimum value of the second shared memory pool size is greater than the fourth threshold, it is determined that the second shared memory pool mechanism is a dynamic memory pool mechanism.
  • a device for dynamically managing a shared memory pool includes: a determining unit for determining a first shared memory pool mechanism, where the first shared memory pool mechanism is a fixed memory pool mechanism or a dynamic memory pool Mechanism; the determining unit is further configured to determine a second shared memory pool mechanism suitable for the second business scenario according to the second business scenario, and the second shared memory pool mechanism is a fixed memory pool mechanism or a dynamic memory pool mechanism; The adjustment unit is configured to adjust the first shared memory pool mechanism to the second shared memory pool mechanism when the second shared memory pool mechanism is different from the first shared memory pool mechanism.
  • the embodiment of the present application also provides a device for dynamically managing a shared memory pool, and the device is used to implement the above-mentioned method for dynamically managing a shared memory pool.
  • the first shared memory pool mechanism is a shared memory pool mechanism suitable for the first business scenario; the determining unit determines that the mechanism is suitable for the second business scenario according to the second business scenario. Before the second shared memory pool mechanism of the second business scenario, the determining unit is further configured to determine that the business scenario has been switched from the first business scenario to the second business scenario.
  • the first shared memory pool mechanism is an initialized shared memory pool mechanism.
  • the determining unit determining a second shared memory pool mechanism suitable for the second business scenario according to the second business scenario includes: determining according to the second business scenario The parameters of the second shared memory pool applicable to the second business scenario; and the second shared memory pool mechanism applicable to the second business scenario is determined according to the parameters of the second shared memory pool.
  • the parameters of the second shared memory pool include the maximum value and the minimum value of the size of the second shared memory pool.
  • the determining unit determining the parameters of the second shared memory pool applicable to the second business scenario according to the second business scenario includes: acquiring the second In the business scenario, the memory usage information of the first time period; the parameters of the second shared memory pool are determined according to the memory usage information.
  • the determining unit determining the parameters of the second shared memory pool according to the memory usage information includes: acquiring the parameters of the second shared memory pool in the second business scenario within a second time The memory usage value;
  • the memory usage value is taken as the maximum size of the second shared memory pool, or if the memory usage value is less than the For the maximum size of the first shared memory pool, the memory usage value is taken as the maximum size of the second shared memory pool. If the memory usage value is greater than the minimum size of the first shared memory pool, then the memory usage value is taken as the minimum size of the second shared memory pool, or if the memory usage value is less than the If the minimum size of the first shared memory pool is the minimum value, the memory usage value is taken as the minimum size of the second shared memory pool.
  • the determining unit determines a second shared memory pool mechanism suitable for the second business scenario according to the parameters of the second shared memory pool, including: if the If the difference between the maximum value of the second shared memory pool size and the minimum value of the second shared memory pool size is less than the third threshold, it is determined that the second shared memory pool mechanism is a fixed memory pool mechanism; If the difference between the maximum size of the shared memory pool and the minimum size of the second shared memory pool is greater than the fourth threshold, it is determined that the second shared memory pool mechanism is a dynamic memory pool mechanism.
  • a computer program storage medium which is characterized in that the computer program storage medium has program instructions that, when the program instructions are executed by a processor, cause the processor to execute any implementation of the first aspect and the first aspect Way way.
  • a chip in a fourth aspect, characterized in that the chip includes at least one processor, and when the program instructions are executed in the at least one processor, the at least one processor is caused to execute any one of the first aspect and the first aspect Way of realization.
  • a terminal device which includes the aforementioned device for dynamically managing a shared memory pool.
  • FIG. 1 is a schematic block diagram of two existing memory pool sharing mechanisms according to an embodiment of the present application
  • FIG. 2 is a schematic block diagram of a possible application scenario of the method for dynamically managing a shared memory pool according to an embodiment of the present application
  • FIG. 3 is an application scenario of the method for dynamically managing a shared memory pool according to an embodiment of the present application
  • FIG. 4 is a schematic flowchart of a method for dynamically managing a shared memory pool according to an embodiment of the present application
  • FIG. 5 is a schematic block diagram of a specific implementation of a method for dynamically managing a shared memory pool according to an embodiment of the present application
  • Fig. 6 is a schematic architecture diagram of a system according to an embodiment of the present application.
  • FIG. 7 is a schematic structural diagram of an apparatus for dynamically managing a shared memory pool provided by an embodiment of the present application.
  • FIG. 8 is a schematic structural diagram of another device for dynamically managing a shared memory pool provided by an embodiment of the present application.
  • FIG. 9 is a schematic structural diagram of another device for dynamically managing a shared memory pool provided by an embodiment of the present application.
  • the shared memory pool is a memory pool of appropriate size that is pre-applied for as a memory pool for multiple processes to access.
  • the multiple processes may be different processes of the same device, or different processes of different devices.
  • Figure 1 shows two existing memory pool sharing mechanisms, including a fixed memory pool mechanism and a dynamic memory pool mechanism.
  • the fixed memory pool mechanism that is, the size of the pre-allocated memory pool has been determined and is fixed.
  • the memory pool will not be dynamically expanded or contracted according to business changes.
  • the memory pool size can be pre-allocated in advance to avoid unnecessary scaling and save a certain amount of memory.
  • the mechanism is not flexible enough. It is suitable for scenarios with multiple threads and unfixed data flow.
  • the dynamic memory pool mechanism means that the size of the memory pool can be changed as needed.
  • the size of the memory pool under this mechanism is a dynamic range [Min, Max].
  • the memory usage can be saved to the greatest extent by dynamically expanding the memory pool and allocating memory on demand.
  • memory expansion and contraction can also cause performance fluctuations.
  • frequent expansion and contraction are required, resulting in system performance fluctuations.
  • Figure 2 shows three possible application scenarios, including:
  • Scene A Single video stream, stable data input
  • Scenario B Single video stream, data stream input fluctuates during the day and stable at night, and the memory consumption has a certain pattern
  • Scenario C Multiple video streams, data input changes dynamically, and memory consumption fluctuates.
  • a memory mechanism is usually determined to apply to all scenarios. That is, scenes A, B, and C all use fixed memory pools, or scenes A, B, and C all use dynamic memory pools.
  • scene A is suitable for using fixed memory pool mechanism
  • scene C is suitable for using dynamic memory pool mechanism
  • scene B is suitable for dynamic memory pool during the day and fixed memory pool at night.
  • the key memory pool configuration parameters such as memory size and range are manually preset based on experience, which cannot really adapt to different scenarios and different needs.
  • the predetermined memory pool mechanism has its own advantages and disadvantages, and cannot be applied to all user business scenarios.
  • the method for dynamically managing a shared memory pool in the embodiment of the present application can dynamically learn the adaptation relationship between each scene and the memory pool mechanism through pre-learning, and then dynamically adjust the memory pool mechanism according to the learned result, so that scene A adopts Fixed memory pool, scenario C uses dynamic memory pool, scenario B dynamically switches between fixed memory pool and dynamic memory pool according to business scenarios, so that business performance is optimal.
  • the embodiment of the application searches for the best matching relationship between different application scenarios and memory pool mechanisms, dynamically adjusts the memory pool mechanisms according to the application scenarios, and makes full use of the advantages of each memory pool mechanism and avoids its shortcomings.
  • Fig. 3 shows an application scenario of the method for dynamically managing a shared memory pool according to an embodiment of the present application.
  • a large number of videos or pictures need to be transmitted to the computing center through smart cameras for inference processing.
  • Specific tasks include recognition (motor vehicles, non-motor vehicles, faces, etc.), image classification, Retrieval and tracking (vehicles, pedestrians, etc.), most of the above tasks rely on the processing power of AI chips.
  • recognition motor vehicles, non-motor vehicles, faces, etc.
  • image classification image classification
  • Retrieval and tracking vehicle, pedestrians, etc.
  • most of the above tasks rely on the processing power of AI chips.
  • AI chips With the continuous improvement of AI chip processing capabilities, various types of AI NPUs currently on the market have different AI computing capabilities.
  • a single chip will process multiple inference tasks at the same time, such as simultaneous access to multiple channels, or multiple chips can co-process a single inference task, such as CPU-intensive retrieval.
  • multiple inference tasks such as simultaneous access to multiple channels
  • multiple chips can co-process a single inference task, such as CPU-intensive retrieval.
  • the method for dynamically managing a shared memory pool in the embodiment of the present application, when a variety of business applications transmit data streams, users do not need to analyze business behavior in advance, and the system can dynamically adapt to memory requirements in different scenarios to optimize system performance.
  • FIG. 4 shows a schematic flowchart of a method for dynamically managing a shared memory pool according to an embodiment of the present application. As shown in FIG. 4, it includes steps 401 to 403, and these steps are described in detail below.
  • S401 Determine a first shared memory pool mechanism, where the first shared memory pool mechanism is a fixed memory pool mechanism or a dynamic memory pool mechanism.
  • the first shared memory pool mechanism is an initialized shared memory pool mechanism. That is, the first shared memory pool mechanism may be a preset fixed memory pool mechanism or a dynamic memory pool mechanism, or a shared memory pool mechanism initialized randomly by the system. After determining the shared memory pool mechanism suitable for the current business scenario according to the business scenario, the shared memory pool mechanism at this time is adjusted.
  • the first shared memory pool mechanism is a shared memory pool mechanism suitable for the first business scenario; before determining the second shared memory pool mechanism suitable for the second business scenario according to the second business scenario, the method further includes: determining The business scenario has been switched from the first business scenario to the second business scenario.
  • the business scenarios may be the business scenarios A, B, and C listed exemplarily in FIG. 2 or other business scenarios.
  • S402 Determine a second shared memory pool mechanism suitable for the second business scenario according to the second business scenario, where the second shared memory pool mechanism is a fixed memory pool mechanism or a dynamic memory pool mechanism.
  • the parameters of the shared memory pool include the maximum and minimum values of the shared memory pool.
  • the shared memory pool is a fixed memory pool
  • the difference between the maximum value and the minimum value of the shared memory pool size is less than the third threshold, where the third threshold may be a value that is artificially specified.
  • the parameters of the second shared memory pool applicable to the second business scenario are determined according to the second business scenario, and the second business scenario may be acquired first,
  • the memory usage information of the first time period, and then the parameters of the second shared memory pool are determined according to the memory usage information.
  • the memory usage information may be a memory usage value, and if the memory usage value is greater than the maximum size of the first shared memory pool, the memory usage value is taken as the maximum size of the second shared memory pool, Alternatively, if the memory usage value is less than the maximum size of the first shared memory pool, the memory usage value is taken as the maximum size of the second shared memory pool.
  • the memory usage value is taken as the minimum size of the second shared memory pool, or if the memory usage value is less than the If the minimum size of the first shared memory pool is the minimum value, the memory usage value is taken as the minimum size of the second shared memory pool.
  • the memory usage information may be the memory usage rate (memory usage value/total size of the memory pool), and if the memory usage rate is greater than the first threshold, the first shared memory pool size of the first shared memory pool mechanism
  • the maximum value of is multiplied by the first coefficient to serve as the maximum value of the second shared memory pool size, and the first coefficient is greater than 1, or the minimum value of the first shared memory pool size is multiplied by the second coefficient , As the minimum value of the second shared memory pool size, the second coefficient is less than 1; if the memory usage rate is less than the second threshold, the maximum value of the first shared memory pool size is multiplied by the first
  • the third coefficient is used as the maximum value of the second shared memory pool size, and the third coefficient is less than 1, or the minimum value of the first shared memory pool size is multiplied by the fourth coefficient as the first 2.
  • the four-most value of the shared memory pool size, and the first coefficient is greater than 1.
  • the memory usage information in the business scenario may also include memory usage information such as the number of memory blocks that need to be increased in the current memory pool, and the number of memory blocks that need to be reduced in the current memory pool.
  • the above method of determining the parameters of the second shared memory pool applicable to the second business scenario according to the second business scenario is only an example of the method of dynamically managing the shared memory pool in the embodiment of the present application, except for the foregoing method,
  • the embodiment of the present application may also use a learning rule set to determine the parameters of the second shared memory pool applicable to the second business scenario.
  • the learning rule set can be a priori rule formed by IF A THEN B.
  • the second shared memory pool mechanism suitable for the second business scenario is determined according to the parameters of the second shared memory pool, which can be determined according to the following method: If the difference between the maximum value of the second shared memory pool size and the minimum value of the second shared memory pool size is less than a third threshold, it is determined that the second shared memory pool mechanism is a fixed memory pool mechanism; 2. The difference between the maximum value of the shared memory pool size and the minimum value of the second shared memory pool size is greater than a fourth threshold, and then it is determined that the second shared memory pool mechanism is a dynamic memory pool mechanism.
  • the fourth threshold may be a value that is artificially specified.
  • the method for dynamically managing the shared memory pool in the embodiment of the present application is a dynamic loop method.
  • the method in the embodiment of the present application further includes: Real-time monitoring of scene changes.
  • the parameters of the shared memory pool mechanism applicable to the current business scenario can be adjusted according to real-time memory usage information (such as memory usage value or memory usage rate), so that the size or size range of the shared memory pool is more suitable for the current business scenario; if The business scenario is switched, so that the current shared memory pool mechanism is no longer suitable for the current business scenario, and the shared memory pool mechanism applicable to the current business scenario can also be re-determined according to the switched business scenario.
  • the method for dynamically managing a shared memory pool in the embodiments of the present application can dynamically switch the shared memory pool mechanism applicable to the current business scenario and dynamically adjust the parameters of the shared memory pool applicable to the current business scenario according to different business scenarios.
  • the method for dynamically managing shared memory pools in the embodiments of this application is not necessarily related to the actual business scenario, but is dynamically switched based on the memory usage information of the actual business scenario and is suitable for the current business scenario
  • the shared memory pool mechanism and dynamic adjustment of the parameters of the shared memory pool mechanism suitable for current business scenarios is not necessarily related to the actual business scenario, but is dynamically switched based on the memory usage information of the actual business scenario and is suitable for the current business scenario.
  • FIG. 5 shows a schematic block diagram of a specific implementation of the method for dynamically managing a shared memory pool according to an embodiment of the present application. As shown in FIG. 5, it mainly includes learning rules and memory hyper-parameters. ), memory adapter (memory adapter) and shared memory pool mechanism (shared memory mechanism).
  • memory adapter memory adapter
  • shared memory pool mechanism shared memory mechanism
  • Cycle A is to determine the memory hyperparameters of the first stage according to the input data and the learning rule set, and then determine the best matching shared memory mechanism for the current business scenario according to the memory hyperparameters.
  • Cycle B adjusts the memory hyper-parameters according to the learning rule set.
  • the current shared memory pool mechanism may no longer be applicable to the current business scenario.
  • the adjusted memory hyper-parameters are used to determine the best match with the current business scenario.
  • a well-matched shared memory pool mechanism is used to determine the best match with the current business scenario.
  • the learning rule set mainly includes a set of prior rules composed of IF A THEN B.
  • the prior rules are as follows:
  • Min min(UsedBlocks);
  • EnlargeCount ⁇ enThreshold the number of memory blocks that need to be increased is less than the upper limit allowed by the system
  • ReduceCount ⁇ reThreshold the number of memory blocks that need to be reduced is less than the upper limit allowed by the system
  • Max-Min ⁇ LowThreshold The interval between the maximum and minimum values of the dynamic memory pool range exceeds a certain minimum threshold
  • Max–Min>HighThreshold The interval between the maximum and minimum values of the dynamic memory pool range exceeds a certain maximum threshold.
  • Memory hyperparameters include: fixed memory pool mechanism parameter FixedMemSize, used to indicate the size of the memory pool; dynamic memory pool mechanism parameter Min, used to indicate the minimum size of the memory pool; dynamic memory pool mechanism parameter Max, used to indicate the size of the memory pool The maximum value; the memory pool mechanism selection button IsFixed is used to indicate whether to switch the memory pool.
  • the memory adapter decides to switch between the dynamic memory pool mechanism and the fixed memory pool mechanism according to the value of IsFixed.
  • the configuration of the current shared memory pool mechanism is set according to the learned memory hyperparameters, that is, the size of the memory pool or the size range of the memory pool.
  • the shared memory pool mechanism in the embodiment of the present application mainly includes a fixed memory pool mechanism and a dynamic memory pool mechanism.
  • the memory pool size of the fixed memory pool mechanism is fixed and will not be adjusted with business changes. All memory application operations are completed in this memory pool; the memory pool size of the dynamic memory pool mechanism will be dynamically adjusted according to business needs ,
  • the adjustment range is generally a fixed size range [Min, Max].
  • the method for dynamically managing shared memory pools in the embodiments of this application can be applied to scenarios such as inference computing platforms and deployed on computing nodes of related equipment.
  • different shared memory pool mechanisms can be implemented in different business scenarios.
  • the dynamic adaptation maximize the advantages of each shared memory pool mechanism.
  • the shared memory pool mechanism is a dynamic memory pool mechanism
  • the minimum value Min of the memory pool size can be dynamically adjusted
  • the maximum memory pool size Max can be dynamically adjusted
  • the minimum memory pool size Min is approximately equal to the maximum memory pool size Max
  • the dynamic memory pool can be adjusted to a fixed memory pool.
  • FIG. 5 is only an example of the method for dynamically managing the shared memory pool in the embodiment of the present application, and does not constitute a limitation on the method for dynamically managing the shared memory pool in the embodiment of the present application.
  • the above-mentioned learning rule set may also be other rules, or the limitation in the above-mentioned a priori rule may also be other limitation methods, or the above-mentioned non-proper nouns may also be replaced by other nouns with the same meaning.
  • those skilled in the art can make equivalent transformations in the above examples to achieve the same or similar effects.
  • the method for dynamically managing the shared memory pool obtained based on these equivalent transformations can still achieve the technical effect of the method for dynamically managing the shared memory pool in the embodiment of the present application. Therefore, these equivalent transformations should fall into the protection scope of this application.
  • Fig. 6 shows a schematic architecture diagram of a system of an embodiment of the present application.
  • the system first obtains relevant application data, specifically, including memory usage information in the current business scenario.
  • the memory hyperparameters can be obtained.
  • the learning rules are the set of rules preset during system initialization to guide the system how to learn; the memory hyperparameters are used to determine the shared memory pool mechanism and the memory size or memory size of the shared memory pool. Range.
  • the scene-memory mechanism adapter is used to switch between the dynamic memory pool mechanism and the fixed memory pool mechanism according to the memory hyperparameters.
  • the data of the relevant application is stored for subsequent processing.
  • FIG. 7 is a schematic structural diagram of an apparatus 700 for dynamically managing a shared memory pool provided by an embodiment of the present application.
  • the memory management device 700 includes a determining unit 710 and an adjusting unit 720.
  • the determining unit 710 is configured to determine a first shared memory pool mechanism, where the first shared memory pool mechanism is a fixed memory pool mechanism or a dynamic memory pool mechanism.
  • the determining unit 710 is further configured to determine a second shared memory pool mechanism suitable for the second business scenario according to the second business scenario, where the second shared memory pool mechanism is a fixed memory pool mechanism or a dynamic memory pool mechanism.
  • the adjusting unit 720 is configured to adjust the first shared memory pool mechanism to the second shared memory pool mechanism when the second shared memory pool mechanism is different from the first shared memory pool mechanism.
  • the first shared memory pool mechanism is a shared memory pool mechanism suitable for the first business scenario.
  • the determining unit 710 Before the determining unit 710 determines a second shared memory pool mechanism suitable for the second business scenario according to the second business scenario, the determining unit 710 is further configured to: determine that the business scenario has been switched from the first business scenario Go to the second business scenario.
  • the first shared memory pool mechanism is an initialized shared memory pool mechanism.
  • the determining unit 720 determines a second shared memory pool mechanism suitable for the second business scenario according to the second business scenario, including: determining a second shared memory pool mechanism suitable for the second business scenario according to the second business scenario Parameters of the shared memory pool; determining a second shared memory pool mechanism suitable for the second business scenario according to the parameters of the second shared memory pool. .
  • the parameters of the second shared memory pool include the maximum value and the minimum value of the size of the second shared memory pool.
  • the determining unit 720 determines the parameters of the second shared memory pool applicable to the second business scenario according to the second business scenario, including: acquiring the memory usage in the first time period in the second business scenario Information; Determine the parameters of the second shared memory pool according to the memory usage information.
  • the determining unit 720 determining the parameters of the second shared memory pool according to the memory usage information includes:
  • the memory usage value in the second time in the second business scenario if the memory usage value is greater than the maximum size of the first shared memory pool, then use the memory usage value as the second shared memory
  • the maximum size of the memory pool or if the memory usage value is less than the maximum size of the first shared memory pool, then the memory usage value is taken as the maximum size of the second shared memory pool. If the memory usage value is greater than the minimum size of the first shared memory pool, then the memory usage value is taken as the minimum size of the second shared memory pool, or if the memory usage value is less than the If the minimum size of the first shared memory pool is the minimum value, the memory usage value is taken as the minimum size of the second shared memory pool.
  • the determining unit 720 determines the second shared memory pool mechanism suitable for the second business scenario according to the parameters of the second shared memory pool, including: if the maximum size of the second shared memory pool is equal to the first 2. The difference between the minimum value of the shared memory pool size is less than the third threshold, then it is determined that the second shared memory pool mechanism is a fixed memory pool mechanism; if the maximum value of the second shared memory pool size is the same as that of the second shared memory pool If the difference between the minimum value of the memory pool size is greater than the fourth threshold, it is determined that the second shared memory pool mechanism is a dynamic memory pool mechanism.
  • the determining unit 710 in FIG. 7 may be used to execute the methods in S401 and S402 in FIG. 4, and the adjusting unit 720 may be used to execute the methods in S403 in FIG.
  • the embodiments of the present application will not be repeated here.
  • FIG. 8 is a schematic structural diagram of an apparatus 800 for dynamically managing a shared memory pool provided by an embodiment of the present application.
  • the memory management device 800 may include: at least one processor 810 and a communication interface 820.
  • the communication interface 820 may be used for the memory management device 800 to exchange information with other devices.
  • the program instructions are executed in the at least one processor 810, the memory
  • the management device 800 implements the various steps or methods or operations or functions performed by the device for dynamically managing the shared memory pool described above.
  • FIG. 9 is a schematic structural diagram of an apparatus for dynamically managing a shared memory pool provided by an embodiment of the present application.
  • the device 900 for dynamically managing a shared memory pool includes a communication module 910 and a memory management module 920.
  • the communication module 910 is used to exchange information with other modules.
  • the memory management module 920 is configured to determine a first shared memory pool mechanism, where the first shared memory pool mechanism is a fixed memory pool mechanism or a dynamic memory pool mechanism.
  • the memory management module 920 is further configured to determine a second shared memory pool mechanism suitable for the second business scenario according to the second business scenario, where the second shared memory pool mechanism is a fixed memory pool mechanism or a dynamic memory pool mechanism.
  • the memory management module 920 is further configured to adjust the first shared memory pool mechanism to the second shared memory pool mechanism when the second shared memory pool mechanism is different from the first shared memory pool mechanism.
  • the first shared memory pool mechanism is a shared memory pool mechanism suitable for the first business scenario.
  • the memory management module 920 determines a second shared memory pool mechanism suitable for the second business scenario according to the second business scenario, the memory management module 920 is further configured to: determine that the business scenario has changed from the first business scenario The scene is switched to the second business scene.
  • the first shared memory pool mechanism is an initialized shared memory pool mechanism.
  • the memory management module 920 determines a second shared memory pool mechanism suitable for the second business scenario according to the second business scenario, including: determining a second shared memory pool mechanism suitable for the second business scenario according to the second business scenario 2. Parameters of the shared memory pool; determining a second shared memory pool mechanism suitable for the second business scenario according to the parameters of the second shared memory pool. .
  • the parameters of the second shared memory pool include the maximum value and the minimum value of the size of the second shared memory pool.
  • the memory management module 920 determines the parameters of the second shared memory pool applicable to the second business scenario according to the second business scenario, including: acquiring the memory of the first time period in the second business scenario Usage information; determining the parameters of the second shared memory pool according to the memory usage information.
  • the memory management module 920 determines the parameters of the second shared memory pool according to the memory usage information, including:
  • the memory usage value in the second time in the second business scenario if the memory usage value is greater than the maximum size of the first shared memory pool, then use the memory usage value as the second shared memory
  • the maximum size of the memory pool or if the memory usage value is less than the maximum size of the first shared memory pool, then the memory usage value is taken as the maximum size of the second shared memory pool. If the memory usage value is greater than the minimum size of the first shared memory pool, then the memory usage value is taken as the minimum size of the second shared memory pool, or if the memory usage value is less than the If the minimum size of the first shared memory pool is the minimum value, the memory usage value is taken as the minimum size of the second shared memory pool.
  • the memory management module 920 determines the second shared memory pool mechanism suitable for the second business scenario according to the parameters of the second shared memory pool, including: if the maximum size of the second shared memory pool is equal to the size of the second shared memory pool The difference between the minimum value of the second shared memory pool size is less than the third threshold, then it is determined that the second shared memory pool mechanism is a fixed memory pool mechanism; if the maximum value of the second shared memory pool size is greater than that of the second shared memory pool The difference between the minimum value of the shared memory pool size is greater than the fourth threshold, then it is determined that the second shared memory pool mechanism is a dynamic memory pool mechanism
  • memory management module 920 in FIG. 9 may be used to execute the methods in S401 to S403 in FIG.
  • An embodiment of the present application also provides a terminal device, which includes the aforementioned device for dynamically managing the shared memory pool.
  • An embodiment of the present application also provides a computer program storage medium, which is characterized in that the computer program storage medium has program instructions, and when the program instructions are executed by a processor, the processor executes the method for dynamically managing the shared memory pool described above.
  • An embodiment of the present application also provides a chip system, characterized in that the chip system includes at least one processor, and when the program instructions are executed in the at least one processor, the at least one processor executes the dynamic management of the shared memory pool described above. method.
  • At least one refers to one or more
  • multiple refers to two or more.
  • And/or describes the association relationship of the associated objects, indicating that there can be three relationships, for example, A and/or B, which can mean the existence of A alone, A and B at the same time, and B alone. Among them, A and B can be singular or plural.
  • the character “/” generally indicates that the associated objects before and after are in an “or” relationship.
  • “The following at least one item” and similar expressions refer to any combination of these items, including any combination of single items or plural items.
  • At least one of a, b, and c can represent: a, b, c, a-b, a-c, b-c, or a-b-c, where a, b, and c can be single or multiple.
  • the disclosed system, device, and method can be implemented in other ways.
  • the device embodiments described above are merely illustrative, for example, the division of units is only a logical function division, and there may be other divisions in actual implementation, for example, multiple units or components can be combined or integrated. To another system, or some features can be ignored, or not implemented.
  • the displayed or discussed mutual coupling or direct coupling or communication connection may be indirect coupling or communication connection through some interfaces, devices or units, and may be in electrical, mechanical or other forms.
  • the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the objectives of the solutions of the embodiments.
  • the functional units in the various embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units may be integrated into one unit.
  • the function is realized in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer readable storage medium.
  • the technical solution of the present application essentially or the part that contributes to the existing technology or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including Several instructions are used to make a computer device (which may be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the methods in the various embodiments of the present application.
  • the aforementioned storage media include: U disk, mobile hard disk, read-only memory (read-only memory, ROM), random access memory (random access memory, RAM), magnetic disks or optical disks and other media that can store program codes. .

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Human Computer Interaction (AREA)
  • Software Systems (AREA)
  • Memory System (AREA)

Abstract

一种动态管理共享内存池的方法和装置,根据不同业务场景确定适用于当前业务场景的共享内存池机制,然后根据确定的结果动态调整内存池机制,提高系统的性能。该动态管理共享内存池的方法包括:确定第一共享内存池机制,所述第一共享内存池机制为固定内存池机制或动态内存池机制(S401);根据第二业务场景确定适合于所述第二业务场景的第二共享内存池机制,所述第二共享内存池机制为固定内存池机制或动态内存池机制(S402);在所述第二共享内存池机制和所述第一共享内存池机制不同时,将所述第一共享内存池机制调整为所述第二共享内存池机制(S403)。

Description

动态管理共享内存池的方法和装置 技术领域
本申请涉及存储领域,并且更具体地,涉及一种动态管理共享内存池的方法和装置。
背景技术
近年来,随着深度学习和嵌入式神经网络处理器(neural network processing units,NPU)的普及,越来越多的应用场景采用深度学习技术。为适用多种多样的应用场景,越来越多的满足训练和推理的统一应用平台被推出。针对基于推理的应用场景,如智能监控、人脸识别、图像分类、交通告警和跟踪等。无论是边缘计算还是中心侧计算,均需要实时将大力的数据从远端传输到具有人工智能(artificial intelligence,AI)处理能力的芯片侧进行推理任务。大量的数据传输不仅消耗网络带宽,同时还会占用大量的内存资源。针对后者,当前业界提供了内存池共享机制,通过复用内存的方式避免大量的申请和释放来提高数据传输效率和节约内存资源。目前常用的内存池共享机制有两种,一种是固定内存池机制,该方式对于内存使用比较稳定的场景,内存池大小可以提前预分配,避免不必要的缩放,节省一定内存,但是这种方式不够灵活,无法适用于多线程、数据流不固定的场景;另一种是动态内存池机制,该方式对于多线程、数据流存在波动等场景,通过动态扩缩内存池,按需分配内存,可以最大程度节省内存使用,但频繁扩缩,会造成系统性能出现波动。
发明内容
本申请提供一种动态管理共享内存池的方法和装置,根据不同业务场景确定适用于当前业务场景的共享内存池机制,然后根据确定的结果动态调整内存池机制,提高系统的性能。
第一方面,提供了一种动态管理共享内存池的方法,该方法包括:确定第一共享内存池机制,所述第一共享内存池机制为固定内存池机制或动态内存池机制;根据第二业务场景确定适合于所述第二业务场景的第二共享内存池机制,所述第二共享内存池机制为固定内存池机制或动态内存池机制;在所述第二共享内存池机制和所述第一共享内存池机制不同时,将所述第一共享内存池机制调整为所述第二共享内存池机制。
本申请实施例的动态管理共享内存池的方法针对不同的业务场景采用不同的共享内存池机制,根据不同业务场景确定适用于当前业务场景的共享内存池机制,然后根据确定的结果动态调整内存池机制,充分发挥不同共享内存池机制的优点,使其更好地满足业务场景的需求。
结合第一方面,在一种可能的实现方式中,所述第一共享内存池机制为适合于第一业务场景的共享内存池机制;所述根据第二业务场景确定适合于所述第二业务场景的第二共享内存池机制之前,还包括:确定业务场景已经从所述第一业务场景切换到所述第二业务场景。
本申请实施例的动态管理共享内存池的方法可以适用于在业务场景发生切换时,如果适用于当前业务场景的共享内存池机制也改变了,则可以重新确定适用于当前业务场景的共享内存池机制。
结合第一方面,在一种可能的实现方式中,所述第一共享内存池机制为初始化的共享内存池机制。
本申请实施例的动态管理共享内存池的方法可以适用于在系统初始化的共享内存池不适用于当前的业务场景时,可以重新确定适用于当前业务场景的共享内存池机制。
结合第一方面,在一种可能的实现方式中,所述根据所述第二业务场景确定适合于所述第二业务场景的第二共享内存池机制,包括:根据所述第二业务场景确定适用于所述第二业务场景的第二共享内存池的参数;根据所述第二共享内存池的参数确定适用于所述第二业务场景的第二共享内存池机制。
结合第一方面,在一种可能的实现方式中,所述第二共享内存池的参数包括所述第二共享内存池大小的最大值和最小值。
本申请实施例的动态管理共享内存池的方法中,可以先确定共享内存池的大小的最大值和最小值,根据共享内存池的大小的最大值和最小值即可确定该共享内存池的机制。
结合第一方面,在一种可能的实现方式中,所述根据所述第二业务场景确定适用于所述第二业务场景的第二共享内存池的参数,包括:获取所述第二业务场景中,第一时间段的内存使用信息;根据所述内存使用信息确定所述第二共享内存池的参数。
本申请实施例的动态管理共享内存池的方法,根据实际的内存使用信息来确定共享内存池的参数,可以得出更加适用于当前业务场景的共享内存池参数。
结合第一方面,在一种可能的实现方式中,所述根据所述内存使用信息确定所述第二共享内存池的参数,包括:获取所述第二业务场景中,第二时间内的内存使用值;如果所述内存使用值大于所述第一共享内存池大小的最大值,则将所述内存使用值作为所述第二共享内存池大小的最大值,或者,如果所述内存使用值小于所述第一共享内存池大小的最大值,则将所述内存使用值作为所述第二共享内存池大小的最大值。如果所述内存使用值大于所述第一共享内存池大小的最小值,则将所述内存使用值作为所述第二共享内存池大小的最小值,或者,如果所述内存使用值小于所述第一共享内存池大小的最小值,则将所述内存使用值作为所述第二共享内存池大小的最小值。
本申请实施例的动态管理共享内存池的方法,提供了一种根据实际内存使用值来确定共享内存池参数的方法,将实际内存使用值作为共享内存池的大小,使得该共享内存池可以更加适合当前业务场景,直观且方便。
结合第一方面,在一种可能的实现方式中,所述根据所述第二共享内存池的参数确定适用于所述第二业务场景的第二共享内存池机制,包括:如果所述第二共享内存池大小的最大值与所述第二共享内存池大小的最小值的差值小于第三阈值,则确定所述第二共享内存池机制为固定内存池机制;如果所述第二共享内存池大小的最大值与所述第二共享内存池大小的最小值的差值大于第四阈值,则确定所述第二共享内存池机制为动态内存池机制。
第二方面,提供了一种动态管理共享内存池的装置,该装置包括:确定单元,用于确定第一共享内存池机制,所述第一共享内存池机制为固定内存池机制或动态内存池机制; 所述确定单元还用于根据第二业务场景确定适合于所述第二业务场景的第二共享内存池机制,所述第二共享内存池机制为固定内存池机制或动态内存池机制;调整单元,用于在所述第二共享内存池机制和所述第一共享内存池机制不同时,将所述第一共享内存池机制调整为所述第二共享内存池机制。
本申请实施例还提供一种动态管理共享内存池的装置,该装置用于实现上述动态管理共享内存池的方法。
结合第二方面,在一种可能的实现方式中,所述第一共享内存池机制为适合于第一业务场景的共享内存池机制;所述确定单元在根据第二业务场景确定适合于所述第二业务场景的第二共享内存池机制之前,所述确定单元还用于:确定业务场景已经从所述第一业务场景切换到所述第二业务场景。
结合第二方面,在一种可能的实现方式中,所述第一共享内存池机制为初始化的共享内存池机制。
结合第二方面,在一种可能的实现方式中,所述确定单元根据第二业务场景确定适合于所述第二业务场景的第二共享内存池机制,包括:根据所述第二业务场景确定适用于所述第二业务场景的第二共享内存池的参数;根据所述第二共享内存池的参数确定适用于所述第二业务场景的第二共享内存池机制。
结合第二方面,在一种可能的实现方式中,所述第二共享内存池的参数包括所述第二共享内存池大小的最大值和最小值。
结合第二方面,在一种可能的实现方式中,所述确定单元根据所述第二业务场景确定适用于所述第二业务场景的第二共享内存池的参数,包括:获取所述第二业务场景中,第一时间段的内存使用信息;根据所述内存使用信息确定所述第二共享内存池的参数。
结合第二方面,在一种可能的实现方式中,所述确定单元根据所述内存使用信息确定所述第二共享内存池的参数,包括:获取所述第二业务场景中,第二时间内的内存使用值;
如果所述内存使用值大于所述第一共享内存池大小的最大值,则将所述内存使用值作为所述第二共享内存池大小的最大值,或者,如果所述内存使用值小于所述第一共享内存池大小的最大值,则将所述内存使用值作为所述第二共享内存池大小的最大值。如果所述内存使用值大于所述第一共享内存池大小的最小值,则将所述内存使用值作为所述第二共享内存池大小的最小值,或者,如果所述内存使用值小于所述第一共享内存池大小的最小值,则将所述内存使用值作为所述第二共享内存池大小的最小值。
结合第二方面,在一种可能的实现方式中,所述确定单元根据所述第二共享内存池的参数确定适用于所述第二业务场景的第二共享内存池机制,包括:如果所述第二共享内存池大小的最大值与所述第二共享内存池大小的最小值的差值小于第三阈值,则确定所述第二共享内存池机制为固定内存池机制;如果所述第二共享内存池大小的最大值与所述第二共享内存池大小的最小值的差值大于第四阈值,则确定所述第二共享内存池机制为动态内存池机制。
第三方面,提供了一种计算机程序存储介质,其特征在于,计算机程序存储介质具有程序指令,当程序指令被处理器执行时,使得处理器执行第一方面和第一方面的任一种实现方式的方法。
第四方面,提供了一种芯片,其特征在于,芯片包括至少一个处理器,当程序指令被 至少一个处理器中执行时,使得至少一个处理器执行第一方面和第一方面的任一种实现方式的方法。
第五方面,提供一种终端设备,其包括前述的动态管理共享内存池的装置。
附图说明
图1是本申请实施例的现有的两种内存池共享机制的示意性框图;
图2是本申请实施例的动态管理共享内存池方法的可能应用场景的示意性框图;
图3是本申请实施例的动态管理共享内存池方法的一种应用场景;
图4是本申请实施例的动态管理共享内存池方法的示意性流程图;
图5是本申请实施例的动态管理共享内存池方法的一种具体实现的示意性框图;
图6是本申请实施例的系统的示意性架构图;
图7是本申请实施例提供的一种动态管理共享内存池的装置的示意性结构图;
图8是本申请实施例提供的另一种动态管理共享内存池的装置的示意性结构图;
图9是本申请实施例提供的又一种动态管理共享内存池的装置的示意性结构图。
具体实施方式
下面将结合附图,对本申请中的技术方案进行描述。
共享内存池是预先申请的适当大小的内存作为一个内存池,供多个进程访问。其中,多个进程可以是同一设备的不同进程,也可以是不同设备的不同进程。图1示出了现有的两种内存池共享机制,包括固定内存池机制和动态内存池机制。其中,固定内存池机制即预先分配的内存池大小已经确定,是固定不变的。内存池不会根据业务变化而进行动态扩缩,这种机制对于内存使用比较稳定的场景,内存池大小可以提前预分配,避免不必要的缩放,节省一定的内存,但是该机制不够灵活,无法适用于多线程、数据流不固定的场景。在多线程情况下,所需内存池大小无法事先确定,会导致固定内存池被快速耗尽,后续内存申请将会阻塞,即使还有物理内存,但用户业务却申请不到内存,导致业务性能瓶颈。动态内存池机制即内存池大小可以按需变化。这种机制下内存池大小为一个动态范围[Min,Max],对于多线程、数据流存在波动等场景,通过动态扩缩内存池、按需分配内存,可以最大程度节省内存使用。但是内存扩缩同时也会导致性能波动,对于多进程/多线程等复杂业务场景需要频繁扩缩,造成系统性能波动。
内存池机制的应用场景多种多样,图2示出了三种可能的应用场景,包括:
场景A:单路视频流,数据输入稳定;
场景B:单路视频流,数据流输入白天波动,晚上平稳,内存消耗有一定规律;
场景C:多路视频流,数据输入动态变化,内存消耗存在波动。
在现有技术中,通常是确定一种内存机制来适用所有的场景。即场景A、B、C都使用固定内存池,或者场景A、B、C都使用动态内存池。实际上,场景A适合使用固定内存池机制,场景C适合使用动态内存池机制,场景B中白天适合动态内存池,晚上适合固定内存池。并且无论是动态内存池还是固定内存池,其内存大小和范围等关键内存池配置参数都是根据经验人工预先设置,无法真正适应不同场景和不同需求。针对开放应用场景,尤其是基础计算平台,必然存在多种不同业务场景。而目前没有一种方案可以针对应 用场景进行动态适配,预先确定的内存池机制各有优缺点,无法适用于所有的用户业务场景。本申请实施例的动态管理共享内存池方法,可以通过预先学习的方式,动态学习各个场景和内存池机制之间的适配关系,然后根据学习到的结果动态调整内存池机制,使场景A采用固定内存池,场景C采用动态内存池,场景B根据业务场景动态切换固定内存池和动态内存池,使得业务性能达到最佳。
本申请实施例通过寻找不同应用场景和内存池机制之间的最佳匹配关系,根据应用场景动态调整内存池机制,充分发挥每一种内存池机制的优点,规避其缺点。通过充分发挥固定内存池的快速、高效和稳定的优势,以及动态内存池灵活、节约和按需的优势,解决单一内存池机制不能动态适配不同场景的问题。
应理解,上述业务场景A、B、C只是对业务场景的举例,并不构成对本申请实施例的限定,除了图2中的业务场景,本申请实施例的动态管理共享内存池方法还可以应用于其他业务场景。
图3示出了本申请实施例的动态管理共享内存池方法的一种应用场景。在当前广泛应用的智能安防、平安城市等应用场景,大量视频或者图片需要通过智能摄像头传输到计算中心进行推理处理,具体任务包括识别(机动车、非机动车、人脸等)、图片分类、检索和跟踪(车辆、行人等),以上大部分任务均依赖AI芯片的处理能力。随着AI芯片处理能力的不断提升,目前市场上各种类型的AI NPU其AI计算能力也不相同。为充分发挥不同芯片的处理能力,单芯片会同时处理多个推理任务,例如多路视频同时接入,或者多个芯片协同处理单个推理任务,例如CPU密集型的检索等。本申请实施例的动态管理共享内存池方法,当多种多样的业务应用传输数据流时,用户无需事先分析业务流行为,系统可以动态适应不同场景下的内存需求,使系统性能达到最优。
图4示出了本申请实施例的动态管理共享内存池方法的示意性流程图,如图4所示,包括步骤401至步骤403,以下对这些步骤进行详细介绍。
S401,确定第一共享内存池机制,第一共享内存池机制为固定内存池机制或动态内存池机制。
可选的,第一共享内存池机制为初始化的共享内存池机制。即第一共享内存池机制可以是预设的固定内存池机制或动态内存池机制,也可以是系统随机初始化的一种共享内存池机制。在根据业务场景确定适合于当前业务场景的共享内存池机制之后,再对此时的共享内存池机制进行调整。
可选的,第一共享内存池机制为适合于第一业务场景的共享内存池机制;根据第二业务场景确定适合于所述第二业务场景的第二共享内存池机制之前,还包括:确定业务场景已经从第一业务场景切换到第二业务场景。具体地,业务场景可以是图2中示例性列出的业务场景A、B、C,也可以是其他业务场景。
S402,根据第二业务场景确定适合于所述第二业务场景的第二共享内存池机制,所述第二共享内存池机制为固定内存池机制或动态内存池机制。
具体地,先根据所述第二业务场景确定适用于所述第二业务场景的第二共享内存池的参数;再根据所述第二共享内存池的参数确定适用于所述第二业务场景的第二共享内存池机制。
其中,共享内存池的参数包括共享内存池大小的最大值和最小值。当共享内存池为固 定内存池时,共享内存池大小的最大值和最小值的差值小于第三阈值,其中,第三阈值可以是人为规定的值。
本申请实施例的动态管理共享内存池的方法中,根据所述第二业务场景确定适用于所述第二业务场景的第二共享内存池的参数,可以先获取所述第二业务场景中,第一时间段的内存使用信息,然后根据所述内存使用信息确定所述第二共享内存池的参数。例如,内存使用信息可以是内存使用值,如果所述内存使用值大于所述第一共享内存池大小的最大值,则将所述内存使用值作为所述第二共享内存池大小的最大值,或者,如果所述内存使用值小于所述第一共享内存池大小的最大值,则将所述内存使用值作为所述第二共享内存池大小的最大值。如果所述内存使用值大于所述第一共享内存池大小的最小值,则将所述内存使用值作为所述第二共享内存池大小的最小值,或者,如果所述内存使用值小于所述第一共享内存池大小的最小值,则将所述内存使用值作为所述第二共享内存池大小的最小值。又例如,内存使用信息可以是内存使用率(内存使用值/内存池总大小),如果所述内存使用率大于第一阈值,则将所述第一共享内存池机制的第一共享内存池大小的最大值乘以第一系数,以作为所述第二共享内存池大小的最大值,所述第一系数大于1,或者,将所述第一共享内存池大小的最小值乘以第二系数,以作为所述第二共享内存池大小的最小值,所述第二系数小于1;如果所述内存使用率小于第二阈值,则将所述第一共享内存池大小的最大值乘以第三系数,以作为所述第二共享内存池大小的最大值,所述第三系数小于1,或者,将所述第一共享内存池大小的最小值乘以第四系数,以作为所述第二共享内存池大小的最四值,所述第一系数大于1。
应理解,业务场景中的内存使用信息除了上述内存使用值和内存使用率,还可以包括当前内存池需要增加的内存块个数、当前内存池需要减少的内存块个数等内存使用信息。
应理解,以上根据所述第二业务场景确定适用于所述第二业务场景的第二共享内存池的参数的方法只是对本申请实施例的动态管理共享内存池的方法的举例,除了上述方法,本申请实施例还可以采用学习规则集来确定适用于所述第二业务场景的第二共享内存池的参数。其中,学习规则集可以是IF A THEN B构成的先验规则。
本申请实施例的动态管理共享内存池的方法中,根据所述第二共享内存池的参数确定适用于所述第二业务场景的第二共享内存池机制,可以按照如下方法来确定:如果所述第二共享内存池大小的最大值与所述第二共享内存池大小的最小值的差值小于第三阈值,则确定所述第二共享内存池机制为固定内存池机制;如果所述第二共享内存池大小的最大值与所述第二共享内存池大小的最小值的差值大于第四阈值,则确定所述第二共享内存池机制为动态内存池机制。其中,第四阈值可以是人为规定的值。
S403,在所述第二共享内存池机制和所述第一共享内存池机制不同时,将所述第一共享内存池机制调整为所述第二共享内存池机制。
应理解,如果第二共享内存池机制和所述第一共享内存池机制相同时,则不做调整。
应理解,本申请实施例的动态管理共享内存池方法为一种动态循环的方法,在根据业务场景确定适用于当前业务场景的共享内存池机制之后,本申请实施例的方法还包括,对业务场景的变化进行实时监控。例如,可以根据实时的内存使用信息(例如内存使用值或内存使用率)调整适用于当前业务场景的共享内存池机制的参数,使得共享内存池的大小或大小范围更加适合于当前业务场景;如果业务场景发生了切换,使得当前的共享内存池 机制不再适合与当前的业务场景,则还可以根据切换后的业务场景重新确定适用于当前业务场景的共享内存池机制。
应理解,本申请实施例的动态管理共享内存池方法可以根据不同的业务场景动态切换适用于当前业务场景的共享内存池机制和动态调整适用于当前业务场景的共享内存池的参数,但是由于实际的业务场景多种多样无法穷举,因此本申请实施例的动态管理共享内存池方法与实际的业务场景没有必然的联系,而是根据实际业务场景的内存使用信息来动态切换适用于当前业务场景的共享内存池机制和动态调整适用于当前业务场景的共享内存池机制的参数。
图5示出了本申请实施例的动态管理共享内存池方法的一种具体实现的示意性框图,如图5所示,主要包括学习规则集(learning rules)、内存超参数(memory hyper-parameter)、内存适配器(memory adapter)和共享内存池机制(shared memory mechanism)。
其中,基于数据流和学习规则集构成两个动态反馈循环:循环A和循环B。循环A是根据输入的数据和学习规则集确定第一阶段的内存超参数,然后根据内存超参数确定当前业务场景的最佳匹配的共享内存机制。循环B是根据学习规则集调整内存超参数,当发生业务场景切换时,当前的共享内存池机制可能不再适用于当前的业务场景,则根据调整后的内存超参数确定与当前业务场景的最佳匹配的共享内存池机制。
学习规则集主要包括一组IF A THEN B构成的先验规则,该先验规则如下所示:
1、If UsedBlocks>Min&&Duration>TimeThreshold&&RepeatedTimes>TimesThreshold,Then Min=min(UsedBlocks);
2、If MemUsageRate>95%&&Duration>TimeThreshold&&RepeatedTimes>TimesThreshold,Then Max=Max*(1+10%);
3、If EnlargeCount<enThreshold&&ReduceCount<reThreshold,Then IsFixed=true;
4、If Max–Min<LowThreshold&&IsFixed==false,Then IsFixed=true;
5、If Max–Min>HighThreshold&&IsFixed==true,Then IsFixed=false;
6、If Max-Min<LowThreshold,Then FixedMemSize=Max.
其中:
1、UsedBlocks:已使用的内存块个数;Duration>TimeThreshold:被使用的内存块连续超过某一个阈值时间;RepeatedTimes>TimesThreshold:该情况出现的次数大于某一个阈值次数;其中Min=min(UsedBlocks)也可以是其他限定,例如,Min的值可以设定为已使用的内存块个数中出现频率最高的一个较小值,此处只是示例,本申请实施例对此不作具体限定;
2、MemUsageRate:当前内存使用率,即已使用内存块大小/内存池总大小;其中,Max=Max*(1+10%)也可以是其他限定,例如,可以是其他百分比,或者将当前的Max的值加上一个具体的值例如200M,此处只是示例,本申请实施例对此不作具体限定;
3、EnlargeCount<enThreshold:需要增加的内存块个数小于系统允许增加的上限;ReduceCount<reThreshold:需要减少的内存块个数小于系统允许减少的上限;
4、Max–Min<LowThreshold:动态内存池范围最大值和最小值间隔超过某一个最小阈值;
5、Max–Min>HighThreshold:动态内存池范围最大值和最小值间隔超过某一个最大 阈值。
内存超参数包括:固定内存池机制参数FixedMemSize,用于表示内存池大小;动态内存池机制参数Min,用于表示内存池大小的最小值;动态内存池机制参数Max,用于表示内存池大小的最大值;内存池机制选择按钮IsFixed,用于表示是否进行内存池切换。
内存适配器根据IsFixed的值来决定在动态内存池机制和固定内存池机制之间进行切换。同时,在切换过程中根据学习到的内存超参数来设置当前共享内存池机制的配置,即内存池的大小或内存池的大小范围。
本申请实施例中的共享内存池机制主要包括固定内存池机制和动态内存池机制。其中,固定内存池机制的内存池大小是固定的,不会随业务变化进行调整,所有申请内存的操作都在该内存池内完成;动态内存池机制的内存池大小会随着业务需求进行动态调整,其调整范围一般为一个固定大小范围区间[Min,Max]。
本申请实施例的动态管理共享内存池方法可以应用在推理计算平台等场景,部署在相关设备的计算节点上,通过对基材平台软件的改造,能够实现在不同业务场景下不同共享内存池机制的动态适配,最大程度发挥每一种共享内存池机制的优点。具体地,共享内存池机制为动态内存池机制时,当内存池使用的内存块数长时间居高不下,则内存池大小的最小值Min可以动态调整;当内存池使用率长时间高于阈值(95%)时,则内存池大小的最大值Max可以动态调整;当内存池大小的最小值Min约等于内存池大小的最大值Max,动态内存池可以被调整为固定内存池。
应理解,图5中的示例只是对本申请实施例动态管理共享内存池方法的一种举例,并不构成对本申请实施例动态管理共享内存池方法的限定。上述学习规则集也可以是其他的规则,或者上述先验规则中的限定也可以是其他限定方式,或者上述非专有名词也可以由其他相同意思的名词代替。基于相同的构思,本领域的技术人员可以在上述示例中做出等价变换,以达到实现相同或相似的效果。基于这些等价变换得到的动态管理共享内存池方法,依然能够达到本申请实施例的动态管理共享内存池方法的技术效果。因此,这些等价变换均应落入本申请的保护范围。
图6示出了本申请实施例的系统的示意性架构图。如图6所示,系统首先获取相关应用的数据,具体地,包括当前业务场景下的内存使用信息。然后结合学习规则可以得到内存超参数,其中学习规则为系统初始化时预先设置的规则集合,用来指导系统如何学习;内存超参数用来确定共享内存池机制以及共享内存池的内存大小或内存大小的范围。场景-内存机制适配器用于根据内存超参数切换动态内存池机制和固定内存池机制。确定好适用于当前业务场景的共享内存池机制后,再对相关应用的数据进行存储以便后续处理。
图7是本申请实施例提供的一种动态管理共享内存池的装置700的示意性结构图。内存管理的装置700包括确定单元710,调整单元720。
确定单元710用于,确定第一共享内存池机制,所述第一共享内存池机制为固定内存池机制或动态内存池机制。
确定单元710还用于,根据第二业务场景确定适合于所述第二业务场景的第二共享内存池机制,所述第二共享内存池机制为固定内存池机制或动态内存池机制。
调整单元720用于,在所述第二共享内存池机制和所述第一共享内存池机制不同时,将所述第一共享内存池机制调整为所述第二共享内存池机制。
可选的,所述第一共享内存池机制为适合于第一业务场景的共享内存池机制。
所述确定单元710在根据第二业务场景确定适合于所述第二业务场景的第二共享内存池机制之前,所述确定单元710还用于:确定业务场景已经从所述第一业务场景切换到所述第二业务场景。
可选的,第一共享内存池机制为初始化的共享内存池机制。
可选地,确定单元720根据第二业务场景确定适合于所述第二业务场景的第二共享内存池机制,包括:根据所述第二业务场景确定适用于所述第二业务场景的第二共享内存池的参数;根据所述第二共享内存池的参数确定适用于所述第二业务场景的第二共享内存池机制。。
可选的,第二共享内存池的参数包括所述第二共享内存池大小的最大值和最小值。
可选地,确定单元720根据所述第二业务场景确定适用于所述第二业务场景的第二共享内存池的参数,包括:获取所述第二业务场景中,第一时间段的内存使用信息;根据所述内存使用信息确定所述第二共享内存池的参数。
可选地,确定单元720根据所述内存使用信息确定所述第二共享内存池的参数,包括:
获取所述第二业务场景中,第二时间内的内存使用值;如果所述内存使用值大于所述第一共享内存池大小的最大值,则将所述内存使用值作为所述第二共享内存池大小的最大值,或者,如果所述内存使用值小于所述第一共享内存池大小的最大值,则将所述内存使用值作为所述第二共享内存池大小的最大值。如果所述内存使用值大于所述第一共享内存池大小的最小值,则将所述内存使用值作为所述第二共享内存池大小的最小值,或者,如果所述内存使用值小于所述第一共享内存池大小的最小值,则将所述内存使用值作为所述第二共享内存池大小的最小值。
可选地,确定单元720根据第二共享内存池的参数确定适用于所述第二业务场景的第二共享内存池机制,包括:如果所述第二共享内存池大小的最大值与所述第二共享内存池大小的最小值的差值小于第三阈值,则确定所述第二共享内存池机制为固定内存池机制;如果所述第二共享内存池大小的最大值与所述第二共享内存池大小的最小值的差值大于第四阈值,则确定所述第二共享内存池机制为动态内存池机制。
应理解,图7中的确定单元710可以用于执行上述图4中S401和S402中的方法,调整单元720可以用于执行上述图4中S403中的方法,具体可以参照上述对于图4的描述,为了简洁,本申请实施例在此不再赘述。
图8是本申请一个实施例提供的动态管理共享内存池的装置800的示意性结构图。内存管理的装置800可包括:至少一个处理器810和通信接口820,通信接口820可用于内存管理的装置800与其他装置进行信息交互,当程序指令在至少一个处理器810中执行时,使得内存管理的装置800实现前文中的动态管理共享内存池的装置执行的各个步骤或方法或操作或功能。
图9是本申请实施例提供的一种动态管理共享内存池装置的示意性结构图。动态管理共享内存池装置900包括通信模块910、内存管理模块920。
通信模块910用于,与其他模块进行信息交互。
内存管理模块920用于,确定第一共享内存池机制,所述第一共享内存池机制为固定内存池机制或动态内存池机制。
内存管理模块920还用于,根据第二业务场景确定适合于所述第二业务场景的第二共享内存池机制,所述第二共享内存池机制为固定内存池机制或动态内存池机制。
内存管理模块920还用于,在所述第二共享内存池机制和所述第一共享内存池机制不同时,将所述第一共享内存池机制调整为所述第二共享内存池机制。
可选的,所述第一共享内存池机制为适合于第一业务场景的共享内存池机制。
所述内存管理模块920在根据第二业务场景确定适合于所述第二业务场景的第二共享内存池机制之前,所述内存管理模块920还用于:确定业务场景已经从所述第一业务场景切换到所述第二业务场景。
可选的,第一共享内存池机制为初始化的共享内存池机制。
可选地,内存管理模块920根据第二业务场景确定适合于所述第二业务场景的第二共享内存池机制,包括:根据所述第二业务场景确定适用于所述第二业务场景的第二共享内存池的参数;根据所述第二共享内存池的参数确定适用于所述第二业务场景的第二共享内存池机制。。
可选的,第二共享内存池的参数包括所述第二共享内存池大小的最大值和最小值。
可选地,内存管理模块920根据所述第二业务场景确定适用于所述第二业务场景的第二共享内存池的参数,包括:获取所述第二业务场景中,第一时间段的内存使用信息;根据所述内存使用信息确定所述第二共享内存池的参数。
可选地,内存管理模块920根据所述内存使用信息确定所述第二共享内存池的参数,包括:
获取所述第二业务场景中,第二时间内的内存使用值;如果所述内存使用值大于所述第一共享内存池大小的最大值,则将所述内存使用值作为所述第二共享内存池大小的最大值,或者,如果所述内存使用值小于所述第一共享内存池大小的最大值,则将所述内存使用值作为所述第二共享内存池大小的最大值。如果所述内存使用值大于所述第一共享内存池大小的最小值,则将所述内存使用值作为所述第二共享内存池大小的最小值,或者,如果所述内存使用值小于所述第一共享内存池大小的最小值,则将所述内存使用值作为所述第二共享内存池大小的最小值。
可选地,内存管理模块920根据第二共享内存池的参数确定适用于所述第二业务场景的第二共享内存池机制,包括:如果所述第二共享内存池大小的最大值与所述第二共享内存池大小的最小值的差值小于第三阈值,则确定所述第二共享内存池机制为固定内存池机制;如果所述第二共享内存池大小的最大值与所述第二共享内存池大小的最小值的差值大于第四阈值,则确定所述第二共享内存池机制为动态内存池机制
应理解,图9中的内存管理模块920可以用于执行上述图4中S401至S403中的方法,具体可以参照上述对于图4的描述,为了简洁,本申请实施例在此不再赘述。
本申请实施例还提供一种终端设备,其包括前述的动态管理共享内存池的装置。
本申请实施例还提供一种计算机程序存储介质,其特征在于,计算机程序存储介质具有程序指令,当程序指令被处理器执行时,使得处理器执行前文中动态管理共享内存池的方法。
本申请实施例还提供一种芯片系统,其特征在于,芯片系统包括至少一个处理器,当程序指令在至少一个处理器中执行时,使得至少一个处理器执行前文中的动态管理共享内 存池的方法。
本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。
本申请实施例中,“至少一个”是指一个或者多个,“多个”是指两个或两个以上。“和/或”,描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示单独存在A、同时存在A和B、单独存在B的情况。其中A,B可以是单数或者复数。字符“/”一般表示前后关联对象是一种“或”的关系。“以下至少一项”及其类似表达,是指的这些项中的任意组合,包括单项或复数项的任意组合。例如,a,b和c中的至少一项可以表示:a,b,c,a-b,a-c,b-c,或a-b-c,其中a,b,c可以是单个,也可以是多个。所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统、装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。
在本申请所提供的几个实施例中,应该理解到,所揭露的系统、装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。
作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。
功能如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本申请各个实施例方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(read-only memory,ROM)、随机存取存储器(random access memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。
以上,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以权利要求的保护范围为准。

Claims (18)

  1. 一种动态管理共享内存池的方法,其特征在于,包括:
    确定第一共享内存池机制,所述第一共享内存池机制为固定内存池机制或动态内存池机制;
    根据第二业务场景确定适合于所述第二业务场景的第二共享内存池机制,所述第二共享内存池机制为固定内存池机制或动态内存池机制;
    在所述第二共享内存池机制和所述第一共享内存池机制不同时,将所述第一共享内存池机制调整为所述第二共享内存池机制。
  2. 根据权利要求1所述的方法,其特征在于,
    所述第一共享内存池机制为适合于第一业务场景的共享内存池机制;
    所述根据第二业务场景确定适合于所述第二业务场景的第二共享内存池机制之前,还包括:
    确定业务场景已经从所述第一业务场景切换到所述第二业务场景。
  3. 根据权利要求1所述的方法,其特征在于,所述第一共享内存池机制为初始化的共享内存池机制。
  4. 根据权利要求1至3中任一项所述的方法,其特征在于,所述根据所述第二业务场景确定适合于所述第二业务场景的第二共享内存池机制,包括:
    根据所述第二业务场景确定适用于所述第二业务场景的第二共享内存池的参数;
    根据所述第二共享内存池的参数确定适用于所述第二业务场景的第二共享内存池机制。
  5. 根据权利要求4所述的方法,其特征在于,所述第二共享内存池的参数包括所述第二共享内存池大小的最大值和最小值。
  6. 根据权利要求4或5所述的方法,其特征在于,所述根据所述第二业务场景确定适用于所述第二业务场景的第二共享内存池的参数,包括:
    获取所述第二业务场景中,第一时间段的内存使用信息;
    根据所述内存使用信息确定所述第二共享内存池的参数。
  7. 根据权利要求6所述的方法,其特征在于,所述根据所述内存使用信息确定所述第二共享内存池的参数,包括:
    获取所述第二业务场景中,第二时间内的内存使用值;
    如果所述内存使用值大于所述第一共享内存池大小的最大值,则将所述内存使用值作为所述第二共享内存池大小的最大值,或者,
    如果所述内存使用值小于所述第一共享内存池大小的最大值,则将所述内存使用值作为所述第二共享内存池大小的最大值;
    如果所述内存使用值大于所述第一共享内存池大小的最小值,则将所述内存使用值作为所述第二共享内存池大小的最小值,或者,
    如果所述内存使用值小于所述第一共享内存池大小的最小值,则将所述内存使用值作为所述第二共享内存池大小的最小值。
  8. 根据权利要求5至7中任一项所述的方法,其特征在于,所述根据所述第二共享 内存池的参数确定适用于所述第二业务场景的第二共享内存池机制,包括:
    如果所述第二共享内存池大小的最大值与所述第二共享内存池大小的最小值的差值小于第三阈值,则确定所述第二共享内存池机制为固定内存池机制;
    如果所述第二共享内存池大小的最大值与所述第二共享内存池大小的最小值的差值大于第四阈值,则确定所述第二共享内存池机制为动态内存池机制。
  9. 一种动态管理共享内存池的装置,其特征在于,包括:
    确定单元,用于确定第一共享内存池机制,所述第一共享内存池机制为固定内存池机制或动态内存池机制;
    所述确定单元还用于根据第二业务场景确定适合于所述第二业务场景的第二共享内存池机制,所述第二共享内存池机制为固定内存池机制或动态内存池机制;
    调整单元,用于在所述第二共享内存池机制和所述第一共享内存池机制不同时,将所述第一共享内存池机制调整为所述第二共享内存池机制。
  10. 根据权利要求9所述的装置,其特征在于,
    所述第一共享内存池机制为适合于第一业务场景的共享内存池机制;
    所述确定单元在根据第二业务场景确定适合于所述第二业务场景的第二共享内存池机制之前,所述确定单元还用于:
    确定业务场景已经从所述第一业务场景切换到所述第二业务场景。
  11. 根据权利要求9所述的装置,其特征在于,所述第一共享内存池机制为初始化的共享内存池机制。
  12. 根据权利要求9至11中任一项所述的装置,其特征在于,所述确定单元根据第二业务场景确定适合于所述第二业务场景的第二共享内存池机制,包括:
    根据所述第二业务场景确定适用于所述第二业务场景的第二共享内存池的参数;
    根据所述第二共享内存池的参数确定适用于所述第二业务场景的第二共享内存池机制。
  13. 根据权利要求12所述的装置,其特征在于,所述第二共享内存池的参数包括所述第二共享内存池大小的最大值和最小值。
  14. 根据权利要求12或13所述的装置,其特征在于,所述确定单元根据所述第二业务场景确定适用于所述第二业务场景的第二共享内存池的参数,包括:
    获取所述第二业务场景中,第一时间段的内存使用信息;
    根据所述内存使用信息确定所述第二共享内存池的参数。
  15. 根据权利要求14所述的装置,其特征在于,所述确定单元根据所述内存使用信息确定所述第二共享内存池的参数,包括:
    获取所述第二业务场景中,第二时间内的内存使用值;
    如果所述内存使用值大于所述第一共享内存池大小的最大值,则将所述内存使用值作为所述第二共享内存池大小的最大值,或者,
    如果所述内存使用值小于所述第一共享内存池大小的最大值,则将所述内存使用值作为所述第二共享内存池大小的最大值;
    如果所述内存使用值大于所述第一共享内存池大小的最小值,则将所述内存使用值作为所述第二共享内存池大小的最小值,或者,
    如果所述内存使用值小于所述第一共享内存池大小的最小值,则将所述内存使用值作为所述第二共享内存池大小的最小值。
  16. 根据权利要求13至15中任一项所述的装置,其特征在于,所述确定单元根据所述第二共享内存池的参数确定适用于所述第二业务场景的第二共享内存池机制,包括:
    如果所述第二共享内存池大小的最大值与所述第二共享内存池大小的最小值的差值小于第三阈值,则确定所述第二共享内存池机制为固定内存池机制;
    如果所述第二共享内存池大小的最大值与所述第二共享内存池大小的最小值的差值大于第四阈值,则确定所述第二共享内存池机制为动态内存池机制。
  17. 一种计算机程序存储介质,其特征在于,所述计算机程序存储介质具有程序指令,当所述程序指令被处理器执行时,使得所述处理器执行如权利要求1至8中任一项所述的方法。
  18. 一种芯片,其特征在于,所述芯片包括至少一个处理器,当程序指令被所述至少一个处理器中执行时,使得所述至少一个处理器执行如权利要求1至8中任一项所述的方法。
PCT/CN2020/091686 2020-05-22 2020-05-22 动态管理共享内存池的方法和装置 WO2021232386A1 (zh)

Priority Applications (4)

Application Number Priority Date Filing Date Title
EP20936608.7A EP4141671A4 (en) 2020-05-22 2020-05-22 METHOD AND DEVICE FOR DYNAMIC MANAGEMENT FOR A SHARED MEMORY POOL
CN202080101088.XA CN115668144A (zh) 2020-05-22 2020-05-22 动态管理共享内存池的方法和装置
PCT/CN2020/091686 WO2021232386A1 (zh) 2020-05-22 2020-05-22 动态管理共享内存池的方法和装置
US17/990,990 US20230085979A1 (en) 2020-05-22 2022-11-21 Method and apparatus for dynamically managing shared memory pool

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2020/091686 WO2021232386A1 (zh) 2020-05-22 2020-05-22 动态管理共享内存池的方法和装置

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US17/990,990 Continuation US20230085979A1 (en) 2020-05-22 2022-11-21 Method and apparatus for dynamically managing shared memory pool

Publications (1)

Publication Number Publication Date
WO2021232386A1 true WO2021232386A1 (zh) 2021-11-25

Family

ID=78709126

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/091686 WO2021232386A1 (zh) 2020-05-22 2020-05-22 动态管理共享内存池的方法和装置

Country Status (4)

Country Link
US (1) US20230085979A1 (zh)
EP (1) EP4141671A4 (zh)
CN (1) CN115668144A (zh)
WO (1) WO2021232386A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115729716B (zh) * 2023-01-10 2023-05-09 云和恩墨(北京)信息技术有限公司 多线程内存管理方法及系统、计算机设备、存储介质

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101281491A (zh) * 2008-05-12 2008-10-08 北京邮电大学 基于VxWorks的空间机器人中央处理器的内存模块及其管理方法
CN106933670A (zh) * 2015-12-29 2017-07-07 航天信息股份有限公司 一种动态管理应用程序内存的方法
CN108255608A (zh) * 2018-01-10 2018-07-06 武汉斗鱼网络科技有限公司 一种内存池的管理方法
CN109062715A (zh) * 2018-07-05 2018-12-21 Oppo(重庆)智能科技有限公司 内存时钟频率的确定方法、装置及终端
CN109918203A (zh) * 2019-03-18 2019-06-21 深圳市网心科技有限公司 接入服务器内存管理优化方法、接入服务器及通信系统

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP3610528B2 (ja) * 1995-01-24 2005-01-12 ブラザー工業株式会社 メモリ管理方法及び装置
US20040107322A1 (en) * 2002-11-29 2004-06-03 Daniel Mulligan System and method for dynamically allocating shared memory within a multiple function device
US8713268B2 (en) * 2010-08-05 2014-04-29 Ut-Battelle, Llc Coordinated garbage collection for raid array of solid state disks
US9292216B1 (en) * 2010-09-24 2016-03-22 Emc Corporation Calculating an allocation mode for a storage pool based on a policy
CN103077126B (zh) * 2012-12-24 2016-08-03 中兴通讯股份有限公司 一种内存管理方法和装置
CN103927264B (zh) * 2014-05-12 2016-08-24 中国航空无线电电子研究所 一种机载数字地图软件地图数据运行内存空间的分配方法
US10359933B2 (en) * 2016-09-19 2019-07-23 Micron Technology, Inc. Memory devices and electronic systems having a hybrid cache including static and dynamic caches with single and multiple bits per cell, and related methods

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101281491A (zh) * 2008-05-12 2008-10-08 北京邮电大学 基于VxWorks的空间机器人中央处理器的内存模块及其管理方法
CN106933670A (zh) * 2015-12-29 2017-07-07 航天信息股份有限公司 一种动态管理应用程序内存的方法
CN108255608A (zh) * 2018-01-10 2018-07-06 武汉斗鱼网络科技有限公司 一种内存池的管理方法
CN109062715A (zh) * 2018-07-05 2018-12-21 Oppo(重庆)智能科技有限公司 内存时钟频率的确定方法、装置及终端
CN109918203A (zh) * 2019-03-18 2019-06-21 深圳市网心科技有限公司 接入服务器内存管理优化方法、接入服务器及通信系统

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP4141671A4 *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115729716B (zh) * 2023-01-10 2023-05-09 云和恩墨(北京)信息技术有限公司 多线程内存管理方法及系统、计算机设备、存储介质

Also Published As

Publication number Publication date
EP4141671A1 (en) 2023-03-01
EP4141671A4 (en) 2023-05-24
US20230085979A1 (en) 2023-03-23
CN115668144A (zh) 2023-01-31

Similar Documents

Publication Publication Date Title
CN110197234B (zh) 一种基于双通道卷积神经网络的加密流量分类方法
CN111079670B (zh) 人脸识别方法、装置、终端和介质
Bar-Hillel et al. Learning distance functions using equivalence relations
Jin et al. A modular machine learning system for flow-level traffic classification in large networks
CN112532451A (zh) 基于异步通信的分层联邦学习方法、装置、终端设备及存储介质
Chew et al. Dual/spl nu/-support vector machine with error rate and training size biasing
CN111614769B (zh) 一种深度学习技术的行为智能分析引擎系统及控制方法
CN110705344A (zh) 一种基于深度学习的人群计数模型及其实现方法
CN109872279B (zh) 一种基于神经网络的智能云平台人脸识别并局部加密方法
WO2021232386A1 (zh) 动态管理共享内存池的方法和装置
CN109547541B (zh) 雾计算环境下基于过滤及分配机制的节点低开销协作方法
CN113158243A (zh) 分布式图像识别的模型推理方法及系统
CN116385857B (zh) 一种基于ai智能调度的算力分配方法
CN111753671A (zh) 一种现实场景的人群计数方法
EP4311202A1 (en) End-edge-cloud coordination system and method based on digital retina, and device
Wang et al. Tile-Weighted Rate-Distortion Optimized Packet Scheduling for 360° VR Video Streaming
CN112118494A (zh) 一种视频数据处理方法、装置及存储介质
Lan et al. Distributed multi-agent video fast-forwarding
CN116310758A (zh) 基于组合语义区域关系模型的室内场景识别方法及系统
CN114025163A (zh) 一种图像解码方法、图像解码系统及相关装置
CN114449346A (zh) 视频处理方法、装置、设备以及存储介质
CN109685101B (zh) 一种多维数据自适应采集方法及系统
Felea et al. Improving Light-weight Convolutional Neural Networks for Face Recognition Targeting Resource Constrained Platforms.
Zhang et al. Crossvision: Real-time on-camera video analysis via common roi load balancing
Xu et al. Ddpg-based edge resource management for coal mine surveillance video analysis in cloud-edge cooperation framework

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20936608

Country of ref document: EP

Kind code of ref document: A1

ENP Entry into the national phase

Ref document number: 2020936608

Country of ref document: EP

Effective date: 20221123

NENP Non-entry into the national phase

Ref country code: DE