Memory allocation method and device in data query

By combining the target memory allocator and the general memory allocator, memory allocation is allocated according to different data query requests, the problem of poor memory allocation performance in the prior art is solved, and more efficient memory allocation is achieved and memory fragmentation is reduced.

CN119440831APending Publication Date: 2025-02-14BEIJING VOLCANO ENGINE TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411525009.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-29
Publication Date
2025-02-14

AI Technical Summary

Technical Problem

The prior art uses a general memory allocator when the database applies for memory from the operating system, resulting in poor memory allocation performance and affecting the processing efficiency of data query requests.

Method used

Using a combination of target memory allocator and general memory allocator, memory is allocated through target memory allocator and general memory allocator, depending on the data query request. The target memory allocator preallocates virtual memory during the initialization phase to allocate larger memory to create specific types of objects, and the general memory allocator is used to allocate smaller memory to create other types of objects.

Benefits of technology

Effectively reduces page table failure and bypass fast table buffering loss, improves memory allocation performance, and reduces memory fragmentation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119440831A_ABST
    Figure CN119440831A_ABST
Patent Text Reader

Abstract

The invention discloses a memory allocation method in data query. The method comprises the following steps: receiving a data query request; according to the data query request, utilizing a target memory allocator to allocate a first memory, and utilizing a general memory allocator to allocate a second memory, the first memory being used for creating an object of a specific type, the second memory being used for creating objects of other types, and the other types being types except the specific type; wherein the first memory is larger than the second memory, the target memory allocator is different from the general memory allocator, and the target memory allocator pre-allocates a virtual memory in an initialization stage. According to the scheme, page table failure and TLB loss can be effectively reduced, and memory fragments can be effectively reduced. According to the scheme provided by the invention, the memory allocation performance can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of software, and in particular to a method and device for allocating memory in data query. Background Art

[0002] Currently, the database can support data query. When the database receives a data query request, it can apply for memory from the operating system (OS) so as to use the applied memory to process the data query request.

[0003] Currently, when a database requests memory from an operating system, a general memory allocator can be used to allocate memory. However, the memory allocation performance is poor when a general memory allocator is used to allocate memory.

[0004] Therefore, a solution is urgently needed to solve the above problems. Summary of the invention

[0005] In order to solve or at least partially solve the above technical problems, the present application provides a memory allocation method and device in data query.

[0006] In a first aspect, the present application provides a memory allocation method in data query, the method comprising:

[0007] Receive data query requests;

[0008] According to the data query request, a first memory is allocated using a target memory allocator, and a second memory is allocated using a general memory allocator, wherein the first memory is used to create an object of a specific type, and the second memory is used to create objects of other types, wherein the other types are types other than the specific type; wherein:

[0009] The first memory is larger than the second memory, the target memory allocator is different from the general memory allocator, and the target memory allocator pre-allocates virtual memory during the initialization phase.

[0010] Optionally, allocating the first memory using the target memory allocator includes:

[0011] Allocating a target virtual memory from the pre-allocated virtual memory;

[0012] The first memory is allocated based on the target virtual memory.

[0013] Optionally, the method is applied to a server, the server is integrated with a memory allocation service, and the method further includes:

[0014] In response to the server being started, the memory allocation service is initialized, wherein initializing the memory allocation service comprises: compiling the memory allocation service, and when the memory allocation service is in a compiling stage, allocating the virtual memory to the target memory allocator.

[0015] Optionally, the specific type of object includes one or more of the following:

[0016] Hash tables, arrays of pure data, and data structures including linked lists.

[0017] Optionally, the other types of objects include one or more of the following:

[0018] Pipeline executors, thread pools, columns, strings, vectors, and graphs.

[0019] Optionally, the page table corresponding to the virtual memory is obtained by segmenting the virtual memory using a large page table technology.

[0020] Optionally, the universal memory allocator includes:

[0021] Jemalloc, or Tcmalloc.

[0022] In a second aspect, the present application provides a memory allocation device in data query, the device comprising:

[0023] A receiving unit, used for receiving a data query request;

[0024] an allocation unit, configured to allocate a first memory using a target memory allocator and a second memory using a general memory allocator according to the data query request, wherein the first memory is used to create an object of a specific type, and the second memory is used to create objects of other types, wherein the other types are types other than the specific type; wherein:

[0025] The first memory is larger than the second memory, the target memory allocator is different from the general memory allocator, and the target memory allocator pre-allocates virtual memory during the initialization phase.

