CN114546665B - Object processing method and system - Google Patents

Object processing method and system Download PDF

Info

Publication number
CN114546665B
CN114546665B CN202210429453.0A CN202210429453A CN114546665B CN 114546665 B CN114546665 B CN 114546665B CN 202210429453 A CN202210429453 A CN 202210429453A CN 114546665 B CN114546665 B CN 114546665B
Authority
CN
China
Prior art keywords
target
pool
thread
memory
processing
Prior art date
Legal status (The legal status 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 status listed.)
Active
Application number
CN202210429453.0A
Other languages
Chinese (zh)
Other versions
CN114546665A (en
Inventor
费斯
朱金奇
董攀峰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hundsun Technologies Inc
Original Assignee
Hundsun Technologies Inc
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 Hundsun Technologies Inc filed Critical Hundsun Technologies Inc
Priority to CN202210429453.0A priority Critical patent/CN114546665B/en
Publication of CN114546665A publication Critical patent/CN114546665A/en
Application granted granted Critical
Publication of CN114546665B publication Critical patent/CN114546665B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5016Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/5011Pool
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/5018Thread allocation
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

An embodiment of the present specification provides an object processing method and a system, where the object processing method includes: according to an object acquisition instruction sent by an execution thread of an application program, creating a processing thread based on an object processing program library; the processing thread determines a target object pool in a target thread object pool set based on the object type information carried in the object acquisition instruction; and under the condition that the processing thread determines that the memory objects exist in the target object pool, sending the target memory objects meeting the object quantity requirements carried in the object acquisition instruction in the target object pool to the execution thread of the application program, so that the memory object acquisition efficiency is improved, part of traversed computing resources of the execution thread are reduced, and the processing efficiency of the execution thread is improved.

Description

Object processing method and system
Technical Field
The embodiment of the specification relates to the technical field of computers, in particular to an object processing method.
Background
The object pool technology is widely applied to the internet, and can reduce energy consumption of creating, using and destroying objects. In practical application, the object can be created in advance and stored in the object pool, when the current execution thread needs to acquire the object, the object can be directly extracted from the object pool, and after the use is finished, the object can be put back into the object pool to continue waiting for the next request for using the object. However, in a complex service scenario, when an execution thread requests an object from an object pool, all object pools need to be traversed to perform query, an object pool of the same type as the object of the requested object is found, and then the object is obtained and returned to the execution thread, so that the process of traversing all object pools not only brings a large delay problem to the execution thread, but also occupies a large amount of computing resources, and affects the processing efficiency of the execution thread.
Disclosure of Invention
In view of this, the embodiments of the present specification provide an object processing method. One or more embodiments of the present specification also relate to an object processing system, a computing device, a computer-readable storage medium, and a computer program, so as to solve the technical problems in the prior art.
According to a first aspect of embodiments of the present specification, there is provided an object processing method including:
according to an object acquisition instruction sent by an execution thread of an application program, creating a processing thread based on an object processing program library;
executing the processing thread, and determining a target object pool in a target thread object pool set based on object type information carried in the object acquisition instruction, wherein the target thread object pool set corresponding to the executing thread is created by the processing thread based on the object processing program library, and the target object pool is used for storing a memory object with the same object type information;
and executing the processing thread, and sending the target memory objects meeting the object quantity requirement carried in the object acquisition instruction in the target object pool to the execution thread of the application program under the condition that the memory objects exist in the target object pool.
According to a second aspect of embodiments herein, there is provided an object processing system comprising: the device comprises a processing module and a storage module;
the processing module is configured to respond to an object acquisition instruction sent by an execution thread of an application program and create a processing thread based on the object processing program library;
the processing module is further configured to execute the processing thread, and determine the target object pool in the target thread object pool set based on object type information carried in the object acquisition instruction, where the target thread object pool set corresponding to the execution thread is created by the processing thread based on the object processing program library, and the target object pool is used for storing a memory object that is the same as the object type information;
the processing module is further configured to execute the processing thread, and send a target memory object, which meets the requirement of the number of objects carried in an object acquisition instruction, in the target object pool to the execution thread of the application program under the condition that it is determined that a memory object exists in the target object pool.
According to a third aspect of embodiments herein, there is provided a computing device comprising:
a memory and a processor;
the memory is used for storing computer-executable instructions, and the processor is used for executing the computer-executable instructions, and the computer-executable instructions realize the steps of the object processing method when being executed by the processor.
According to a fourth aspect of embodiments herein, there is provided a computer-readable storage medium storing computer-executable instructions that, when executed by a processor, implement the steps of the above object processing method.
According to a fifth aspect of embodiments herein, there is provided a computer program which, when executed in a computer, causes the computer to perform the steps of the above object processing method.
One embodiment of the present specification creates a processing thread based on an object handler library by an object fetch instruction sent according to an execution thread of an application; executing the processing thread, and determining a target object pool in a target thread object pool set based on object type information carried in the object acquisition instruction, wherein the target thread object pool set corresponding to the executing thread is created by the processing thread based on the object processing program library, and the target object pool is used for storing a memory object with the same object type information; and executing the processing thread, and sending the target memory objects meeting the object quantity requirement carried in the object acquisition instruction in the target object pool to the execution thread of the application program under the condition that the memory objects exist in the target object pool.
Specifically, when an object acquisition instruction sent by an execution thread is received, the processing thread can be activated according to an object processing program library, the processing thread is utilized, a target thread object pool set corresponding to the execution thread is determined according to object type information, a target object pool can be directly determined in the target thread object pool set, and further, a memory object required by the execution thread can be acquired in the target object pool. The processing efficiency of the execution thread is improved.
Drawings
Fig. 1 is a schematic diagram illustrating a memory object obtaining process of an object processing method according to an embodiment of the present disclosure;
FIG. 2 is a flowchart illustrating an object processing method according to an embodiment of the present disclosure;
fig. 3 is a schematic diagram illustrating an association relationship between object pools in an object processing method according to an embodiment of the present specification;
fig. 4 is a schematic process diagram illustrating initialization of a memory object by an application and an object processing apparatus in an object processing method according to an embodiment of the present disclosure;
fig. 5 is a schematic process diagram illustrating an object processing method for allocating a memory object to an application by an object processing apparatus according to an embodiment of the present disclosure;
fig. 6 is a schematic flowchart illustrating an object processing apparatus in an object processing method according to an embodiment of the present disclosure releasing a memory object between application programs;
fig. 7 is a schematic flowchart illustrating an object processing method for controlling the number of memory objects in an object pool in an asynchronous manner according to an embodiment of the present disclosure;
FIG. 8 is a block diagram of an object processing system according to an embodiment of the present disclosure;
fig. 9 is a block diagram of a computing device according to an embodiment of the present disclosure.
Detailed Description
In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present description. This description may be embodied in many different forms and should not be construed as limited to the embodiments set forth herein, as those skilled in the art will be able to make and use the present disclosure without departing from the spirit and scope of the present disclosure.
The terminology used in the description of the one or more embodiments is for the purpose of describing the particular embodiments only and is not intended to be limiting of the description of the one or more embodiments. As used in one or more embodiments of the present specification and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used in one or more embodiments of the present specification refers to and encompasses any and all possible combinations of one or more of the associated listed items.
It will be understood that, although the terms first, second, etc. may be used herein in one or more embodiments to describe various information, these information should not be limited by these terms. These terms are only used to distinguish one type of information from another. For example, a first can also be referred to as a second and, similarly, a second can also be referred to as a first without departing from the scope of one or more embodiments of the present description. The word "if" as used herein may be interpreted as "at … …" or "when … …" or "in response to a determination", depending on the context.
First, the noun terms to which one or more embodiments of the present specification relate are explained.
Memory object: refers to a component of a computer system in which an object contains two meanings, one of which is data and the other of which is an action. The object is a combination of data and actions. The object can not only be operated, but also can timely record the operation result.
Memory management: refers to the technology of allocating and using the memory resource of the computer when the software runs. The main objective is how to efficiently and quickly allocate and, when appropriate, release and reclaim memory resources.
An object pool: the method is characterized in that the method is a memory space for storing memory objects; when an object is needed, it can be fetched from the pool of objects (one can be created if there is no pool), which saves a lot of time for the thread to fetch the object.
Dynamic link library (program library): is an executable module, which contains functions that can be called and executed by an application program to provide services for the application program, such as a so file of linux, and a DLL file of windows.
SMP (Symmetric Multi-processing) architecture: the multiprocessor architecture refers to that a plurality of CPUs in a server work symmetrically without primary and secondary or subordinate relations. In SMP all processors are peers and they share the same block of physical memory through a bus connection, which results in all resources (CPU, memory, I/O, etc.) in the system being shared.
NUMA (Non-Uniform Memory Access) architecture: the storage model is a technical scheme provided for solving poor capacity expandability of the SMP, and the architecture can support hundreds of CPUs for expansion.
In program operation, a memory Object is a real carrier of a data structure, and in the current Object Oriented Programming (OOP), the concept is strengthened. The life cycle of a memory object comprises the following stages: the method comprises the steps of memory space allocation, memory object initialization, read-write operation, destructuring and memory space release.
Currently, both the mainstream operating system and the runtime library of the development language provide a universal memory space allocation and release interface (e.g., mmap and munmap provided by the Linux system; malloc and free provided by the C language runtime library). Meanwhile, many application programs have developed various memory allocation and management techniques for higher requirements on performance or memory utilization, management, and the like, such as: memory pool techniques, and the like. But these techniques only address allocation and release of memory space.
In addition, there is an object pool technique whose principle is: when the external requests the memory object, whether the object of the type already exists in the object pool is judged, and if the object of the type already exists in the object pool, the object is taken out from the object pool and is used by the external; when the object pool does not exist, a batch of objects are created and put into the pool, and then the objects are taken out to be used outside.
In an actual usage scenario, the application program has the following requirements for the memory object: 1. when distributing, the memory object which can be directly used needs to be obtained (namely initialization is completed); 2. when releasing, the resources occupied by the object in the using process thereof need to be released (i.e. destruct is completed). Practice shows that, for initialization and reconstruction of memory objects (such as Linux kernel objects, various service model objects of application programs, and the like), there is a larger performance loss than allocation and release of memory space. The performance loss of the part cannot be solved only by high-performance memory allocation and release.
Meanwhile, the existing object pool technology does not provide a high-performance solution for solving the performance loss; in the process of acquiring the memory object by the execution thread of the application program, the memory object required by the execution thread can be searched in a traversal mode from the established object pool, meanwhile, the operation of the mutual exclusion lock is required to be added to ensure the safety of the thread, but the concurrent operation is limited by the operation of adding the mutual exclusion lock, so that the time consumption is increased and the performance is reduced in the whole process of searching the memory object by traversing the object pool; therefore, even if the object pool technique is used in the memory object obtaining process, the use requirement of the memory object in a general scene can only be solved, and because the number of the memory objects in the object pool cannot be automatically maintained, in a scene with higher performance requirement, the memory object and the memory utilization rate cannot be allocated with high performance by using the general object pool technique.
Based on this, the object processing method provided in this specification, based on the life cycle of the memory object, adopts an asynchronous technical manner, by creating a dedicated thread object pool set for each execution thread of the application program, and creating the memory object corresponding to each execution thread in each thread object pool set, so as to implement high-performance allocation and release of the memory object for the application program, and meanwhile, under the condition that there is no memory object in the thread object pool set corresponding to the execution thread, it is also possible to create an object total pool to generate the memory object required by the execution thread, and allocate the memory object to the thread object pool set corresponding to the execution thread, so that the execution thread can directly go to the thread object pool set to obtain the memory object, which not only can satisfy the usage requirement of a general scene, but also can save the computational resources of the execution thread for a usage scene with severe performance requirement, the processing efficiency of the execution thread is improved; in addition, a dedicated thread object pool set is created for each execution thread, so that the conflict of obtaining memory objects among multiple threads is avoided, the operation of mutual exclusion lock is not required to be executed, and meanwhile, the high-performance concurrency capability is improved.
In the present specification, an object processing method is provided, and the present specification relates to an object processing system, a computing device, a computer-readable storage medium, and a computer program, which are described in detail one by one in the following embodiments.
Referring to fig. 1, fig. 1 is a schematic diagram illustrating a memory object obtaining process of an object processing method according to an embodiment of the present disclosure.
It should be noted that fig. 1 illustrates an interaction diagram between an application 102 and an object processing apparatus 104 in an object processing method provided by an embodiment of the present specification; the object processing apparatus 104 includes a central processing unit 1042 and a memory 1044, and runs a processing thread in the central processing unit 1042 and stores a library and an object pool in the memory 1044.
In practical application, when an application program executes multi-thread tasks under concurrent programs, a memory object corresponding to each task needs to be acquired so as to quickly complete object acquisition tasks; in the embodiment of the present disclosure, the object processing apparatus 104 is provided to quickly obtain a memory object for an execution thread corresponding to an application program. Specifically, an execution thread of the application program sends an object obtaining request to the object processing apparatus 104, and after receiving the object obtaining request, the central processing unit 1042 activates a processing thread based on the library in the memory 1044, and obtains the memory object for the application program by using the processing thread.
Further, the processing thread may determine a thread object pool set corresponding to the execution thread, and then determine an object pool corresponding to the memory object that the application program wants to acquire in the thread object pool set, and further send the memory object in the object pool to the execution thread corresponding to the application program; it should be noted that the thread object pool set and the object pool in the object processing apparatus 104 may be created in advance based on a library, wherein the library may be understood as a dynamic link library, a library that can store code and data used by multiple programs at the same time, for example, a DLL file in a windows system.
In the object processing method provided in the embodiment of the present specification, an object pool for storing a memory object is created for an execution thread in an application by using a library, and the memory object is directly obtained from the object pool corresponding to the execution thread, so that not only is the memory object obtaining efficiency improved, but also a part of traversed computing resources of the execution thread are reduced, and the processing efficiency of the execution thread is improved.
Referring to fig. 2, fig. 2 shows a processing flow chart of an object processing method provided in an embodiment of the present specification, which specifically includes the following steps.
It should be noted that, the object processing method provided in the embodiment of the present specification takes an application program applied to stock trading as an example, and details a process of the application program acquiring a memory object, including but not limited to the above application scenario.
Wherein, the application scenario can be understood as: when the stock exchange application program processes the stock exchange of the user, the execution thread can acquire the memory object in advance, such as a user exchange order, user personal account information and the like, and then execute the subsequent exchange processing process. Based on this, the technical problem that this specification example relates to is: how an execution thread of an application program can quickly acquire a desired memory object for subsequent processing is achieved, so that the problem of high-performance memory object management under multi-thread concurrent application program is solved.
Step 202: and creating a processing thread based on the object processing program library according to an object acquisition instruction sent by the execution thread of the application program.
The object obtaining instruction may be understood as an instruction sent by the execution thread to obtain a memory object, for example, a stock trading application sends an obtaining instruction for a user trading order object, an obtaining instruction for a user personal account information object, and the like.
The object processing library may be understood as a dynamic link library of codes and data used for creating an object pool, for example, a memory object may be generated for an execution thread, an object pool for storing the memory object may be created, and the like by using pre-stored codes and data in the object processing library.
A processing thread may be understood as a thread that executes threads independently of an application, and the processing thread may drive the operation of the entire memory object acquisition process using code and data in the object handler library; therefore, the time-consuming operations of generating the memory object by the execution thread of the application program and then processing the memory object can be completed by the asynchronous operation of the processing thread, and further, the asynchronous operations of memory allocation, object generation, object destructuring, object recycling, memory release and the like of the whole device can be driven.
In practical applications, after receiving an object obtaining instruction sent by an execution thread of an application program, the central processing unit may create a processing thread according to pre-stored codes and data in the object processing program library, and this step may be understood as an activation process for the processing thread.
Step 204: and executing the processing thread, and determining a target object pool in a target thread object pool set based on the object type information carried in the object acquisition instruction.
And the target thread object pool set corresponding to the execution thread is created by the processing thread based on the object processing program library, and the target object pool is used for storing the memory objects with the same object type information.
The object type information may be understood as type information of a memory object that needs to be acquired by the execution thread, for example, the object type information of the user transaction order object is transaction type information, and the object type information of the user personal account information is personal attribute type information.
The target thread object pool set can be understood as an object pool set for storing memory objects of execution threads of the application program, wherein the target thread object pool set can comprise one or more object pools; the target object pool may be understood as an object pool that specifically stores memory objects needed to execute a thread.
In practical applications, after determining object type information of a memory object that needs to be obtained by a processing thread, a target thread object pool set for storing the memory object may be determined in a plurality of thread object pool sets, and a target object pool for storing the memory object may be determined in the target thread object pool set. It should be noted that the processing thread may create a plurality of thread object pool sets in advance based on the object handler library according to different service requirements, that is, a dedicated thread object pool set is created for each execution thread of the application program, and is used to store a memory object that may be needed by each execution thread. Meanwhile, a plurality of object pools can be continuously created in each thread object pool set according to the object processing program library, each object pool stores memory objects of the same type, for example, an object pool 1 storing transaction memory objects is provided in a thread object pool set 1 corresponding to the execution thread 1, and then a subsequent execution thread can directly acquire the memory objects from the object pool 1.
Step 206: and executing the processing thread, and sending the target memory objects meeting the object quantity requirement carried in the object acquisition instruction in the target object pool to the execution thread of the application program under the condition that the memory objects exist in the target object pool.
In practical application, when determining that a memory object exists in a target object pool in a target thread object pool set, a processing thread can directly send a target memory object stored in the target object pool of the target thread object pool set to an execution thread of an application program, so that the execution thread of the application program can complete subsequent work conveniently.
It should be noted that, based on the above steps 202, 204, and 206, all operations of the execution thread are performed in the thread object pool dedicated to the execution thread, that is, it can be understood that the thread shares resources exclusively, and this way does not have the performance overhead caused by the locking or unlocking operation of the mutual exclusion lock, so this process is a flow for rapidly allocating memory objects in most cases.
In practical applications, not all target memory objects can be stored in the target object pool of the target thread object pool set, and then the processing thread needs to further judge, that is, after the processing thread determines the target object pool in which the memory objects are stored, the processing thread needs to further judge whether the target object pool has the memory objects, and under the condition that it is determined that there is no memory object required by the execution thread in the target object pool, the processing thread can drive the target thread object pool set to acquire the memory objects from the object total pool set; specifically, after the executing the processing thread determines the target object pool in the target thread object pool set based on the object type information carried in the object obtaining instruction, the method further includes:
executing the processing thread, and sending the target memory objects meeting the object quantity requirement carried in the object acquisition instruction to a target object pool in the target thread object pool set on the basis of the object total pool set under the condition that the memory objects do not exist in the target object pool and the object total pool set exists; or executing the processing thread, creating the object total pool set based on the object processing program library under the condition that the memory object does not exist in the object pool and the object total pool set does not exist, and sending the target memory object meeting the object quantity requirement carried in the object acquisition instruction to the target object pool in the object pool set of the target thread based on the created object total pool set.
The total object pool set may be understood as an object pool set for generating memory objects required by the execution thread for the application program, and the total object pool set may also include a plurality of object pools for storing all memory objects that may be required by the application program.
A target memory object may be understood as a memory object that an execution thread of an application needs to obtain based on an object obtain instruction.
In practical application, the processing thread may also obtain the memory object from the total object pool set when it is determined that the memory object does not exist in the total target thread object pool set, and then, the processing thread may directly send the target memory object meeting the object quantity requirement carried in the object obtaining instruction from the total object pool set to the target object pool in the target thread object pool set when the memory object exists in the total object pool set; under the condition that the memory object does not exist in the object total pool set, the processing thread can also create an object total pool set, and then acquire a target memory object from the created object total pool set and place the target memory object into a target object pool; it should be noted that the total object pool set is also created based on the object handler library, and is consistent with the creation process in the thread object pool set.
In the object processing method provided in the embodiments of the present specification, when there is no memory object in the thread object pool set, the memory object may be obtained from the object total pool set, and sent to the target thread object pool set corresponding to the execution thread, so that the subsequent execution thread may quickly and directly obtain the memory object from the thread object pool set corresponding to the subsequent execution thread.
After the memory objects in the object total pool set are determined to be sent to the target thread object pool set corresponding to the execution thread, the processing thread can drive the execution thread of the application program to directly obtain the memory objects from the target thread object pool set; specifically, after sending the target memory objects meeting the object quantity requirement carried in the object obtaining instruction to the target object pool in the target thread object pool set, the method further includes:
and executing the processing thread, and sending the target memory objects meeting the object quantity requirements carried in the object acquisition instruction in the target object pool to the execution thread of the application program based on the target object pool in the target thread object pool set.
In practical applications, the execution thread of the application program acquires the target memory object from the target object pool in the target thread object pool set, but if the target memory object does not exist in the target object pool of the target thread object pool set, the processing thread may also drive the target thread object pool set to transport a certain number of target memory objects from the object total pool set, and further, the target thread object pool set sends the acquired target memory object to the execution thread of the application program.
It should be noted that, after the memory object required by the execution thread does not exist in the thread object pool set, the corresponding memory object may be searched from the object total pool set, and in the case that the object total pool set does not exist, the processing thread may drive the object total pool set to generate the memory object for the execution thread, and directly send the generated memory object to the thread object pool set, so that the execution thread may obtain the memory object from the thread object pool set.
In the object processing method provided in the embodiment of the present specification, the execution thread of the application program obtains the memory object from the dedicated thread-level object pool set corresponding to the execution thread, which not only can save the computing resource of the execution thread for generating the memory object, but also can quickly obtain the memory object from the object pool, thereby improving the processing efficiency of the application program.
Furthermore, in order to quickly allocate the memory objects required by the execution thread, the processing thread can also store the memory objects in different object pool sets in a classified manner, and each object pool stores the memory objects of the same type, so that in the process of specifically searching the memory objects, the searching process can be realized according to the object type information of the memory objects; specifically, the executing the processing thread and sending the target memory objects meeting the object quantity requirement carried in the object obtaining instruction to the target object pool in the target thread object pool set based on the object total pool set includes:
executing the processing thread, and determining a target object pool in the object total pool set based on object type information carried in the object acquisition instruction, wherein the object total pool set is created by the processing thread based on an object processing program library, and the target object pool is used for storing a memory object which is the same as the object type information;
and executing the processing thread, and sending the target memory objects meeting the object quantity requirement carried in the object acquisition instruction in the target object pool to the target object pool in the target thread object pool set under the condition of determining that the memory objects exist in the target object pool.
The object type information may be understood as type information of memory objects stored in object pools, and each object pool stores memory objects with the same type information.
In practical application, in the process that the thread object pool set acquires the memory object from the object total pool set, the processing thread can determine an object pool with the same object type information in the object total pool set according to the object type information carried in the object acquisition instruction, and the object pool can be regarded as a target object pool for storing a target memory object; further, whether a memory object exists in the target object pool is judged, and under the condition that the memory object exists in the target object pool, the target memory objects meeting the object quantity requirement in the object acquisition instruction in the target object pool are sent to the target object pool in the target thread object pool set.
In addition, under the condition that the processing thread determines that the target memory object is not stored in the target object pool in the target thread object pool set, whether the target memory object exists in the object total pool set is judged, and if the target memory object does not exist in the object total pool set, the object total pool set can be driven to continue to generate the target memory object for the execution thread; specifically, the sending, based on the created total object pool set, a target memory object that meets the object quantity requirement carried in an object obtaining instruction to a target object pool in the target thread object pool set includes:
executing the processing thread, and creating a target object pool in the created object total pool set based on an object processing program library;
executing the processing thread, and generating a target memory object meeting the object quantity requirement carried in an object acquisition instruction in a target object pool of the object total pool set;
and executing the processing thread, and sending the target memory object to a target object pool in the target thread object pool set.
In practical application, the processing thread may continue to create a target object pool in the created object total pool set based on the object processing library, where the target object pool stores memory objects consistent with a target object pool in the target thread object pool set, or may be understood as that, after the execution thread does not acquire a target memory object in the corresponding target thread object pool set, the target thread object pool set may acquire the target memory object from the object total pool set and send the target memory object to the execution thread, and if the target memory object does not exist in the object total pool set, the processing thread may drive the object total pool set to generate a target memory object meeting the requirement of the number of objects, and then send the newly generated target memory object to the target object pool in the target thread object pool set.
In the object processing method provided in the embodiments of the present specification, a target object pool may be continuously created in a created total object pool set, a target memory object is generated in the target object pool, and the target memory object is provided for a target thread object pool set, so as to meet an application requirement of an execution thread on the target memory object.
Before creating the object pool, the processing thread can also apply for allocating memory to the system memory for storing the created object pool, so that before generating the target memory object for the target thread object pool set, the processing thread can allocate a certain memory space in advance for storing the object pool and the target memory object; specifically, before the executing the processing thread and generating a target memory object meeting the requirement of the number of objects carried in the object obtaining instruction in the target object pool of the total object pool set, the method further includes:
executing the processing thread, allocating a first memory space for a target object pool in the created total object pool set based on a memory pool,
the memory pool is created by the processing thread based on the object processing program library, the memory pool occupies a system memory space of the application program, and the first memory space is a part of a storage space in the memory pool.
In practical applications, the processing thread may create a memory pool in the total object pool set according to the object processing program library, where the memory pool is used to store the running memory data corresponding to all execution threads of the application program, and further, when the processing thread creates a target object pool in the created total object pool set, the processing thread also needs to allocate a first memory space for the target object pool to store a target memory object.
Further, the executing the processing thread and generating a target memory object meeting the requirement of the number of objects carried in an object obtaining instruction in a target object pool of the total object pool set includes:
executing the processing thread, and acquiring running data corresponding to the executing thread from the memory pool based on the object type information carried in the object acquisition instruction;
executing the processing thread, and generating a target memory object meeting the object quantity requirement carried in an object acquisition instruction in a target object pool of the object total pool set based on the running data corresponding to the executing thread, wherein the target memory object occupies the first memory space.
In practical application, a processing thread determines object type information of a memory object required by an execution thread according to an object acquisition instruction, acquires running data corresponding to the execution thread from a memory pool in advance, generates a target memory object for the execution thread based on the running data, and stores the target memory object to a target object pool in an object total pool set.
In the object processing method provided in the embodiment of the present specification, a target memory object is generated in a target object pool of a total object pool set, so that a target thread object pool set can obtain memory objects meeting the requirement of the number of objects in the total object pool set.
It should be noted that, after the target thread object pool set obtains the target memory object from the total object pool set, the target memory object may also be stored in the target object pool of the target thread object pool set, and further, a second memory space also needs to be allocated to the target object pool; specifically, after the executing the processing thread determines the target object pool in the target thread object pool set based on the object type information carried in the object obtaining instruction, the method further includes:
and executing the processing thread, and allocating a second memory space for a target object pool in the target thread object pool set based on a memory pool, wherein the second memory space is a part of storage space in the memory pool.
In practical applications, the processing thread may also allocate a second memory space to the target object pool in the target thread object pool set, so that the target object pool stored in the target thread object pool set occupies a corresponding system memory space.
Furthermore, the processing thread may also continuously detect whether the space of the idle memory in the memory pool is too large, which may cause waste of system space, and therefore, the processing thread needs to determine whether the idle memory space exceeds a preset space threshold interval, and then perform subsequent processing; specifically, still include:
and executing the processing thread, and returning the free memory space exceeding the preset space threshold interval to the system memory space of the application program under the condition that the free memory space in the memory pool is determined to exceed the preset space threshold interval.
The free memory space may be understood as a free memory in the memory pool except for a space allocated to store the object pool.
In practical application, the processing thread can also monitor the memory space of the memory pool in real time and dynamically adjust the free memory space in the memory pool, so that the waste of the system memory space can be avoided while the requirement of storing the object pool is met; if the free memory space exceeds the preset space threshold interval, the exceeded free memory space can be returned to the system memory space of the application program, and if the free memory space is smaller than the preset space threshold interval, the memory pool can continue to apply for the memory space from the system memory space according to the specified step length.
The process of the object processing method may be understood as a process of allocating memory objects, and the following describes association relationships among each thread object pool, an object total pool, and a processing thread by taking fig. 3 as an example, and refers to fig. 3, and fig. 3 shows an association relationship schematic diagram among each object pool of the object processing method provided in an embodiment of the present specification.
Fig. 3 includes an object total pool, a thread 1 object pool, a thread N object pool, and an asynchronous thread, where the thread 1 object pool and the thread N object pool respectively include an object pool 1 and an object pool 2.
In practical application, each execution thread of an application program has a respective exclusive thread object pool, and under a multi-thread concurrent operation working mode, mutual exclusion lock does not need to be introduced for application and release operations of memory objects, so that performance loss caused by locking and unlocking is avoided, and the multi-thread concurrent performance is greatly improved. In addition, the thread object pool may also include different types of object pools, each object pool has a free object list and a release object list, and the thread object pool is responsible for the operation request for memory object allocation and release in the respective threads, and is a boundary surface for peripheral interaction (interaction with the execution thread of the application program); for example, the thread object pool corresponding to the execution thread 1 is a thread 1 object pool, and the thread object pool corresponding to the execution thread N is a thread N object pool; and each thread object pool and the object total pool have an incidence relation, and according to the description of the memory object allocation process, under the condition that the number of the target memory objects stored in the object pool 1 in the thread 1 object pool is insufficient or no target memory objects are stored, the thread 1 object pool can directly obtain the corresponding target memory objects from the object total pool.
Further, the object total pool includes a memory pool, which is responsible for interacting with the operating system, managing allocation and release of the memory, and storing different types of object pools, each of which includes a certain number of spare objects for standby.
In addition, the asynchronous thread drives the whole memory object allocation operation, and all time-consuming operations are asynchronously processed under the driving of the asynchronous thread, including asynchronous memory allocation, object initialization, object destruct, object recycle, memory release and the like.
It should be noted that, when the object processing method provided in this specification is applied to an object processing apparatus, the object processing apparatus may provide a high-performance memory object obtaining process for an application program, and in an actual project requirement, a process of preparing a memory object may be understood as a process of initializing an object, but the initialization process is not a necessary process and does not require forced execution, but a process of generating an object initialization in advance may allow the entire object processing apparatus to be in a working-ready state, and prepare a memory object in advance to improve the overall performance, thereby avoiding additional performance overhead when allocating a memory object for the first time in the future after the apparatus is cold started. Explicit initialization is also a performance optimization technique that trades initialization for higher performance during program operation.
Referring to fig. 4, fig. 4 is a schematic diagram illustrating a process of initializing a memory object by an application and an object processing apparatus in an object processing method according to an embodiment of the present disclosure; it should be noted that the following description is in terms of steps.
Step 1: the application registers an object to be used by itself with the object processing apparatus.
Step 2: the object processing device stores registration information including, but not limited to, thread information, object type, size of occupied space of single object, initialization function, destructor, etc. of the registration behavior. The registration behavior may occur multiple times (depending on the programming language implemented by the object handling device, the user need only provide part of the registration information).
And step 3: the application program initiates an initialization request, and the object processing device responds and is activated.
And 4, step 4: the asynchronous thread creates an object total pool, the device detects a system CPU architecture at the moment, and if the system CPU architecture is an SMP architecture, one or more object total pools are created according to configuration; in the case of a NUMA architecture, one or more object total pools are created at each NUMA node according to configuration (here, it is understood that under multiple CPU architectures, multiple object total pools may be configured, and it is not limited to creating only one object total pool).
And 5: and the asynchronous thread creates a memory pool under each object total pool, is used for interacting with an operating system and is responsible for allocating and releasing the memory.
Step 6: and the asynchronous thread uses the memory pool below the total pool of each object to apply for the memory space from the operating system, and the size of the memory space is determined by the specified allocation step length.
And 7: the asynchronous thread may create a pool of objects for each registered object based on the type of registered object.
And 8: and the asynchronous thread allocates enough memory space for creating a certain number of objects according to the size of the space occupied by the registered object.
And step 9: and initializing the memory space by using an initialization function registered by the object on the allocated memory space by the asynchronous thread, so that the memory object is really created.
Step 10: and the asynchronous thread puts the created objects into idle queues of corresponding object pools.
Step 11: the asynchronous threads create a thread-level pool of objects for the threads based on the thread on which the registration activity occurred and the type of object registered on the thread.
Step 12: the asynchronous thread obtains a certain number of memory objects from the total object pool.
Step 13: and finally, the asynchronous threads place the memory objects into respective idle queues.
Step 14: the entire initialization process is complete.
In addition, the initialization operation of the memory object is a process of allocating the memory object under most conditions, and meanwhile, the asynchronous thread can also maintain the object water level in each object pool, and the fastest path to allocate is taken, that is, the object is taken out from the idle queue of the object pool of the type of the current thread.
Then, the following may describe, with reference to fig. 5, a process of allocating, by the object processing apparatus, a memory object to the application program under the condition that the memory object is not initialized in advance; referring to fig. 5, fig. 5 is a schematic diagram illustrating a process of allocating a memory object for an application by an object processing apparatus according to an object processing method provided in the embodiment of the present specification; the following is described in terms of steps.
Step 1: the application applies for an object from the object processing device.
Step 2: and the asynchronous thread judges whether the current thread object pool exists or not, and if not, the step 5 is carried out.
And step 3: and the asynchronous thread judges whether the object pool of the type of the current thread exists or not, and if not, the step 6 is carried out.
And 4, step 4: and the asynchronous thread determines whether an object exists in the idle queue of the object pool, if so, the object is immediately distributed to a user, and the process is ended. Until the current step, all operations are performed in an object pool exclusive to threads (threads share resources exclusively), and there is no performance overhead caused by locking/unlocking operations of mutual exclusion locks, so that the flow is a rapid allocation flow in most cases. If there are no objects in the free queue (if no), step 7 is entered.
And 5: the asynchronous thread creates a thread object pool.
Step 6: the asynchronous thread creates an object pool of the type in the current thread object pool.
And 7: and the asynchronous thread judges whether the object total pool exists or not, and if not, the step 12 is carried out.
And 8: and the asynchronous thread judges whether the object pool of the type exists in the object total pool, and if not, the step 14 is carried out.
And step 9: and the asynchronous thread judges whether an object exists in the idle queue of the object pool of the type in the object total pool, and if not, the step 15 is carried out.
Step 10: and the asynchronous thread acquires a certain number of objects from the idle queue of the object pool of the type in the object total pool and puts the objects into the idle queue of the object pool of the thread level type.
Step 11: and the asynchronous thread takes out the object from the idle queue of the object pool of the type of the thread level to the application program, and the process is ended.
Step 12: the asynchronous thread creates an aggregate pool of objects.
Step 13: and the asynchronous thread creates a memory pool in the object total pool and applies for a memory from an operating system.
Step 14: and the asynchronous thread creates the type object pool in the object general pool.
Step 15: the asynchronous thread judges whether the residual space of the memory pool of the object total pool is enough to distribute the current time, and then the step is skipped; and when the residual space is insufficient, the memory pool allocates the memory to the operating system according to the specified step length.
Step 16: the asynchronous thread creates a certain number of memory objects of that type, i.e. initialization objects.
And step 17: the asynchronous thread puts the initialized object into the free queue of the object pool of the type in the object total pool, and then the step 10 is carried out.
It should be noted that the other branch in fig. 5 is entered only when the target processing apparatus is cold-started, or when an unregistered target is first allocated, or when the load of the target processing apparatus is large and the asynchronous thread cannot maintain the target level.
Furthermore, after the execution thread of the application program finishes using the memory object, the memory object can be returned to the thread object pool set for storage, so that the subsequent memory object can be reused; specifically, after sending the target memory object in the target object pool, which meets the object quantity requirement carried in the object obtaining instruction, to the execution thread of the application program, the method further includes:
executing the processing thread, and placing the target memory object in a release queue corresponding to the target object pool under the condition of receiving the target memory object returned by the execution thread of the application program;
and executing the processing thread, and releasing the target memory object in the release queue under the condition that the target memory object is determined to meet the release condition.
In practical application, when receiving a target memory object returned by an execution thread of an application program, a processing thread may also place the memory object in a release queue of the type object pool according to an object type of the memory object, and further, when determining that the target memory object satisfies a release condition, release the target memory object stored in the release queue.
Fig. 6 is a schematic flow chart illustrating that an object processing apparatus releases a memory object between application programs in an object processing method provided in an embodiment of the present specification; the following is described in terms of steps.
Step 1: when the object is used, the application returns the memory object (releases the object).
Step 2: and receiving the object pool of the application program execution thread, and putting the object pool into a release queue of the type object pool according to the type of the memory object. Wherein the returning operation occurs in the returning thread and the exclusive thread object pool thereof, so that no lock related operation exists. Meanwhile, the step only returns the memory objects. The release of the memory object is handled by an asynchronous thread described below.
Specifically, the executing the processing thread, and releasing the target memory object in the release queue under the condition that it is determined that the target memory object meets the release condition, includes:
and executing the processing thread, and releasing the target memory object in the release queue under the condition that the target memory object exists in the release queue.
In practical applications, the processing thread may traverse each thread object pool set, and simultaneously, further traverse each type of object pool, and under the condition that it is determined that a target memory object exists in the release queue of the type of object pool, may complete the destruct operation of the memory object (i.e., release any resource occupied by the memory object in the previous use process, and then put into the idle queue), so as to improve the memory object management efficiency.
Under the condition that the processing thread determines that no memory object exists in the release queue, whether the number of the target memory objects in the object pool reaches a high water level (the high water level can be understood as the condition that the number of the memory objects reaches a certain number threshold) can be further judged by the processing thread so as to trigger the memory objects to be returned to the object main pool; specifically, before the executing the processing thread determines that the target memory object exists in the release queue, the method further includes:
and executing the processing thread, and sending the target memory objects corresponding to the number exceeding the first object number threshold interval to a target object pool in a total object pool set under the condition that the target memory objects do not exist in the release queue and the number of the target memory objects in the target object pool of the target thread object pool set exceeds the first object number threshold interval.
The first threshold interval of the number of objects may be understood as an interval of the number of objects in which the water level of the object is a high water level, that is, the interval may be expressed as "high water level ± deviation value".
In practical application, a processing thread firstly determines whether a target memory object exists in a release queue, and when the target memory object does not exist in the release queue, whether the memory object in a target object pool of a current target thread object pool set reaches a high water level can be further determined, wherein the manner of determining whether the memory object reaches the high water level is that whether the object number of the target memory object exceeds a first object number threshold interval is determined, and if the memory object number exceeds the first object number threshold interval, the target memory objects exceeding the first object number threshold interval in number can be stored in an object pool corresponding to the type in an object total pool set.
Further, after determining that no target memory object exists in the release queue and the number of objects of the target memory object in the target object pool of the target thread object pool set exceeds a first object number threshold interval, the executing the processing thread further includes:
executing the processing thread, in case that it is determined that the number of objects of the target memory object in the target object pool of the target thread object pool set does not satisfy a first object number threshold interval and the number of objects of the target memory object in the target object pool of the target thread object pool set is lower than a second object number threshold interval, and
and sending the target memory object to a target object pool of the target thread object pool set under the condition that the target object pool in the object total pool set has the target memory object.
The second threshold interval of the number of objects can be understood as an interval of the number of objects with a low water level, i.e. the interval can be expressed as "low water level ± deviation value".
In practical applications, when determining that the number of the memory objects does not reach the object high level, the processing thread further needs to determine whether the number of the memory objects is lower than the object low level, where the object low level may be understood as whether the number of the memory objects is lower than a certain object number threshold interval, and if determining that the number of the target memory objects in the target object pool is lower than the second object number threshold interval and the target memory objects also exist in the target object pool, the processing thread may obtain a certain number of memory objects to supplement the memory objects in the target object pool of the target thread object pool set.
Furthermore, when it is determined that the target object pool in the total object pool set does not have the target memory object, the processing thread may understand that there are not enough memory objects in the target object pool to allocate, and then the processing thread may drive the total object pool set to allocate and initialize a certain number of memory objects; specifically, after the target memory object exists in the target object pool in the total object pool set, the method further includes:
executing the processing thread, and under the condition that a target memory object does not exist in a target object pool of the total object pool set, continuously generating a target memory object in the target object pool of the total object pool set;
and executing the processing thread, and sending the target memory object to a target object pool of the target thread object pool set.
In practical application, the processing thread may further continue to generate a target memory object for the target object pool of the total object pool set, and directly send the generated target memory object to the target object pool of the target thread object pool set, so as to complete the supplement of the memory object to the type object pool in the thread object pool set.
Referring to fig. 7 in particular, fig. 7 is a schematic flowchart illustrating the number of memory objects in an asynchronous thread control object pool in an object processing method according to this specification; the following is described in terms of steps.
It should be noted that there may be one or more asynchronous threads (processing threads), which is not specifically limited in the embodiments of the present description, because the processing threads are key technical points in the method, the processing threads can destruct and recycle memory objects released by an application program, and simultaneously it is ensured that free memory objects of each object pool are maintained within "[ low water level, high water level ] ± deviation value", and the memory space of the object total pool memory pool is maintained within "high water level ± deviation value", and the calculation of the high and low water levels is obtained according to the size of the memory objects and the usage frequency of the memory objects.
Step 1: the asynchronous thread traverses each thread-level object pool in turn, and the various types of object pools under each thread-level object pool.
Step 2: and the asynchronous thread checks whether an object is to be cleaned in the release queue, and if not, the step 6 is carried out.
And step 3: and the asynchronous thread conducts destruct processing on the object.
And 4, step 4: the asynchronous thread re-initializes the object.
And 5: the asynchronous thread stores the object in the free queue.
Step 6: the asynchronous thread checks the free queue if it has reached a high level and if not proceeds to step 12.
And 7: the asynchronous thread returns the object beyond the high-level part to the free queue of the type object pool in the object total pool.
And 8: the asynchronous thread checks the free queue of the object pool of the type in the object total pool, whether the high water level is reached, if not, the step 12 is entered.
And step 9: and the asynchronous thread analyzes the memory objects of which the free queues of the type of object pools in the object total pool exceed the high-water-level part, and the memory space is returned to the memory pool of the object total pool.
Step 10: and the asynchronous thread judges whether the memory pool of the object total pool reaches a high water level, and if not, the step 12 is carried out.
Step 11: and returning the excessive part of the memory to the operating system by the memory pool of the asynchronous thread driving object main pool, and maintaining the memory level of the memory below a high level.
Step 12: and (3) the asynchronous thread checks an idle queue of the thread-level object pool, whether the idle queue reaches a low water level or not is judged, if not, a new round of circulation traversal is carried out, and the step 1 is carried out.
Step 13: the idle queue of the thread-level object pool of the asynchronous thread reaches a low water level and needs to be supplemented with the object, so that whether the idle queue of the type object pool of the object total pool has the memory object or not is judged, the memory object can be supplemented to a position above the low water level, and if the idle queue of the type object pool of the object total pool reaches the low water level, the step 18 is carried out.
Step 14: the asynchronous thread determines whether the memory pool of the total pool of objects can be allocated to require a sufficient number of the objects, and if the memory space is sufficient (if so), then step 16 is entered.
Step 15: and the asynchronous thread drives the memory pool of the object total pool, and applies for a memory space from the operating system according to the specified step length.
Step 16: the asynchronous thread drives the memory pool of the total pool, and a certain space is allocated to meet the creation of memory objects and complete the initialization of a certain number of objects.
And step 17: the asynchronous thread stores the batch of objects into a free queue of the type object pool in the total object pool.
Step 18: and the asynchronous thread acquires a certain number of memory objects, supplements the memory objects to an idle queue of the type object pool at the thread level, then enters a new round of circulation traversal and enters the step 1.
In summary, in the object processing method provided in the embodiments of the present specification, in order to improve the efficiency of obtaining a memory object by an execution thread of an application program, a dedicated thread object pool set is created for each execution thread, so that locality is increased, and lock operation caused by traversing and searching memory objects in multiple object pools is avoided, so as to achieve high performance under multi-thread concurrence; in addition, when the memory objects are distributed for the execution thread of the application program, the available memory objects can be directly obtained from the thread object pool set, so that the expenses of no lock, no memory application and object initialization are saved; meanwhile, when the memory object is released, the memory object can be directly returned to the object pool in the thread object pool set, and the expenses of no lock, no object analysis and no memory release are saved; in addition, the object water level of the memory objects in each object pool can be controlled by utilizing asynchronous threads, and the used memory objects are allocated efficiently and economically by adopting asynchronous allocation and initialization, asynchronous destructuring, recycling and releasing, so that the memory utilization rate is improved.
Corresponding to the above method embodiment, the present specification further provides an object processing system embodiment, and fig. 8 shows a schematic structural diagram of an object processing system provided in an embodiment of the present specification. As shown in fig. 8, the system includes: a processing module 802 and a storage module 804;
the processing module 802 is configured to respond to an object acquisition instruction sent by an execution thread of an application program, and create a processing thread based on an object processing program library stored in the storage module;
the processing module 802 is further configured to execute the processing thread, and determine a target object pool in a target thread object pool set based on object type information carried in the object obtaining instruction, where the target thread object pool set corresponding to the execution thread is created by the processing thread based on the object processing program library, and the target object pool is used for storing a memory object that is the same as the object type information;
the processing module 802 is further configured to execute the processing thread, and send a target memory object in the target object pool, which meets the requirement of the number of objects carried in the object obtaining instruction, to the execution thread of the application program when it is determined that a memory object exists in the target object pool.
The processing module 802, further configured to:
executing the processing thread, and sending the target memory objects meeting the object quantity requirement carried in the object acquisition instruction to a target object pool in the target thread object pool set on the basis of the object total pool set under the condition that the memory objects do not exist in the target object pool and the object total pool set exists; or
And executing the processing thread, creating the total object pool set based on the object processing program library under the condition that the memory object does not exist in the target object pool and the total object pool set does not exist, and sending the target memory objects meeting the object quantity requirement carried in the object acquisition instruction to the target object pool in the target thread object pool set based on the created total object pool set.
The processing module 802, further configured to:
and executing the processing thread, and sending the target memory objects meeting the object quantity requirements carried in the object acquisition instruction in the target object pool to the execution thread of the application program based on the target object pool in the target thread object pool set.
The processing module 802, further configured to:
executing the processing thread, and determining a target object pool in the total object pool set based on object type information carried in the object acquisition instruction, wherein the total object pool set is created by the processing thread based on an object processing program library, and the target object pool is used for storing a memory object which is the same as the object type information;
and executing the processing thread, and sending the target memory objects meeting the object quantity requirement carried in the object acquisition instruction in the target object pool to the target object pool in the target thread object pool set under the condition that the memory objects exist in the target object pool.
The processing module 802, further configured to:
executing the processing thread, and creating a target object pool in the created object total pool set based on an object processing program library;
executing the processing thread, and generating a target memory object meeting the object quantity requirement carried in an object acquisition instruction in a target object pool of the object total pool set;
and executing the processing thread, and sending the target memory object to a target object pool in the target thread object pool set.
The processing module 802, further configured to:
executing the processing thread, allocating a first memory space for a target object pool in the created total object pool set based on a memory pool,
the memory pool is created by the processing thread based on the object processing program library, the memory pool occupies a system memory space of the application program, and the first memory space is a part of a storage space in the memory pool.
The processing module 802, further configured to:
executing the processing thread, and acquiring running data corresponding to the executing thread from the memory pool based on the object type information carried in the object acquisition instruction;
executing the processing thread, and generating a target memory object meeting the object quantity requirement carried in an object acquisition instruction in a target object pool of the object total pool set based on the running data corresponding to the executing thread, wherein the target memory object occupies the first memory space.
The processing module 802, further configured to:
and executing the processing thread, and allocating a second memory space for a target object pool in the target thread object pool set based on a memory pool, wherein the second memory space is a part of storage space in the memory pool.
The processing module 802, further configured to:
and executing the processing thread, and returning the free memory space exceeding the preset space threshold interval to the system memory space of the application program under the condition that the free memory space in the memory pool is determined to exceed the preset space threshold interval.
The processing module 802, further configured to:
executing the processing thread, and placing the target memory object in a release queue corresponding to the target object pool under the condition of receiving the target memory object returned by the execution thread of the application program;
and executing the processing thread, and releasing the target memory object in the release queue under the condition that the target memory object is determined to meet the release condition.
The processing module 802, further configured to:
and executing the processing thread, and releasing the target memory object in the release queue under the condition that the target memory object exists in the release queue.
The processing module 802, further configured to:
and executing the processing thread, and sending the target memory objects corresponding to the number exceeding the first object number threshold interval to a target object pool in a total object pool set under the condition that the target memory objects do not exist in the release queue and the number of the target memory objects in the target object pool of the target thread object pool set exceeds the first object number threshold interval.
The processing module 802, further configured to:
executing the processing thread, in case it is determined that the number of objects of the target memory object in the target object pool of the target thread object pool set does not satisfy a first object number threshold interval, and the number of objects of the target memory object in the target object pool of the target thread object pool set is lower than a second object number threshold interval, and
and sending the target memory object to a target object pool of the target thread object pool set under the condition that the target object pool in the object total pool set has the target memory object.
The processing module 802, further configured to:
executing the processing thread, and under the condition that a target memory object does not exist in a target object pool of the total object pool set, continuously generating a target memory object in the target object pool of the total object pool set;
and executing the processing thread, and sending the target memory object to a target object pool of the target thread object pool set.
In the object processing system provided in the embodiment of the present specification, when an object obtaining instruction sent by an execution thread is received, a processing thread may be activated according to an object processing library, and a processing thread is utilized to determine a target thread object pool set corresponding to the execution thread according to object type information, so that a target object pool may be directly determined in the target thread object pool set, and further, a memory object required by the execution thread may be obtained in the target object pool. The processing efficiency of the execution thread is improved.
The above is a schematic scheme of an object processing system of the present embodiment. It should be noted that the technical solution of the object processing system and the technical solution of the object processing method belong to the same concept, and details that are not described in detail in the technical solution of the object processing system can be referred to the description of the technical solution of the object processing method.
FIG. 9 illustrates a block diagram of a computing device 900 provided in accordance with one embodiment of the present specification. Components of the computing device 900 include, but are not limited to, a memory 910 and a processor 920. The processor 920 is coupled to the memory 910 via a bus 930, and a database 950 is used to store data.
Computing device 900 also includes access device 940, access device 940 enabling computing device 900 to communicate via one or more networks 960. Examples of such networks include the Public Switched Telephone Network (PSTN), a Local Area Network (LAN), a Wide Area Network (WAN), a Personal Area Network (PAN), or a combination of communication networks such as the internet. Access device 940 may include one or more of any type of network interface (e.g., a Network Interface Card (NIC)) whether wired or wireless, such as an IEEE802.11 Wireless Local Area Network (WLAN) wireless interface, a worldwide interoperability for microwave access (Wi-MAX) interface, an ethernet interface, a Universal Serial Bus (USB) interface, a cellular network interface, a bluetooth interface, a Near Field Communication (NFC) interface, and so forth.
In one embodiment of the present description, the above-described components of computing device 900, as well as other components not shown in FIG. 9, may also be connected to each other, such as by a bus. It should be understood that the block diagram of the computing device architecture shown in FIG. 9 is for purposes of example only and is not limiting as to the scope of the description. Those skilled in the art may add or replace other components as desired.
Computing device 900 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., tablet, personal digital assistant, laptop, notebook, netbook, etc.), a mobile phone (e.g., smartphone), a wearable computing device (e.g., smartwatch, smartglasses, etc.), or other type of mobile device, or a stationary computing device such as a desktop computer or PC. Computing device 900 may also be a mobile or stationary server.
Wherein the processor 920 is configured to execute computer-executable instructions, which when executed by the processor, implement the steps of the object processing method described above.
The above is an illustrative scheme of a computing device of the present embodiment. It should be noted that the technical solution of the computing device and the technical solution of the object processing method belong to the same concept, and details that are not described in detail in the technical solution of the computing device can be referred to the description of the technical solution of the object processing method.
An embodiment of the present specification also provides a computer-readable storage medium storing computer-executable instructions, which when executed by a processor, implement the steps of the above-mentioned object processing method.
The above is an illustrative scheme of a computer-readable storage medium of the present embodiment. It should be noted that the technical solution of the storage medium belongs to the same concept as the technical solution of the object processing method, and details that are not described in detail in the technical solution of the storage medium can be referred to the description of the technical solution of the object processing method.
An embodiment of the present specification further provides a computer program, wherein when the computer program is executed in a computer, the computer is caused to execute the steps of the object processing method.
The above is an illustrative scheme of a computer program of the present embodiment. It should be noted that the technical solution of the computer program is the same concept as the technical solution of the object processing method, and details that are not described in detail in the technical solution of the computer program can be referred to the description of the technical solution of the object processing method.
The foregoing description has been directed to specific embodiments of this disclosure. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing may also be possible or may be advantageous.
The computer instructions comprise computer program code which may be in the form of source code, object code, an executable file or some intermediate form, or the like. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution medium, and the like. It should be noted that the computer readable medium may contain content that is subject to appropriate increase or decrease as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable media does not include electrical carrier signals and telecommunications signals as is required by legislation and patent practice.
It should be noted that, for the sake of simplicity, the foregoing method embodiments are described as a series of acts, but those skilled in the art should understand that the present embodiment is not limited by the described acts, because some steps may be performed in other sequences or simultaneously according to the present embodiment. Further, those skilled in the art should also appreciate that the embodiments described in this specification are preferred embodiments and that acts and modules referred to are not necessarily required for an embodiment of the specification.
In the foregoing embodiments, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to the related descriptions of other embodiments.
The preferred embodiments of the present specification disclosed above are intended only to aid in the description of the specification. Alternative embodiments are not exhaustive and do not limit the invention to the precise embodiments described. Obviously, many modifications and variations are possible in light of the above teaching. The embodiments were chosen and described in order to best explain the principles of the embodiments and the practical application, to thereby enable others skilled in the art to best understand and utilize the embodiments. The specification is limited only by the claims and their full scope and equivalents.

