WO2020259208A1 - Memory scheduling method and apparatus, device and storage medium - Google Patents

Memory scheduling method and apparatus, device and storage medium Download PDF

Info

Publication number
WO2020259208A1
WO2020259208A1 PCT/CN2020/093404 CN2020093404W WO2020259208A1 WO 2020259208 A1 WO2020259208 A1 WO 2020259208A1 CN 2020093404 W CN2020093404 W CN 2020093404W WO 2020259208 A1 WO2020259208 A1 WO 2020259208A1
Authority
WO
WIPO (PCT)
Prior art keywords
memory
level
pool
target sub
client
Prior art date
Application number
PCT/CN2020/093404
Other languages
French (fr)
Chinese (zh)
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 平安科技(深圳)有限公司
Publication of WO2020259208A1 publication Critical patent/WO2020259208A1/en

Links

Images

Classifications

    • 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/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/4881Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
    • 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
    • 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/5022Mechanisms to release resources
    • 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/544Buffers; Shared memory; Pipes
    • 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

Definitions

  • This application relates to the field of computer technology, and in particular to a memory scheduling method, device, device and storage medium.
  • a common method is to use shared memory, that is, there is a server that can be shared by different clients Logical memory accessed.
  • each client maps a memory pool in the shared memory, in the actual use of the memory pool, due to the real-time and volatility of the client's usage of the memory pool, it may There will be an unbalanced resource allocation of the memory pool, that is, the usage rate of some memory pools in a certain period of time is too high, while the usage rate of the memory pool in other periods of time is lower.
  • the inventor realizes that high usage of the memory pool usually causes the application process of the client to run slower. Therefore, the unbalanced resource allocation of the memory pool will not only slow down the running speed of the client, but also reduce the utilization of shared memory, resulting in a waste of memory.
  • This application provides a memory scheduling method, device, equipment, and storage medium, so as to save memory and improve memory utilization.
  • this application provides a memory scheduling method, which includes:
  • the hierarchical memory pool including multiple sub-level memory pools, the sub-level memory pool including multiple memory blocks;
  • the present application also provides a memory scheduling device, the device including:
  • the determining establishment unit is configured to determine an initial memory from the shared memory, and establish a hierarchical memory pool for the client to use according to the initial memory, the hierarchical memory pool includes multiple sub-level memory pools, and the sub-level memory pool includes multiple Memory block
  • An application receiving unit configured to receive a memory application request sent by the client, where the memory application request includes the required length and the required quantity of the required memory block;
  • a sub-level determining unit configured to determine a target sub-level memory pool from the level memory pool according to the required length
  • the memory allocation unit is configured to allocate memory blocks for the client from the determined target sub-level memory pool according to the demand quantity.
  • the present application also provides a computer device, the computer device includes a memory and a processor; the memory is used to store a computer program; the processor is used to execute the computer program and execute the The computer program implements the above-mentioned memory scheduling method, including:
  • the hierarchical memory pool including multiple sub-level memory pools, the sub-level memory pool including multiple memory blocks;
  • this application also provides a computer-readable storage medium that stores a computer program that when executed by a processor causes the processor to implement the memory scheduling method described above ,include:
  • the hierarchical memory pool including multiple sub-level memory pools, the sub-level memory pool including multiple memory blocks;
  • This application discloses a memory scheduling method, device, equipment, and storage medium.
  • the initial memory is determined from the shared memory and a hierarchical memory pool is established for the client to use, and then a memory application request sent by the client is received, according to the memory application request.
  • the required length of the required memory block in the middle level determines the target sub-level memory pool from the level memory pool, and then allocates the memory block in the target sub-level memory pool according to the number of required memory blocks in the memory application request. Allocate memory for the client according to the memory request sent by the client, so that the server can allocate memory according to the memory usage requirements of the client, thereby improving the utilization of shared memory and saving memory.
  • FIG. 1 is a schematic flowchart of steps of a memory scheduling method provided by an embodiment of the present application
  • FIG. 2 is a schematic diagram of the framework of a hierarchical memory pool provided by an embodiment of the present application
  • FIG. 3 is a schematic flowchart of sub-steps of determining initial memory from shared memory provided by an embodiment of the present application
  • FIG. 4 is a schematic flowchart of sub-steps of the memory scheduling method in FIG. 1;
  • FIG. 5 is a schematic flowchart of another memory scheduling method provided by an embodiment of the present application.
  • FIG. 6 is a schematic flowchart of sub-steps of the memory scheduling method provided in FIG. 5;
  • FIG. 7 is a schematic block diagram of a memory scheduling device provided by an embodiment of the present application.
  • FIG. 8 is a schematic block diagram of another memory scheduling device provided by an embodiment of the present application.
  • FIG. 9 is a schematic block diagram of the structure of a computer device provided by an embodiment of the present application.
  • the embodiments of the present application provide a memory scheduling method, device, computer equipment, and storage medium.
  • the memory scheduling method is used to improve the utilization of shared memory and save memory when one server uses shared memory to interact with multiple clients.
  • FIG. 1 is a schematic flowchart of steps of a memory scheduling method provided by an embodiment of the present application.
  • the memory scheduling method is to allocate memory according to the actual memory usage requirements of the client, so as to achieve the purpose of improving the utilization of shared memory and saving memory.
  • the memory scheduling method specifically includes the following:
  • S101 Determine an initial memory from the shared memory, and establish a hierarchical memory pool for use by the client according to the initial memory.
  • the hierarchical memory pool includes multiple sub-level memory pools, and the sub-level memory pool includes multiple memory blocks.
  • the number of memory blocks in each sub-level memory pool can be the same or different, and each sub-level memory pool can include memory blocks of different lengths, and of course, can also include all memory blocks of the same length.
  • one sub-level memory pool may include memory blocks with a length of 4K and 32K, respectively, and another sub-level memory pool includes memory blocks with a length of 32K.
  • FIG. 2 is a schematic diagram of the framework of a hierarchical memory pool provided by an embodiment of the present application.
  • the hierarchical memory pool may include n sub-level memory pools, each sub-level memory pool includes m n memory blocks, and the length of the memory block is 4K, 32K, and 64K.
  • n ⁇ 1, m n ⁇ 2, and n and m n are both positive integers. It should be noted that the length of the memory block listed in this embodiment only illustrates the process of establishing the sub-level memory pool, and does not limit the length of the memory block in the sub-memory pool.
  • the sub-level memory pool 1 includes m 1 memory blocks with a length of 4K
  • the sub-level memory pool 2 includes memory blocks with a length of 4K and 32K, and memory blocks with two lengths.
  • the sum of the numbers of is m 2
  • the sub-level memory pool n includes memory blocks with lengths of 4K, 32K, and 64K
  • the sum of the numbers of memory blocks with three lengths is m 3 .
  • the server determines the initial memory allocated for the client from the shared memory, and establishes a hierarchical memory pool for the client to use in the shared memory according to the initial memory.
  • the step of determining the initial memory from the shared memory includes step S101a and step S101b.
  • S101a When the configuration memory of the client is less than the maximum free memory of the shared memory, use the configuration memory of the client as the initial memory; S101b. When the configuration memory of the client is greater than or equal to the maximum free memory of the shared memory, set the shared memory The maximum free memory of the pool is used as the initial memory.
  • the configuration memory of the client can be configured according to actual requirements, for example, it can be preset according to the configuration of the client.
  • the configured memory of the client refers to the length and number of memory blocks configured for the client.
  • the configuration memory set for the client is 16 memory blocks with a length of 32K.
  • the configuration memory of the client can be used as the initial memory.
  • the maximum free memory of the shared memory is 10 memory blocks with a length of 32K, and the configured memory of the client is greater than the maximum free memory of the shared memory at this time, the maximum free memory of the shared memory can be used as the initial memory.
  • the configuration memory of the client is equal to the maximum free memory of the shared memory.
  • the maximum free memory of the shared memory can be used as the initial memory, or the client’s Configure memory as initial memory.
  • the memory application request includes the required length and the required quantity of the required memory block.
  • the client needs to use the memory blocks in the hierarchical memory pool in the process of implementing its functions. Therefore, when the client realizes its functions, it can send a memory request request to apply for the required memory block according to the required length and the required quantity. , And the server receives the memory request sent by it.
  • the client can send a memory application request to the server based on a preset memory application rule.
  • the preset memory application rule may be a mapping relationship rule between the function to be implemented by the client and the length and number of memory blocks required to implement the function.
  • the realization of the client's password login function requires 10 memory blocks of 4K in length, and the realization of the client's face recognition function requires 50 memory blocks of 32K in length.
  • the client needs to implement the function of password login, it can send a memory application request to the server based on the preset memory application rules to apply for 10 memory blocks with a length of 4K to achieve this function.
  • the sub-level memory pool is determined as the target sub-level memory pool, so that the server can serve as the client from the target sub-level memory pool.
  • the end allocates memory blocks.
  • the server can select a sub-level memory from the multiple sub-level memory pools that meet the aforementioned conditions
  • the pool is used as the target sub-level memory pool, and multiple sub-level memory pools can also be selected as the target sub-level memory pool from multiple sub-level memory pools that meet the aforementioned conditions.
  • the server selection of a sub-level memory pool or multiple sub-level memory pools can be determined according to the actual situation.
  • the server determines the target sub-level memory pool, it can allocate free memory blocks equal to the required number from the target sub-level memory pool from the target sub-level memory pool for use by the client according to the number of needs of the client. Specifically, the server fulfills the needs of the client according to the allocated memory block.
  • the server when the server selects multiple sub-level memory pools as the target sub-level memory pool, when the server allocates free memory blocks according to the required quantity, it can select multiple sub-level memory as the target sub-level memory pool. Select a sub-level memory pool for priority allocation in the pool. That is, a sub-level memory pool is selected from the multiple sub-level memory pools, and all the free memory blocks in the sub-level memory pool are allocated to the client. If there are still shortcomings, another sub-level memory pool is selected from the multiple sub-level memory pools for priority allocation.
  • the server selects sub-level memory pool 1, sub-level memory pool 2, and sub-level memory pool 3 as the target sub-level memory pools.
  • the sub-level memory pool 1 has 7 free memory blocks
  • the sub-level memory pool 2 has 5 free memory blocks
  • the sub-level memory pool 3 has 6 free memory blocks.
  • the number of free memory blocks required by the client is 10.
  • the server can first allocate the 7 free memory blocks in the sub-level memory pool 1 to the client, and then allocate the 3 free memory blocks in the sub-level memory pool 2 to the client to complete the allocation.
  • step S104 may include the following steps:
  • S104a Calculate the complementary quantity of the required memory block.
  • the supplementary quantity is the difference between the required quantity and the quantity of free memory blocks in the target sub-level memory pool.
  • the calculating the complementary quantity of the required memory blocks includes: calculating the complementary quantity of the required memory blocks according to a quantity calculation formula.
  • the quantity calculation formula is:
  • Y is the number of supplements
  • P is the number of requirements
  • R 1 is the i-th target sub-level memory pool
  • n is the number of target sub-level memory pools in the hierarchical memory pool
  • m 1 is the i-th target sub-level memory pool The number of memory blocks required.
  • the required number of required memory blocks is 50.
  • the server selects five sub-level memory pools from the level memory pool as the target sub-level memory pool.
  • the five sub-level memory pools as the target sub-level memory pool two sub-level memory pools each include 5 free memory blocks, one sub-level memory pool includes 8 free memory blocks, and the two sub-level memory pools each include 10 A free memory block.
  • the supplementary quantity can be calculated as follows:
  • S104b When the supplementary quantity is a positive integer, allocate memory blocks from the shared memory to the target sub-level memory pool according to the supplementary quantity and the required length.
  • the server can allocate memory blocks from the shared memory for the target sub-level memory pool according to the number of supplements and the required length to meet the needs of the client.
  • the length of the memory block allocated from the shared memory is consistent with the length of the client.
  • the required length of the required memory block is the same.
  • the server can directly allocate free memory blocks to the client from the target sub-level memory pool. To meet the needs of the client.
  • the client establishes a hierarchical memory pool in the shared memory.
  • the client sends a memory application request to the server when it needs to use the memory block, and then the server allocates the required memory block from the hierarchical memory pool to the client according to the needs of the client. End-use, so that the server can allocate memory according to the client's real-time memory usage requirements, thereby increasing the usage rate of shared memory and saving memory.
  • FIG. 5 is a schematic flowchart of another memory scheduling method provided by an embodiment of the present application.
  • the memory scheduling method can enable the server to monitor the memory usage of the client in real time after allocating the memory to the client, so as to actively allocate the memory according to the real-time memory usage of the client and increase the memory usage rate.
  • the memory scheduling method specifically includes: step S201 to step S206.
  • S201 Determine an initial memory from the shared memory, and establish a hierarchical memory pool for use by the client according to the initial memory.
  • the hierarchical memory pool includes multiple sub-level memory pools, and the sub-level memory pool includes multiple memory blocks.
  • the number of memory blocks in each sub-level memory pool may be the same or different, and each sub-level memory pool may include memory blocks of different lengths, and of course, may also include all memory blocks of the same length.
  • one sub-level memory pool may include memory blocks with a length of 4K and 32K, respectively, and another sub-level memory pool includes memory blocks with a length of 32K.
  • S202 Receive a memory application request sent by the client.
  • the memory application request includes the required length and the required quantity of the required memory block.
  • the client needs to use the memory blocks in the hierarchical memory pool in the process of implementing its functions. Therefore, when the client realizes its functions, it can send a memory request request to the server to apply according to the required length and the required quantity.
  • the memory block is required, and the memory request sent by the server is received.
  • S203 Determine a target sub-level memory pool from the level memory pool according to the required length.
  • the sub-level memory pool is determined as the target sub-level memory pool, so that the server can serve as the client from the target sub-level memory pool.
  • the end allocates memory blocks.
  • the server determines the target sub-level memory pool, it can allocate free memory blocks equal to the required number from the target sub-level memory pool from the target sub-level memory pool for use by the client according to the number of needs of the client. Specifically, the server fulfills the needs of the client according to the allocated memory block.
  • the client monitors and counts the allocated memory blocks, and calculates the memory usage information of the memory block within a preset time period, and then The calculated memory usage information is sent to the server.
  • the preset time period may be a preset use time period. For example, the client uses one minute as the preset time period to count the memory usage information of the memory block within one minute.
  • the memory usage information may include the usage rate of the memory block.
  • the memory usage information of the target sub-level memory pool calculated by the client within a preset time period includes:
  • the used memory block refers to the memory block currently being used by the client.
  • the usage rate calculation formula is:
  • U f is the usage rate of the memory block with the length of f in the target sub-level memory pool
  • Q is the number of used memory blocks with the length of f in the target sub-level memory pool
  • S ⁇ is including l e
  • j is the number of target sub-level memory pools with a memory block of memory block length f
  • l e is the memory block in the e-th target sub-level memory pool The number of memory blocks of length f.
  • the number of target sub-level memory pools with a memory block length of 64K is 3, and the sum of the number of used memory blocks with a memory block length of 64K in the 3 target sub-level memory pools is 10.
  • the number of target sub-level memory pools including 10 memory blocks with a length of 64K is two, and the number of target sub-level memory pools including 20 memory blocks with a length of 64K is one. Then the usage rate of the 64K memory block in the target sub-level memory pool can be calculated by the above formula:
  • S206 Allocate memory blocks of the target sub-level memory pool according to the memory usage information.
  • the server allocates the memory blocks of the target sub-level memory pool according to the memory usage information sent by the client.
  • allocating the memory blocks of the target sub-level memory pool may include allocating memory blocks from the shared memory to the target sub-level memory pool, or releasing memory blocks in the target sub-level memory pool.
  • step S106 may further include substeps S206a and S206b.
  • S206a If the usage rate is greater than the first usage threshold, allocate a memory block from the shared memory to the target sub-level memory pool according to the length of the memory block in the target sub-level memory pool.
  • the length of the memory block allocated from the shared memory is the same as the length of the memory block whose usage rate is greater than the first usage threshold in the target sub-level memory pool.
  • the first usage threshold can be set according to actual needs. After obtaining the usage rate of a memory block of a certain length calculated by the client, the server compares the usage rate with the first usage threshold. If the usage rate is greater than the first usage threshold, it means that the client uses a large amount of memory block of this length at this time, and the server can allocate the memory block from the shared memory to the target sub-level memory block, where, The length of the memory block allocated by the server from the shared memory is the same as the length of the memory block whose usage rate is greater than the first usage threshold, so as to actively allocate the memory block in real time.
  • the number of memory blocks allocated from the shared memory may be one-half of the number of memory blocks of this length in the target sub-level memory pool.
  • the length of the free memory block is the same as the length of the memory block whose usage rate is less than the second usage threshold in the target sub-level memory pool.
  • the second usage threshold can be set according to actual needs. After obtaining the usage rate of a memory block of a certain length calculated by the client, the server compares the usage rate with the second usage threshold. If the usage rate is less than the second usage threshold, it means that the client's usage of the memory block of this length is small and there are more free memory blocks. In order to increase the usage rate of the memory block, the server can set the target The free memory block of this length in the sub-level memory block is released, so that the free memory block in the target sub-level memory pool will not always be occupied. After the free memory block is released, the free memory block can be used by other clients. The problem of memory waste caused by the client's continuous occupation of free memory blocks is avoided.
  • the client after the client is allocated memory according to the initial memory, the client can obtain the memory usage information of the target sub-level memory pool calculated by the client within a preset time period, so that the server can be based on the memory. Use the information to actively allocate the memory blocks in the target sub-level memory pool in real time to achieve real-time on-demand allocation of memory and improve memory usage.
  • FIG. 7 is a schematic block diagram of a memory scheduling device provided by an embodiment of the present application, and the memory scheduling device is configured to execute the foregoing memory scheduling method.
  • the memory scheduling device can be configured in a server or a terminal.
  • the server can be an independent server or a server cluster.
  • the terminal can be an electronic device such as a mobile phone, a tablet computer, a notebook computer, a desktop computer, a personal digital assistant, and a wearable device.
  • the memory scheduling device 300 includes: a determination establishment unit 301, an application receiving unit 302, a sub-level determination unit 303 and a memory allocation unit 304.
  • the determining establishment unit 301 is configured to determine an initial memory from the shared memory, and establish a hierarchical memory pool for the client to use according to the initial memory.
  • the determining establishment unit 301 includes a configuration memory subunit 3011 and a free memory subunit 3012.
  • the configuration memory subunit 3011 is used to use the configuration memory of the client as the initial memory when the configuration memory of the client is less than the maximum free memory of the shared memory; the free memory subunit 3012 is used for when the configuration memory of the client is greater than When it is equal to the maximum free memory of the shared memory, the maximum free memory of the shared memory pool is used as the initial memory.
  • the application receiving unit 302 is configured to receive a memory application request sent by the client.
  • the sub-level determining unit 303 is configured to determine a target sub-level memory pool from the level memory pool according to the required length.
  • the memory allocation unit 304 is configured to allocate a memory block for the client from the determined target sub-level memory pool according to the demand quantity.
  • the memory allocation unit 304 includes a supplement calculation sub-unit 3041 and a supplement allocation sub-unit 3042.
  • the supplement calculation sub-unit 3041 is used to calculate the supplementary quantity of the required memory block; the supplementary allocation sub-unit 3042 is used to, when the supplementary quantity is a positive integer, from the supplementary quantity and the required length from the Allocate memory blocks from the shared memory to the target sub-level memory pool.
  • FIG. 8 is a schematic block diagram of another memory scheduling device provided by an embodiment of the present application, and the memory scheduling device is used to execute the foregoing memory scheduling method.
  • the memory scheduling device can be configured in the server.
  • the memory scheduling device 400 includes: a determination establishment unit 401, an application receiving unit 402, a sub-level determination unit 403, a memory allocation unit 404, an information acquisition unit 405 and a memory allocation unit 406.
  • the determining establishment unit 401 is configured to determine an initial memory from the shared memory, and establish a hierarchical memory pool for the client to use according to the initial memory.
  • the application receiving unit 402 is configured to receive a memory application request sent by the client.
  • the sub-level determining unit 403 is configured to determine a target sub-level memory pool from the level memory pool according to the required length.
  • the memory allocation unit 404 is configured to allocate a memory block for the client from the determined target sub-level memory pool according to the demand quantity.
  • the information acquiring unit 405 is configured to acquire the memory usage information of the target sub-level memory pool calculated by the client within a preset time period.
  • the memory allocation unit 406 is configured to allocate memory blocks of the target sub-level memory pool according to the memory usage information.
  • the memory allocation unit 406 includes: a memory block calling subunit 4061 and a memory block releasing subunit 4062.
  • the memory block calling subunit 4061 is configured to allocate a memory block from the shared memory to the target according to the length of the memory block in the target sub-level memory pool if the usage rate is greater than the first usage threshold.
  • the foregoing memory scheduling device may be implemented in the form of a computer program, and the computer program may run on the computer device shown in FIG. 9.
  • FIG. 9 is a schematic block diagram of the structure of a computer device according to an embodiment of the present application.
  • the computer device can be a server or a terminal.
  • the computer device includes a processor, a memory, and a network interface connected by a system bus, where the memory may include a non-volatile storage medium and an internal memory.
  • the non-volatile storage medium can store an operating system and a computer program.
  • the computer program includes program instructions, and when the program instructions are executed, the processor can execute any memory scheduling method.
  • the processor is used to provide computing and control capabilities and support the operation of the entire computer equipment.
  • the internal memory provides an environment for the operation of the computer program in the non-volatile storage medium.
  • the processor can execute any memory scheduling method.
  • the network interface is used for network communication, such as sending assigned tasks.
  • the network interface is used for network communication, such as sending assigned tasks.
  • FIG. 9 is only a block diagram of part of the structure related to the solution of the present application, and does not constitute a limitation on the computer equipment to which the solution of the present application is applied.
  • the specific computer equipment may Including more or less parts than shown in the figure, or combining some parts, or having a different part arrangement.
  • the processor may be a central processing unit (Central Processing Unit, CPU), the processor may also be other general-purpose processors, digital signal processors (Digital Signal Processor, DSP), and application specific integrated circuits (Application Specific Integrated Circuits). Circuit, ASIC), Field-Programmable Gate Array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc.
  • the general-purpose processor may be a microprocessor or the processor may also be any conventional processor.
  • the processor is used to run a computer program stored in a memory to implement the following steps:
  • the hierarchical memory pool includes a plurality of sub-level memory pools, the sub-level memory pool includes a plurality of memory blocks; receiving the A memory application request sent by the client, where the memory application request includes the required length of the required memory block and the required quantity; the target sub-level memory pool is determined from the hierarchical memory pool according to the required length; the target sub-level memory pool is determined according to the required quantity Allocate memory blocks for the client in the target sub-level memory pool of.
  • the processor when the processor implements the determination of the initial memory from the shared memory, it is used to implement:
  • the configuration memory of the client is used as the initial memory; when the configuration memory of the client is greater than or equal to the maximum free memory of the shared memory, the maximum free memory of the shared memory pool is set The memory is used as the initial memory.
  • the processor when the processor realizes the allocation of a memory block for the client from the determined target sub-level memory pool according to the demand quantity, the processor is configured to realize:
  • the complementary quantity is the difference between the required quantity and the number of free memory blocks in the target sub-level memory pool; when the complementary quantity is a positive integer, according to the complementary quantity And the required length allocates a memory block from the shared memory to the target sub-level memory pool.
  • the processor is used to run a computer program stored in the memory to implement the following steps:
  • the hierarchical memory pool includes a plurality of sub-level memory pools, the sub-level memory pool includes a plurality of memory blocks; receiving the A memory application request sent by the client, where the memory application request includes the required length of the required memory block and the required quantity; the target sub-level memory pool is determined from the hierarchical memory pool according to the required length; the target sub-level memory pool is determined according to the required quantity Allocate memory blocks for the client in the target sub-level memory pool of the client; obtain the memory usage information of the target sub-level memory pool calculated by the client within a preset period of time; The memory blocks of the sub-level memory pool are allocated.
  • the memory usage information includes the usage rate of the memory block in the target sub-level memory pool; the processor is implementing the comparison of the memory usage of the target sub-level memory pool according to the memory usage information.
  • the block When the block is deployed, it is used to achieve:
  • the usage rate is greater than the first usage threshold, allocate a memory block from the shared memory to the target sub-level memory pool according to the length of the memory block in the target sub-level memory pool, and the shared memory
  • the length of the memory block allocated in the target sub-level memory pool is the same as the length of the memory block whose usage rate is greater than the first usage threshold.
  • the memory usage information includes the usage rate of the memory block in the target sub-level memory pool; the processor is implementing the comparison of the memory usage of the target sub-level memory pool according to the memory usage information.
  • the block When the block is deployed, it is used to achieve:
  • the usage rate is less than the second usage threshold, release free memory blocks in the target sub-level memory pool, and the length of the free memory block and the usage rate in the target sub-level memory pool are less than the second usage
  • the threshold memory block length is the same.
  • the embodiments of the present application also provide a computer-readable storage medium.
  • the computer-readable storage medium may be non-volatile or volatile.
  • the computer-readable storage medium stores a computer program, the computer program includes program instructions, and the processor executes the program instructions to implement any of the memory scheduling methods provided in the embodiments of the present application, including:
  • the hierarchical memory pool including multiple sub-level memory pools, the sub-level memory pool including multiple memory blocks;
  • the computer-readable storage medium may be the internal storage unit of the computer device described in the foregoing embodiment, such as the hard disk or memory of the computer device.
  • the computer-readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a smart memory card (SMC), or a secure digital (Secure Digital, SD) equipped on the computer device. ) Card, Flash Card, etc.