[0026] Optionally, the allocation unit is used to:

[0027] Allocating a target virtual memory from the pre-allocated virtual memory;

[0028] The first memory is allocated based on the target virtual memory.

[0029] Optionally, the device is applied to a server, the server is integrated with a memory allocation service, and the device further includes:

[0030] An initialization unit is used to initialize the memory allocation service in response to the server being started, wherein initializing the memory allocation service includes: compiling the memory allocation service, and when the memory allocation service is in the compiling stage, allocating the virtual memory to the target memory allocator.

[0031] Optionally, the specific type of object includes one or more of the following:

[0032] Hash tables, arrays of pure data, and data structures including linked lists.

[0033] Optionally, the other types of objects include one or more of the following:

[0034] Pipeline executors, thread pools, columns, strings, vectors, and graphs.

[0035] Optionally, the page table corresponding to the virtual memory is obtained by segmenting the virtual memory using a large page table technology.

[0036] Optionally, the universal memory allocator includes:

[0037] Jemalloc, or Tcmalloc.

[0038] In a third aspect, an embodiment of the present application provides an electronic device, the electronic device comprising a processor and a memory;

[0039] The processor is used to execute instructions stored in the memory so that the electronic device performs the method as described in any one of the first aspects above.

[0040] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, comprising instructions, wherein the instructions instruct a device to execute a method as described in any one of the above first aspects.

[0041] In a fifth aspect, an embodiment of the present application provides a computer program product, which, when executed on a computer, enables the computer to execute any of the methods described in the first aspect above.

[0042] Compared with the prior art, the embodiments of the present application have the following advantages:

[0043] The present application provides a memory allocation method in data query, the method comprising: receiving a data query request, and the process of processing the data query request needs to create a specific type of object and other types of objects in the memory, wherein the other types of objects refer to other objects other than the aforementioned specific types of objects. The difference between a specific type of object and an object of other types is that the memory required to create the two is different. Specifically, the memory occupied by creating a specific type of object is greater than the memory occupied by creating the other types of objects. In the present application, for objects that occupy less memory (i.e., objects of other types), a general memory allocator is used to allocate a second memory, so that the object with smaller memory is created based on the second memory later. For objects that occupy larger memory (i.e., objects of a specific type), a general memory allocator is no longer used to allocate memory, but a target memory allocator is used to allocate a first memory, so that the object of the specific type is created based on the first memory later, wherein the target memory allocator pre-allocates virtual memory in the initialization phase, therefore, allocating the first memory based on the target memory allocator can effectively reduce page table failures (pagefault) and bypass fast table buffers (translation lookaside buffer, TLB) misses (miss), so as to improve the performance of memory allocation. Moreover, by using this solution, memory fragmentation can be effectively reduced. Therefore, by using this solution, the performance of memory allocation can be improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0045] Figure 1 A flowchart of a memory allocation method in data query provided by an embodiment of the present application;

[0046] Figure 2 A flowchart of a memory allocation method provided in an embodiment of the present application;

[0047] Figure 3 A schematic diagram of the structure of a memory allocation device in data query provided by an embodiment of the present application;

[0048] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0049] In order to enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be described clearly and completely below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present application.

[0050] The inventor of the present application has found through research that when the database receives a data query request, it can apply for memory from the operating system so as to utilize the memory applied for to process the data query request. At present, the system memory allocator provided by the operating system can be used to allocate memory. However, the performance of the memory allocator provided by the operating system is relatively poor, which often affects the processing efficiency of the data query request. Therefore, a general memory allocator with better performance can be selected to allocate memory. For example, one of the general memory allocators is selected from the two general memory allocators of Jemalloc and Tcmalloc to allocate memory.

[0051] Among them, the general memory allocator has better performance when allocating smaller memory. In scenarios where larger memory needs to be allocated, the performance of the general memory allocator cannot meet the requirements. Specifically, it can be reflected in the serious page fault phenomenon and TLB miss phenomenon, and more memory fragmentation will be generated. During the execution of data query tasks, it is often necessary to apply for a larger memory. For example, during the vectorized execution process, each column of data is stored in the memory using an array of 64 kilobytes (k) in length; during the execution of commonly used aggregation (Aggregation), Join and other operators, a large amount of memory needs to be applied for to build a hash table.

[0052] Therefore, in data query tasks, the performance of using a general memory allocator to allocate memory cannot meet the requirements.

[0053] In order to solve the above problems, an embodiment of the present application provides a memory allocation method and device in data query.