Claims (17)

1. An object processing method, comprising;
according to an object acquisition instruction sent by an execution thread of an application program, creating a processing thread based on an object processing program library;
executing the processing thread, and determining a target object pool in a target thread object pool set based on object type information carried in the object acquisition instruction, wherein the target thread object pool set corresponding to the executing thread is created by the processing thread based on the object processing program library, and the target object pool is used for storing a memory object with the same object type information;
and executing the processing thread, and sending the target memory objects meeting the object quantity requirement carried in the object acquisition instruction in the target object pool to the execution thread of the application program under the condition that the memory objects exist in the target object pool.
2. The object processing method according to claim 1, wherein the executing the processing thread, after determining a target object pool in a target thread object pool set based on object type information carried in the object obtaining instruction, further comprises:
executing the processing thread, and sending the target memory objects meeting the object quantity requirement carried in the object acquisition instruction to a target object pool in the target thread object pool set on the basis of the object total pool set under the condition that the memory objects do not exist in the target object pool and the object total pool set exists; or
And executing the processing thread, creating the total object pool set based on the object processing program library under the condition that the memory object does not exist in the target object pool and the total object pool set does not exist, and sending the target memory objects meeting the object quantity requirement carried in the object acquisition instruction to the target object pool in the target thread object pool set based on the created total object pool set.
3. The object processing method according to claim 2, wherein after sending the target memory object that satisfies the object quantity requirement carried in the object obtaining instruction to the target object pool in the target thread object pool set, the method further comprises:
and executing the processing thread, and sending the target memory objects meeting the object quantity requirements carried in the object acquisition instruction in the target object pool to the execution thread of the application program based on the target object pool in the target thread object pool set.
4. The object processing method according to claim 2, wherein the executing the processing thread and sending the target memory object that meets the object quantity requirement carried in the object obtaining instruction to the target object pool in the target thread object pool set based on the total object pool set comprises:
executing the processing thread, and determining a target object pool in the object total pool set based on object type information carried in the object acquisition instruction, wherein the object total pool set is created by the processing thread based on an object processing program library, and the target object pool is used for storing a memory object which is the same as the object type information;
and executing the processing thread, and sending the target memory objects meeting the object quantity requirement carried in the object acquisition instruction in the target object pool to the target object pool in the target thread object pool set under the condition that the memory objects exist in the target object pool.
5. The object processing method according to claim 2, wherein the sending, based on the created total pool set of objects, the target memory object that meets the requirement of the number of objects carried in the object obtaining instruction to the target object pool in the target thread object pool set, includes:
executing the processing thread, and creating a target object pool in the created object total pool set based on an object processing program library;
executing the processing thread, and generating a target memory object meeting the object quantity requirement carried in an object acquisition instruction in a target object pool of the object total pool set;
and executing the processing thread, and sending the target memory object to a target object pool in the target thread object pool set.
6. The object processing method according to claim 5, wherein before executing the processing thread to generate a target memory object that meets a requirement of the number of objects carried in an object obtaining instruction in a target object pool of the total object pool set, the method further comprises:
executing the processing thread, allocating a first memory space for a target object pool in the created total object pool set based on a memory pool,
the memory pool is created by the processing thread based on the object processing program library, the memory pool occupies a system memory space of the application program, and the first memory space is a part of a storage space in the memory pool.
7. The object processing method according to claim 6, wherein the executing the processing thread to generate the target memory object satisfying the requirement of the number of objects carried in the object obtaining instruction in the target object pool of the total object pool set includes:
executing the processing thread, and acquiring running data corresponding to the executing thread from the memory pool based on the object type information carried in the object acquisition instruction;
and executing the processing thread, and generating a target memory object meeting the requirement of the object quantity carried in an object acquisition instruction in a target object pool of the object total pool set based on the running data corresponding to the executing thread, wherein the target memory object occupies the first memory space.
8. The object processing method according to claim 7, wherein the executing the processing thread, after determining a target object pool in a target thread object pool set based on object type information carried in the object obtaining instruction, further comprises:
and executing the processing thread, and allocating a second memory space for a target object pool in the target thread object pool set based on a memory pool, wherein the second memory space is a part of storage space in the memory pool.
9. The object processing method according to claim 8, further comprising:
and executing the processing thread, and returning the free memory space exceeding the preset space threshold interval to the system memory space of the application program under the condition that the free memory space in the memory pool is determined to exceed the preset space threshold interval.
10. The object processing method according to claim 1 or 3, wherein after sending the target memory object in the target object pool that meets the requirement of the number of objects carried in the object obtaining instruction to the execution thread of the application program, the method further comprises:
executing the processing thread, and placing the target memory object in a release queue corresponding to the target object pool under the condition of receiving the target memory object returned by the execution thread of the application program;
and executing the processing thread, and releasing the target memory object in the release queue under the condition that the target memory object is determined to meet the release condition.
11. The object processing method according to claim 10, wherein the executing the processing thread to release the target memory object in the release queue if it is determined that the target memory object satisfies a release condition comprises:
and executing the processing thread, and releasing the target memory object in the release queue under the condition that the target memory object exists in the release queue.
12. The object processing method of claim 11, wherein executing the processing thread, prior to determining that a target memory object exists in the release queue, further comprises:
and executing the processing thread, and sending the target memory objects corresponding to the number exceeding the first object number threshold interval to a target object pool in a total object pool set under the condition that the target memory objects do not exist in the release queue and the number of the target memory objects in the target object pool of the target thread object pool set exceeds the first object number threshold interval.
13. The object processing method according to claim 12, wherein the executing the processing thread, after determining that no target memory object exists in the release queue and that the number of objects in the target object pool of the target thread object pool set exceeds a first object number threshold interval, further comprises:
executing the processing thread, in case that it is determined that the number of objects of the target memory object in the target object pool of the target thread object pool set does not satisfy a first object number threshold interval and the number of objects of the target memory object in the target object pool of the target thread object pool set is lower than a second object number threshold interval, and
and sending the target memory object to a target object pool of the target thread object pool set under the condition that the target object pool in the object total pool set has the target memory object.
14. The object processing method according to claim 13, wherein after the target memory object exists in the target object pool in the total object pool set, the method further comprises:
executing the processing thread, and under the condition that a target memory object does not exist in a target object pool of the total object pool set, continuously generating a target memory object in the target object pool of the total object pool set;
and executing the processing thread, and sending the target memory object to a target object pool of the target thread object pool set.
15. An object handling system, comprising: the device comprises a processing module and a storage module;
the processing module is configured to respond to an object acquisition instruction sent by an execution thread of an application program and create a processing thread based on an object processing program library stored in the storage module;
the processing module is further configured to execute the processing thread, and determine a target object pool in a target thread object pool set based on object type information carried in the object acquisition instruction, where the target thread object pool set corresponding to the execution thread is created by the processing thread based on the object processing program library, and the target object pool is used for storing a memory object that is the same as the object type information;
the processing module is further configured to execute the processing thread, and send a target memory object, which meets the requirement of the number of objects carried in an object acquisition instruction, in the target object pool to the execution thread of the application program under the condition that it is determined that a memory object exists in the target object pool.
16. A computing device, comprising:
a memory and a processor;
the memory is for storing computer-executable instructions, and the processor is for executing the computer-executable instructions, which when executed by the processor, implement the steps of the object processing method of any one of claims 1 to 14.
17. A computer-readable storage medium, characterized in that it stores computer-executable instructions which, when executed by a processor, implement the steps of the object processing method of any one of claims 1 to 14.
CN202210429453.0A 2022-04-22 2022-04-22 Object processing method and system Active CN114546665B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210429453.0A CN114546665B (en) 2022-04-22 2022-04-22 Object processing method and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210429453.0A CN114546665B (en) 2022-04-22 2022-04-22 Object processing method and system