Abstract

The present application relates to the field of data storage. Disclosed are a memory scheduling method and apparatus, a device and a storage medium. The method comprises: determining an initial memory from a shared memory, and establishing, according to the initial memory, a hierarchical memory pool for use by a client, wherein the hierarchical memory pool comprises a plurality of sub-hierarchical memory pools, and the sub-hierarchical memory pool comprises a plurality of memory blocks; receiving a memory application request sent by the client, wherein the memory application request comprises the required length and required quantity of required memory blocks; determining a target sub-hierarchical memory pool from the hierarchical memory pool according to the required length; and allocating memory blocks to the client from the determined target sub-hierarchical memory pool according to the required quantity. Thus, memory utilization is improved, and memory is saved.

Description

内存调度方法、装置、设备及存储介质Memory scheduling method, device, equipment and storage medium
本申请要求于2019年06月25日提交中国专利局、申请号为201910553419.2,发明名称为“内存调度方法、装置、设备及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of the Chinese patent application filed with the Chinese Patent Office on June 25, 2019, the application number is 201910553419.2, and the invention title is "Memory scheduling method, device, equipment and storage medium", the entire content of which is incorporated by reference In this application.
技术领域Technical field
本申请涉及计算机技术领域,尤其涉及一种内存调度方法、装置、设备及存储介质。This application relates to the field of computer technology, and in particular to a memory scheduling method, device, device and storage medium.
背景技术Background technique
对于单机的客户端和服务端程序而言,通常需要一个服务端对应多个客户端进行数据交互,常用的一种方法是使用共享内存,也即在服务端中存在一个可以被不同客户端共同访问的逻辑内存。For stand-alone client and server programs, it is usually necessary for a server to correspond to multiple clients for data exchange. A common method is to use shared memory, that is, there is a server that can be shared by different clients Logical memory accessed.
对于多个客户端而言,如果每一个客户端分别映射共享内存中的一个内存池,在内存池的实际使用过程中,由于客户端对于内存池的使用率存在实时性和波动性,因此可能会出现内存池的资源分配不均衡的情况,也即在某时段一些内存池的使用率过高,而在其他时间段内存池的使用率则较低。发明人意识到,内存池的使用率过高通常会导致客户端的应用进程运行速度变慢。因此,内存池的资源分配不均衡不仅会拖慢客户端的运行速度,也会降低共享内存的利用率,造成内存的浪费。For multiple clients, if each client maps a memory pool in the shared memory, in the actual use of the memory pool, due to the real-time and volatility of the client's usage of the memory pool, it may There will be an unbalanced resource allocation of the memory pool, that is, the usage rate of some memory pools in a certain period of time is too high, while the usage rate of the memory pool in other periods of time is lower. The inventor realizes that high usage of the memory pool usually causes the application process of the client to run slower. Therefore, the unbalanced resource allocation of the memory pool will not only slow down the running speed of the client, but also reduce the utilization of shared memory, resulting in a waste of memory.
因此,如何节约内存,提高内存的利用率成为亟待解决的问题。Therefore, how to save memory and improve memory utilization has become an urgent problem to be solved.
技术问题technical problem
本申请提供了一种内存调度方法、装置、设备及存储介质,以节约内存,提高内存的利用率。This application provides a memory scheduling method, device, equipment, and storage medium, so as to save memory and improve memory utilization.
技术解决方案Technical solutions
第一方面,本申请提供了一种内存调度方法,所述方法包括:In the first aspect, this application provides a memory scheduling method, which includes:
从共享内存中确定初始内存,根据所述初始内存建立供客户端使用的层级内存池,所述层级内存池包括多个子层级内存池,所述子层级内存池包括多个内存块;Determining an initial memory from the shared memory, and establishing a hierarchical memory pool for use by the client according to the initial memory, the hierarchical memory pool including multiple sub-level memory pools, the sub-level memory pool including multiple memory blocks;
接收所述客户端发送的内存申请请求,所述内存申请请求包括需求内存块的需求长度和需求数量;Receiving a memory application request sent by the client, where the memory application request includes the required length and the required quantity of the required memory block;
根据所述需求长度从所述层级内存池中确定目标子层级内存池;Determining a target sub-level memory pool from the level memory pool according to the required length;
根据所述需求数量从确定的目标子层级内存池中为所述客户端分配内存块。Allocating memory blocks for the client from the determined target sub-level memory pool according to the required quantity.
第二方面,本申请还提供了一种内存调度装置,所述装置包括:In the second aspect, the present application also provides a memory scheduling device, the device including:
确定建立单元,用于从共享内存中确定初始内存,根据所述初始内存建立供客户端使用的层级内存池,所述层级内存池包括多个子层级内存池,所述子层级内存池包括多个内存块;The determining establishment unit is configured to determine an initial memory from the shared memory, and establish a hierarchical memory pool for the client to use according to the initial memory, the hierarchical memory pool includes multiple sub-level memory pools, and the sub-level memory pool includes multiple Memory block
申请接收单元,用于接收所述客户端发送的内存申请请求,所述内存申请请求包括需求内存块的需求长度和需求数量;An application receiving unit, configured to receive a memory application request sent by the client, where the memory application request includes the required length and the required quantity of the required memory block;
子层级确定单元,用于根据所述需求长度从所述层级内存池中确定目标子层级内存池;A sub-level determining unit, configured to determine a target sub-level memory pool from the level memory pool according to the required length;
内存分配单元,用于根据所述需求数量从确定的目标子层级内存池中为所述客户端分配内存块。The memory allocation unit is configured to allocate memory blocks for the client from the determined target sub-level memory pool according to the demand quantity.
第三方面,本申请还提供了一种计算机设备,所述计算机设备包括存储器和处理器;所述存储器用于存储计算机程序;所述处理器,用于执行所述计算机程序并在执行所述计算机程序时实现如上述的内存调度方法,包括:In a third aspect, the present application also provides a computer device, the computer device includes a memory and a processor; the memory is used to store a computer program; the processor is used to execute the computer program and execute the The computer program implements the above-mentioned memory scheduling method, including:
从共享内存中确定初始内存,根据所述初始内存建立供客户端使用的层级内存池,所述层级内存池包括多个子层级内存池,所述子层级内存池包括多个内存块;Determining an initial memory from the shared memory, and establishing a hierarchical memory pool for use by the client according to the initial memory, the hierarchical memory pool including multiple sub-level memory pools, the sub-level memory pool including multiple memory blocks;
接收所述客户端发送的内存申请请求,所述内存申请请求包括需求内存块的需求长度和需求数量;Receiving a memory application request sent by the client, where the memory application request includes the required length and the required quantity of the required memory block;
根据所述需求长度从所述层级内存池中确定目标子层级内存池;Determining a target sub-level memory pool from the level memory pool according to the required length;
根据所述需求数量从确定的目标子层级内存池中为所述客户端分配内存块。Allocating memory blocks for the client from the determined target sub-level memory pool according to the required quantity.
第四方面,本申请还提供了一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,所述计算机程序被处理器执行时使所述处理器实现如上述的内存调度方法,包括:In a fourth aspect, this application also provides a computer-readable storage medium that stores a computer program that when executed by a processor causes the processor to implement the memory scheduling method described above ,include:
从共享内存中确定初始内存,根据所述初始内存建立供客户端使用的层级内存池,所述层级内存池包括多个子层级内存池,所述子层级内存池包括多个内存块;Determining an initial memory from the shared memory, and establishing a hierarchical memory pool for use by the client according to the initial memory, the hierarchical memory pool including multiple sub-level memory pools, the sub-level memory pool including multiple memory blocks;
接收所述客户端发送的内存申请请求,所述内存申请请求包括需求内存块的需求长度和需求数量;Receiving a memory application request sent by the client, where the memory application request includes the required length and the required quantity of the required memory block;
根据所述需求长度从所述层级内存池中确定目标子层级内存池;Determining a target sub-level memory pool from the level memory pool according to the required length;
根据所述需求数量从确定的目标子层级内存池中为所述客户端分配内存块。Allocating memory blocks for the client from the determined target sub-level memory pool according to the required quantity.
有益效果Beneficial effect
本申请公开了一种内存调度方法、装置、设备及存储介质,通过从共享内存中确定初始内存并建立供客户端使用的层级内存池,然后接收客户端发送的内存申请请求,根据内存申请请求中需求内存块的需求长度从层级内存池中确定目标子层级内存池,再根据内存申请请求中需求内存块的需求数量在目标子层级内存池中进行内存块的分配。根据客户端发送的内存申请请求为客户端分配内存,使得服务端能够根据客户端的内存使用需求进行内存的分配,从而提高了共享内存的利用率,节约内存。This application discloses a memory scheduling method, device, equipment, and storage medium. The initial memory is determined from the shared memory and a hierarchical memory pool is established for the client to use, and then a memory application request sent by the client is received, according to the memory application request The required length of the required memory block in the middle level determines the target sub-level memory pool from the level memory pool, and then allocates the memory block in the target sub-level memory pool according to the number of required memory blocks in the memory application request. Allocate memory for the client according to the memory request sent by the client, so that the server can allocate memory according to the memory usage requirements of the client, thereby improving the utilization of shared memory and saving memory.
附图说明Description of the drawings
图1是本申请的实施例提供的内存调度方法的步骤示意流程图;FIG. 1 is a schematic flowchart of steps of a memory scheduling method provided by an embodiment of the present application;
图2是本申请的实施例提供的层级内存池的框架示意图;2 is a schematic diagram of the framework of a hierarchical memory pool provided by an embodiment of the present application;
图3是本申请实施例提供的从共享内存中确定初始内存的子步骤示意流程图;3 is a schematic flowchart of sub-steps of determining initial memory from shared memory provided by an embodiment of the present application;
图4是图1中的内存调度方法的子步骤示意流程图;4 is a schematic flowchart of sub-steps of the memory scheduling method in FIG. 1;
图5是本申请实施例提供的另一种内存调度方法的示意流程图;FIG. 5 is a schematic flowchart of another memory scheduling method provided by an embodiment of the present application;
图6是图5中提供的内存调度方法的子步骤示意流程图;FIG. 6 is a schematic flowchart of sub-steps of the memory scheduling method provided in FIG. 5;
图7是本申请实施例提供的一种内存调度装置的示意性框图;FIG. 7 is a schematic block diagram of a memory scheduling device provided by an embodiment of the present application;
图8是本申请实施例提供的另一种内存调度装置的示意性框图;FIG. 8 is a schematic block diagram of another memory scheduling device provided by an embodiment of the present application;
图9是本申请实施例提供的一种计算机设备的结构示意性框图。FIG. 9 is a schematic block diagram of the structure of a computer device provided by an embodiment of the present application.
本发明的最佳实施方式The best mode of the invention
本申请的实施例提供了一种内存调度方法、装置、计算机设备及存储介质。该内存调度方法用于在一个服务端使用共享内存与多个客户端进行数据交互时,提高共享内存的利用率,节约内存。The embodiments of the present application provide a memory scheduling method, device, computer equipment, and storage medium. The memory scheduling method is used to improve the utilization of shared memory and save memory when one server uses shared memory to interact with multiple clients.
下面结合附图,对本申请的一些实施方式作详细说明。在不冲突的情况下,下述的实施例及实施例中的特征可以相互组合。Hereinafter, some embodiments of the present application will be described in detail with reference to the accompanying drawings. In the case of no conflict, the following embodiments and features in the embodiments can be combined with each other.
请参阅图1,图1是本申请的实施例提供的内存调度方法的步骤示意流程图。该内存调度方法是根据客户端对于内存的实际使用需求进行内存的分配,从而达到提高共享内存的利用率,节约内存的目的。Please refer to FIG. 1. FIG. 1 is a schematic flowchart of steps of a memory scheduling method provided by an embodiment of the present application. The memory scheduling method is to allocate memory according to the actual memory usage requirements of the client, so as to achieve the purpose of improving the utilization of shared memory and saving memory.
如图1所示,该内存调度方法具体包括以下内容:As shown in Figure 1, the memory scheduling method specifically includes the following:
S101、从共享内存中确定初始内存,根据所述初始内存建立供客户端使用的层级内存池。S101. Determine an initial memory from the shared memory, and establish a hierarchical memory pool for use by the client according to the initial memory.
其中,层级内存池包括多个子层级内存池,子层级内存池包括多个内存块。在具体实施过程中,各个子层级内存池中内存块的数量可以相同,也可以不同,且每个子层级内存 池中可以包括不同长度的内存块,当然也可以包括全部相同长度的内存块。例如,一个子层级内存池中可以分别包括长度为4K和32K的内存块,另一个子层级内存池包括长度为32K的内存块。Among them, the hierarchical memory pool includes multiple sub-level memory pools, and the sub-level memory pool includes multiple memory blocks. In the specific implementation process, the number of memory blocks in each sub-level memory pool can be the same or different, and each sub-level memory pool can include memory blocks of different lengths, and of course, can also include all memory blocks of the same length. For example, one sub-level memory pool may include memory blocks with a length of 4K and 32K, respectively, and another sub-level memory pool includes memory blocks with a length of 32K.
请参考图2,图2是本申请的实施例提供的层级内存池的框架示意图。Please refer to FIG. 2, which is a schematic diagram of the framework of a hierarchical memory pool provided by an embodiment of the present application.
其中,层级内存池中可以包括n个子层级内存池,每个子层级内存池中包括m n个内存块,内存块的长度为4K、32K和64K。其中,n≥1,m n≥2,且n和m n均为正整数。需要说明的是,本实施例中所列举的内存块的长度仅为说明子层级内存池的建立过程,并不因此而限定子内存池中内存块的长度。 Among them, the hierarchical memory pool may include n sub-level memory pools, each sub-level memory pool includes m n memory blocks, and the length of the memory block is 4K, 32K, and 64K. Among them, n≥1, m n ≥2, and n and m n are both positive integers. It should be noted that the length of the memory block listed in this embodiment only illustrates the process of establishing the sub-level memory pool, and does not limit the length of the memory block in the sub-memory pool.
具体地,如图2所示,子层级内存池1中包括了m 1个长度为4K的内存块,子层级内存池2中包括了长度为4K和32K的内存块,两种长度的内存块的数量之和为m 2,子层级内存池n中包括了长度为4K、32K和64K的内存块,三种长度的内存块的数量之和为m 3Specifically, as shown in Figure 2, the sub-level memory pool 1 includes m 1 memory blocks with a length of 4K, and the sub-level memory pool 2 includes memory blocks with a length of 4K and 32K, and memory blocks with two lengths. The sum of the numbers of is m 2 , the sub-level memory pool n includes memory blocks with lengths of 4K, 32K, and 64K, and the sum of the numbers of memory blocks with three lengths is m 3 .
在具体实施过程中,客户端首次与服务端连接后,服务端即从共享内存中确定为客户端分配的初始内存,从而根据该初始内存在共享内存中建立供客户端使用的层级内存池。In the specific implementation process, after the client connects to the server for the first time, the server determines the initial memory allocated for the client from the shared memory, and establishes a hierarchical memory pool for the client to use in the shared memory according to the initial memory.
在一个实施例中,如图3所示,从共享内存中确定初始内存的步骤,包括步骤S101a和步骤S101b。In one embodiment, as shown in FIG. 3, the step of determining the initial memory from the shared memory includes step S101a and step S101b.
S101a、当客户端的配置内存小于共享内存的最大空闲内存时,将所述客户端的配置内存作为初始内存;S101b、当客户端的配置内存大于或等于共享内存的最大空闲内存时,将所述共享内存池的最大空闲内存作为初始内存。S101a. When the configuration memory of the client is less than the maximum free memory of the shared memory, use the configuration memory of the client as the initial memory; S101b. When the configuration memory of the client is greater than or equal to the maximum free memory of the shared memory, set the shared memory The maximum free memory of the pool is used as the initial memory.
其中,客户端的配置内存可以根据实际需求进行配置,例如,可以是根据客户端的配置而预先设置的。具体地,客户端的配置内存是指为客户端配置的内存块的长度和数量。The configuration memory of the client can be configured according to actual requirements, for example, it can be preset according to the configuration of the client. Specifically, the configured memory of the client refers to the length and number of memory blocks configured for the client.
例如,为客户端设置的配置内存为16个长度为32K的内存块。For example, the configuration memory set for the client is 16 memory blocks with a length of 32K.
当共享内存的最大空闲内存为50个长度为32K的内存块时,此时客户端的配置内存小于共享内存的最大空闲内存,即可将客户端的配置内存作为初始内存。When the maximum free memory of the shared memory is 50 memory blocks with a length of 32K, and the configuration memory of the client is less than the maximum free memory of the shared memory at this time, the configuration memory of the client can be used as the initial memory.
当共享内存的最大空闲内存为10个长度为32K的内存块时,此时客户端的配置内存大于共享内存的最大空闲内存,即可将共享内存的最大空闲内存作为初始内存。When the maximum free memory of the shared memory is 10 memory blocks with a length of 32K, and the configured memory of the client is greater than the maximum free memory of the shared memory at this time, the maximum free memory of the shared memory can be used as the initial memory.
当共享内存的最大空闲内存为16个长度为32K的内存块时,此时客户端的配置内存等于共享内存的最大空闲内存,既可以将共享内存的最大空闲内存作为初始内存,也可以将客户端的配置内存作为初始内存。When the maximum free memory of the shared memory is 16 memory blocks with a length of 32K, the configuration memory of the client is equal to the maximum free memory of the shared memory. The maximum free memory of the shared memory can be used as the initial memory, or the client’s Configure memory as initial memory.
通过将共享内存的最大空闲内存和客户端的配置内存进行比较,从而取一个较小的内存作为初始内存为客户端进行内存分配,能够避免对客户端分配的初始内存过大,导致的内存浪费的情况。By comparing the maximum free memory of the shared memory with the configured memory of the client, a smaller memory is used as the initial memory for the client to allocate memory, which can avoid the excessive initial memory allocated to the client, which causes a waste of memory Happening.
S102、接收所述客户端发送的内存申请请求。S102. Receive a memory application request sent by the client.
其中,所述内存申请请求包括需求内存块的需求长度和需求数量。具体地,客户端在其功能实现的过程中,需要利用层级内存池中的内存块,因此,客户端在实现其功能时,可以发送内存申请请求,以按照需求长度和需求数量申请需求内存块,并由服务端接收其发送的内存申请请求。Wherein, the memory application request includes the required length and the required quantity of the required memory block. Specifically, the client needs to use the memory blocks in the hierarchical memory pool in the process of implementing its functions. Therefore, when the client realizes its functions, it can send a memory request request to apply for the required memory block according to the required length and the required quantity. , And the server receives the memory request sent by it.
在具体实施过程中,客户端可以基于预设的内存申请规则向服务端发送内存申请请求。预设的内存申请规则可以是客户端所要实现的功能与为实现该功能所需要的内存块的长度和数量的映射关系规则。In the specific implementation process, the client can send a memory application request to the server based on a preset memory application rule. The preset memory application rule may be a mapping relationship rule between the function to be implemented by the client and the length and number of memory blocks required to implement the function.
例如,客户端密码登陆功能的实现需要10个长度为4K的内存块,客户端人脸识别功能的实现需要50个长度为32K的内存块。当客户端需要实现密码登陆的功能时,即可基于预设的内存申请规则向服务端发送内存申请请求,申请10个长度为4K的内存块,以实现该功能。For example, the realization of the client's password login function requires 10 memory blocks of 4K in length, and the realization of the client's face recognition function requires 50 memory blocks of 32K in length. When the client needs to implement the function of password login, it can send a memory application request to the server based on the preset memory application rules to apply for 10 memory blocks with a length of 4K to achieve this function.
S103、根据所述需求长度从所述层级内存池中确定目标子层级内存池。S103. Determine a target sub-level memory pool from the level memory pool according to the required length.
具体地,当子层级内存池中存在长度与需求长度相同的空闲内存块时,则将该子层级内存池确定为目标子层级内存池,以便于服务端从该目标子层级内存池中为客户端进行内 存块的分配。Specifically, when there are free memory blocks with the same length as the required length in the sub-level memory pool, the sub-level memory pool is determined as the target sub-level memory pool, so that the server can serve as the client from the target sub-level memory pool. The end allocates memory blocks.
在具体实施过程中,当层级内存池中有多个子层级内存池均存在长度与需求长度相同的空闲内存块时,则服务端可以从符合前述条件的多个子层级内存池中选取一个子层级内存池作为目标子层级内存池,也可以从符合前述条件的多个子层级内存池中选择多个子层级内存池作为目标子层级内存池。服务端选择一个子层级内存池或选择多个子层级内存池可以根据实际情况来确定。In the specific implementation process, when there are multiple sub-level memory pools in the hierarchical memory pool that all have free memory blocks with the same length as the required length, the server can select a sub-level memory from the multiple sub-level memory pools that meet the aforementioned conditions The pool is used as the target sub-level memory pool, and multiple sub-level memory pools can also be selected as the target sub-level memory pool from multiple sub-level memory pools that meet the aforementioned conditions. The server selection of a sub-level memory pool or multiple sub-level memory pools can be determined according to the actual situation.
S104、根据所述需求数量从确定的目标子层级内存池中为所述客户端分配内存块。S104. Allocate memory blocks for the client from the determined target sub-level memory pool according to the required quantity.
具体地,在服务端确定目标子层级内存池后,即可以根据客户端的需求数量,从目标子层级内存池中为所述客户端分配与需求数量相等的空闲内存块,以供客户端使用,具体为服务端根据分配的内存块完成客户端的需求。Specifically, after the server determines the target sub-level memory pool, it can allocate free memory blocks equal to the required number from the target sub-level memory pool from the target sub-level memory pool for use by the client according to the number of needs of the client. Specifically, the server fulfills the needs of the client according to the allocated memory block.
在具体实施过程中,当服务端选择多个子层级内存池作为目标子层级内存池时,服务端在按照需求数量进行空闲内存块的分配时,可以从作为目标子层级内存池的多个子层级内存池中选择一个子层级内存池进行优先分配。也即,从所述多个子层级内存池中选择一个子层级内存池,将该子层级内存池中的空闲内存块全部分配给客户端。如果还有不足,则从所述多个子层级内存池中另选子层级内存池进行优先分配。In the specific implementation process, when the server selects multiple sub-level memory pools as the target sub-level memory pool, when the server allocates free memory blocks according to the required quantity, it can select multiple sub-level memory as the target sub-level memory pool. Select a sub-level memory pool for priority allocation in the pool. That is, a sub-level memory pool is selected from the multiple sub-level memory pools, and all the free memory blocks in the sub-level memory pool are allocated to the client. If there are still shortcomings, another sub-level memory pool is selected from the multiple sub-level memory pools for priority allocation.
例如,服务端选择子层级内存池1、子层级内存池2和子层级内存池3为目标子层级内存池。其中,子层级内存池1中有空闲内存块7个,子层级内存池2有空闲内存块5个,子层级内存池3中有空闲内存块6个,而客户端的需求数量为10个,此时,服务端可以优先将子层级内存池1中的7个空闲内存块分配给客户端,然后将子层级内存池2中的3个空闲内存块分配给客户端,即可完成分配。For example, the server selects sub-level memory pool 1, sub-level memory pool 2, and sub-level memory pool 3 as the target sub-level memory pools. Among them, the sub-level memory pool 1 has 7 free memory blocks, the sub-level memory pool 2 has 5 free memory blocks, and the sub-level memory pool 3 has 6 free memory blocks. The number of free memory blocks required by the client is 10. At this time, the server can first allocate the 7 free memory blocks in the sub-level memory pool 1 to the client, and then allocate the 3 free memory blocks in the sub-level memory pool 2 to the client to complete the allocation.
在一个实施例中,请参考图4,步骤S104可以包括如下步骤:In one embodiment, referring to FIG. 4, step S104 may include the following steps:
S104a、计算需求内存块的补足数量。S104a: Calculate the complementary quantity of the required memory block.
在本实施例中,所述补足数量为所述需求数量与所述目标子层级内存池中的空闲内存块数量的数量差。In this embodiment, the supplementary quantity is the difference between the required quantity and the quantity of free memory blocks in the target sub-level memory pool.
具体地,所述计算需求内存块的补足数量包括:根据数量计算公式计算需求内存块的补足数量。Specifically, the calculating the complementary quantity of the required memory blocks includes: calculating the complementary quantity of the required memory blocks according to a quantity calculation formula.
所述数量计算公式为:The quantity calculation formula is:
Figure PCTCN2020093404-appb-000001
Figure PCTCN2020093404-appb-000001
其中,Y为补足数量,P为需求数量,R 1为第i个目标子层级内存池,n为层级内存池中目标子层级内存池的数量,m 1为第i个目标子层级内存池中所需内存块的数量。 Among them, Y is the number of supplements, P is the number of requirements, R 1 is the i-th target sub-level memory pool, n is the number of target sub-level memory pools in the hierarchical memory pool, m 1 is the i-th target sub-level memory pool The number of memory blocks required.
例如,需求内存块的需求数量为50个。且服务端从层级内存池内选择了五个子层级内存池作为目标子层级内存池。作为目标子层级内存池的五个子层级内存池中,两个子层级内存池中分别包括5个空闲内存块,一个子层级内存池中包括8个空闲内存块,两个子层级内存池中分别包括10个空闲内存块。则根据上述的数量计算公式,可以计算出补足数量如下:For example, the required number of required memory blocks is 50. And the server selects five sub-level memory pools from the level memory pool as the target sub-level memory pool. Among the five sub-level memory pools as the target sub-level memory pool, two sub-level memory pools each include 5 free memory blocks, one sub-level memory pool includes 8 free memory blocks, and the two sub-level memory pools each include 10 A free memory block. According to the above-mentioned quantity calculation formula, the supplementary quantity can be calculated as follows:
Y=50-(2×5+1×8+2×10)=12;Y=50-(2×5+1×8+2×10)=12;
S104b、当所述补足数量为正整数时,根据所述补足数量和所述需求长度从所述共享内存中调配内存块至所述目标子层级内存池。S104b: When the supplementary quantity is a positive integer, allocate memory blocks from the shared memory to the target sub-level memory pool according to the supplementary quantity and the required length.
具体地,当所述补足数量为正整数时,则说明此时客户端的需求数量多于目标子层级内存池中的空闲内存块数量,目标子层级内存池中的内存块不能够满足客户端的使用需求,此时服务端可以根据补足数量和需求长度,从共享内存中为该目标子层级内存池调配内存块,以满足客户端的使用需求,从共享内存中调配的内存块的长度与客户端所需求内存块的需求长度相同。Specifically, when the number of supplements is a positive integer, it means that the number of requirements of the client is more than the number of free memory blocks in the target sub-level memory pool at this time, and the memory blocks in the target sub-level memory pool cannot satisfy the client's use At this time, the server can allocate memory blocks from the shared memory for the target sub-level memory pool according to the number of supplements and the required length to meet the needs of the client. The length of the memory block allocated from the shared memory is consistent with the length of the client. The required length of the required memory block is the same.
当补足数量为0或者为负数时,则说明此时客户端的需求数量少于目标子层级内存池 中的空闲内存块数量,服务端可以直接从目标子层级内存池中为客户端分配空闲内存块,以满足客户端的使用需求。When the number of supplements is 0 or a negative number, it means that the client's demand is less than the number of free memory blocks in the target sub-level memory pool. The server can directly allocate free memory blocks to the client from the target sub-level memory pool. To meet the needs of the client.
上述实施例为客户端在共享内存中建立一个层级内存池,客户端在需要使用内存块时向服务端发送内存申请请求,然后服务端根据客户端的需求从层级内存池中调配需求内存块给客户端使用,使得服务端能够根据客户端实时的内存使用需求进行内存的分配,从而提高了共享内存的使用率,节约内存。In the above embodiment, the client establishes a hierarchical memory pool in the shared memory. The client sends a memory application request to the server when it needs to use the memory block, and then the server allocates the required memory block from the hierarchical memory pool to the client according to the needs of the client. End-use, so that the server can allocate memory according to the client's real-time memory usage requirements, thereby increasing the usage rate of shared memory and saving memory.
请参阅图5,图5是本申请实施例提供的另一种内存调度方法的示意流程图。该内存调度方法能够使得服务端在将内存分配至客户端后能够对于客户端的内存使用进行实时的监控,以便根据客户端实时的内存使用情况主动进行内存的分配,提高内存使用率。Please refer to FIG. 5, which is a schematic flowchart of another memory scheduling method provided by an embodiment of the present application. The memory scheduling method can enable the server to monitor the memory usage of the client in real time after allocating the memory to the client, so as to actively allocate the memory according to the real-time memory usage of the client and increase the memory usage rate.
如图5所示,该内存调度方法,具体包括:步骤S201至步骤S206。As shown in FIG. 5, the memory scheduling method specifically includes: step S201 to step S206.
S201、从共享内存中确定初始内存,根据所述初始内存建立供客户端使用的层级内存池。S201. Determine an initial memory from the shared memory, and establish a hierarchical memory pool for use by the client according to the initial memory.
具体地,层级内存池包括多个子层级内存池,子层级内存池包括多个内存块。在具体实施过程中,各个子层级内存池中内存块的数量可以相同,也可以不同,且每个子层级内存池中可以包括不同长度的内存块,当然也可以包括全部相同长度的内存块。例如,一个子层级内存池中可以分别包括长度为4K和32K的内存块,另一个子层级内存池包括长度为32K的内存块。Specifically, the hierarchical memory pool includes multiple sub-level memory pools, and the sub-level memory pool includes multiple memory blocks. In a specific implementation process, the number of memory blocks in each sub-level memory pool may be the same or different, and each sub-level memory pool may include memory blocks of different lengths, and of course, may also include all memory blocks of the same length. For example, one sub-level memory pool may include memory blocks with a length of 4K and 32K, respectively, and another sub-level memory pool includes memory blocks with a length of 32K.
S202、接收所述客户端发送的内存申请请求。S202: Receive a memory application request sent by the client.
其中,所述内存申请请求包括需求内存块的需求长度和需求数量。具体地,客户端在其功能实现的过程中,需要利用层级内存池中的内存块,因此,客户端在实现其功能时,可以向服务端发送内存申请请求,以按照需求长度和需求数量申请需求内存块,并由服务端接收其发送的内存申请请求。Wherein, the memory application request includes the required length and the required quantity of the required memory block. Specifically, the client needs to use the memory blocks in the hierarchical memory pool in the process of implementing its functions. Therefore, when the client realizes its functions, it can send a memory request request to the server to apply according to the required length and the required quantity. The memory block is required, and the memory request sent by the server is received.
S203、根据所述需求长度从所述层级内存池中确定目标子层级内存池。S203: Determine a target sub-level memory pool from the level memory pool according to the required length.
具体地,当子层级内存池中存在长度与需求长度相同的空闲内存块时,则将该子层级内存池确定为目标子层级内存池,以便于服务端从该目标子层级内存池中为客户端进行内存块的分配。Specifically, when there are free memory blocks with the same length as the required length in the sub-level memory pool, the sub-level memory pool is determined as the target sub-level memory pool, so that the server can serve as the client from the target sub-level memory pool. The end allocates memory blocks.
S204、根据所述需求数量从确定的目标子层级内存池中为所述客户端分配内存块。S204. Allocate a memory block for the client from the determined target sub-level memory pool according to the required quantity.
具体地,在服务端确定目标子层级内存池后,即可以根据客户端的需求数量,从目标子层级内存池中为所述客户端分配与需求数量相等的空闲内存块,以供客户端使用,具体为服务端根据分配的内存块完成客户端的需求。Specifically, after the server determines the target sub-level memory pool, it can allocate free memory blocks equal to the required number from the target sub-level memory pool from the target sub-level memory pool for use by the client according to the number of needs of the client. Specifically, the server fulfills the needs of the client according to the allocated memory block.
S205、获取所述客户端计算的所述目标子层级内存池在预设时段内的内存使用信息。S205. Obtain memory usage information of the target sub-level memory pool calculated by the client within a preset time period.
具体地,在服务端根据客户端的使用需求为客户端分配内存块后,由客户端对其所分配到的内存块进行监测统计,并计算在预设时段内内存块的内存使用信息,然后将计算出的内存使用信息发送至服务端。在具体实施过程中,预设时段可以是预先设置的使用时间段,例如,客户端以一分钟为预设时段统计其在一分钟内内存块的内存使用信息。Specifically, after the server allocates memory blocks to the client according to the usage requirements of the client, the client monitors and counts the allocated memory blocks, and calculates the memory usage information of the memory block within a preset time period, and then The calculated memory usage information is sent to the server. In a specific implementation process, the preset time period may be a preset use time period. For example, the client uses one minute as the preset time period to count the memory usage information of the memory block within one minute.
在一个实施例中,内存使用信息可以包括内存块的使用率。客户端计算的所述目标子层级内存池在预设时段内的内存使用信息,包括:In one embodiment, the memory usage information may include the usage rate of the memory block. The memory usage information of the target sub-level memory pool calculated by the client within a preset time period includes:
统计所述目标子层级内存池在预设时段内的已用内存块的数量;基于使用率计算公式,根据所述已用内存块的数量计算所述目标子层级内存池中内存块的使用率。在具体实施过程中,已用内存块是指客户端当前正在使用的内存块。Count the number of used memory blocks in the target sub-level memory pool within a preset time period; based on the usage rate calculation formula, calculate the use rate of the memory blocks in the target sub-level memory pool according to the number of used memory blocks . In the specific implementation process, the used memory block refers to the memory block currently being used by the client.
具体地,所述使用率计算公式为:Specifically, the usage rate calculation formula is:
Figure PCTCN2020093404-appb-000002
Figure PCTCN2020093404-appb-000002
其中,U f为目标子层级内存池中内存块长度为f的内存块的使用率,Q为目标子层级内存池中内存块长度为f的已用内存块的数量;S θ为包括l e个长度为f的内存块的目标子层级内 存池的数量,j为具有内存块长度为f的内存块的目标子层级内存池的数量,l e为第e个目标子层级内存池中内存块长度为f的内存块的数量。 Among them, U f is the usage rate of the memory block with the length of f in the target sub-level memory pool, Q is the number of used memory blocks with the length of f in the target sub-level memory pool; S θ is including l e The number of target sub-level memory pools of a memory block of length f, j is the number of target sub-level memory pools with a memory block of memory block length f, and l e is the memory block in the e-th target sub-level memory pool The number of memory blocks of length f.
例如,在层级内存池中,具有长度为64K的内存块的目标子层级内存池的数量为3个,3个目标子层级内存池中内存块长度为64K的已用内存块的数量之和为10个。其中,包括10个长度为64K的内存块的目标子层级内存池的数量为2个,包括20个长度为64K的内存块的目标子层级内存池的数量为1个。则通过上式可以计算出该目标子层级内存池中长度为64K的内存块的使用率为:For example, in the hierarchical memory pool, the number of target sub-level memory pools with a memory block length of 64K is 3, and the sum of the number of used memory blocks with a memory block length of 64K in the 3 target sub-level memory pools is 10. Among them, the number of target sub-level memory pools including 10 memory blocks with a length of 64K is two, and the number of target sub-level memory pools including 20 memory blocks with a length of 64K is one. Then the usage rate of the 64K memory block in the target sub-level memory pool can be calculated by the above formula:
Figure PCTCN2020093404-appb-000003
Figure PCTCN2020093404-appb-000003
S206、根据所述内存使用信息对所述目标子层级内存池的内存块进行调配。S206: Allocate memory blocks of the target sub-level memory pool according to the memory usage information.
具体地,由服务端根据客户端所发送的内存使用信息对目标子层级内存池的内存块进行调配。在具体实施过程中,对目标子层级内存池的内存块进行调配可以包括从共享内存中调配内存块至目标子层级内存池,也可以是释放目标子层级内存池中的内存块。Specifically, the server allocates the memory blocks of the target sub-level memory pool according to the memory usage information sent by the client. In the specific implementation process, allocating the memory blocks of the target sub-level memory pool may include allocating memory blocks from the shared memory to the target sub-level memory pool, or releasing memory blocks in the target sub-level memory pool.
在一个实施例中,为了在客户端的使用过程中主动优化客户端的内存分配,以提高客户端的体验度,如图6所示,步骤S106还可以包括子步骤S206a和S206b。In an embodiment, in order to actively optimize the memory allocation of the client during the use of the client to improve the experience of the client, as shown in FIG. 6, step S106 may further include substeps S206a and S206b.
S206a、如果所述使用率大于第一使用阈值,则根据所述目标子层级内存池中的内存块长度从所述共享内存中调配内存块至所述目标子层级内存池。S206a: If the usage rate is greater than the first usage threshold, allocate a memory block from the shared memory to the target sub-level memory pool according to the length of the memory block in the target sub-level memory pool.
具体地,所述从所述共享内存中调配的内存块的长度与所述目标子层级内存池中使用率大于所述第一使用阈值的内存块长度相同。Specifically, the length of the memory block allocated from the shared memory is the same as the length of the memory block whose usage rate is greater than the first usage threshold in the target sub-level memory pool.
在具体实施过程中,第一使用阈值可以根据实际需求进行设置。服务端在获取到客户端计算的某一长度的内存块的使用率后,将所述使用率与第一使用阈值进行大小比较。如果所述使用率大于第一使用阈值,则说明此时客户端对于该长度的内存块的使用量较大,服务端即可从共享内存中调配内存块至目标子层级内存块中,其中,服务端从共享内存中调配的内存块的长度与所述使用率大于第一使用阈值的内存块的长度相同,以主动对内存块进行实时分配。In the specific implementation process, the first usage threshold can be set according to actual needs. After obtaining the usage rate of a memory block of a certain length calculated by the client, the server compares the usage rate with the first usage threshold. If the usage rate is greater than the first usage threshold, it means that the client uses a large amount of memory block of this length at this time, and the server can allocate the memory block from the shared memory to the target sub-level memory block, where, The length of the memory block allocated by the server from the shared memory is the same as the length of the memory block whose usage rate is greater than the first usage threshold, so as to actively allocate the memory block in real time.
在一个实施例中,从所述共享内存中调配的内存块的数量可以为所述目标子层级内存池中该长度的内存块数量的二分之一。In an embodiment, the number of memory blocks allocated from the shared memory may be one-half of the number of memory blocks of this length in the target sub-level memory pool.
S206b、如果所述使用率小于第二使用阈值,则释放所述目标子层级内存池中的空闲内存块。S206b: If the usage rate is less than the second usage threshold, release free memory blocks in the target sub-level memory pool.
具体地,所述空闲内存块的长度与所述目标子层级内存池中使用率小于所述第二使用阈值的内存块长度相同。Specifically, the length of the free memory block is the same as the length of the memory block whose usage rate is less than the second usage threshold in the target sub-level memory pool.
在具体实施过程中,第二使用阈值可以根据实际需求进行设置。服务端在获取到客户端计算的某一长度的内存块的使用率后,将所述使用率与第二使用阈值进行大小比较。如果所述使用率小于第二使用阈值,则说明此时客户端对于该长度的内存块的使用量较小,存在较多空闲内存块,为了提高内存块的使用率,服务端即可将目标子层级内存块中该长度的空闲内存块进行释放,使得目标子层级内存池中的空闲内存块不会一直被占用,释放该空闲内存块后,该空闲内存块即可被其他客户端使用,避免了客户端持续占有空闲内存块导致的内存浪费的问题。In the specific implementation process, the second usage threshold can be set according to actual needs. After obtaining the usage rate of a memory block of a certain length calculated by the client, the server compares the usage rate with the second usage threshold. If the usage rate is less than the second usage threshold, it means that the client's usage of the memory block of this length is small and there are more free memory blocks. In order to increase the usage rate of the memory block, the server can set the target The free memory block of this length in the sub-level memory block is released, so that the free memory block in the target sub-level memory pool will not always be occupied. After the free memory block is released, the free memory block can be used by other clients. The problem of memory waste caused by the client's continuous occupation of free memory blocks is avoided.
上述实施例提供的内存调度方法,在根据初始内存对客户端进行内存的分配后,通过获取客户端计算的目标子层级内存池在预设时段内的内存使用信息,使得服务端能够基于该内存使用信息对目标子层级内存池中的内存块主动进行实时的调配,以实现内存的实时按需分配,提高内存的使用率。In the memory scheduling method provided by the foregoing embodiment, after the client is allocated memory according to the initial memory, the client can obtain the memory usage information of the target sub-level memory pool calculated by the client within a preset time period, so that the server can be based on the memory. Use the information to actively allocate the memory blocks in the target sub-level memory pool in real time to achieve real-time on-demand allocation of memory and improve memory usage.
请参阅图7,图7是本申请的实施例还提供的一种内存调度装置的示意性框图,该内存调度装置用于执行前述的内存调度方法。其中,该内存调度装置可以配置于服务器或终端中。Please refer to FIG. 7. FIG. 7 is a schematic block diagram of a memory scheduling device provided by an embodiment of the present application, and the memory scheduling device is configured to execute the foregoing memory scheduling method. Wherein, the memory scheduling device can be configured in a server or a terminal.
其中,服务器可以为独立的服务器,也可以为服务器集群。该终端可以是手机、平板 电脑、笔记本电脑、台式电脑、个人数字助理和穿戴式设备等电子设备。Among them, the server can be an independent server or a server cluster. The terminal can be an electronic device such as a mobile phone, a tablet computer, a notebook computer, a desktop computer, a personal digital assistant, and a wearable device.
如图7所示,内存调度装置300包括:确定建立单元301、申请接收单元302、子层级确定单元303和内存分配单元304。As shown in FIG. 7, the memory scheduling device 300 includes: a determination establishment unit 301, an application receiving unit 302, a sub-level determination unit 303 and a memory allocation unit 304.
确定建立单元301,用于从共享内存中确定初始内存,根据所述初始内存建立供客户端使用的层级内存池。The determining establishment unit 301 is configured to determine an initial memory from the shared memory, and establish a hierarchical memory pool for the client to use according to the initial memory.
在一个实施例中,确定建立单元301包括配置内存子单元3011和空闲内存子单元3012。In one embodiment, the determining establishment unit 301 includes a configuration memory subunit 3011 and a free memory subunit 3012.
具体地,配置内存子单元3011,用于当客户端的配置内存小于共享内存的最大空闲内存时,将所述客户端的配置内存作为初始内存;空闲内存子单元3012,用于当客户端的配置内存大于或等于共享内存的最大空闲内存时,将所述共享内存池的最大空闲内存作为初始内存。Specifically, the configuration memory subunit 3011 is used to use the configuration memory of the client as the initial memory when the configuration memory of the client is less than the maximum free memory of the shared memory; the free memory subunit 3012 is used for when the configuration memory of the client is greater than When it is equal to the maximum free memory of the shared memory, the maximum free memory of the shared memory pool is used as the initial memory.
申请接收单元302,用于接收所述客户端发送的内存申请请求。The application receiving unit 302 is configured to receive a memory application request sent by the client.
子层级确定单元303,用于根据所述需求长度从所述层级内存池中确定目标子层级内存池。The sub-level determining unit 303 is configured to determine a target sub-level memory pool from the level memory pool according to the required length.
内存分配单元304,用于根据所述需求数量从确定的目标子层级内存池中为所述客户端分配内存块。The memory allocation unit 304 is configured to allocate a memory block for the client from the determined target sub-level memory pool according to the demand quantity.
在一个实施例中,内存分配单元304包括补足计算子单元3041和补足调配子单元3042。In one embodiment, the memory allocation unit 304 includes a supplement calculation sub-unit 3041 and a supplement allocation sub-unit 3042.
具体地,补足计算子单元3041,用于计算需求内存块的补足数量;补足调配子单元3042,用于当所述补足数量为正整数时,根据所述补足数量和所述需求长度从所述共享内存中调配内存块至所述目标子层级内存池。Specifically, the supplement calculation sub-unit 3041 is used to calculate the supplementary quantity of the required memory block; the supplementary allocation sub-unit 3042 is used to, when the supplementary quantity is a positive integer, from the supplementary quantity and the required length from the Allocate memory blocks from the shared memory to the target sub-level memory pool.
请参阅图8,图8是本申请的实施例还提供另一种内存调度装置的示意性框图,该内存调度装置用于执行前述的内存调度方法。其中,该内存调度装置可以配置于服务器中。Please refer to FIG. 8. FIG. 8 is a schematic block diagram of another memory scheduling device provided by an embodiment of the present application, and the memory scheduling device is used to execute the foregoing memory scheduling method. Wherein, the memory scheduling device can be configured in the server.
如图8所示,该内存调度装置400包括:确定建立单元401、申请接收单元402、子层级确定单元403、内存分配单元404、信息获取单元405和内存调配单元406。As shown in FIG. 8, the memory scheduling device 400 includes: a determination establishment unit 401, an application receiving unit 402, a sub-level determination unit 403, a memory allocation unit 404, an information acquisition unit 405 and a memory allocation unit 406.
确定建立单元401,用于从共享内存中确定初始内存,根据所述初始内存建立供客户端使用的层级内存池。The determining establishment unit 401 is configured to determine an initial memory from the shared memory, and establish a hierarchical memory pool for the client to use according to the initial memory.
申请接收单元402,用于接收所述客户端发送的内存申请请求。The application receiving unit 402 is configured to receive a memory application request sent by the client.
子层级确定单元403,用于根据所述需求长度从所述层级内存池中确定目标子层级内存池。The sub-level determining unit 403 is configured to determine a target sub-level memory pool from the level memory pool according to the required length.
内存分配单元404,用于根据所述需求数量从确定的目标子层级内存池中为所述客户端分配内存块。The memory allocation unit 404 is configured to allocate a memory block for the client from the determined target sub-level memory pool according to the demand quantity.
信息获取单元405,用于获取所述客户端计算的所述目标子层级内存池在预设时段内的内存使用信息。The information acquiring unit 405 is configured to acquire the memory usage information of the target sub-level memory pool calculated by the client within a preset time period.
内存调配单元406,用于根据所述内存使用信息对所述目标子层级内存池的内存块进行调配。The memory allocation unit 406 is configured to allocate memory blocks of the target sub-level memory pool according to the memory usage information.
其中,在一个实施例中,内存调配单元406包括:内存块调用子单元4061和内存块释放子单元4062。Wherein, in one embodiment, the memory allocation unit 406 includes: a memory block calling subunit 4061 and a memory block releasing subunit 4062.
具体地,内存块调用子单元4061,用于如果所述使用率大于第一使用阈值,则根据所述目标子层级内存池中的内存块长度从所述共享内存中调配内存块至所述目标子层级内存池;内存块释放子单元4062,如果所述使用率小于第二使用阈值,则释放所述目标子层级内存池中的空闲内存块。Specifically, the memory block calling subunit 4061 is configured to allocate a memory block from the shared memory to the target according to the length of the memory block in the target sub-level memory pool if the usage rate is greater than the first usage threshold. Sub-level memory pool; a memory block release sub-unit 4062, if the usage rate is less than the second usage threshold, release free memory blocks in the target sub-level memory pool.
需要说明的是,所属领域的技术人员可以清楚地了解到,为了描述的方便和简洁,上述描述的内存调度装置和各单元的具体工作过程,可以参考前述内存调度方法实施例中的对应过程,在此不再赘述。It should be noted that those skilled in the art can clearly understand that, for convenience and concise description, the specific working process of the memory scheduling device and each unit described above can refer to the corresponding process in the foregoing memory scheduling method embodiment. I will not repeat them here.
上述的内存调度装置可以实现为一种计算机程序的形式,该计算机程序可以在如图9所示的计算机设备上运行。The foregoing memory scheduling device may be implemented in the form of a computer program, and the computer program may run on the computer device shown in FIG. 9.
请参阅图9,图9是本申请实施例提供的一种计算机设备的结构示意性框图。该计算 机设备可以是服务器或终端。Please refer to FIG. 9, which is a schematic block diagram of the structure of a computer device according to an embodiment of the present application. The computer device can be a server or a terminal.
参阅图9,该计算机设备包括通过系统总线连接的处理器、存储器和网络接口,其中,存储器可以包括非易失性存储介质和内存储器。Referring to FIG. 9, the computer device includes a processor, a memory, and a network interface connected by a system bus, where the memory may include a non-volatile storage medium and an internal memory.
非易失性存储介质可存储操作系统和计算机程序。该计算机程序包括程序指令,该程序指令被执行时,可使得处理器执行任意一种内存调度方法。The non-volatile storage medium can store an operating system and a computer program. The computer program includes program instructions, and when the program instructions are executed, the processor can execute any memory scheduling method.
处理器用于提供计算和控制能力,支撑整个计算机设备的运行。The processor is used to provide computing and control capabilities and support the operation of the entire computer equipment.
内存储器为非易失性存储介质中的计算机程序的运行提供环境,该计算机程序被处理器执行时,可使得处理器执行任意一种内存调度方法。The internal memory provides an environment for the operation of the computer program in the non-volatile storage medium. When the computer program is executed by the processor, the processor can execute any memory scheduling method.
该网络接口用于进行网络通信,如发送分配的任务等。本领域技术人员可以理解,图9中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的计算机设备的限定,具体的计算机设备可以包括比图中所示更多或更少的部件,或者组合某些部件,或者具有不同的部件布置。The network interface is used for network communication, such as sending assigned tasks. Those skilled in the art can understand that the structure shown in FIG. 9 is only a block diagram of part of the structure related to the solution of the present application, and does not constitute a limitation on the computer equipment to which the solution of the present application is applied. The specific computer equipment may Including more or less parts than shown in the figure, or combining some parts, or having a different part arrangement.
应当理解的是,处理器可以是中央处理单元(Central Processing Unit,CPU),该处理器还可以是其他通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现场可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。其中,通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。It should be understood that the processor may be a central processing unit (Central Processing Unit, CPU), the processor may also be other general-purpose processors, digital signal processors (Digital Signal Processor, DSP), and application specific integrated circuits (Application Specific Integrated Circuits). Circuit, ASIC), Field-Programmable Gate Array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor.
其中,在一个实施例中,所述处理器用于运行存储在存储器中的计算机程序,以实现如下步骤:Wherein, in an embodiment, the processor is used to run a computer program stored in a memory to implement the following steps:
从共享内存中确定初始内存,根据所述初始内存建立供客户端使用的层级内存池,所述层级内存池包括多个子层级内存池,所述子层级内存池包括多个内存块;接收所述客户端发送的内存申请请求,所述内存申请请求包括需求内存块的需求长度和需求数量;根据所述需求长度从所述层级内存池中确定目标子层级内存池;根据所述需求数量从确定的目标子层级内存池中为所述客户端分配内存块。Determine the initial memory from the shared memory, establish a hierarchical memory pool for the client to use according to the initial memory, the hierarchical memory pool includes a plurality of sub-level memory pools, the sub-level memory pool includes a plurality of memory blocks; receiving the A memory application request sent by the client, where the memory application request includes the required length of the required memory block and the required quantity; the target sub-level memory pool is determined from the hierarchical memory pool according to the required length; the target sub-level memory pool is determined according to the required quantity Allocate memory blocks for the client in the target sub-level memory pool of.
在一个实施例中,所述处理器在实现所述从共享内存中确定初始内存时,用于实现:In an embodiment, when the processor implements the determination of the initial memory from the shared memory, it is used to implement:
当客户端的配置内存小于共享内存的最大空闲内存时,将所述客户端的配置内存作为初始内存;当客户端的配置内存大于或等于共享内存的最大空闲内存时,将所述共享内存池的最大空闲内存作为初始内存。When the configuration memory of the client is less than the maximum free memory of the shared memory, the configuration memory of the client is used as the initial memory; when the configuration memory of the client is greater than or equal to the maximum free memory of the shared memory, the maximum free memory of the shared memory pool is set The memory is used as the initial memory.
在一个实施例中,所述处理器在实现所述根据所述需求数量从确定的所述目标子层级内存池中为所述客户端分配内存块时,用于实现:In an embodiment, when the processor realizes the allocation of a memory block for the client from the determined target sub-level memory pool according to the demand quantity, the processor is configured to realize:
计算需求内存块的补足数量,所述补足数量为所述需求数量与所述目标子层级内存池中的空闲内存块数量的数量差;当所述补足数量为正整数时,根据所述补足数量和所述需求长度从所述共享内存中调配内存块至所述目标子层级内存池。Calculate the complementary quantity of the required memory block, the complementary quantity is the difference between the required quantity and the number of free memory blocks in the target sub-level memory pool; when the complementary quantity is a positive integer, according to the complementary quantity And the required length allocates a memory block from the shared memory to the target sub-level memory pool.
其中,在另一实施例中,所述处理器用于运行存储在存储器中的计算机程序,以实现如下步骤:Wherein, in another embodiment, the processor is used to run a computer program stored in the memory to implement the following steps:
从共享内存中确定初始内存,根据所述初始内存建立供客户端使用的层级内存池,所述层级内存池包括多个子层级内存池,所述子层级内存池包括多个内存块;接收所述客户端发送的内存申请请求,所述内存申请请求包括需求内存块的需求长度和需求数量;根据所述需求长度从所述层级内存池中确定目标子层级内存池;根据所述需求数量从确定的目标子层级内存池中为所述客户端分配内存块;获取所述客户端计算的所述目标子层级内存池在预设时段内的内存使用信息;根据所述内存使用信息对所述目标子层级内存池的内存块进行调配。Determine the initial memory from the shared memory, establish a hierarchical memory pool for the client to use according to the initial memory, the hierarchical memory pool includes a plurality of sub-level memory pools, the sub-level memory pool includes a plurality of memory blocks; receiving the A memory application request sent by the client, where the memory application request includes the required length of the required memory block and the required quantity; the target sub-level memory pool is determined from the hierarchical memory pool according to the required length; the target sub-level memory pool is determined according to the required quantity Allocate memory blocks for the client in the target sub-level memory pool of the client; obtain the memory usage information of the target sub-level memory pool calculated by the client within a preset period of time; The memory blocks of the sub-level memory pool are allocated.
在一个实施例中,所述内存使用信息包括所述目标子层级内存池中内存块的使用率;所述处理器在实现所述根据所述内存使用信息对所述目标子层级内存池的内存块进行调配时,用于实现:In one embodiment, the memory usage information includes the usage rate of the memory block in the target sub-level memory pool; the processor is implementing the comparison of the memory usage of the target sub-level memory pool according to the memory usage information. When the block is deployed, it is used to achieve:
如果所述使用率大于第一使用阈值,则根据所述目标子层级内存池中的内存块长度从 所述共享内存中调配内存块至所述目标子层级内存池,所述从所述共享内存中调配的内存块的长度与所述目标子层级内存池中使用率大于所述第一使用阈值的内存块长度相同。If the usage rate is greater than the first usage threshold, allocate a memory block from the shared memory to the target sub-level memory pool according to the length of the memory block in the target sub-level memory pool, and the shared memory The length of the memory block allocated in the target sub-level memory pool is the same as the length of the memory block whose usage rate is greater than the first usage threshold.
在一个实施例中,所述内存使用信息包括所述目标子层级内存池中内存块的使用率;所述处理器在实现所述根据所述内存使用信息对所述目标子层级内存池的内存块进行调配时,用于实现:In one embodiment, the memory usage information includes the usage rate of the memory block in the target sub-level memory pool; the processor is implementing the comparison of the memory usage of the target sub-level memory pool according to the memory usage information. When the block is deployed, it is used to achieve:
如果所述使用率小于第二使用阈值,则释放所述目标子层级内存池中的空闲内存块,所述空闲内存块的长度与所述目标子层级内存池中使用率小于所述第二使用阈值的内存块长度相同。If the usage rate is less than the second usage threshold, release free memory blocks in the target sub-level memory pool, and the length of the free memory block and the usage rate in the target sub-level memory pool are less than the second usage The threshold memory block length is the same.
本申请的实施例中还提供一种计算机可读存储介质,所述计算机可读存储介质可以是非易失性,也可以是易失性。所述计算机可读存储介质存储有计算机程序,所述计算机程序中包括程序指令,所述处理器执行所述程序指令,实现本申请实施例提供的任一项内存调度方法,包括:The embodiments of the present application also provide a computer-readable storage medium. The computer-readable storage medium may be non-volatile or volatile. The computer-readable storage medium stores a computer program, the computer program includes program instructions, and the processor executes the program instructions to implement any of the memory scheduling methods provided in the embodiments of the present application, including:
从共享内存中确定初始内存,根据所述初始内存建立供客户端使用的层级内存池,所述层级内存池包括多个子层级内存池,所述子层级内存池包括多个内存块;Determining an initial memory from the shared memory, and establishing a hierarchical memory pool for use by the client according to the initial memory, the hierarchical memory pool including multiple sub-level memory pools, the sub-level memory pool including multiple memory blocks;
接收所述客户端发送的内存申请请求,所述内存申请请求包括需求内存块的需求长度和需求数量;Receiving a memory application request sent by the client, where the memory application request includes the required length and the required quantity of the required memory block;
根据所述需求长度从所述层级内存池中确定目标子层级内存池;Determining a target sub-level memory pool from the level memory pool according to the required length;
根据所述需求数量从确定的目标子层级内存池中为所述客户端分配内存块。Allocating memory blocks for the client from the determined target sub-level memory pool according to the required quantity.
其中,所述计算机可读存储介质可以是前述实施例所述的计算机设备的内部存储单元,例如所述计算机设备的硬盘或内存。所述计算机可读存储介质也可以是所述计算机设备的外部存储设备,例如所述计算机设备上配备的插接式硬盘,智能存储卡(Smart Media Card,SMC),安全数字(Secure Digital,SD)卡,闪存卡(Flash Card)等。The computer-readable storage medium may be the internal storage unit of the computer device described in the foregoing embodiment, such as the hard disk or memory of the computer device. The computer-readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a smart memory card (SMC), or a secure digital (Secure Digital, SD) equipped on the computer device. ) Card, Flash Card, etc.