[0054] Before introducing the solutions provided by the embodiments of the present application, the related concepts involved in the present application are introduced.

[0055] 1. Physical Memory

[0056] Physical memory refers to the actual memory in the computer, which can be composed of random access memory (RAM) and is directly managed by the computer hardware. The size of physical memory is fixed and depends on the configuration of the computer hardware.

[0057] 2. Virtual Memory

[0058] Virtual memory is an abstract concept provided by the operating system. The size of virtual memory is configurable and can be adjusted according to the operating system settings and application requirements.

[0059] 3. Page fault

[0060] Page fault means: when a page in the virtual address space corresponding to the virtual memory is accessed, if this page does not currently correspond to a page in the physical memory, a page fault signal will be generated.

[0061] 4.TLB miss

[0062] The basic unit stored in the TLB is the page table entry, which corresponds to the page table entry stored in the physical memory (such as RAM). The size of the page table entry stored in the TLB is fixed, so the larger the TLB capacity, the more page table entries can be stored, and the greater the probability of a TLB hit. Once a page entry in the physical memory cannot hit a page table entry in the TLB, a TLB miss occurs.

[0063] 5. Memory Fragmentation

[0064] As the name implies, memory fragmentation can be understood as fragmented memory, that is, memory with a smaller capacity. In this application, memory fragmentation refers to physical memory with a smaller capacity and not allocated.

[0065] Various non-limiting implementations of the present application are described in detail below in conjunction with the accompanying drawings.

[0066] Exemplary Methods

[0067] See also Figure 1 , which is a flow chart of a memory allocation method in a data query provided by an embodiment of the present application. The solution provided by the embodiment of the present application can be applied to a server, which can be a server integrated with a database or a server integrated with a database function.

[0068] In the embodiment of the present application, the method may include the following steps: S101-S102.

[0069] S101: receiving a data query request.

[0070] In one example, the data query request sent by other devices, such as other servers or clients, can be received, and the data query request is used to query target data from the database. The embodiment of the present application does not specifically limit the data query request, and the data query request can be, for example, a structured query language (SQL) statement.

[0071] S102: According to the data query request, a first memory is allocated using a target memory allocator, and a second memory is allocated using a general memory allocator, wherein the first memory is used to create objects of a specific type, and the second memory is used to create objects of other types, wherein the other types are types other than the specific types, wherein the first memory is larger than the second memory, the target memory allocator is different from the general memory allocator, and the target memory allocator pre-allocates memory during the initialization phase.

[0072] After receiving the data query request, the server may process the data query request to query the database for the target data requested by the data query request.

[0073] In the present application, processing the data query request requires a certain amount of memory, so before processing the data query request, memory needs to be allocated for the data query request. In a specific example, processing the data query request requires creating multiple objects in the memory, and the multiple objects include: objects of a specific type and objects of other types except the specific type.

[0074] In the present application, the memory required for a specific type of object is greater than the memory required for the other types of objects. In other words, the specific type of object requires a large memory, and the other types of objects require a smaller memory.

[0075] In one example, considering that a hash table is a basic data structure for join and aggregation calculations, its corresponding memory application and release are very intensive, creating a hash table requires a large amount of memory, and the impact on the query performance of the database is also very important. Therefore, in one example, the specific type of object includes a hash table.

[0076] In another example, considering that the data structure including the linked list needs to occupy multiple large (e.g., 4k) blocks of memory. Therefore, in one example, the specific type of object includes the aforementioned data structure including the linked list. The data structure including the linked list mentioned here may be, for example, Arena. Arena is similar to a memory pool, which avoids frequent memory application and release caused by temporary objects by applying for large blocks of memory, and is mainly used to store intermediate results of functions or intermediate results of aggregation.

[0077] In another example, considering that a plain data array (POD Array) also needs to frequently apply for and release large memory during the calculation process, in one example, the specific type of object includes a plain data array. Among them, the plain data array can include 3 types:

[0078] The first category is basic data types including numeric types and character types. Among them:

[0079] Numeric types can include integer types (int, short, long, etc.) and floating-point types (float, double, etc.). These types occupy a fixed size in memory and have a clear range of numerical representations. For example, an int type usually occupies 4 bytes and can represent a numerical range of -2147483648 to 2147483647.

[0080] Character types include, for example, the char type, which is used to represent a single character. In some systems, the char type may be signed or unsigned, depending on the compiler and platform.