Publications (2)

Publication Number Publication Date
CN114546665A CN114546665A (en) 2022-05-27
CN114546665B true CN114546665B (en) 2022-08-05

Family

ID=81667659

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210429453.0A Active CN114546665B (en) 2022-04-22 2022-04-22 Object processing method and system

Country Status (1)

Country Link
CN (1) CN114546665B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107818023A (en) * 2017-11-06 2018-03-20 深圳市雷鸟信息科技有限公司 Thread-based message processing method, intelligent device and storage medium
CN109298901A (en) * 2018-08-29 2019-02-01 百度在线网络技术(北京)有限公司 Object processing method, device, equipment, storage medium and vehicle
CN110471763A (en) * 2019-07-29 2019-11-19 平安科技(深圳)有限公司 Dispatching method, system, medium and electronic equipment based on shared object pond
CN111522645A (en) * 2020-04-29 2020-08-11 北京字节跳动网络技术有限公司 Object processing method and device, electronic equipment and computer-readable storage medium
CN114020994A (en) * 2021-09-18 2022-02-08 北京快乐茄信息技术有限公司 Recommendation system recall rate determination method and device, electronic equipment and storage medium

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050060372A1 (en) * 2003-08-27 2005-03-17 Debettencourt Jason Techniques for filtering data from a data stream of a web services application
US20090157817A1 (en) * 2007-12-12 2009-06-18 International Business Machines Corporation Using an unsynchronized event pool to improve performance of an event driven im gateway
CN109388485B (en) * 2018-09-26 2021-01-22 广州虎牙信息科技有限公司 Processing method, device and equipment of task execution thread and storage medium
CN113835992B (en) * 2020-06-23 2023-10-20 抖音视界有限公司 Memory leakage processing method and device, electronic equipment and computer storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107818023A (en) * 2017-11-06 2018-03-20 深圳市雷鸟信息科技有限公司 Thread-based message processing method, intelligent device and storage medium
CN109298901A (en) * 2018-08-29 2019-02-01 百度在线网络技术(北京)有限公司 Object processing method, device, equipment, storage medium and vehicle
CN110471763A (en) * 2019-07-29 2019-11-19 平安科技(深圳)有限公司 Dispatching method, system, medium and electronic equipment based on shared object pond
CN111522645A (en) * 2020-04-29 2020-08-11 北京字节跳动网络技术有限公司 Object processing method and device, electronic equipment and computer-readable storage medium
CN114020994A (en) * 2021-09-18 2022-02-08 北京快乐茄信息技术有限公司 Recommendation system recall rate determination method and device, electronic equipment and storage medium