Claims (20)

  1. 一种内存调度方法,其中,包括:A memory scheduling method, which includes:
    从共享内存中确定初始内存,根据所述初始内存建立供客户端使用的层级内存池,所述层级内存池包括多个子层级内存池,所述子层级内存池包括多个内存块;Determining an initial memory from the shared memory, and establishing a hierarchical memory pool for use by the client according to the initial memory, the hierarchical memory pool including multiple sub-level memory pools, the sub-level memory pool including multiple memory blocks;
    接收所述客户端发送的内存申请请求,所述内存申请请求包括需求内存块的需求长度和需求数量;Receiving a memory application request sent by the client, where the memory application request includes the required length and the required quantity of the required memory block;
    根据所述需求长度从所述层级内存池中确定目标子层级内存池;Determining a target sub-level memory pool from the level memory pool according to the required length;
    根据所述需求数量从确定的目标子层级内存池中为所述客户端分配内存块。Allocating memory blocks for the client from the determined target sub-level memory pool according to the required quantity.
  2. 根据权利要求1所述的内存调度方法,其中,所述从共享内存中确定初始内存,包括:The memory scheduling method according to claim 1, wherein said determining the initial memory from the shared memory comprises:
    当客户端的配置内存小于共享内存的最大空闲内存时,将所述客户端的配置内存作为初始内存;When the configuration memory of the client is less than the maximum free memory of the shared memory, use the configuration memory of the client as the initial memory;
    当客户端的配置内存大于或等于共享内存的最大空闲内存时,将所述共享内存池的最大空闲内存作为初始内存。When the configured memory of the client is greater than or equal to the maximum free memory of the shared memory, the maximum free memory of the shared memory pool is used as the initial memory.
  3. 根据权利要求1所述的内存调度方法,其中,所述根据所述需求数量从确定的所述目标子层级内存池中为所述客户端分配内存块,包括:The memory scheduling method according to claim 1, wherein the allocating a memory block for the client from the determined target sub-level memory pool according to the demand quantity comprises:
    计算需求内存块的补足数量,所述补足数量为所述需求数量与所述目标子层级内存池中的空闲内存块数量的数量差;Calculate the complementary quantity of required memory blocks, where the complementary quantity is the difference between the required quantity and the quantity of free memory blocks in the target sub-level memory pool;
    当所述补足数量为正整数时,根据所述补足数量和所述需求长度从所述共享内存中调配内存块至所述目标子层级内存池。When the supplementary quantity is a positive integer, a memory block is allocated from the shared memory to the target sub-level memory pool according to the supplementary quantity and the required length.
  4. 根据权利要求3所述的内存调度方法,其中,所述计算需求内存块的补足数量,包括:根据数量计算公式计算需求内存块的补足数量;The memory scheduling method according to claim 3, wherein the calculating the complementary quantity of the required memory blocks comprises: calculating the complementary quantity of the required memory blocks according to a quantity calculation formula;
    所述数量计算公式为:The quantity calculation formula is:
    Figure PCTCN2020093404-appb-100001
    Figure PCTCN2020093404-appb-100001
    其中,Y为补足数量,P为需求数量,R i为第i个目标子层级内存池,n为层级内存池中目标子层级内存池的数量,m i为第i个目标子层级内存池中所需内存块的数量。 Wherein, Y is a complement number, P is the number of needs, R i is the i-th sub-level target memory pool, n is the number of target sub-level hierarchical memory pool memory pool, m i is the i th sub-goal level memory pool The number of memory blocks required.
  5. 根据权利要求1所述的内存调度方法,其中,还包括:The memory scheduling method according to claim 1, further comprising:
    获取所述客户端计算的所述目标子层级内存池在预设时段内的内存使用信息;Acquiring memory usage information of the target sub-level memory pool calculated by the client within a preset time period;
    根据所述内存使用信息对所述目标子层级内存池的内存块进行调配。Allocate memory blocks of the target sub-level memory pool according to the memory usage information.
  6. 根据权利要求5所述的内存调度方法,其中,所述内存使用信息包括所述目标子层级内存池中内存块的使用率;所述根据所述内存使用信息对所述目标子层级内存池的内存块进行调配,包括:The memory scheduling method according to claim 5, wherein the memory usage information includes the usage rate of the memory blocks in the target sub-level memory pool; and the comparison of the target sub-level memory pool based on the memory usage information The memory block is allocated, including:
    如果所述使用率大于第一使用阈值,则根据所述目标子层级内存池中的内存块长度从所述共享内存中调配内存块至所述目标子层级内存池,所述从所述共享内存中调配的内存块的长度与所述目标子层级内存池中使用率大于所述第一使用阈值的内存块长度相同。If the usage rate is greater than the first usage threshold, allocate a memory block from the shared memory to the target sub-level memory pool according to the length of the memory block in the target sub-level memory pool, and the shared memory The length of the memory block allocated in the target sub-level memory pool is the same as the length of the memory block whose usage rate is greater than the first usage threshold.
  7. 根据权利要求5所述的内存调度方法,其中,所述内存使用信息包括所述目标子层级内存池中内存块的使用率;所述根据所述内存使用信息对所述目标子层级内存池的内存块进行调配,包括:The memory scheduling method according to claim 5, wherein the memory usage information includes the usage rate of the memory blocks in the target sub-level memory pool; and the comparison of the target sub-level memory pool based on the memory usage information The memory block is allocated, including:
    如果所述使用率小于第二使用阈值,则释放所述目标子层级内存池中的空闲内存块,所述空闲内存块的长度与所述目标子层级内存池中使用率小于所述第二使用阈值的内存块长度相同。If the usage rate is less than the second usage threshold, release free memory blocks in the target sub-level memory pool, and the length of the free memory block and the usage rate in the target sub-level memory pool are less than the second usage The threshold memory block length is the same.
  8. 一种内存调度装置,其中,包括:A memory scheduling device, which includes:
    确定建立单元,用于从共享内存中确定初始内存,根据所述初始内存建立供客户端使用的层级内存池,所述层级内存池包括多个子层级内存池,所述子层级内存池包括多个内存块;The determining establishment unit is configured to determine an initial memory from the shared memory, and establish a hierarchical memory pool for the client to use according to the initial memory, the hierarchical memory pool includes multiple sub-level memory pools, and the sub-level memory pool includes multiple Memory block
    申请接收单元,用于接收所述客户端发送的内存申请请求,所述内存申请请求包括需求内存块的需求长度和需求数量;An application receiving unit, configured to receive a memory application request sent by the client, where the memory application request includes the required length and the required quantity of the required memory block;
    子层级确定单元,用于根据所述需求长度从所述层级内存池中确定目标子层级内存池;A sub-level determining unit, configured to determine a target sub-level memory pool from the level memory pool according to the required length;
    内存分配单元,用于根据所述需求数量从确定的目标子层级内存池中为所述客户端分配内存块。The memory allocation unit is configured to allocate memory blocks for the client from the determined target sub-level memory pool according to the demand quantity.
  9. 一种计算机设备,其中,所述计算机设备包括存储器和处理器;A computer device, wherein the computer device includes a memory and a processor;
    所述存储器用于存储计算机程序;The memory is used to store computer programs;
    所述处理器,用于执行所述计算机程序并在执行所述计算机程序时实现一种内存调度方法,包括:The processor is configured to execute the computer program and implement a memory scheduling method when the computer program is executed, including:
    从共享内存中确定初始内存,根据所述初始内存建立供客户端使用的层级内存池,所述层级内存池包括多个子层级内存池,所述子层级内存池包括多个内存块;Determining an initial memory from the shared memory, and establishing a hierarchical memory pool for use by the client according to the initial memory, the hierarchical memory pool including multiple sub-level memory pools, the sub-level memory pool including multiple memory blocks;
    接收所述客户端发送的内存申请请求,所述内存申请请求包括需求内存块的需求长度和需求数量;Receiving a memory application request sent by the client, where the memory application request includes the required length and the required quantity of the required memory block;
    根据所述需求长度从所述层级内存池中确定目标子层级内存池;Determining a target sub-level memory pool from the level memory pool according to the required length;
    根据所述需求数量从确定的目标子层级内存池中为所述客户端分配内存块。Allocating memory blocks for the client from the determined target sub-level memory pool according to the required quantity.
  10. 根据权利要求9所述的计算机设备,其中,所述从共享内存中确定初始内存,包括:The computer device according to claim 9, wherein said determining the initial memory from the shared memory comprises:
    当客户端的配置内存小于共享内存的最大空闲内存时,将所述客户端的配置内存作为初始内存;When the configuration memory of the client is less than the maximum free memory of the shared memory, use the configuration memory of the client as the initial memory;
    当客户端的配置内存大于或等于共享内存的最大空闲内存时,将所述共享内存池的最大空闲内存作为初始内存。When the configured memory of the client is greater than or equal to the maximum free memory of the shared memory, the maximum free memory of the shared memory pool is used as the initial memory.
  11. 根据权利要求9所述的计算机设备,其中,所述根据所述需求数量从确定的所述目标子层级内存池中为所述客户端分配内存块,包括:9. The computer device according to claim 9, wherein the allocating a memory block for the client from the determined target sub-level memory pool according to the demand quantity comprises:
    计算需求内存块的补足数量,所述补足数量为所述需求数量与所述目标子层级内存池中的空闲内存块数量的数量差;Calculate the complementary quantity of required memory blocks, where the complementary quantity is the difference between the required quantity and the quantity of free memory blocks in the target sub-level memory pool;
    当所述补足数量为正整数时,根据所述补足数量和所述需求长度从所述共享内存中调配内存块至所述目标子层级内存池。When the supplementary quantity is a positive integer, a memory block is allocated from the shared memory to the target sub-level memory pool according to the supplementary quantity and the required length.
  12. 根据权利要求11所述的计算机设备,其中,所述计算需求内存块的补足数量,包括:根据数量计算公式计算需求内存块的补足数量;11. The computer device according to claim 11, wherein the calculating the complementary quantity of the required memory blocks comprises: calculating the complementary quantity of the required memory blocks according to a quantity calculation formula;
    所述数量计算公式为:The quantity calculation formula is:
    Figure PCTCN2020093404-appb-100002
    Figure PCTCN2020093404-appb-100002
    其中,Y为补足数量,P为需求数量,R i为第i个目标子层级内存池,n为层级内存池中目标子层级内存池的数量,m i为第i个目标子层级内存池中所需内存块的数量。 Wherein, Y is a complement number, P is the number of needs, R i is the i-th sub-level target memory pool, n is the number of target sub-level hierarchical memory pool memory pool, m i is the i th sub-goal level memory pool The number of memory blocks required.
  13. 根据权利要求9所述的计算机设备,其中,还包括:The computer device according to claim 9, further comprising:
    获取所述客户端计算的所述目标子层级内存池在预设时段内的内存使用信息;Acquiring memory usage information of the target sub-level memory pool calculated by the client within a preset time period;
    根据所述内存使用信息对所述目标子层级内存池的内存块进行调配。Allocate memory blocks of the target sub-level memory pool according to the memory usage information.
  14. 根据权利要求13所述的计算机设备,其中,所述内存使用信息包括所述目标子层级内存池中内存块的使用率;所述根据所述内存使用信息对所述目标子层级内存池的内存 块进行调配,包括:The computer device according to claim 13, wherein the memory usage information includes a usage rate of a memory block in the target sub-level memory pool; and the memory usage information of the target sub-level memory pool is calculated according to the memory usage information. The block is deployed, including:
    如果所述使用率大于第一使用阈值,则根据所述目标子层级内存池中的内存块长度从所述共享内存中调配内存块至所述目标子层级内存池,所述从所述共享内存中调配的内存块的长度与所述目标子层级内存池中使用率大于所述第一使用阈值的内存块长度相同。If the usage rate is greater than the first usage threshold, allocate a memory block from the shared memory to the target sub-level memory pool according to the length of the memory block in the target sub-level memory pool, and the shared memory The length of the memory block allocated in the target sub-level memory pool is the same as the length of the memory block whose usage rate is greater than the first usage threshold.
  15. 根据权利要求13所述的计算机设备,其中,所述内存使用信息包括所述目标子层级内存池中内存块的使用率;所述根据所述内存使用信息对所述目标子层级内存池的内存块进行调配,包括:The computer device according to claim 13, wherein the memory usage information includes a usage rate of a memory block in the target sub-level memory pool; and the memory usage information of the target sub-level memory pool is calculated according to the memory usage information. The block is deployed, including:
    如果所述使用率小于第二使用阈值,则释放所述目标子层级内存池中的空闲内存块,所述空闲内存块的长度与所述目标子层级内存池中使用率小于所述第二使用阈值的内存块长度相同。If the usage rate is less than the second usage threshold, release free memory blocks in the target sub-level memory pool, and the length of the free memory block and the usage rate in the target sub-level memory pool are less than the second usage The threshold memory block length is the same.
  16. 一种计算机可读存储介质,其中,所述计算机可读存储介质存储有计算机程序,所述计算机程序被处理器执行时使所述处理器实现一种内存调度方法,包括:A computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor realizes a memory scheduling method, including:
    从共享内存中确定初始内存,根据所述初始内存建立供客户端使用的层级内存池,所述层级内存池包括多个子层级内存池,所述子层级内存池包括多个内存块;Determining an initial memory from the shared memory, and establishing a hierarchical memory pool for use by the client according to the initial memory, the hierarchical memory pool including multiple sub-level memory pools, the sub-level memory pool including multiple memory blocks;
    接收所述客户端发送的内存申请请求,所述内存申请请求包括需求内存块的需求长度和需求数量;Receiving a memory application request sent by the client, where the memory application request includes the required length and the required quantity of the required memory block;
    根据所述需求长度从所述层级内存池中确定目标子层级内存池;Determining a target sub-level memory pool from the level memory pool according to the required length;
    根据所述需求数量从确定的目标子层级内存池中为所述客户端分配内存块。Allocating memory blocks for the client from the determined target sub-level memory pool according to the required quantity.
  17. 根据权利要求16所述的计算机可读存储介质,其中,所述从共享内存中确定初始内存,包括:The computer-readable storage medium according to claim 16, wherein the determining the initial memory from the shared memory comprises:
    当客户端的配置内存小于共享内存的最大空闲内存时,将所述客户端的配置内存作为初始内存;When the configuration memory of the client is less than the maximum free memory of the shared memory, use the configuration memory of the client as the initial memory;
    当客户端的配置内存大于或等于共享内存的最大空闲内存时,将所述共享内存池的最大空闲内存作为初始内存。When the configured memory of the client is greater than or equal to the maximum free memory of the shared memory, the maximum free memory of the shared memory pool is used as the initial memory.
  18. 根据权利要求16所述的计算机可读存储介质,其中,所述根据所述需求数量从确定的所述目标子层级内存池中为所述客户端分配内存块,包括:16. The computer-readable storage medium according to claim 16, wherein the allocating a memory block for the client from the determined target sub-level memory pool according to the demand quantity comprises:
    计算需求内存块的补足数量,所述补足数量为所述需求数量与所述目标子层级内存池中的空闲内存块数量的数量差;Calculate the complementary quantity of required memory blocks, where the complementary quantity is the difference between the required quantity and the quantity of free memory blocks in the target sub-level memory pool;
    当所述补足数量为正整数时,根据所述补足数量和所述需求长度从所述共享内存中调配内存块至所述目标子层级内存池。When the supplementary quantity is a positive integer, a memory block is allocated from the shared memory to the target sub-level memory pool according to the supplementary quantity and the required length.
  19. 根据权利要求18所述的计算机可读存储介质,其中,所述计算需求内存块的补足数量,包括:根据数量计算公式计算需求内存块的补足数量;18. The computer-readable storage medium according to claim 18, wherein the calculating the supplementary quantity of the required memory block comprises: calculating the supplementary quantity of the required memory block according to a quantity calculation formula;
    所述数量计算公式为:The quantity calculation formula is:
    Figure PCTCN2020093404-appb-100003
    Figure PCTCN2020093404-appb-100003
    其中,Y为补足数量,P为需求数量,R i为第i个目标子层级内存池,n为层级内存池中目标子层级内存池的数量,m i为第i个目标子层级内存池中所需内存块的数量。 Wherein, Y is a complement number, P is the number of needs, R i is the i-th sub-level target memory pool, n is the number of target sub-level hierarchical memory pool memory pool, m i is the i th sub-goal level memory pool The number of memory blocks required.
  20. 根据权利要求16所述的内存调度方法,其中,还包括:The memory scheduling method according to claim 16, further comprising:
    获取所述客户端计算的所述目标子层级内存池在预设时段内的内存使用信息;Acquiring memory usage information of the target sub-level memory pool calculated by the client within a preset time period;
    根据所述内存使用信息对所述目标子层级内存池的内存块进行调配。Allocate memory blocks of the target sub-level memory pool according to the memory usage information.
PCT/CN2020/093404 2019-06-25 2020-05-29 Memory scheduling method and apparatus, device and storage medium WO2020259208A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910553419.2 2019-06-25
CN201910553419.2A CN110427273A (en) 2019-06-25 2019-06-25 Scheduling memory method, apparatus, equipment and storage medium

Publications (1)

Publication Number Publication Date
WO2020259208A1 true WO2020259208A1 (en) 2020-12-30

Family

ID=68408617

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/093404 WO2020259208A1 (en) 2019-06-25 2020-05-29 Memory scheduling method and apparatus, device and storage medium

Country Status (2)

Country Link
CN (1) CN110427273A (en)
WO (1) WO2020259208A1 (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110427273A (en) * 2019-06-25 2019-11-08 平安科技(深圳)有限公司 Scheduling memory method, apparatus, equipment and storage medium
CN112286688B (en) * 2020-11-05 2024-01-05 北京深维科技有限公司 Memory management and use method, device, equipment and medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8271550B2 (en) * 2006-10-27 2012-09-18 Hewlett-Packard Development Company, L.P. Memory piece categorization
CN105138475A (en) * 2015-08-21 2015-12-09 东软集团股份有限公司 Memory pool and memory allocation method
CN109375985A (en) * 2018-09-06 2019-02-22 新华三技术有限公司成都分公司 Dynamic memory management method and device
CN110427273A (en) * 2019-06-25 2019-11-08 平安科技(深圳)有限公司 Scheduling memory method, apparatus, equipment and storage medium

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103838859B (en) * 2014-03-19 2019-04-26 厦门雅迅网络股份有限公司 A method of data copy between multi-process under reduction linux
WO2016127291A1 (en) * 2015-02-09 2016-08-18 华为技术有限公司 Memory management device and method

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8271550B2 (en) * 2006-10-27 2012-09-18 Hewlett-Packard Development Company, L.P. Memory piece categorization
CN105138475A (en) * 2015-08-21 2015-12-09 东软集团股份有限公司 Memory pool and memory allocation method
CN109375985A (en) * 2018-09-06 2019-02-22 新华三技术有限公司成都分公司 Dynamic memory management method and device
CN110427273A (en) * 2019-06-25 2019-11-08 平安科技(深圳)有限公司 Scheduling memory method, apparatus, equipment and storage medium

Also Published As

Publication number Publication date
CN110427273A (en) 2019-11-08

Similar Documents

Publication Publication Date Title
WO2020199487A1 (en) Method, apparatus and device for responding to access request, and storage medium
US8429666B2 (en) Computing platform with resource constraint negotiation
WO2018177012A1 (en) Method, apparatus and device for controlling bandwidth
US10235047B2 (en) Memory management method, apparatus, and system
US20170126583A1 (en) Method and electronic device for bandwidth allocation based on online media services
WO2020019743A1 (en) Traffic control method and device
WO2020259208A1 (en) Memory scheduling method and apparatus, device and storage medium
WO2016127291A1 (en) Memory management device and method
CN112600761B (en) Resource allocation method, device and storage medium
WO2022142478A1 (en) Model calculation method and system
CN109800261B (en) Dynamic control method and device for double-database connection pool and related equipment
CN112749002A (en) Method and device for dynamically managing cluster resources
WO2020224531A1 (en) Method and device for assigning tokens in storage system
US11709707B2 (en) Low latency distributed counters for quotas
WO2021164164A1 (en) Storage service quality control method, apparatus and device, and storage medium
KR20220025746A (en) Dynamic allocation of computing resources
CN116244231A (en) Data transmission method, device and system, electronic equipment and storage medium
WO2022057718A1 (en) Coding scheduling method, server and client terminal, and system for acquiring remote desktop
CN114327862A (en) Memory allocation method and device, electronic equipment and storage medium
CN108257077B (en) GPU-based clustering data processing method and system and computing device
CN114489978A (en) Resource scheduling method, device, equipment and storage medium
CN112328387A (en) Multi-tenant-oriented micro-service resource scheduling method
CN112286695A (en) Server resource allocation method and edge data center
CN114489463A (en) Method and device for dynamically adjusting QOS (quality of service) of storage volume and computing equipment
CN111988403A (en) Request processing method and system of electronic equipment, storage medium and electronic equipment

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: 20832993

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20832993

Country of ref document: EP

Kind code of ref document: A1