[0081] The second category is simple structure types. Simple structure types include: structures whose members are POD types, and structures without special member functions. Among them:

[0082] If all members of a structure are of POD type, then the structure itself is also of POD type. For example: structPoint{int x; int y;}; This structure contains two integer members, both of which are of POD type, so Point is also of POD type. The memory layout of this structure is continuous, and the members are stored in memory in the order in which they are declared. Objects of this structure can be copied by simple memory copy operations.

[0083] If a structure does not contain special member functions such as user-defined constructors, destructors, copy assignment operators, and has no virtual functions and virtual base classes, then it may also be a POD type. For example, structSimpleStruct{int a; float b;}; This structure does not have any special member functions, so it is a POD type.

[0084] The third category is array types. Array types include arrays of basic data types and arrays of POD type structures. Among them, arrays composed of basic data types are of POD type. For example, int arr

[10] ; this integer array is of POD type because its element type int is of POD type and the memory layout of the array is continuous. If the element type of an array is a POD type structure, then this array is also of POD type. For example, struct Point points[5]; the points array here is of POD type because the Point structure is of POD type.

[0085] In the present application, the aforementioned other types of objects include other objects except the hash table, pure data array, and data structures including linked lists. As a specific example, the other types of objects include: one or more of: pipeline executor (PipelineExecutor), thread pool (ThreadPool), data column (Column), string (String), vector (vector) and map (map). Regarding PipelineExecutor, ThreadPool, Column, String, vector and map, they are all basic concepts in computer software and will not be described in detail here.

[0086] Considering that a specific type of object needs to occupy a large amount of memory, and the general memory allocator (such as the aforementioned Jemalloc or Tcmalloc) has poor performance in allocating large memory, therefore, in this application, a general memory allocator is no longer used to allocate memory for a specific type of object, but a target memory allocator different from the general memory allocator is used to allocate memory for the specific type of object. Specifically, the target memory allocator can be used to allocate a first memory, and the first memory is used to create the aforementioned specific type of object.

[0087] In the present application, the target memory allocator pre-allocates virtual memory in the initialization phase. When allocating the first memory, the target memory allocator can first allocate the target virtual memory from the pre-allocated virtual memory, and then allocate the first memory based on the target virtual memory. Specifically, the physical memory can be mapped to the target virtual memory. Correspondingly, the physical memory mapped to the target virtual memory is the first memory allocated by the target memory allocator for the specific type of object.

[0088] Because the target memory allocator pre-allocates virtual memory in the initialization phase, the target memory allocator can directly allocate the target virtual memory from the pre-allocated virtual memory when allocating the first memory, thereby effectively reducing the page fault corresponding to the virtual memory and effectively reducing TLB misses.

[0089] In one example, after pre-allocating virtual memory, the virtual memory can be segmented to obtain a page table corresponding to the virtual memory. As an example, if the kernel version of the server is higher and supports the huge page table (huge_page) technology, the pre-allocated virtual memory can be segmented using the huge_page technology to obtain a page table corresponding to the virtual memory. For example, the madvise function can be used to start the huge_page technology to segment the pre-allocated virtual memory using the huge_page technology to obtain a page table corresponding to the virtual memory. In this scenario, relative to not applying the huge_page technology, the larger the capacity of the virtual memory corresponding to a page table, the smaller the possibility of generating a page fault when allocating the first memory, and the better the effect of reducing TLB miss. As another example, if the kernel version of the server is not higher and does not support the huge_page technology, the page table corresponding to the virtual memory can also be obtained by segmenting the pre-allocated virtual memory in a conventional manner.

[0090] In the present application, the server side that executes the solution provided by the embodiment of the present application may be integrated with a memory allocation service, which is used to provide the memory allocation function provided by the aforementioned target memory allocator. In this scenario, the aforementioned general memory allocator pre-allocates virtual memory in the initialization phase, which may be the case when the memory allocation service is initialized. Specifically, the memory allocation service may be initialized when the server side is turned on. Among them, initializing the memory allocation service includes performing at least one initialization operation of the memory allocation service, wherein the at least one initialization operation includes: compiling the memory allocation service. Accordingly, the aforementioned operation of pre-allocating virtual memory may be performed when the memory allocation service is compiled. In other words, the server side may allocate the virtual memory to the target memory allocator when the memory allocation service is in the compilation phase, so as to facilitate the subsequent allocation of the first memory based on the pre-allocated virtual memory.

[0091] In addition, considering that the memory occupied by the aforementioned other types of objects is small, and the general memory allocator has better performance in allocating small memory, the general memory allocator can be used to allocate memory for the aforementioned other types of objects. Specifically, the general memory allocator can be used to allocate the second memory, and the second memory is used to create the aforementioned other types of objects. The second memory is smaller than the first memory.

[0092] For reference Figure 2 To understand, Figure 2 A flowchart of a memory allocation method provided in an embodiment of the present application is shown as follows: Figure 2 As shown, after receiving a data query request, a target memory allocator is used to allocate a first memory for a hash table, a pure data array, and a data structure including a linked list, and a general memory allocator is used to allocate a second memory for a pipeline executor, a thread pool, a data column, a string, a vector, and one or more objects in the graph.

[0093] It can be known from the above description that, using the solution provided by the embodiment of the present application, for objects that occupy less memory (i.e., objects of other types), a general memory allocator is used to allocate the second memory, so that the object with smaller memory is created based on the second memory later. For objects that occupy larger memory (i.e., objects of a specific type), a general memory allocator is no longer used to allocate memory, but a target memory allocator is used to allocate the first memory, so that the object of the specific type is created based on the first memory later. The target memory allocator pre-allocates virtual memory in the initialization phase, so that the first memory is allocated based on the target memory allocator, which can effectively reduce page faults and TLB misses.

[0094] Moreover, in the conventional technology, both large memory and small memory are allocated by a universal memory allocator, which easily generates memory fragmentation. In the present solution, large memory is allocated by a target memory allocator, and the target memory allocator allocates the first memory based on the pre-allocated virtual memory, which does not generate memory fragmentation. Compared with the case where both large memory and small memory are allocated by a universal memory allocator, the memory fragmentation generated by allocating small memory using a universal memory allocator is also greatly reduced. That is, using the present solution can also effectively reduce memory fragmentation.

[0095] In summary, it can be seen that the solution of the embodiment of the present application can effectively improve the memory allocation performance.

[0096] Exemplary Devices

[0097] Based on the method provided in the above embodiment, the embodiment of the present application further provides a device, which is described below in conjunction with the accompanying drawings.

[0098] See also Figure 3 , Figure 3 A schematic diagram of the structure of a memory allocation device in data query provided in an embodiment of the present application. Figure 3 The device 300 shown is used to execute the memory allocation method in data query provided by the above method embodiment.

[0099] The device 300 may specifically include, for example: a receiving unit 301 and an allocating unit 302 .

[0100] The receiving unit 301 is used to receive a data query request.

[0101] The allocation unit 302 is used to allocate a first memory using a target memory allocator and a second memory using a general memory allocator according to the data query request, wherein the first memory is used to create an object of a specific type, and the second memory is used to create objects of other types, and the other types are types other than the specific type; wherein:

[0102] The first memory is larger than the second memory, the target memory allocator is different from the general memory allocator, and the target memory allocator pre-allocates virtual memory during the initialization phase.

[0103] Optionally, the allocating unit 302 is configured to:

[0104] Allocating a target virtual memory from the pre-allocated virtual memory;

[0105] The first memory is allocated based on the target virtual memory.

[0106] Optionally, the device is applied to a server, and the server is integrated with a memory allocation service. The device also includes: an initialization unit, which is used to initialize the memory allocation service in response to the server being started, wherein initializing the memory allocation service includes: compiling the memory allocation service, and when the memory allocation service is in the compilation stage, allocating the virtual memory to the target memory allocator.

[0107] Optionally, the specific type of object includes one or more of the following:

[0108] Hash tables, arrays of pure data, and data structures including linked lists.

[0109] Optionally, the other types of objects include one or more of the following:

[0110] Pipeline executors, thread pools, columns, strings, vectors, and graphs.

[0111] Optionally, the page table corresponding to the virtual memory is obtained by segmenting the virtual memory using a large page table technology.

[0112] Optionally, the universal memory allocator includes:

[0113] Jemalloc, or Tcmalloc.

[0114] Since the device 200 is a device corresponding to the image processing method provided by the above method embodiment, the specific implementation of each unit of the device 200 is based on the same concept as the above method embodiment. Therefore, regarding the specific implementation of each unit of the device 200, please refer to the relevant description part of the above method embodiment, which will not be repeated here.

[0115] The embodiment of the present application also provides a device, the device comprising a processor and a memory;

[0116] The processor is used to execute instructions stored in the memory so that the device executes the method described in any one of the above method embodiments.

[0117] Reference below Figure 4, which shows a schematic diagram of the structure of an electronic device 400 suitable for implementing the embodiment of the present application. The electronic devices in the embodiment of the present application may include but are not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (portable android devices), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs (televisions), desktop computers, etc. Figure 4 The electronic device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0118] like Figure 4 As shown, the electronic device 400 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 401, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 402 or a program loaded from a storage device 408 into a random access memory (RAM) 403. In the RAM 403, various programs and data required for the operation of the electronic device 400 are also stored. The processing device 401, the ROM 402, and the RAM 403 are connected to each other via a bus 404. An input / output (I / O) interface 405 is also connected to the bus 404.

[0119] Typically, the following devices may be connected to the I / O interface 405: an input device 406 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 407 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 408 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 409. The communication device 409 may allow the electronic device 400 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 4 The electronic device 400 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.

[0120] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 409, or installed from the storage device 408, or installed from the ROM 402. When the computer program is executed by the processing device 401, the above-mentioned functions defined in the method of the embodiment of the present application are executed.

[0121] The electronic device provided in the embodiment of the present application and the method provided in the above embodiment belong to the same inventive concept. The technical details not fully described in this embodiment can be referred to the above embodiment, and this embodiment has the same beneficial effects as the above embodiment.

[0122] An embodiment of the present application provides a computer-readable medium having a computer program stored thereon, wherein when the program is executed by a processor, the method described in any of the above embodiments is implemented.

[0123] It should be noted that the computer-readable medium mentioned above in the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.

[0124] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.

[0125] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.

[0126] The computer-readable medium carries one or more programs, and when the one or more programs are executed by the electronic device, the electronic device executes the method.

[0127] Computer program code for performing the operations of the present application may be written in one or more programming languages ​​or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0128] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0129] The units involved in the embodiments described in this application may be implemented by software or hardware. The name of a unit / module does not limit the unit itself in some cases. For example, a voice data acquisition module may also be described as a "data acquisition module".

[0130] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.

[0131] In the context of the present application, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0132] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the following claims.

[0133] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.

[0134] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the protection scope of the present application.

Claims

1. A memory allocation method in data query, characterized in that: The method comprises: Receive data query requests; According to the data query request, a first memory is allocated using a target memory allocator, and a second memory is allocated using a general memory allocator, wherein the first memory is used to create an object of a specific type, and the second memory is used to create objects of other types, wherein the other types are types other than the specific type; wherein: The first memory is larger than the second memory, the target memory allocator is different from the general memory allocator, and the target memory allocator pre-allocates virtual memory during the initialization phase.

2. The method according to claim 1, characterized in that The step of allocating the first memory using the target memory allocator comprises: Allocating a target virtual memory from the pre-allocated virtual memory; The first memory is allocated based on the target virtual memory.

3. The method according to claim 1, characterized in that The method is applied to a server, the server is integrated with a memory allocation service, and the method further comprises: In response to the server being started, the memory allocation service is initialized, wherein initializing the memory allocation service comprises: compiling the memory allocation service, and when the memory allocation service is in a compiling stage, allocating the virtual memory to the target memory allocator.

4. The method according to claim 1, characterized in that: The specific type of object includes one or more of the following: Hash tables, arrays of pure data, and data structures including linked lists.

5. The method according to claim 1, characterized in that The other types of objects include one or more of the following: Pipeline executors, thread pools, columns, strings, vectors, and graphs.

6. The method according to claim 1, characterized in that The page table corresponding to the virtual memory is obtained by dividing the virtual memory using a large page table technology.

7. The method according to any one of claims 1 to 6, characterized in that: The universal memory allocator comprises: Jemalloc, or Tcmalloc.

8. A memory allocation device in data query, characterized in that: The device comprises: A receiving unit, used for receiving a data query request; an allocation unit, configured to allocate a first memory using a target memory allocator and a second memory using a general memory allocator according to the data query request, wherein the first memory is used to create an object of a specific type, and the second memory is used to create objects of other types, wherein the other types are types other than the specific type; wherein: The first memory is larger than the second memory, the target memory allocator is different from the general memory allocator, and the target memory allocator pre-allocates virtual memory during the initialization phase.

9. An electronic device, characterized in that: The electronic device comprises a processor and a memory; The processor is used to execute instructions stored in the memory so that the electronic device executes the method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: The method comprises instructions, wherein the instructions instruct a device to execute the method according to any one of claims 1 to 7.