Non-Patent Citations (4)

* Cited by examiner, † Cited by third party
Title
"Study of Multiple Instances Schedule Based on Object Pool";Linlan Liu等;《2010 Third International Symposium on Information Processing》;20101217;第46-49页 *
"基于对象池的活动多实例调度研究";张琳;《现代工业经济和信息化》;20160815;第6卷(第15期);第64-67页 *
基于对象池技术的移动Agent对象管理算法研究;张会影;《微计算机信息》;20101025(第30期);全文 *
资源池模式在基于J2EE架构下的ERP产品中的应用;高云鹏等;《制造业自动化》;20031130(第11期);全文 *

Also Published As

Publication number Publication date
CN114546665A (en) 2022-05-27

Similar Documents

Publication Publication Date Title
US10545789B2 (en) Task scheduling for highly concurrent analytical and transaction workloads
CN1717645B (en) Apparatus and method for multi-threaded processors performance control
US9201689B2 (en) Software emulation of massive hardware threading for tolerating remote memory references
US10977092B2 (en) Method for efficient task scheduling in the presence of conflicts
CN108228343B (en) Memory recovery method and device, computer device and computer readable storage medium
US20230038051A1 (en) Data transmission method and apparatus
US10768684B2 (en) Reducing power by vacating subsets of CPUs and memory
WO2012016472A1 (en) Method and system for loading linux operating system in multicore central processing unit (cpu)
US20190073243A1 (en) User-space spinlock efficiency using c-state and turbo boost
KR102320324B1 (en) Method for using heterogeneous hardware accelerator in kubernetes environment and apparatus using the same
CN109840151B (en) Load balancing method and device for multi-core processor
CN114546665B (en) Object processing method and system
Francis et al. Implementation of parallel clustering algorithms using Join and Fork model
Chen et al. FlexGPU: A flexible and efficient scheduler for GPU sharing systems
Alvarez Valera An energy saving perspective for distributed environments: Deployment, scheduling and simulation with multidimensional entities for Software and Hardware
COMODIN Thesis Supervisors
Tang et al. A shared cache-aware Task scheduling strategy for multi-core systems
Valera An energy saving perspective for distributed environments: Deployment, scheduling and simulation with multidimensional entities for Software and Hardware
Shi et al. DFlow: Efficient Dataflow-based Invocation Workflow Execution for Function-as-a-Service
Xu et al. Task assignments based on shared memory multi-core communication
Rang et al. A unified hybrid memory system for scalable deep learning and big data applications
Aamodt et al. Crosscutting Research on GPU Computing Architectures
KR20230143025A (en) Resource-aware device allocation of multiple gpgpu applications on multi-accelerator system
Kachris et al. on FPGAs
CN117251259A (en) Data processing method, device, equipment and system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant