WO2017167061A1 - 用于垃圾回收的并行标记处理方法及装置 - Google Patents
用于垃圾回收的并行标记处理方法及装置 Download PDFInfo
- Publication number
- WO2017167061A1 WO2017167061A1 PCT/CN2017/077446 CN2017077446W WO2017167061A1 WO 2017167061 A1 WO2017167061 A1 WO 2017167061A1 CN 2017077446 W CN2017077446 W CN 2017077446W WO 2017167061 A1 WO2017167061 A1 WO 2017167061A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- thread
- marking
- pointer
- memory block
- threads
- 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.)
- Ceased
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F12/00—Accessing, addressing or allocating within memory systems or architectures
- G06F12/02—Addressing or allocation; Relocation
- G06F12/0223—User address space allocation, e.g. contiguous or non contiguous base addressing
- G06F12/023—Free address space management
- G06F12/0253—Garbage collection, i.e. reclamation of unreferenced memory
- G06F12/0269—Incremental or concurrent garbage collection, e.g. in real-time systems
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F12/00—Accessing, addressing or allocating within memory systems or architectures
- G06F12/02—Addressing or allocation; Relocation
- G06F12/0223—User address space allocation, e.g. contiguous or non contiguous base addressing
- G06F12/023—Free address space management
- G06F12/0253—Garbage collection, i.e. reclamation of unreferenced memory
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F12/00—Accessing, addressing or allocating within memory systems or architectures
- G06F12/02—Addressing or allocation; Relocation
- G06F12/0223—User address space allocation, e.g. contiguous or non contiguous base addressing
- G06F12/023—Free address space management
- G06F12/0253—Garbage collection, i.e. reclamation of unreferenced memory
- G06F12/0261—Garbage collection, i.e. reclamation of unreferenced memory using reference counting
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F12/00—Accessing, addressing or allocating within memory systems or architectures
- G06F12/02—Addressing or allocation; Relocation
- G06F12/0223—User address space allocation, e.g. contiguous or non contiguous base addressing
- G06F12/023—Free address space management
- G06F12/0253—Garbage collection, i.e. reclamation of unreferenced memory
- G06F12/0269—Incremental or concurrent garbage collection, e.g. in real-time systems
- G06F12/0276—Generational garbage collection
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/44—Arrangements for executing specific programs
- G06F9/455—Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
- G06F9/45533—Hypervisors; Virtual machine monitors
- G06F9/45558—Hypervisor-specific management and integration aspects
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/46—Multiprogramming arrangements
- G06F9/48—Program initiating; Program switching, e.g. by interrupt
- G06F9/4806—Task transfer initiation or dispatching
- G06F9/4843—Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
- G06F9/4881—Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5005—Allocation of resources, e.g. of the central processing unit [CPU] to service a request
- G06F9/5011—Allocation 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/5016—Allocation 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
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5005—Allocation of resources, e.g. of the central processing unit [CPU] to service a request
- G06F9/5011—Allocation 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/5022—Mechanisms to release resources
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/44—Arrangements for executing specific programs
- G06F9/455—Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
- G06F9/45533—Hypervisors; Virtual machine monitors
- G06F9/45558—Hypervisor-specific management and integration aspects
- G06F2009/45583—Memory management, e.g. access or allocation
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2212/00—Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
- G06F2212/10—Providing a specific technical effect
- G06F2212/1016—Performance improvement
- G06F2212/1024—Latency reduction
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2212/00—Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
- G06F2212/10—Providing a specific technical effect
- G06F2212/1041—Resource optimization
- G06F2212/1044—Space efficiency improvement
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2212/00—Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
- G06F2212/65—Details of virtual memory and virtual address translation
- G06F2212/657—Virtual address space management
Definitions
- the present application relates to the field of computer technology, and in particular, to a parallel tag processing method and apparatus for garbage collection.
- GC Garbage Collection
- the GC technology can be divided into two types according to the relationship between the garbage collector (collector) and the host (Mutator for short): Mutator pauses when Collector works (Stop-The-World-GC is STW-GC), and Mutator does not pause when Collector works. (referred to as concurrent GC or Concurrent-GC).
- concurrent GC Concurrent-GC
- the popular high-level language virtual machines such as JVM and V8 are all STW-GC or part of Concurrent-GC.
- the non-reference count STW-GC scheme can be divided into three types, namely, mark-copy (referred to as marking-copy), mark-clean (referred to as marking-sweep), and mark-compression (referred to as marking-compact).
- heap a specified size of memory blocks (referred to as a page, generally the operating system's memory page size integer Times) organized for the basic unit.
- the page size of the V8 virtual machine is 1MByte.
- a bitmap area (called a bitmap) is divided at the beginning of each memory block (ie, page) to mark whether each object in the page is an active object. For example, if an object in a page corresponds to a bitmap bit set to 1 in the header of the page, the object is an active object and should not be recycled when performing GC.
- the current marking method for garbage collection is a single-threaded marking method. According to the increasing number of marking objects, the occupied memory space will continue to increase. It can be seen that the current single-threaded marking method wastes a large amount of memory space and reduces Processing performance and efficiency.
- the present application aims to solve at least one of the technical problems in the related art to some extent.
- the first object of the present application is to propose a parallel tag processing method for garbage collection, which utilizes limited memory to implement multi-threaded parallel tag processing, thereby improving the performance of the entire garbage collection.
- a second object of the present application is to propose a parallel tag processing method for garbage collection.
- a third object of the present application is to propose a parallel mark processing apparatus for garbage collection.
- a fourth object of the present application is to propose a parallel mark processing apparatus for garbage collection.
- the first aspect of the present application provides a parallel tag processing method for garbage collection, including: traversing the virtual machine according to a correspondence between a memory block and a N tag thread in a virtual machine heap.
- the first object in the heap where N is an integer greater than 1, and the memory capacity occupied by the N marking threads is preset, and each marking thread includes at least: 1 private stack; the first object to be processed first a pointer presses a private stack of the markup thread corresponding to the memory block in which the first object is located, performs a first mark processing on the first object according to the press-in condition of the first pointer; traverses the first object After completion, the thread start instruction is sent to the N mark threads, so that the N mark threads synchronously perform mark processing for garbage collection according to the press-in condition of the first pointer in the respective private stack.
- the parallel tag processing method for garbage collection in the embodiment of the present application traverses the first object in the virtual machine heap according to the correspondence between the memory block and the N tag threads in the virtual machine heap, wherein the N tags
- the memory capacity occupied by the thread is preset, and the first pointer of the currently processed first object is pushed into the private thread of the marking thread corresponding to the memory block where the first object is located.
- Having a stack performing a first marking process on the first object according to the pressing condition of the first pointer, and sending a thread start instruction to the N marking threads after the traversing of the first object is completed, so that
- the N markup threads synchronously perform tag processing for garbage collection according to the press-in condition of the first pointer in the respective private stacks.
- multi-threaded parallel tag processing is implemented with limited memory to improve the performance of the entire garbage collection.
- each of the preset N tag threads includes at least: a private stack.
- the method is applied in each markup thread, wherein the method of applying in the first markup thread comprises the step of: the first markup thread fetching the pre-pressed first object from the first private stack according to the thread start instruction a first pointer; the first marking thread traverses the second object referenced by the first object indicated by the first pointer, and according to a correspondence relationship between the preset N marking threads and a memory block in the virtual machine heap
- the second object performs a second marking process.
- the first pointer of the first object that is pre-pressed is taken out from the first private stack by the first mark thread according to the thread start instruction, and the first pointer is traversed. Instructing the second object that is referenced by the first object, and performing second marking processing on the second object according to a preset correspondence between the N marking threads and a memory block in the virtual machine heap.
- the parallel marking process of the N marking threads realizes parallel marking processing with limited memory, thereby improving the performance of the entire garbage collection.
- the third aspect of the present application provides a parallel tag processing apparatus for garbage collection, including: a traversal module, configured to perform a correspondence between a memory block in a virtual machine heap and N mark threads, Traversing the first object in the virtual machine heap, where N is an integer greater than 1, the memory capacity occupied by the N marking threads is preset, and each marking thread includes at least: 1 private stack; the first marking module For pressing the first pointer of the currently processed first object into the private stack of the markup thread corresponding to the memory block in which the first object is located, according to the The first pointer is pressed to perform the first marking process on the first object; the startup module is configured to send a thread start instruction to the N marking threads after the first object traversing is completed, so that the The N tag threads synchronously perform tag processing for garbage collection according to the press-in condition of the first pointer in the respective private stacks.
- a traversal module configured to perform a correspondence between a memory block in a virtual machine heap and N mark threads, Traversing the first
- the parallel tag processing apparatus for garbage collection in the embodiment of the present application traverses the first object in the virtual machine heap according to the correspondence between the memory block in the virtual machine heap and the N mark threads, wherein the N tags
- the memory capacity occupied by the thread is preset, and the first pointer of the currently processed first object is pushed into the private stack of the marking thread corresponding to the memory block where the first object is located, according to the pressing condition of the first pointer.
- the tag processing for garbage collection is performed synchronously.
- multi-threaded parallel tag processing is implemented with limited memory to improve the performance of the entire garbage collection.
- each of the preset N tag threads includes at least: a private stack
- the apparatus is applied to each of the marking threads, wherein the means for applying in the first marking thread comprises: an obtaining module, configured to retrieve the pre-pressed first object from the first private stack according to the thread starting instruction a first pointer; a second marking module, configured to traverse the second object referenced by the first object indicated by the first pointer, and according to a correspondence between a preset N marking threads and a memory block in the virtual machine heap The second object performs a second marking process.
- the first pointer of the first object that is pre-pressed is taken out from the first private stack by the first marking thread according to the thread start instruction, and the first pointer is traversed. Instructing the second object that is referenced by the first object, and performing second marking processing on the second object according to a preset correspondence between the N marking threads and a memory block in the virtual machine heap.
- Parallel markup processing enables parallel markup processing with limited memory to improve the performance of the entire garbage collection.
- FIG. 1 is a flow chart of a parallel tag processing method for garbage collection according to an embodiment of the present application
- FIG. 2 is a flow chart of a parallel tag processing method for garbage collection according to another embodiment of the present application.
- FIG. 3 is a schematic diagram of a first marking process flow for garbage collection
- Figure 5 is a flow chart 1 of applying the mark thread parallel mark processing shown in Figure 4;
- FIG. 6 is a flow chart 2 of applying the markup thread parallel mark processing shown in FIG. 4;
- FIG. 7 is a flow chart 3 of applying the markup thread parallel mark processing shown in FIG. 4;
- Figure 8 is a flow chart 4 of applying the markup thread parallel mark processing shown in Figure 4;
- Figure 9 is a flow chart 5 of applying the markup thread parallel mark processing shown in Figure 4.
- Figure 10 is a flow chart 6 of applying the markup thread parallel mark processing shown in Figure 4.
- FIG. 11 is a schematic structural diagram of a parallel label processing apparatus for garbage collection according to an embodiment of the present application.
- FIG. 12 is a schematic structural diagram of a parallel label processing apparatus for garbage collection according to another embodiment of the present application.
- FIG. 13 is a schematic structural diagram of a parallel label processing apparatus for garbage collection according to another embodiment of the present application.
- FIG. 14 is a parallel mark processing apparatus for garbage collection according to another embodiment of the present application. Schematic;
- 15 is a schematic structural diagram of a parallel label processing apparatus for garbage collection according to another embodiment of the present application.
- 16 is a schematic structural diagram of a parallel label processing apparatus for garbage collection according to another embodiment of the present application.
- FIG. 17 is a schematic structural diagram of a parallel mark processing apparatus for garbage collection according to another embodiment of the present application.
- FIG. 1 is a flow chart of a parallel tag processing method for garbage collection in accordance with an embodiment of the present application.
- the parallel tag processing method for garbage collection includes:
- Step 101 Traverse the first object in the virtual machine heap according to the correspondence between the memory block in the virtual machine heap and the N marking threads, where N is an integer greater than 1, and the memory capacity occupied by the N marking threads is Pre-set, each tag thread includes at least: 1 private stack.
- the processing method provided by the embodiments of the present invention utilizes the parallel processing capability of the multi-core CPU to apply for N marking threads in advance, wherein each marking thread includes at least: A private stack that is used to store pointers to objects that this thread is responsible for marking.
- N is an integer greater than 1, depending on the parallel processing capability of the CPU to which the application is actually applied.
- the parallel tag processing method provided by the present invention pre-sets the memory capacity occupied by the N tag threads, that is, the clubhouse, and the memory capacity occupied by the N tag threads does not increase with the overflow of the tag object, so as to ensure the tag. Processing performance and efficiency.
- the memory capacity occupied by the N mark threads can be set in various ways according to the application requirements, for example:
- Example 1 setting the capacity of each tag thread
- Example 2 The total memory capacity occupied by the N mark threads is set, and each mark thread may be undefined, or, for example, the largest one is defined.
- each tag thread is pre-configured with a memory block corresponding to the virtual machine heap responsible for the tag.
- Example 1 Specify the corresponding markup thread for each memory block; or,
- Example 2 Specify the memory block responsible for the tag for each tag thread.
- all the first objects in the pre-stored virtual machine heap are obtained from the virtual machine system, and the first object in the virtual machine heap is traversed according to the correspondence between the memory blocks in the set virtual machine heap and the N marked threads. .
- Step 102 Push a first pointer of the currently processed first object into a private stack of the marking thread corresponding to the memory block where the first object is located, and perform the first object according to the pressing condition of the first pointer.
- the first tag is processed.
- Step 103 after the traversal of the first object is completed, sending a thread start instruction to the N mark threads, so that the N mark threads are synchronized according to the press-in condition of the first pointer in the respective private stacks.
- Tag processing for garbage collection after the traversal of the first object is completed, sending a thread start instruction to the N mark threads, so that the N mark threads are synchronized according to the press-in condition of the first pointer in the respective private stacks.
- the memory block in which the first object is currently processed is determined, and then the marking thread corresponding to the memory block in which the first object is located is obtained according to the foregoing correspondence.
- the first pointer of the first object is pushed into the private stack of the markup thread corresponding to the memory block in which the first object is located.
- the first object processing is performed on the currently processed first object. That is, if the first pointer of the current first object is successfully pushed into the private stack of the corresponding markup thread, it is determined that the private stack does not overflow, marking the currently processed first object as a push-in state; if not When the first pointer of the current first object is successfully pushed into the private stack of the corresponding markup thread, it is determined that the private stack overflows, and the currently processed first object is marked as an overflow state.
- the pressing of the first object corresponding to the private stack of each marking thread can be recorded by means of a list
- Example 2 the first pair can be marked by the corresponding position in the memory block bitmap of the first object The pressing of the image.
- the first pointer of the first object in the memory block that the thread is responsible for is stored in the private stack of each markup thread. If the private thread of the markup thread overflows, indicating that the space of the private stack is full and cannot continue to store the first pointer of the first object in the memory block that the thread is responsible for marking, the first object is marked as overflowed. When there is new processing space in the private stack of the markup thread, the first pointer of the first object in the memory block that the thread is responsible for is continuously stored.
- a thread start instruction is sent to the N mark threads, so that the N mark threads synchronously perform mark processing for garbage collection according to the press-in condition of the first pointer in the respective private stacks.
- the parallel tag processing method for garbage collection in the embodiment of the present application traverses the first object in the virtual machine heap according to the correspondence between the memory block and the N tag threads in the virtual machine heap, wherein the N tags
- the memory capacity occupied by the thread is preset, and the first pointer of the currently processed first object is pushed into the private stack of the marking thread corresponding to the memory block where the first object is located, according to the pressing condition of the first pointer.
- the tag processing for garbage collection is performed synchronously.
- multi-threaded parallel tag processing is implemented with limited memory to improve the performance of the entire garbage collection.
- FIG. 2 is a flow chart of a parallel tag processing method for garbage collection in accordance with another embodiment of the present application.
- the parallel tag processing method for garbage collection may include the following steps:
- Step 201 Apply N marking threads, where N is an integer greater than 1, and the memory capacity occupied by the N marking threads is preset, and each marking thread includes at least: 1 private stack.
- each markup thread includes a private stack, and the private stack is used to store a pointer of the object that the thread is responsible for marking.
- Step 202 traversing all memory blocks of the virtual machine heap, and assigning a number to each memory block;
- Step 203 Determine a tag thread number corresponding to each memory block number according to the memory block number and the total number of tag threads N.
- tag thread number corresponding to each memory block number is determined based on the memory block number and the total number of tag threads N.
- N is the total number of marked threads; id is the memory block number; ID is the marked thread number; "%" indicates the remainder processing after N is divisible by id.
- the tag thread number corresponding to the memory block number 1 is 0;
- the tag thread number corresponding to the memory block number 2 is 1;
- the tag thread number corresponding to the memory block number 3 is 2;
- the tag thread number corresponding to the memory block number 4 is 3;
- the tag thread number corresponding to the memory block number 5 is 0;
- the tag thread number corresponding to the memory block number 6 is 1;
- the tag thread number corresponding to the memory block number 7 is 2;
- the tag thread number corresponding to the memory block number 8 is 3;
- the tag thread number corresponding to the memory block number 9 is 1;
- the tag thread number corresponding to the memory block number 10 is 2.
- Step 204 traverse the first object in the virtual machine heap according to the correspondence between the memory block and the N mark threads in the virtual machine heap, and press the first pointer of the currently processed first object into the first object.
- Step 205 determining whether the first pointer of the current first object is successfully pushed into the private stack of the corresponding markup thread
- Step 206 If the first pointer is successfully pushed into the private stack of the corresponding markup thread, mark the state corresponding to the first object in the bitmap of the memory block where the current first object is located as a push-in state;
- Step 207 If the first pointer fails to be successfully pushed into the private stack of the corresponding markup thread, the state corresponding to the first object in the bitmap of the memory block where the current first object is located is marked as an overflow state.
- Step 208 After the traversal of the first object is completed, send a thread start instruction to the N mark threads, so that the N mark threads are synchronized according to the press-in condition of the first pointer in the respective private stacks.
- Tag processing for garbage collection After the traversal of the first object is completed, send a thread start instruction to the N mark threads, so that the N mark threads are synchronized according to the press-in condition of the first pointer in the respective private stacks.
- the memory block where the first object currently processed is located is determined, and then the marking thread corresponding to the memory block where the first object is located is obtained according to the foregoing correspondence.
- the first pointer of the first object is pushed into the private stack of the markup thread corresponding to the memory block in which the first object is located.
- the first pair of the current processing Like the first marking process. That is, if the first pointer of the current first object is successfully pushed into the private stack of the corresponding markup thread, it is determined that the private stack does not overflow, marking the currently processed first object as a push-in state; if not When the first pointer of the current first object is successfully pushed into the private stack of the corresponding markup thread, it is determined that the private stack overflows, and the currently processed first object is marked as an overflow state.
- the first pointer of the first object in the memory block marked by the thread is stored in the private stack of each mark thread. If the private thread of the markup thread overflows, indicating that the space of the private stack is full and cannot continue to store the first pointer of the first object in the memory block that the thread is responsible for marking, the first object is marked as overflowed. When there is new processing space in the private stack of the markup thread, the first pointer of the first object in the memory block that the thread is responsible for is continuously stored.
- a thread start instruction is sent to the N mark threads, so that the N mark threads synchronously perform mark processing for garbage collection according to the press-in condition of the first pointer in the respective private stacks.
- FIG. 3 is a schematic diagram of a first marking process flow for garbage collection.
- the first marking process is performed on the pressing condition of the first object by using a coloring mark in the bitmap of the memory block, and the specific marking is as follows:
- the corresponding position in the memory block bitmap of the first object is grayed out.
- the root object A in the virtual heap is processed (the root object in the virtual heap in this example is equivalent to the first object involved in the above embodiment) as an example:
- Step 10 Apply N tag threads, where N is an integer greater than 1, and the memory capacity occupied by the N tag threads is preset, and each tag thread includes at least: 1 private stack.
- Step 20 Establish a correspondence between a memory block in the virtual machine heap and N marked threads.
- Step 30 Traverse the root object in the virtual machine heap, and if the traversal is completed, exit, otherwise step 40 is performed.
- Step 40 Push the first pointer of the currently processed root object A into the private stack 1 of the marking thread 1 corresponding to the memory block 10 where A is located.
- Step 50 Determine whether the first pointer of A is successfully pushed into the private stack 1 of the marking thread 1;
- Step 60 If the first pointer of A is successfully pushed into the private stack 1 of the marking thread 1, the position corresponding to A in the bitmap of the memory block 10 is marked black, that is, A is the pressed state.
- Step 70 If the first pointer of A is not successfully pushed into the private stack 1 of the marking thread 1, the position corresponding to A in the bitmap of the memory block 10 is grayed out, that is, A is an overflow state.
- the parallel mark processing method for garbage collection in the embodiment of the present application by applying N mark threads, traverses all memory blocks of the virtual machine heap, assigns a number to each memory block; and determines according to the memory block number and the total number of marked threads N. a mark thread number corresponding to each memory block number, and further pressing a first pointer of the currently processed first object into a private stack of the mark thread corresponding to the memory block where the first object is located, according to the first pointer Performing a first marking process on the first object, and sending a thread start instruction to the N marking threads after the traversing of the first object is completed, so that the N marking threads are in accordance with respective private stacks
- the press-in of the first pointer synchronously performs tag processing for garbage collection.
- the first pointer of the first object in the memory block that the thread is responsible for is stored in the private stack of each mark thread. If the private thread of the markup thread overflows, indicating that the space of the private stack is full and cannot continue to store the first pointer of the first object in the memory block that the thread is responsible for marking, the first object is marked as overflowed. When there is new processing space in the private stack of the markup thread, the first pointer of the first object in the memory block that the thread is responsible for is continuously stored.
- a thread start instruction is sent to the N mark threads, so that the N mark threads synchronously perform mark processing for garbage collection according to the press-in condition of the first pointer in the respective private stacks.
- the processing process of the N marking threads that are applied in advance is synchronous and parallel.
- the marking processing process of the first marking thread is taken as an example, and the following implementation is implemented.
- the tag processing process of other (N-1) tag threads is referred to the first tag thread, and will not be described one by one.
- FIG. 4 is a schematic diagram of N tag threads pre-applied.
- the N tag threads pre-applied, and the memory capacity occupied by the N tag threads.
- the N tag threads include: Thread-1, Thread-2, ... Thread-N.
- Each of the markup threads includes at least one private stack. After the above processing, each private stack stores a first pointer of the first object (Root Objects) that the thread is responsible for.
- FIG. 5 is a flow chart 1 for applying the markup thread parallel mark processing shown in FIG.
- the parallel marking processing method for garbage collection includes:
- Step 301 The first marking thread extracts the first pointer of the pre-pressed first object from the first private stack according to the thread starting instruction.
- Step 302 The first marking thread traverses the second object referenced by the first object indicated by the first pointer, and according to a preset N marking thread and a corresponding memory block in the virtual machine stack The relationship performs a second marking process on the second object.
- the first marking thread extracts the first pointer of the pre-pressed first object from the first private stack according to the thread start instruction.
- the first marking thread queries the pre-stored object relation table to obtain the second object indicated by the first pointer currently processed. It is necessary to explain that the second object is a reference object of the first object.
- the first marking thread traverses the second object indicated by the first pointer currently processed, and determines, according to the correspondence between the preset N marking threads and the memory block in the virtual machine heap, the marking thread responsible for processing the memory block where the current second object is located. Whether it is the thread, so that the second object is subjected to the second marking process.
- the first pointer of the first object that is pre-pressed is taken out from the first private stack by the first marking thread according to the thread start instruction, and the first object referenced by the first pointer is traversed.
- the second object performs second marking processing on the second object according to a preset correspondence between the N marking threads and the memory blocks in the virtual machine heap.
- the parallel marking process of the N marking threads realizes parallel marking processing with limited memory, thereby improving the performance of the entire garbage collection.
- FIG. 6 is a second flowchart of applying the markup thread parallel mark processing shown in FIG.
- each tag thread further includes: (N-1) common output queues (queue-1, queue-2...queue-N-1), and 1 cache queue. (buf-queue).
- (N-1) common output queues are used to store pointers to other (N-1) tagged objects responsible for tagging; when common output queues corresponding to other (N-1) tagged threads overflow, 1
- the cache queue is used to cache pointers to other (N-1) tagged objects that are responsible for tagging.
- Step 302 in the embodiment shown in FIG. 5 specifically includes:
- Step 401 The first marking thread determines, according to the correspondence, whether it is responsible for the current location.
- the memory block P1 where the second object of the second object is located is marked;
- the first marking thread determines, according to the correspondence between the preset N marking threads and the memory blocks in the virtual machine heap, whether the thread is responsible for marking the memory block P1 where the currently processed second object is located.
- the first markup thread knows that the markup thread responsible for marking the memory block P1 is the first markup thread, that is, the thread is responsible for marking the memory block P1, and then performing steps 402-step 406;
- the marking thread M is not the first marking thread, that is, the thread is not responsible for marking the memory block P1, and then step 407 is performed. - Step 415.
- Step 402 Push a second pointer of the currently processed second object into the first private stack.
- the first branching thread is responsible for marking the memory block P1
- the first marking thread pushes the pointer responsible for processing the object into the private stack of the thread for processing.
- the second pointer of the currently processed second object is pushed into the first private stack for the second marking process.
- Step 403 The first marking thread determines whether the second pointer is successfully pushed into the first private stack.
- the first marking thread determines whether the second pointer of the currently processed second object is successfully pushed into the first private stack of the thread.
- step 404 and step 405 performing tag processing on the overflow state of the second object
- step 406 is performed to continue to perform the second label on the next second object. Record processing.
- Step 404 marking a state corresponding to the second object in the bitmap of the memory block P1 as an overflow state.
- Step 405 setting an overflow flag corresponding to the memory block P1.
- the second object is set to an overflow state for the determination branch in step 403 that the first mark thread fails to successfully push the second pointer of the currently processed second object into the first private stack of the thread.
- the state corresponding to the second object in the bitmap of the memory block P1 is marked as an overflow state.
- an overflow flag corresponding to the memory block P1 is further set.
- Step 406 If the first marking thread successfully pushes the second pointer into the first private stack, proceed to process the next second object corresponding to the first pointer.
- Step 407 determining that the marking thread M is responsible for marking the memory block P1;
- Step 408 pressing the second pointer into the common output queue M corresponding to the marking thread M in the first marking thread
- determining branch that the first marking thread in step 401 is not responsible for marking the memory block P1 determining, according to the correspondence between the N marking threads and the memory block in the virtual machine heap, determining that the marking thread M is responsible for the The memory block P1 performs tag processing.
- the first marking thread pushes the second pointer of the currently processed second object into the common output queue M corresponding to the marking thread M in the first marking thread, so that the marking thread M is subsequently followed from the first marking thread.
- the second pointer of the second object to be processed is obtained in the common output queue M.
- Step 409 the first marking thread determines whether the second pointer is successfully pushed into the public output queue M;
- the first marking thread determines whether the second pointer of the currently processed second object is successfully pushed into the common output queue M.
- step 410 is performed to continue to the current current from the first private stack.
- the next second object corresponding to a pointer is processed.
- step 411 is performed to buffer the first cache queue through the first tag thread. The second pointer.
- Step 410 Continue processing the next second object corresponding to the first pointer.
- step 409 the first marking thread successfully pushes the current second pointer into the judgment branch in the common output queue M in the first marking thread, and continues to process the next second object corresponding to the first pointer.
- Step 411 pressing the second pointer into the first buffer queue in the first marking thread
- the second pointer is pushed into the first marking thread. In the first cache queue.
- Step 412 The first marking thread determines whether the second pointer is successfully pushed into the first buffer queue.
- the first marking thread determines whether the second pointer is successfully pushed into the first buffer queue of the first marking thread
- step 413 and step 414 are performed, and the currently processed second object is marked with an overflow state
- step 415 is performed to continue tag processing for the next second object.
- Step 413 marking a state corresponding to the currently processed second object in the bitmap of the memory block P1 as an overflow state.
- Step 414 setting an overflow flag corresponding to the memory block P1.
- the bitmap of the merchant memory block P1 is compared with the currently processed second The state corresponding to the object is marked as an overflow state, and an overflow flag corresponding to the memory block P1 is further set.
- Step 415 Continue processing the next second object corresponding to the first pointer.
- processing continues on the next second object corresponding to the current first pointer.
- the method further includes:
- Example 1 the pressing condition of each second object can be recorded by means of a list
- the pressing condition of the second object can be marked by the corresponding position in the bitmap of the memory block where the second object is located.
- the first pointer of the first object that is pre-pressed is taken out from the first private stack by the first marking thread according to the thread start instruction, and the first object referenced by the first pointer is traversed.
- Two objects, and according to the preset N markup threads and memory blocks in the virtual machine heap The corresponding relationship performs a second marking process on the second object. Therefore, with reference to the marking process of the first marking thread, the parallel marking processing of the N marking threads realizes efficient parallel marking with limited memory, and at the same time realizes load balancing of the marking thread, thereby reducing CPU cache consistency conflict and improving the whole.
- the performance of garbage collection is performed.
- Figure 7 is a flow chart 3 of the application of the mark thread parallel mark processing shown in Figure 4.
- each tag thread includes: 1 private stack (stack), (N-1) common output queues (queue-1, queue-2...queue-N-1), and 1 cache queue ( Buf-queue).
- a private stack is used to store pointers to objects that the thread is responsible for marking
- (N-1) public output queues are used to store pointers to other (N-1) marking objects that are responsible for marking
- one cache queue is used to cache pointers to other (N-1) tagged objects that are responsible for tagging.
- the method further includes:
- Step 501 After receiving the thread start instruction, the first marking thread determines whether the first private stack of the thread is empty.
- the first marking thread determines whether the first private stack of the thread is empty
- the first pointer of the pre-pressed first object is retrieved from the first private stack according to step 302 in the embodiment shown in FIG. 5, and according to FIG. Or the implementation process shown in FIG. 6 is processed, and details are not described herein again.
- step 502 is performed to continue to determine whether the first cache queue in the first marked thread is empty.
- Step 502 The first marking thread determines whether the first buffer queue of the thread is empty.
- the first marking thread determines whether the first cache queue of the thread is empty
- step 503 is executed, so that the third object that is not responsible for processing by the first marking thread performs allocation processing to the public output queue corresponding to the third object in the thread;
- Step 503 the first marking thread extracts a third pointer of the third object that is pre-pressed from the first cache queue, where the first marking thread is not responsible for the memory of the currently processed third object.
- Block P2 performs labeling processing
- Step 504 the first marking thread determines, according to the correspondence, that the marking thread W is responsible for marking the memory block P2 where the currently processed third object is located;
- Step 505 the first marking thread pushes the third pointer into a common output queue W corresponding to the marking thread W in the first marking thread;
- the first marking thread extracts the third pointer of the pre-pressed third object from the first cache queue of the thread, because the object stored in the first cache queue is a common output that needs to be placed in the first marking thread. In the queue, it is processed by the corresponding other markup thread. When an overflow occurs in the common output queue in the first tag thread, the overflowed third object is placed in the first cache queue in the first tag thread.
- the first marking thread is not responsible for marking the memory block P2 where the currently processed third object is located.
- the first marking thread determines, according to the correspondence between the memory block of the virtual machine heap and the marking thread, that the marking thread W is responsible for marking the memory block P2 where the currently processed third object is located.
- the first marking thread pushes the third pointer into the common output queue W corresponding to the marking thread W in the first marking thread, so that the marking thread W obtains the first thread from the common output queue W of the first marking thread.
- the three pointers are marked for processing.
- Step 506 the first marking thread determines whether the third pointer currently processed is successfully pushed into the common output queue W;
- Step 507 continuing to the next third object in the first cache queue to the corresponding public Push processing with the output queue.
- Step 508 re-pressing the third pointer into the first cache queue.
- the first marking thread determines whether the third pointer currently processed is successfully pushed into the public output queue W of the thread.
- step 507 is executed to continue to press the next third object in the first buffer queue to the corresponding public output queue. Into the process.
- the third pointer is re-pressed into the first cache queue of the thread. At this point, there is no overflow problem because the third pointer is taken from the first cache queue of the thread.
- the third pointer of the third object that is pre-pressed is removed from the first buffering queue.
- the common output queue in the thread and the corresponding markup thread is pushed into the markup thread for marking processing with the markup thread corresponding to the third object.
- FIG. 8 is a flow chart 4 of the application of the mark thread parallel mark processing shown in FIG.
- the embodiment is based on step 502 in FIG. 7 , and is determined by the embodiment shown in FIG. 8 if the first buffer queue in the first marking thread is empty. How to further perform marking processing on the fourth object in the common output queue corresponding to the first marking thread among the other (N-1) marking threads, including:
- Step 601 The first marking thread determines whether the public output queue corresponding to the first marking thread among the other (N-1) marking threads is empty.
- the first marking thread determines whether the public output queue corresponding to the first marking thread among the other (N-1) marking threads is empty;
- step 602 is performed, so that the first marking thread obtains the fourth object that the thread is responsible for processing from the other marking threads. Push processing into the first private stack of this thread.
- the fifth object performs labeling processing, which is described in detail in the subsequent embodiments.
- Step 602 The first marking thread extracts a fourth pointer of the fourth object that is pre-pressed from the currently processed common output queue, wherein the fourth object is pre-pressed by the marking thread T by the first a marking thread is responsible for marking the memory block P3 where the fourth object is located;
- Step 603 the first marking thread pushes the fourth pointer into the first private stack
- step 601 if the common output queue corresponding to the first marking thread in the other (N-1) marking threads is not empty in step 601, it is indicated that the other marking threads also have to be marked by the first marking thread.
- the first marking thread extracts the fourth pointer of the fourth object that is pre-pressed from the currently processed common output queue, wherein the fourth object is pre-pressed by the marking thread T and is responsible for the first marking thread.
- the memory block P3 where the fourth object is located is subjected to label processing. Thereby the first marking thread pushes the fourth pointer into the first private stack.
- Step 604 the first marking thread determines whether the fourth pointer is successfully pushed into the first private stack
- Step 605 marking a state corresponding to the fourth object in the bitmap of the memory block P3 as an overflow state.
- Step 606 setting an overflow flag corresponding to the memory block P3.
- Step 607 proceeding to push-in processing the next fourth object into the first private stack.
- the first marking thread determines whether the fourth pointer is successfully pushed into the first private stack of the thread.
- step 605 and step 606 are performed, and the bitmap of the memory block P3 where the fourth object is located is The state corresponding to the fourth object is marked as an overflow state, and an overflow flag corresponding to the memory block P3 is set.
- step 607 is executed to continue to push the next fourth object into the first private stack of the thread.
- the first marking thread of the present application is empty when the first private stack and the first cache queue are empty, and the common output queue corresponding to the first marking thread in other marking threads is not empty, and the pre-pressed is taken out.
- the fourth pointer of the fourth object is pushed into the processing of the first private stack in the thread.
- Figure 9 is a flow chart 5 of the application of the mark thread parallel mark processing shown in Figure 4.
- the embodiment is based on step 601 in FIG. 9 , and is determined if the public output queue corresponding to the first marking thread among other (N-1) marking threads is empty.
- the branching process is performed by using the embodiment shown in FIG. 9 to further perform marking processing on the fifth object that is marked by the first marking thread and has an overflow state, and specifically includes:
- Step 701 The first marking thread determines whether the memory block in which the thread is responsible for marking has a fifth object in an overflow state
- Step 702 If the first marking thread is responsible for the fifth object in the memory block that is not marked with an overflow state, the marking ends and the thread is exited.
- Step 703 if the first marking thread is responsible for the fifth object having the overflow state in the marked memory block, the first marking thread modifies the fifth object marked in the overflow state of the currently processed memory block P4 to the pressed state. Pressing the fifth pointer of the current fifth object into the first private stack;
- the first marking thread determines whether the memory block in which the thread is responsible for marking has a fifth object in an overflow state.
- step 702 is executed to exit the thread.
- the first marking thread executes step 703 to modify the fifth object marked in the overflow state in the currently processed memory block P4 to the pressed state, and press the fifth pointer of the current fifth object into the first private stack. .
- Step 704 the first marking thread determines whether the fifth pointer is successfully pushed into the first private stack.
- Step 705 If the first marking thread fails to successfully push the fifth pointer into the first private stack, the state corresponding to the fifth object in the bitmap of the memory block P4 is Marked as overflow.
- Step 706 setting an overflow flag corresponding to the memory block P5.
- Step 707 If the first marking thread successfully pushes the fifth pointer into the first private stack, proceeding to processing the next fifth object.
- the first marking thread determines whether the current fifth pointer is successfully pushed into the first private stack of the thread.
- step 705 and step 706 are performed, where the fifth object is located.
- the state corresponding to the fifth object is marked as an overflow state, and an overflow flag corresponding to the memory block P5 is further set.
- step 707 is executed to continue processing the next fifth object.
- the parallel marking processing of the N marking threads realizes efficient parallel marking with limited memory, thereby improving the performance of the entire garbage collection.
- FIG. 10 is a flow chart 6 of applying the markup thread parallel mark processing shown in FIG.
- the pressing condition of the second object to the fifth object is marked by using a coloring mark in the bitmap of the memory block, and the specific marking is as follows:
- the coloring processing performed on the corresponding position of the current processing object in the bitmap of the memory block is merely an exemplary description, and may be according to specific application requirements. Make adjustments.
- the object A is equivalent to the first object involved in the above embodiment
- the object A1 is equivalent to the second object involved in the above embodiment
- the object B is equivalent to the third object involved in the above embodiment
- the object D is equivalent to the fourth object involved in the above embodiment
- the object C is equivalent to the fifth object involved in the above embodiment, and is illustrated as follows:
- the parallel tag processing method includes:
- Step 1 The thread starts.
- Step 2 If the private stack is empty, skip to step 3. Otherwise an object such as A pops up and jumps to step 4.
- Step 3 If buf-queue is empty, go to step 7. Otherwise, traverse buf-queue, pop up the object such as B, and go to step 5. If the traversal has been completed, skip to step 7.
- Step 4 Iterate through all the objects referenced by object A in turn, and jump to step 2 when the traversal is completed. Otherwise, for example, traverse to object A1 and jump to step 9.
- Step 5 Try to push the object B popped up in step 3 into the queue of T(B) in the line. If the press is successful, jump to step 3, otherwise the page (memory block) where the object B is located overflows, and then Go to step 6.
- Step 6 Object B is pressed back into buf-queue, this time will not fail, because object B is popped from buf-queue.
- Step 7 Traverse the queue corresponding to the thread in the other N-1 threads, and take out the marked object. As long as there is a queue that is not empty, pop out (pop) the markup object, such as object D, and then jump to step 16. If the queue corresponding to this thread is empty in all N-1 threads, go to step 8.
- Step 8 If you find that there is an overflow when you traverse the page responsible for this thread, iterate through the bitmap (bitmap) of the overflowed page, find the gray object such as C, and if it finds, jump to step 14. After the traversal is completed, clean up the overflow flag of the page, then jump to step 15.
- bitmap bitmap
- Step 9 Determine the corresponding bitmap of the page where the object A1 traversed in step 4 is located. Whether it is white, if it is already black, jump to step 4. If it is white, skip to step 10.
- Step 10 The corresponding bitmap value of the page where the mark object A1 is located is black. If T(A1) is the thread, go to step 17. Otherwise jump to step 11.
- Step 11 Try to push the object A1 into the T (A1) number queue of this thread. If the push fails, set the overflow of the Page where A1 is located. And jump to step 12, if successful, then jump to step 4.
- Step 12 Try to push object A1 into buf-queue, and if successful, go to step 4. Otherwise go to step 13.
- Step 13 Set the value of the bitmap corresponding to the page where the object A1 is located to be gray, and set the overflow flag of the page.
- Step 14 The corresponding bitmap of the gray object C mark traversed in step 8 is black and pressed into the private stack stack, and if successful, jumps to step 8. If it fails, set the overflow flag of the Page where C is located, and jump to step 19.
- Step 15 If the tag ends, the thread exits, otherwise jump to step 2 to continue the parallel tag.
- Step 16 Mark the object corresponding to the bitmap D as black, and try to push the object D into the stack of the thread. If the push is successful, go to step 7. The overflow jumps to step 19.
- Step 17 Try to push the object A1 into the private stack of the thread. If the push is successful, there is no overflow, then jump to step 4, otherwise jump to step 18.
- Step 18 Mark the bitmap corresponding to the object A1 to be gray, and set the overflow flag of the Page where A1 is located. Then go to step 4.
- Step 19 Mark the object (D or C, which may be from step 14 or 16), the corresponding bitmap is gray, and set the overflow flag of the Page where the markup object is located. Then go to step 2.
- FIG. 6 to FIG. 9 the detailed description process refers to the embodiment shown in FIG. 6 to FIG. Let me repeat.
- Step (1) is shown in the following.
- Step (1) is shown in the following.
- Step (4) is shown in the following.
- Step (4) is shown in the following.
- Step process (4)
- the present application also proposes a parallel tag processing apparatus for garbage collection.
- FIG. 11 is a schematic structural diagram of a parallel tag processing apparatus for garbage collection according to an embodiment of the present application.
- the parallel tag processing apparatus for garbage collection includes:
- the traversing module 11 is configured to traverse the first object in the virtual machine heap according to the correspondence between the memory block in the virtual machine heap and the N marking threads, where N is an integer greater than 1, and the N marking threads occupy
- the memory capacity is preset, and each markup thread includes at least: 1 private stack;
- a first marking module 12 configured to press a first pointer of the currently processed first object into a private stack of the marking thread corresponding to the memory block in which the first object is located, according to the pressing situation of the first pointer Decoding the first object to perform the first marking process;
- the startup module 13 is configured to send a thread start instruction to the N mark threads after the traversal of the first object is completed, so that the N mark threads are pressed according to the first pointer in the respective private stacks. , synchronous tag processing for garbage collection.
- the parallel tag processing apparatus for garbage collection traverses the first object in the virtual machine heap according to the correspondence between the memory block and the N mark threads in the virtual machine heap, wherein the N tags
- the memory capacity occupied by the thread is preset, and the first pointer of the currently processed first object is pushed into the private stack of the marking thread corresponding to the memory block where the first object is located, according to the pressing condition of the first pointer.
- the tag processing for garbage collection is performed synchronously.
- multi-threaded parallel tag processing is implemented with limited memory to improve the performance of the entire garbage collection.
- FIG. 12 is a schematic structural diagram of a parallel tag processing apparatus for garbage collection according to another embodiment of the present application.
- the parallel tag processing apparatus for garbage collection further includes:
- An application module 14 is configured to apply for the N marking threads
- the establishing module 15 is configured to traverse a memory block in the virtual machine heap, and establish a correspondence between the memory block and the N marking threads.
- the establishing module 15 is configured to:
- the establishing module 15 includes:
- An allocating unit 151 configured to traverse memory blocks in the virtual machine heap, and assign a number to each of the memory blocks;
- the determining unit 152 is configured to determine a marking thread number corresponding to each memory block number according to the number of the memory block and the total number N of marking threads.
- the determining unit 152 is configured to:
- the first marking module 12 is configured to:
- the bitmap corresponding to the first object in the bitmap of the memory block where the current first object is located The status is marked as an overflow status.
- the parallel tag processing apparatus for garbage collection provided by the embodiment, by applying N mark threads, traverses all memory blocks of the virtual machine heap, assigns a number to each memory block; and determines according to the memory block number and the total number of marked threads N. a mark thread number corresponding to each memory block number, and further pressing a first pointer of the currently processed first object into a private stack of the mark thread corresponding to the memory block where the first object is located, according to the first pointer Performing a first marking process on the first object, and sending a thread start instruction to the N marking threads after the traversing of the first object is completed, so that the N marking threads are in accordance with respective private stacks
- the press-in of the first pointer synchronously performs tag processing for garbage collection. As a result, efficient parallel tagging is achieved with limited memory, while tag thread load balancing is achieved, improving the overall garbage collection performance.
- FIG. 13 is a schematic structural diagram of a parallel label processing apparatus for garbage collection according to another embodiment of the present application.
- the N tag threads pre-applied in this embodiment, and the memory capacity occupied by the N tag threads.
- the N tag threads include: Thread-1, Thread-2, ... Thread-N.
- Each of the markup threads includes at least one private stack. After the above processing, each private stack stores a first pointer of the first object (Root Objects) that the thread is responsible for.
- the parallel tag processing apparatus for garbage collection in this embodiment includes:
- the obtaining module 21 is configured to extract, from the first private stack, the first pointer of the pre-pressed first object according to the thread start instruction;
- a second marking module 22 configured to traverse the second object referenced by the first object indicated by the first pointer, and according to a preset correspondence relationship between the N marking threads and a memory block in the virtual machine stack The second object performs the second marking process.
- the parallel mark processing apparatus for garbage collection provided by the embodiment, by using the first mark thread, according to the thread start instruction, extracting the first pointer of the pre-pressed first object from the first private stack, traversing the first pointer Instructing the second object that is referenced by the first object, and performing second marking processing on the second object according to a preset correspondence between the N marking threads and a memory block in the virtual machine heap.
- the parallel marking process of the N marking threads realizes parallel marking processing with limited memory, thereby improving the performance of the entire garbage collection.
- FIG. 14 is a schematic structural diagram of a parallel label processing apparatus for garbage collection according to another embodiment of the present application.
- the second marking module 22 includes:
- the first determining unit 221 is configured to determine, according to the correspondence, whether it is responsible for performing labeling processing on the memory block P1 where the currently processed second object is located;
- the first processing unit 222 is configured to: if the first marking thread is responsible for marking the memory block P1, press the second pointer of the currently processed second object into the first private In the stack
- a second determining unit 223, configured to determine whether the second pointer is successfully pushed into the first private stack
- a second processing unit 224 configured to: if the first marking thread fails to push the second pointer into the first private stack, insert the bitmap of the memory block P1 with the first The status corresponding to the two objects is marked as an overflow status.
- the second processing unit 224 is further configured to:
- An overflow flag corresponding to the memory block P1 is set.
- the second processing unit 224 is further configured to: if the first marking thread successfully pushes the second pointer into the first private stack, continue to the next second corresponding to the first pointer The object is processed.
- the second marking module 22 further includes:
- the first processing unit 222 is further configured to: if the first marking thread is not responsible for marking the memory block P1, determine that the marking thread M is responsible for marking the memory block P1, and the second a pointer is pushed into the common output queue M corresponding to the marking thread M in the first marking thread;
- a third determining unit 225 configured to determine whether the second pointer is successfully pushed into the common output queue M
- the third processing unit 226 is configured to continue processing the next second object corresponding to the first pointer if the first marking thread successfully pushes the second pointer into the common output queue M .
- the second marking module 22 further includes:
- the third processing unit 226 is further configured to: if the first marking thread fails to press the second pointer into the common output queue M, press the second pointer into the The first cache queue in the first mark thread;
- the fourth determining unit 227 is configured to determine whether the second pointer is successfully pushed into the first buffer queue
- a fourth processing unit 228, configured to: in the bitmap of the memory block P1, and current processing if the first tag thread fails to successfully push the second pointer into the first cache queue The status of the second object is marked as an overflow status.
- the fourth processing unit 228 is further configured to:
- An overflow flag corresponding to the memory block P1 is set.
- the fourth processing unit 228 is further configured to: if the first marking thread successfully pushes the second pointer into the first buffer queue, continue to the next second corresponding to the first pointer The object is processed.
- the second processing unit 224 is further configured to query a status flag corresponding to the second object in the bitmap of the memory block P1; if the status flag corresponding to the second object is an untagged status, The state corresponding to the second object is modified to the pressed state.
- the parallel mark processing apparatus for garbage collection provided by the embodiment, by using the first mark thread, according to the thread start instruction, extracting the first pointer of the pre-pressed first object from the first private stack, traversing the first pointer Instructing the second object that is referenced by the first object, and performing second marking processing on the second object according to a preset correspondence between the N marking threads and a memory block in the virtual machine heap.
- Parallel markup processing using efficient memory for efficient parallel markup, while implementing markup thread load balancing, thereby reducing CPU cache consistency conflicts and improving overall garbage collection performance.
- FIG. 15 is a schematic structural diagram of a parallel mark processing apparatus for garbage collection according to another embodiment of the present application.
- each of the N marked threads preset in this embodiment further includes: 1 cache queue, and corresponding to other (N-1) mark threads ( N-1) a common output queue; the second marking module 22 further includes:
- the fifth determining unit 229 is configured to determine whether the first private stack is empty.
- the sixth determining unit 210 is configured to determine, if the first private stack is empty, whether the first cache queue of the first marking thread is empty;
- the fifth processing unit 211 is configured to: if the first cache queue is not empty, the first marking thread extracts a third pointer of the third object that is pre-pressed from the first cache queue, where the The first marking thread is not responsible for marking the memory block P2 where the currently processed third object is located; according to the correspondence, determining that the marking thread W is responsible for marking the memory block P2 where the currently processed third object is located; The third pointer is pushed into the common output queue W corresponding to the marking thread W in the first marking thread;
- the seventh determining unit 212 is configured to determine whether the third pointer currently processed is successfully pushed into the common output queue W;
- a sixth processing unit 213, configured to continue to the next third object in the first cache queue if the first tag thread successfully pushes the third pointer into the common output queue W The corresponding public output queue is pushed in.
- the sixth processing unit 213 is further configured to: if the first marking thread fails to press the third pointer into the common output queue W, press the third pointer into the In the first cache queue.
- the parallel mark processing apparatus for garbage collection provided by the embodiment, when the first private stack of the first mark thread is empty, and the first cache queue is not empty, the pre-pressed first is taken out from the first cache queue The third pointer of the three objects is pushed into the common output queue of the corresponding mark thread in the thread for marking processing by the mark thread corresponding to the third object.
- collaborative marking processing of the N marking threads enables efficient parallel marking with limited memory, and at the same time implements tag thread load balancing, thereby reducing CPU cache consistency conflicts. To improve the performance of the entire garbage collection.
- 16 is a schematic structural diagram of a parallel tag processing apparatus for garbage collection according to another embodiment of the present application.
- the second marking module 22 further includes:
- the eighth determining unit 214 is configured to determine, if the first buffer queue is empty, whether the public output queue corresponding to the first marking thread among the other (N-1) marking threads is empty;
- the seventh processing unit 215 is configured to: if the public output queue corresponding to the first marking thread in the currently processed marking thread T is not empty, the first marking thread is pre-pressed from the currently processed common output queue. a fourth pointer of the fourth object, wherein the fourth object is pre-pressed by the marking thread T, and the first marking thread is responsible for marking the memory block P3 where the fourth object is located; Pressing the fourth pointer into the first private stack;
- the ninth determining unit 216 is configured to determine whether the fourth pointer is successfully pushed into the first private stack.
- the eighth processing unit 217 is configured to: if the first marking thread fails to push the fourth pointer into the first private stack, insert the bitmap of the memory block P3 with the first The status corresponding to the four objects is marked as an overflow status.
- the eighth processing unit 217 is further configured to set an overflow flag corresponding to the memory block P3.
- the eighth processing unit 217 is further configured to continue to the first fourth object to the first private if the first marking thread successfully pushes the fourth pointer into the first private stack Push processing in the stack.
- the first mark thread is empty in the first private stack and the first cache queue, and the common output queue corresponding to the first mark thread in other mark threads is not empty.
- the fourth pointer of the fourth object pushed in advance is fetched, and the processing is pushed to the first private stack in the thread.
- FIG. 17 is a schematic structural diagram of a parallel mark processing apparatus for garbage collection according to another embodiment of the present application.
- the second marking module 22 further includes:
- the tenth determining unit 218 is configured to: if the common output queue corresponding to the first marking thread among the other (N-1) marking threads is empty, the first marking thread determines that the thread is responsible for marking the memory block Whether there is a fifth object in the overflow state;
- the ninth processing unit 219 is configured to: if the first marking thread is responsible for the fifth object having an overflow state in the marked memory block, the first marking thread will mark the fifth object of the overflow state in the currently processed memory block P4 Modified to the pressed state, pressing the fifth pointer of the current fifth object Into the first private stack;
- the eleventh determining unit 220 is configured to determine, by the first marking thread, whether the fifth pointer is successfully pushed into the first private stack;
- the tenth processing unit 221 is configured to: if the first marking thread fails to push the fifth pointer into the first private stack, insert the bitmap of the memory block P4 with the first The status corresponding to the five objects is marked as an overflow status.
- the tenth processing unit 221 is further configured to set an overflow flag corresponding to the memory block P5.
- the tenth processing unit 221 is further configured to continue processing the next fifth object if the first marking thread successfully pushes the fifth pointer into the first private stack.
- the ninth processing unit 219 is further configured to: if the first tag thread is responsible for the fifth object in the memory block that is not in the overflow state, the tag ends and the thread is exited.
- the parallel mark processing apparatus for garbage collection provided by the embodiment, when the first mark thread is empty in the public output queue corresponding to the first mark thread in the first private stack, the first cache queue, and other mark threads, The push-in processing is performed according to the fifth object having the overflow state that the thread is responsible for marking.
- the parallel marking processing of the N marking threads realizes efficient parallel marking with limited memory, thereby improving the performance of the entire garbage collection.
- first and second are used for descriptive purposes only and are not to be construed as indicating or implying a relative importance or implicitly indicating the number of technical features indicated.
- features defining “first” or “second” may include at least one of the features, either explicitly or implicitly.
- the meaning of "a plurality” is at least two, such as two, three, etc., unless specifically defined otherwise.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Memory System (AREA)
- Management, Administration, Business Operations System, And Electronic Commerce (AREA)
Abstract
一种用于垃圾回收的标记方法及装置,通过根据虚拟机堆中的内存块与N个标记线程的对应关系,遍历所述虚拟机堆中的第一对象,其中,N为大于1的整数,N个标记线程占用的内存容量是预先设置的,每个标记线程至少包括:1个私有栈(101);将当前处理的第一对象的第一指针压入与该第一对象所在的内存块对应的标记线程的私有栈,根据所述第一指针的压入情况对所述第一对象进行第一标记处理(102);对所述第一对象遍历完成后,向所述N个标记线程发送线程启动指令,以使所述N个标记线程根据各自私有栈中所述第一指针的压入情况,同步进行用于垃圾回收的标记处理(103)。由此,利用有限的内存实现多线程的并行标记处理,提高整个垃圾回收的性能。
Description
本申请涉及计算机技术领域,尤其涉及一种用于垃圾回收的并行标记处理方法及装置。
垃圾回收(即Garbage Collection简称GC)技术被广泛使用在当今流行的许多高级语言虚拟机中。GC技术根据垃圾收集器(简称Collector)和宿主(简称Mutator)的关系可以分为两种:Collector工作时Mutator暂停(简称Stop-The-World-GC即STW-GC),Collector工作时Mutator不暂停(简称并发GC即Concurrent-GC)。目前完全并发GC还没有哪一款虚拟机真正实现,流行的高级语言虚拟机比如JVM,V8等都是STW-GC或者部分Concurrent-GC。非引用计数的STW-GC方案可以分为3种,即标记-拷贝(简称marking-copy),标记-清理(简称marking-sweep),和标记-压缩(简称marking-compact)。
目前流行的高级语言虚拟机产品比如JVM,V8等的内存都是通过堆(heap)来进行统一管理,堆以指定大小的内存块(简称为一个page,一般为操作系统的内存页大小的整数倍)为基本单位进行组织。比如V8虚拟机的page大小为1MByte。而且在每一个内存块(即page)的起始部分划分出一块位图区域(称为bitmap)用来标记所在的page中每一个对象是否是活跃对象。比如某个page中的某个对象对应在该page头部的bitmap位被置为1,则说明该对象是活跃对象,进行GC时候不应该进行回收。
当前用于垃圾回收的标记方法为单线程的标记方式,根据标记对象的不断增加,所占用的内存空间会不断增大,由此可见,目前的单线程标记方式浪费了大量的内存空间,降低了处理性能和效率。
发明内容
本申请旨在至少在一定程度上解决相关技术中的技术问题之一。
为此,本申请的第一个目的在于提出一种用于垃圾回收的并行标记处理方法,该方法利用有限的内存实现多线程的并行标记处理,提高整个垃圾回收的性能。
本申请的第二个目的在于提出一种用于垃圾回收的并行标记处理方法。
本申请的第三个目的在于提出一种用于垃圾回收的并行标记处理装置。
本申请的第四个目的在于提出一种用于垃圾回收的并行标记处理装置。
为达上述目的,本申请第一方面实施例提出了一种用于垃圾回收的并行标记处理方法,包括:根据虚拟机堆中的内存块与N个标记线程的对应关系,遍历所述虚拟机堆中的第一对象,其中,N为大于1的整数,N个标记线程占用的内存容量是预先设置的,每个标记线程至少包括:1个私有栈;将当前处理的第一对象的第一指针压入与该第一对象所在的内存块对应的标记线程的私有栈,根据所述第一指针的压入情况对所述第一对象进行第一标记处理;对所述第一对象遍历完成后,向所述N个标记线程发送线程启动指令,以使所述N个标记线程根据各自私有栈中所述第一指针的压入情况,同步进行用于垃圾回收的标记处理。
本申请实施例的用于垃圾回收的并行标记处理方法,通过根据虚拟机堆中的内存块与N个标记线程的对应关系,遍历所述虚拟机堆中的第一对象,其中,N个标记线程占用的内存容量是预先设置的,将当前处理的第一对象的第一指针压入与该第一对象所在的内存块对应的标记线程的私
有栈,根据所述第一指针的压入情况对所述第一对象进行第一标记处理,对所述第一对象遍历完成后,向所述N个标记线程发送线程启动指令,以使所述N个标记线程根据各自私有栈中所述第一指针的压入情况,同步进行用于垃圾回收的标记处理。由此,利用有限的内存实现多线程的并行标记处理,提高整个垃圾回收的性能。
为达上述目的,本申请第二方面实施例提出了一种用于垃圾回收的并行标记处理方法,包括:预设的N个标记线程中的每个标记线程至少包括:1个私有栈,所述方法应用在每个标记线程中,其中,应用在第一标记线程中的所述方法包括以下步骤:第一标记线程根据线程启动指令,从第一私有栈中取出预先压入的第一对象的第一指针;所述第一标记线程遍历所述第一指针指示的所述第一对象引用的第二对象,并根据预设的N个标记线程与虚拟机堆中内存块的对应关系对所述第二对象进行第二标记处理。
本申请实施例的用于垃圾回收的并行标记处理方法,通过第一标记线程根据线程启动指令,从第一私有栈中取出预先压入的第一对象的第一指针,遍历所述第一指针指示的所述第一对象引用的第二对象,并根据预设的N个标记线程与虚拟机堆中内存块的对应关系对所述第二对象进行第二标记处理。由此,参照第一标记线程的标记处理过程,通过N个标记线程的并行标记处理,实现了利用有限的内存进行并行标记处理,提高整个垃圾回收的性能。
为达上述目的,本申请第三方面实施例提出了一种用于垃圾回收的并行标记处理装置,包括:遍历模块,用于根据虚拟机堆中的内存块与N个标记线程的对应关系,遍历所述虚拟机堆中的第一对象,其中,N为大于1的整数,N个标记线程占用的内存容量是预先设置的,每个标记线程至少包括:1个私有栈;第一标记模块,用于将当前处理的第一对象的第一指针压入与该第一对象所在的内存块对应的标记线程的私有栈,根据所述
第一指针的压入情况对所述第一对象进行第一标记处理;启动模块,用于对所述第一对象遍历完成后,向所述N个标记线程发送线程启动指令,以使所述N个标记线程根据各自私有栈中所述第一指针的压入情况,同步进行用于垃圾回收的标记处理。
本申请实施例的用于垃圾回收的并行标记处理装置,通过根据虚拟机堆中的内存块与N个标记线程的对应关系,遍历所述虚拟机堆中的第一对象,其中,N个标记线程占用的内存容量是预先设置的,将当前处理的第一对象的第一指针压入与该第一对象所在的内存块对应的标记线程的私有栈,根据所述第一指针的压入情况对所述第一对象进行第一标记处理,对所述第一对象遍历完成后,向所述N个标记线程发送线程启动指令,以使所述N个标记线程根据各自私有栈中所述第一指针的压入情况,同步进行用于垃圾回收的标记处理。由此,利用有限的内存实现多线程的并行标记处理,提高整个垃圾回收的性能。
为达上述目的,本申请第四方面实施例提出了一种用于垃圾回收的并行标记处理装置,包括:预设的N个标记线程中的每个标记线程至少包括:1个私有栈,所述装置应用在每个标记线程中,其中,应用在第一标记线程中的所述装置包括:获取模块,用于根据线程启动指令,从第一私有栈中取出预先压入的第一对象的第一指针;第二标记模块,用于遍历所述第一指针指示的所述第一对象引用的第二对象,并根据预设的N个标记线程与虚拟机堆中内存块的对应关系对所述第二对象进行第二标记处理。
本申请实施例的用于垃圾回收的并行标记处理装置,通过第一标记线程根据线程启动指令,从第一私有栈中取出预先压入的第一对象的第一指针,遍历所述第一指针指示的所述第一对象引用的第二对象,并根据预设的N个标记线程与虚拟机堆中内存块的对应关系对所述第二对象进行第二标记处理。由此,参照第一标记线程的标记处理过程,通过N个标记线程
的并行标记处理,实现了利用有限的内存进行并行标记处理,提高整个垃圾回收的性能。
本发明上述的和/或附加的方面和优点从下面结合附图对实施例的描述中将变得明显和容易理解,其中:
图1是本申请一个实施例的用于垃圾回收的并行标记处理方法的流程图;
图2是本申请另一个实施例的用于垃圾回收的并行标记处理方法的流程图;
图3为用于垃圾回收的第一标记处理流程示意图;
图4为预先申请的N个标记线程的示意图;
图5是应用图4所示的标记线程并行标记处理的流程图一;
图6是应用图4所示的标记线程并行标记处理的流程图二;
图7是应用图4所示的标记线程并行标记处理的流程图三;
图8是应用图4所示的标记线程并行标记处理的流程图四;
图9是应用图4所示的标记线程并行标记处理的流程图五;
图10是应用图4所示的标记线程并行标记处理的流程图六;
图11是本申请一个实施例的用于垃圾回收的并行标记处理装置的结构示意图;
图12是本申请另一个实施例的用于垃圾回收的并行标记处理装置的结构示意图;
图13是本申请另一个实施例的用于垃圾回收的并行标记处理装置的结构示意图;
图14是本申请另一个实施例的用于垃圾回收的并行标记处理装置的
结构示意图;
图15是本申请另一个实施例的用于垃圾回收的并行标记处理装置的结构示意图;
图16是本申请另一个实施例的用于垃圾回收的并行标记处理装置的结构示意图;
图17是本申请另一个实施例的用于垃圾回收的并行标记处理装置的结构示意图。
下面详细描述本申请的实施例,所述实施例的示例在附图中示出,其中自始至终相同或类似的标号表示相同或类似的元件或具有相同或类似功能的元件。下面通过参考附图描述的实施例是示例性的,旨在用于解释本申请,而不能理解为对本申请的限制。
下面参考附图描述本申请实施例的用于垃圾回收的并行标记处理方法及装置。
图1是本申请一个实施例的用于垃圾回收的并行标记处理方法的流程图。
如图1所示,该用于垃圾回收的并行标记处理方法包括:
步骤101,根据虚拟机堆中的内存块与N个标记线程的对应关系,遍历所述虚拟机堆中的第一对象,其中,N为大于1的整数,N个标记线程占用的内存容量是预先设置的,每个标记线程至少包括:1个私有栈。
具体地,为了提高用于垃圾回收的标记处理效率,本发明各实施例提供的处理方法利用了多核CPU的并行处理能力,预先申请N个标记线程,其中,每个标记线程至少包括:1个私有栈,私有栈用于存储本线程负责标记的对象的指针。
需要说明的是,N为大于1的整数,根据实际应用的CPU的并行处理能力而定。例如:
如果CPU的并行处理能力为双核,可以申请2个容量限定的标记线程;或,
如果CPU的并行处理能力为四核,可以申请4个容量限定的标记线程;或,
如果CPU的并行处理能力为八核,可以申请8个容量限定的标记线程。
需要注意的是,以上仅为举例说明,可以根据实际应用需要进行设置和调整。
需要强调的是,随着标记对象的增加,现有的标记处理技术需要不断的增加标记线程的内存占用量,降低了标记处理的性能和效率。因此,本发明提供的并行标记处理方法,预先对N个标记线程占用的内存容量进行设置,也就是会所,N个标记线程占用的内存容量不会随着标记对象的溢出而增加,以便保证标记处理的性能和效率。
需要说明的是,可以根据应用需要采用多种方式对N个标记线程占用的内存容量进行设置,例如:
示例一,对每个标记线程的容量进行设置;
示例二,对N个标记线程占用的内存总容量进行设置,每个标记线程可以不限定,或者,比如限定最大的一个等。
为了提高标记效率,实现多线程并行标记的负载均衡,预先建立虚拟机堆中的内存块与N标记线程的对应关系。也就是说,预先为每个标记线程配置好对应负责标记的虚拟机堆中的内存块。
需要注意的是,可以根据实际应用需要建立虚拟机堆中内存块与N个标记线程的对应关系,例如包括:
示例一:为每个内存块指定对应的标记线程;或者,
示例二:为每个标记线程指定负责标记的内存块。
进而,从虚拟机系统中获取预先存储的虚拟机堆中所有的第一对象,根据上述设置的虚拟机堆中的内存块与N个标记线程的对应关系,遍历虚拟机堆中的第一对象。
步骤102,将当前处理的第一对象的第一指针压入与该第一对象所在的内存块对应的标记线程的私有栈,根据所述第一指针的压入情况对所述第一对象进行第一标记处理。
步骤103,对所述第一对象遍历完成后,向所述N个标记线程发送线程启动指令,以使所述N个标记线程根据各自私有栈中所述第一指针的压入情况,同步进行用于垃圾回收的标记处理。
具体地,首先确定当前处理的第一对象所在的内存块,然后根据上述的对应关系获取与该第一对象所在的内存块对应的标记线程。将该第一对象的第一指针压入到与该第一对象所在的内存块对应的标记线程的私有栈中。
进而,根据该第一对象的第一指针的压入情况,对当前处理的第一对象进行第一标记处理。也就是说,如果将当前第一对象的第一指针成功压入到对应标记线程的私有栈中,则确定该私有栈没有溢出,将当前处理的第一对象标记为压入状态;如果没有将当前第一对象的第一指针成功压入到对应标记线程的私有栈中,则确定该私有栈溢出,将当前处理的第一对象标记为溢出状态。
需要说明的是,对第一对象是否溢出的标记方式有很多,可以根据需要进行选择,例如:
示例一,可以通过列表的方式记录与每个标记线程的私有栈对应的第一对象的压入情况;或者,
示例二,可以通过第一对象所在内存块位图中的相应位置标记第一对
象的压入情况。
需要说明的是,以上仅为举例说明,可以根据实际应用需要进行选择标记方式。
对虚拟机堆中的第一对象遍历完成后,各个标记线程的私有栈中都存放了本线程负责标记的内存块中第一对象的第一指针。如果标记线程的私有栈中溢出,说明私有栈的空间已满,无法继续存放本线程负责标记的内存块中第一对象的第一指针,则将这些第一对象标记为溢出状态。当标记线程的私有栈中有新的处理空间时,继续存放本线程负责标记的内存块中第一对象的第一指针。
进而,向N个标记线程发送线程启动指令,从而N个标记线程根据各自私有栈中第一指针的压入情况,同步进行用于垃圾回收的标记处理。
本申请实施例的用于垃圾回收的并行标记处理方法,通过根据虚拟机堆中的内存块与N个标记线程的对应关系,遍历所述虚拟机堆中的第一对象,其中,N个标记线程占用的内存容量是预先设置的,将当前处理的第一对象的第一指针压入与该第一对象所在的内存块对应的标记线程的私有栈,根据所述第一指针的压入情况对所述第一对象进行第一标记处理,对所述第一对象遍历完成后,向所述N个标记线程发送线程启动指令,以使所述N个标记线程根据各自私有栈中所述第一指针的压入情况,同步进行用于垃圾回收的标记处理。由此,利用有限的内存实现多线程的并行标记处理,提高整个垃圾回收的性能。
为了更加清楚的说明上述实施例中虚拟机堆中所有内存块与N个标记线程的对应关系的建立过程,以及第一标记过程,通过图2所示实施例进行说明。
图2是本申请另一个实施例的用于垃圾回收的并行标记处理方法的流程图。
如图2所示,该用于垃圾回收的并行标记处理方法可以包括以下步骤:
步骤201,申请N个标记线程,其中,N为大于1的整数,N个标记线程占用的内存容量是预先设置的,每个标记线程至少包括:1个私有栈。
具体地,根据实际应用需要和CPU的多核处理能力,设置标记线程的数量N,以及设置N个标记线程所占的内存容量。其中,每个标记线程包括一个私有栈,私有栈用于存储本线程负责标记的对象的指针。
步骤202,遍历虚拟机堆的所有内存块,为每个内存块分配编号;
步骤203,根据内存块编号和标记线程总数N,确定与每个内存块编号对应的标记线程编号。
具体地,为了向虚拟机堆的每个内存块分配负责标记内存块对象的标记线程,遍历虚拟机堆的内存块,为每个内存块分配编号。
进而,根据内存块编号和标记线程总数N,确定与每个内存块编号对应的标记线程编号。
需要说明的是,根据内存块编号和标记线程总数N,确定与每个内存块编号对应的标记线程编号的方式有很多,例如:可以通过获取标记线程总数N被内存块编号整除后的余数,确定与每个内存块编号对应的标记线程编号,公式表达如下所示:
ID=id%N,其中,
N为标记线程总数;id为内存块编号;ID为标记线程编号;“%”表示N被id整除后的取余处理。
例如:假设当前申请的标记线程总数N=4,编号分别为0-3,内存块为十个,编号分别为1-10,通过上述公式处理后获知:
内存块编号1对应的标记线程编号为0;
内存块编号2对应的标记线程编号为1;
内存块编号3对应的标记线程编号为2;
内存块编号4对应的标记线程编号为3;
内存块编号5对应的标记线程编号为0;
内存块编号6对应的标记线程编号为1;
内存块编号7对应的标记线程编号为2;
内存块编号8对应的标记线程编号为3;
内存块编号9对应的标记线程编号为1;
内存块编号10对应的标记线程编号为2。
步骤204,根据虚拟机堆中的内存块与N个标记线程的对应关系,遍历所述虚拟机堆中的第一对象,将当前处理的第一对象的第一指针压入与该第一对象所在的内存块对应的标记线程的私有栈;
步骤205,判断是否将当前第一对象的第一指针成功压入对应标记线程的私有栈中;
步骤206,如果将所述第一指针成功压入对应标记线程的私有栈,则将当前第一对象所在内存块的位图中、与该第一对象对应的状态标记为压入状态;
步骤207,如果未能将所述第一指针成功压入对应标记线程的私有栈,则将当前第一对象所在内存块的位图中、与该第一对象对应的状态标记为溢出状态。
步骤208,对所述第一对象遍历完成后,向所述N个标记线程发送线程启动指令,以使所述N个标记线程根据各自私有栈中所述第一指针的压入情况,同步进行用于垃圾回收的标记处理。
具体地,确定当前处理的第一对象所在的内存块,然后根据上述的对应关系获取与该第一对象所在的内存块对应的标记线程。将该第一对象的第一指针压入到与该第一对象所在的内存块对应的标记线程的私有栈中。
进而,根据该第一对象的第一指针的压入情况,对当前处理的第一对
象进行第一标记处理。也就是说,如果将当前第一对象的第一指针成功压入到对应标记线程的私有栈中,则确定该私有栈没有溢出,将当前处理的第一对象标记为压入状态;如果没有将当前第一对象的第一指针成功压入到对应标记线程的私有栈中,则确定该私有栈溢出,将当前处理的第一对象标记为溢出状态。
对所述第一对象遍历完成后,各个标记线程的私有栈中都存放了本线程负责标记的内存块中第一对象的第一指针。如果标记线程的私有栈中溢出,说明私有栈的空间已满,无法继续存放本线程负责标记的内存块中第一对象的第一指针,则将这些第一对象标记为溢出状态。当标记线程的私有栈中有新的处理空间时,继续存放本线程负责标记的内存块中第一对象的第一指针。
进而,向N个标记线程发送线程启动指令,从而N个标记线程根据各自私有栈中第一指针的压入情况,同步进行用于垃圾回收的标记处理。
为了更加清楚的说明上述实施例中涉及的对第一对象进行第一标记处理的处理过程,通过图3所示实施例说明如下。
图3为用于垃圾回收的第一标记处理流程示意图。
参见图3,本实施例中采用在内存块位图中进行着色标记的方式对第一对象的压入情况进行第一标记处理,具体标记如下:
如果将当前处理的第一对象的第一指针成功压入对应标记线程的私有栈中,则将与该第一对象所在内存块位图中的对应位置进行标黑处理;
如果没有将当前处理的第一对象的第一指针成功压入对应标记线程的私有栈中,则将与该第一对象所在内存块位图中的对应位置进行标灰处理。
需要说明的是,以上根据第一对象的第一指针向对应标记线程的私有栈的不同压入情况,在内存块位图中与第一对象的对应位置进行的着色处
理仅仅是示例性说明,可以根据具体的应用需要进行调整。
基于上述标记方式,具体以处理虚拟堆中的根对象A(本示例中虚拟堆中的根对象相当于上述实施例中涉及的第一对象)为例说明如下:
步骤10:申请N个标记线程,其中,N为大于1的整数,N个标记线程占用的内存容量是预先设置的,每个标记线程至少包括:1个私有栈。
步骤20:建立虚拟机堆中的内存块与N个标记线程的对应关系。
步骤30:遍历虚拟机堆中的根对象,如果遍历完毕,则退出,否则执行步骤40。
步骤40:将当前处理的根对象A的第一指针压入与A所在的内存块10对应的标记线程1的私有栈1中。
步骤50:判断是否将A的第一指针成功压入标记线程1的私有栈1中;
步骤60:如果将A的第一指针成功压入标记线程1的私有栈1中,则将内存块10的位图中、与A对应的位置标黑,即A为压入状态。
步骤70:如果没有将A的第一指针成功压入标记线程1的私有栈1中,则将内存块10的位图中、与A对应的位置标灰,即A为溢出状态。
本申请实施例的用于垃圾回收的并行标记处理方法,通过申请N个标记线程,遍历虚拟机堆的所有内存块,为每个内存块分配编号;根据内存块编号和标记线程总数N,确定与每个内存块编号对应的标记线程编号,进而将当前处理的第一对象的第一指针压入与该第一对象所在的内存块对应的标记线程的私有栈,根据所述第一指针的压入情况对所述第一对象进行第一标记处理,对所述第一对象遍历完成后,向所述N个标记线程发送线程启动指令,以使所述N个标记线程根据各自私有栈中所述第一指针的压入情况,同步进行用于垃圾回收的标记处理。由此,利用有限的内存实现高效的并行标记,同时实现标记线程负载均衡,提高整个垃圾回收的
性能。
基于上述实施例,对所述第一对象遍历完成后,各个标记线程的私有栈中都存放了本线程负责标记的内存块中第一对象的第一指针。如果标记线程的私有栈中溢出,说明私有栈的空间已满,无法继续存放本线程负责标记的内存块中第一对象的第一指针,则将这些第一对象标记为溢出状态。当标记线程的私有栈中有新的处理空间时,继续存放本线程负责标记的内存块中第一对象的第一指针。
进而,向N个标记线程发送线程启动指令,从而N个标记线程根据各自私有栈中第一指针的压入情况,同步进行用于垃圾回收的标记处理。
需要说明的是,预先申请的N个标记线程的处理过程是同步并行的,为了更加清楚的说明N个标记线程的标记处理过程,以第一标记线程的标记处理过程为例,通过下述实施例说明如下,其他(N-1)个标记线程的标记处理过程参见第一标记线程,不再一一赘述。
图4为预先申请的N个标记线程的示意图。
参见图4,预先申请的N个标记线程,以及N个标记线程所占用的内存容量。N个标记线程包括:Thread-1、Thread-2,…Thread-N。其中,每个标记线程至少包括:1个私有栈(stack),经过上述处理,各个私有栈中存储有本线程负责标记的第一对象(Root Objects)的第一指针。
图5是应用图4所示的标记线程并行标记处理的流程图一。
参见图5,本实施例中以第一标记线程(Thread-1)的标记处理过程为例,该用于垃圾回收的并行标记处理方法包括:
步骤301,第一标记线程根据线程启动指令,从第一私有栈中取出预先压入的第一对象的第一指针。
步骤302,所述第一标记线程遍历所述第一指针指示的所述第一对象引用的第二对象,并根据预设的N个标记线程与虚拟机堆中内存块的对应
关系对所述第二对象进行第二标记处理。
具体地,第一标记线程接收到线程启动指令之后,根据该线程启动指令,从第一私有栈中取出预先压入的第一对象的第一指针。
进而,第一标记线程查询预存的对象关系表,获取当前处理的第一指针指示的第二对象,需要解释的是,第二对象为第一对象的引用对象。
第一标记线程遍历当前处理的第一指针指示的第二对象,根据预设的N个标记线程与虚拟机堆中内存块的对应关系,判断负责处理当前第二对象所在的内存块的标记线程是否为本线程,从而对第二对象进行第二标记处理。
本申请实施例,通过第一标记线程根据线程启动指令,从第一私有栈中取出预先压入的第一对象的第一指针,遍历所述第一指针指示的所述第一对象引用的第二对象,并根据预设的N个标记线程与虚拟机堆中内存块的对应关系对所述第二对象进行第二标记处理。由此,参照第一标记线程的标记处理过程,通过N个标记线程的并行标记处理,实现了利用有限的内存进行并行标记处理,提高整个垃圾回收的性能。
图6是应用图4所示的标记线程并行标记处理的流程图二。
继续参见图4,基于图5所示实施例,每个标记线程还包括:(N-1)个公用输出队列(queue-1、queue-2…queue-N-1),以及1个缓存队列(buf-queue)。其中,(N-1)个公用输出队列用于存储其他(N-1)个标记线程负责标记的对象的指针;当与其他(N-1)个标记线程对应的公用输出队列溢出时,1个缓存队列用于缓存其他(N-1)个标记线程负责标记的对象的指针。
参见图6,继续以第一标记线程(Thread-1)的标记处理过程为例,图5所示实施例中的步骤302具体包括:
步骤401,第一标记线程根据所述对应关系,判断是否负责对当前处
理的第二对象所在的内存块P1进行标记处理;
具体地,第一标记线程根据预设的N个标记线程与虚拟机堆中内存块的对应关系,判断本线程是否负责对当前处理的第二对象所在的内存块P1进行标记处理。
如果第一标记线程获知负责对该内存块P1进行标记处理的标记线程为第一标记线程,即本线程负责对该内存块P1进行标记处理,进而执行步骤402-步骤406;
如果第一标记线程获知负责对该内存块P1进行标记处理的标记线程为标记线程M,标记线程M不是第一标记线程,即本线程不负责对该内存块P1进行标记处理,进而执行步骤407-步骤415。
步骤402,将当前处理的第二对象的第二指针压入到所述第一私有栈中。
具体地,针对步骤401中第一标记线程负责对所述内存块P1进行标记处理的判断分支,第一标记线程将负责处理对象的指针压入到本线程的私有栈中进行处理。即将当前处理的第二对象的第二指针压入到所述第一私有栈中进行第二标记处理。
步骤403,所述第一标记线程判断是否成功将所述第二指针压入到所述第一私有栈中。
具体地,第一标记线程判断是否成功将当前处理的第二对象的第二指针压入到本线程的第一私有栈中。
如果第一标记线程未能成功将当前处理的第二对象的第二指针压入到本线程的第一私有栈中,则执行步骤404和步骤405对第二对象进行溢出状态的标记处理;
如果第一标记线程成功将当前处理的第二对象的第二指针压入到本线程的第一私有栈中,则执行步骤406继续对下一个第二对象进行第二标
记处理。
步骤404,将所述内存块P1的位图中、与该第二对象对应的状态标记为溢出状态。
步骤405,设置与所述内存块P1对应的溢出标志。
具体地,针对步骤403中第一标记线程未能成功将当前处理的第二对象的第二指针压入到本线程的第一私有栈中的判断分支,将第二对象设置为溢出状态。例如:将上述内存块P1的位图中、与该第二对象对应的状态标记为溢出状态。并且进一步地设置与该内存块P1对应的溢出标志。
步骤406,如果所述第一标记线程成功将所述第二指针压入到所述第一私有栈中,则继续对所述第一指针对应的下一个第二对象进行处理。
具体地,针对步骤403中第一标记线程成功将所述第二指针压入到所述第一私有栈中的判断分支,继续对从第一私有栈中取出的第一指针对应的下一个第二对象进行处理。
步骤407,确定标记线程M负责对所述内存块P1进行标记处理;
步骤408,将所述第二指针压入到所述第一标记线程中与所述标记线程M对应的公用输出队列M中;
具体地,针对步骤401中第一标记线程不负责对所述内存块P1进行标记处理的判断分支,根据N个标记线程与虚拟机堆中内存块的对应关系,确定标记线程M负责对所述内存块P1进行标记处理。
进而,第一标记线程将当前处理的第二对象的第二指针压入到第一标记线程中与标记线程M对应的公用输出队列M中,以使标记线程M后续从第一标记线程中的公用输出队列M中获取待处理的第二对象的第二指针。
步骤409,所述第一标记线程判断是否成功将所述第二指针压入到所述公用输出队列M中;
第一标记线程判断是否成功将当前处理的第二对象的第二指针压入到公用输出队列M中。
如果第一标记线程成功将当前处理的第二对象的第二指针压入到第一标记线程中的公用输出队列M中,则执行步骤410,继续对当前从第一私有栈中中获取的第一指针对应的下一个第二对象进行处理。
如果第一标记线程未能成功将当前处理的第二对象的第二指针压入到第一标记线程中的公用输出队列M中,则执行步骤411,通过第一标记线程的第一缓存队列缓存该第二指针。
步骤410,继续对所述第一指针对应的下一个第二对象进行处理。
具体地,针对步骤409中第一标记线程成功将当前第二指针压入到第一标记线程中的公用输出队列M中的判断分支,继续对上述第一指针对应的下一个第二对象进行处理。
步骤411,将所述第二指针压入到所述第一标记线程中的第一缓存队列中;
具体地,针对步骤409中第一标记线程未能成功将当前第二指针压入到第一标记线程中的公用输出队列M中的判断分支,将该第二指针压入到第一标记线程中的第一缓存队列中。
步骤412,所述第一标记线程判断是否成功将所述第二指针压入到所述第一缓存队列中;
具体地,第一标记线程判断是否成功将该第二指针压入到第一标记线程的第一缓存队列中;
如果第一标记线程未能成功将所述第二指针压入到所述第一缓存队列中,则执行步骤413和步骤414,对当前处理的第二对象标记溢出状态;
如果第一标记线程成功将所述第二指针压入到所述第一缓存队列中,则执行步骤415,对下一个第二对象继续进行标记处理。
步骤413,将所述内存块P1的位图中、与当前处理的第二对象对应的状态标记为溢出状态。
步骤414,设置与所述内存块P1对应的溢出标志。
具体地,针对步骤412中第一标记线程未能成功将所述第二指针压入到所述第一缓存队列中的判断分支,将商户内存块P1的位图中、与当前处理的第二对象对应的状态标记为溢出状态,并进一步地设置与该内存块P1对应的溢出标志。
步骤415,继续对所述第一指针对应的下一个第二对象进行处理。
具体地,针对步骤412中第一标记线程成功将所述第二指针压入到所述第一缓存队列中的判断分支,继续对当前第一指针对应的下一个第二对象进行处理。
基于图6所示实施例,进一步地,在步骤401之前,还包括:
查询当前处理的第二对象所在内存块P1的位图中与该第二对象对应的状态标记。如果与该第二对象对应的状态标记为未标记状态,则将与该第二对象对应的状态修改为压入状态。
需要说明的是,对第二对象是否溢出的标记方式有很多,可以根据需要进行选择,例如:
示例一,可以通过列表的方式记录与每个第二对象的压入情况;或者,
示例二,可以通过第二对象所在内存块位图中的相应位置标记第二对象的压入情况。
需要说明的是,以上仅为举例说明,可以根据实际应用需要进行选择标记方式。
本申请实施例,通过第一标记线程根据线程启动指令,从第一私有栈中取出预先压入的第一对象的第一指针,遍历所述第一指针指示的所述第一对象引用的第二对象,并根据预设的N个标记线程与虚拟机堆中内存块
的对应关系对所述第二对象进行第二标记处理。由此,参照第一标记线程的标记处理过程,通过N个标记线程的并行标记处理,利用有限的内存实现高效的并行标记,同时实现标记线程负载均衡,从而减少CPU缓存一致性冲突,提高整个垃圾回收的性能。
图7是应用图4所示的标记线程并行标记处理的流程图三。
继续参见图4,每个标记线程包括:1个私有栈(stack)、(N-1)个公用输出队列(queue-1、queue-2…queue-N-1),以及1个缓存队列(buf-queue)。其中,1个私有栈(stack)用于存储本线程负责标记的对象的指针;(N-1)个公用输出队列用于存储其他(N-1)个标记线程负责标记的对象的指针;当与其他(N-1)个标记线程对应的公用输出队列溢出时,1个缓存队列用于缓存其他(N-1)个标记线程负责标记的对象的指针。
参见图7,基于图5所示实施例,所述方法还包括:
步骤501,第一标记线程接到线程启动指令后,判断本线程的第一私有栈是否为空;
具体地,第一标记线程判断本线程的第一私有栈是否为空;
如果第一标记线程的第一私有栈不为空,则按照图5中所示实施例中的步骤302从第一私有栈中取出预先压入的第一对象的第一指针,并按照图5或图6所示的实施过程进行处理,此处不再赘述。
如果第一标记线程的第一私有栈为空,则执行步骤502继续判断第一标记线程中的第一缓存队列是否为空。
步骤502,所述第一标记线程判断本线程的第一缓存队列是否为空;
具体地,第一标记线程判断本线程的第一缓存队列是否为空;
如果第一标记线程中的第一缓存队列不为空,执行步骤503,从而对第一标记线程不负责处理的第三对象向本线程中与该第三对象对应的公用输出队列进行分配处理;
如果第一标记线程中的第一缓存队列为空,则通过图8所示实施例描述如何进一步地对其他(N-1)个标记线程中与第一标记线程对应的公用输出队列中的第四对象进行标记处理,后续实施例详细说明。
步骤503,所述第一标记线程从所述第一缓存队列中取出预先压入的第三对象的第三指针,其中,所述第一标记线程不负责对当前处理的第三对象所在的内存块P2进行标记处理;
步骤504,所述第一标记线程根据所述对应关系,确定标记线程W负责对当前处理的第三对象所在的内存块P2进行标记处理;
步骤505,所述第一标记线程将所述第三指针压入到所述第一标记线程中与所述标记线程W对应的公用输出队列W中;
具体地,第一标记线程从本线程的第一缓存队列中取出预先压入的第三对象的第三指针,由于第一缓存队列中存放的对象是需要放入第一标记线程中的公用输出队列中,以供对应的其他标记线程进行处理的。当第一标记线程中的公用输出队列中出现溢出时,将溢出的第三对象放入第一标记线程中的第一缓存队列中缓存。
由此可见,第一标记线程不负责对当前处理的第三对象所在的内存块P2进行标记处理。第一标记线程根据虚拟机堆的内存块与标记线程的对应关系,确定标记线程W负责对当前处理的第三对象所在的内存块P2进行标记处理。
进而,第一标记线程将该第三指针压入到第一标记线程中与标记线程W对应的公用输出队列W中,以供标记线程W从第一标记线程的公用输出队列W中获取该第三指针进行标记处理。
步骤506,所述第一标记线程判断是否成功将当前处理的第三指针压入到所述公用输出队列W中;
步骤507,继续对所述第一缓存队列中的下一个第三对象向对应的公
用输出队列进行压入处理。
步骤508,将所述第三指针重新压入所述第一缓存队列中。
具体地,第一标记线程判断是否成功将当前处理的第三指针压入到本线程的公用输出队列W中。
如果第一标记线程成功将该第三指针压入到本线程的公用输出队列W中,则执行步骤507,继续对所第一缓存队列中的下一个第三对象向对应的公用输出队列进行压入处理。
如果第一标记线程未能成功将该第三指针压入到本线程的公用输出队列W中,则将该第三指针重新压入本线程的第一缓存队列中。此时,不存在溢出的问题,因为该第三指针就是从本线程的第一缓存队列中取出来的。
基于上述实施例,本申请在第一标记线程的第一私有栈为空时,且第一缓存队列不为空,从第一缓存队列中取出预先压入的第三对象的第三指针,向本线程中与对应标记线程的公用输出队列中进行压入处理,以供与第三对象对应的标记线程对其进行标记处理。由此,参照第一标记线程的标记处理过程,通过N个标记线程的进行协同并行的标记处理,利用有限的内存实现高效的并行标记,同时实现标记线程负载均衡,从而减少CPU缓存一致性冲突,提高整个垃圾回收的性能。
图8是应用图4所示的标记线程并行标记处理的流程图四。
参见图8,基于图7所示实施例,本实施例是基于图7中的步骤502,针对如果第一标记线程中的第一缓存队列为空的判断分支,通过图8所示实施例描述如何进一步地对其他(N-1)个标记线程中与第一标记线程对应的公用输出队列中的第四对象进行标记处理,具体包括:
步骤601,第一标记线程判断其他(N-1)个标记线程中与所述第一标记线程对应的公用输出队列是否为空;
具体地,第一标记线程判断其他(N-1)个标记线程中与所述第一标记线程对应的公用输出队列是否为空;
如果其他(N-1)个标记线程中与第一标记线程对应的公用输出队列不为空,则执行步骤602,从而第一标记线程从其他标记线程中获取本线程负责处理的第四对象,向本线程的第一私有栈进行压入处理。
如果其他(N-1)个标记线程中与第一标记线程对应的公用输出队列为空,则通过图9所示实施例描述如何进一步地对第一标记线程负责标记的、且具有溢出状态的第五对象进行标记处理,后续实施例详细说明。
步骤602,第一标记线程从当前处理的公用输出队列中取出预先压入的第四对象的第四指针,其中,所述第四对象为所述标记线程T预先压入的、由所述第一标记线程负责对所述第四对象所在的内存块P3进行标记处理;
步骤603,所述第一标记线程将所述第四指针压入到所述第一私有栈中;
具体地,针对步骤601中如果其他(N-1)个标记线程中与第一标记线程对应的公用输出队列不为空的判断分支,说明其他的标记线程中还具有需要由第一标记线程标记处理的第四对象。
进而,第一标记线程从当前处理的公用输出队列中取出预先压入的第四对象的第四指针,其中,该第四对象为标记线程T预先压入的、并且由第一标记线程负责对该第四对象所在的内存块P3进行标记处理。从而第一标记线程将该第四指针压入到所述第一私有栈中。
步骤604,所述第一标记线程判断是否成功将所述第四指针压入到所述第一私有栈中;
步骤605,将所述内存块P3的位图中、与该第四对象对应的状态标记为溢出状态。
步骤606,设置与所述内存块P3对应的溢出标志。
步骤607,继续对下一个第四对象向所述第一私有栈中进行压入处理。
具体地,第一标记线程判断是否成功将该第四指针压入到本线程的第一私有栈中。
如果第一标记线程未能成功将该第四指针压入到本线程的第一私有栈中,则执行步骤605和步骤606,将该第四对象所在的内存块P3的位图中、与该第四对象对应的状态标记为溢出状态,并且设置与所述内存块P3对应的溢出标志。
如果第一标记线程成功将该第四指针压入到本线程的第一私有栈中,则则执行步骤607,继续对下一个第四对象向本线程的第一私有栈中进行压入处理。
基于上述实施例,本申请的第一标记线程在第一私有栈和第一缓存队列为空,且其他标记线程中与第一标记线程对应的公用输出队列不为空时,取出预先压入的第四对象的第四指针,向本线程中的第一私有栈压入处理。由此,参照第一标记线程的标记处理过程,通过N个标记线程的进行协同并行的标记处理,利用有限的内存实现高效的并行标记,同时实现标记线程负载均衡,从而减少CPU缓存一致性冲突,提高整个垃圾回收的性能。
图9是应用图4所示的标记线程并行标记处理的流程图五。
参见图9,基于图8所示实施例,本实施例是基于图9中的步骤601,针对如果其他(N-1)个标记线程中与第一标记线程对应的公用输出队列为空的判断分支,则通过图9所示实施例描述如何进一步地对第一标记线程负责标记的、且具有溢出状态的第五对象进行标记处理,具体包括:
步骤701,第一标记线程判断本线程负责标记的内存块中是否有溢出状态的第五对象;
步骤702,如果所述第一标记线程负责标记的内存块中不具有溢出状态的第五对象,则标记结束,退出线程。
步骤703,如果所述第一标记线程负责标记的内存块中具有溢出状态的第五对象,所述第一标记线程将当前处理的内存块P4中标记溢出状态的第五对象修改为压入状态,将当前第五对象的第五指针压入到所述第一私有栈中;
具体地,第一标记线程判断本线程负责标记的内存块中是否有溢出状态的第五对象。
如果第一标记线程负责标记的内存块中不具有溢出状态的第五对象,则说明本线程负责标记的对象遍历完成,标记结束,执行步骤702退出线程。
如果第一标记线程负责标记的内存块中具有溢出状态的第五对象,则说明本线程负责标记的对象还没有遍历完成。进而,第一标记线程执行步骤703,将当前处理的内存块P4中标记溢出状态的第五对象修改为压入状态,将当前第五对象的第五指针压入到所述第一私有栈中。
步骤704,所述第一标记线程判断是否成功将所述第五指针压入到所述第一私有栈中;
步骤705,如果所述第一标记线程未能成功将所述第五指针压入到所述第一私有栈中,则将所述内存块P4的位图中、与该第五对象对应的状态标记为溢出状态。
步骤706,设置与所述内存块P5对应的溢出标志。
步骤707,如果所述第一标记线程成功将所述第五指针压入到所述第一私有栈中,则继续对下一个第五对象进行处理。
具体地,第一标记线程判断是否成功将当前的第五指针压入到本线程的第一私有栈中。
如果第一标记线程未能成功将该第五指针压入到本线程的第一私有栈中,则说明第一私有栈空间不足有溢出,则执行步骤705和步骤706,将该第五对象所在的内存块P4的位图中、与该第五对象对应的状态标记为溢出状态,并且进一步地设置与所述内存块P5对应的溢出标志。
如果第一标记线程成功将该第五指针压入到本线程的第一私有栈中,则执行步骤707,继续对下一个第五对象进行处理。
基于上述实施例,本申请的第一标记线程在第一私有栈、第一缓存队列、以及其他标记线程中与第一标记线程对应的公用输出队列都为空时,根据本线程负责标记的具有溢出状态的第五对象进行压入处理。由此,参照第一标记线程的标记处理过程,通过N个标记线程的并行的标记处理,利用有限的内存实现高效的并行标记,提高整个垃圾回收的性能。
为了更加清楚的说明图4-图9所示实施例中涉及的对第二对象至第五对象进行处理的处理过程,通过图10所示实施例说明如下。
图10是应用图4所示的标记线程并行标记处理的流程图六。
参见图10,本实施例中采用在内存块位图中进行着色标记的方式对第二对象至第五对象的压入情况进行标记处理,具体标记如下:
如果将当前处理的对象的指针成功压入对应的目标空间中,则将与当前对象所在内存块位图中的对应位置进行标黑处理;
如果没有将当前处理的对象的指针成功压入对应的目标空间中,则将与当前对象所在内存块位图中的对应位置进行标灰处理;
如果当前处理对象所在内存块位图中的对应位置为标白状态,说明该对象为未处理状态。
需要说明的是,以上根据处理对象的指针向对应目标空间的不同压入情况,在内存块位图中与当前处理对象的对应位置进行的着色处理仅仅是示例性说明,可以根据具体的应用需要进行调整。
基于上述标记方式,具体以对象A等同于上述实施例中涉及的第一对象,对象A1等同于上述实施例中涉及的第二对象,对象B等同于上述实施例中涉及的第三对象,对象D等同于上述实施例中涉及的第四对象,对象C等同于上述实施例中涉及的第五对象,举例说明如下:
如图10所示,该并行标记处理方法包括:
步骤1:线程启动。
步骤2:如果私有stack已经空了,则跳转到步骤3。否则弹出一个对象比如A,跳转到步骤4。
步骤3:如果buf-queue为空,跳转到步骤7,否则遍历buf-queue,弹出对象比如B,跳转到步骤5。如果已经遍历完成,则跳转到步骤7。
步骤4:依次遍历对象A所引用的所有对象,遍历完成则跳转到步骤2。否则,比如遍历到对象A1,并跳转到步骤9。
步骤5:尝试把步骤3中弹出来的对象B压入本线中T(B)号queue中,压入成功则跳转到步骤3,反之标记对象B所在的page(内存块)溢出,然后跳转到步骤6。
步骤6:对象B重新压回到buf-queue中,这时候不会失败,因为对象B是从buf-queue中弹出来的。
步骤7:遍历另外N-1个线程中的本线程对应的queue,取出标记对象。只要有一个queue非空,则pop出(弹出)标记对象,比如对象D,然后跳转到步骤16。如果所有N-1个线程中和本线程对应的queue都为空,则跳转到步骤8。
步骤8:遍历本线程负责的page时如发现有溢出,则遍历有溢出的page的bitmap(位图),找到灰色的对象比如C,如果找到则跳转到步骤14。遍历完毕,清理page的溢出标志,然后跳转到步骤15。
步骤9:判断步骤4中遍历到的对象A1所在的page的对应的bitmap
是否为白色,如果已经是黑色则跳转到步骤4。如果是白色,则跳转到步骤10。
步骤10:标记对象A1所在的page的对应的bitmap值为黑色。如果T(A1)为本线程,则跳转到步骤17。否则跳转到步骤11。
步骤11:尝试把对象A1压入本线程的T(A1)号queue中,如果压入失败,则设置A1所在的Page的溢出。并跳转到步骤12,如果成功,则跳转到步骤4。
步骤12:尝试把对象A1压入buf-queue,如果成功则跳转到步骤4。反之跳转到步骤13。
步骤13:设置对象A1所在的page对应的bitmap的值为灰色,并设置page的溢出标志。
步骤14:把步骤8遍历到的灰色对象C标记对应的bitmap为黑色并压入私有栈stack中,如果成功则跳转到步骤8。如果失败,则设置C所在的Page的溢出标志,并跳转到步骤19。
步骤15:如果标记结束,则线程退出,否则跳转到步骤2,继续并行标记。
步骤16:标记对象D对应的bitmap为黑色,尝试把对象D压入本线程的stack中,如压入成功,跳转到步骤7。溢出跳转到步骤19。
步骤17:尝试把对象A1压入本线程的私有stack中,如果压入成功即没有溢出,则跳转到步骤4,否则跳转到步骤18。
步骤18:标记对象A1对应的bitmap为灰色,并设置A1所在的Page的溢出标志。然后跳转到步骤4。
步骤19:标记对象(D或者C,即可能来自步骤14或者16)对应的bitmap为灰色,并设置标记对象所在的Page的溢出标志。然后跳转到步骤2。
具体地,结合本示例中的19个步骤和附图,具体通过下述的处理步骤示意图6至图9的处理过程,其详细的描述过程参见图6至图9所示实施例,此处不再赘述。
针对图6所示实施例的处理过程如下示意的步骤流程(1),其具体实施过程参见上述实施例,此处不再赘述。
步骤流程(1):
针对图7所示实施例的处理过程如下示意的步骤流程(2),其具体实施过程参见上述实施例,此处不再赘述。
步骤流程(2):
针对图8所示实施例的处理过程如下示意的步骤流程(3),其具体实施过程参见上述实施例,此处不再赘述。
步骤流程(3):
针对图9所示实施例的处理过程如下示意的步骤流程(4),其具体实施过程参见上述实施例,此处不再赘述。
步骤流程(4):
为了实现上述实施例,本申请还提出一种用于垃圾回收的并行标记处理装置。
图11是本申请一个实施例的用于垃圾回收的并行标记处理装置的结构示意图。
参见图11,该用于垃圾回收的并行标记处理装置包括:
遍历模块11,用于根据虚拟机堆中的内存块与N个标记线程的对应关系,遍历所述虚拟机堆中的第一对象,其中,N为大于1的整数,N个标记线程占用的内存容量是预先设置的,每个标记线程至少包括:1个私有栈;
第一标记模块12,用于将当前处理的第一对象的第一指针压入与该第一对象所在的内存块对应的标记线程的私有栈,根据所述第一指针的压入情况对所述第一对象进行第一标记处理;
启动模块13,用于对所述第一对象遍历完成后,向所述N个标记线程发送线程启动指令,以使所述N个标记线程根据各自私有栈中所述第一指针的压入情况,同步进行用于垃圾回收的标记处理。
需要说明的是,前述对用于垃圾回收的并行标记处理方法实施例的解释说明也适用于该实施例的用于垃圾回收的并行标记处理装置,此处不再赘述。
本实施例提供的用于垃圾回收的并行标记处理装置,通过根据虚拟机堆中的内存块与N个标记线程的对应关系,遍历所述虚拟机堆中的第一对象,其中,N个标记线程占用的内存容量是预先设置的,将当前处理的第一对象的第一指针压入与该第一对象所在的内存块对应的标记线程的私有栈,根据所述第一指针的压入情况对所述第一对象进行第一标记处理,对所述第一对象遍历完成后,向所述N个标记线程发送线程启动指令,以使所述N个标记线程根据各自私有栈中所述第一指针的压入情况,同步进行用于垃圾回收的标记处理。由此,利用有限的内存实现多线程的并行标记处理,提高整个垃圾回收的性能。
图12是本申请另一个实施例的用于垃圾回收的并行标记处理装置的结构示意图。
参见图12,基于图11,该用于垃圾回收的并行标记处理装置还包括:
申请模块14,用于申请所述N个标记线程;
建立模块15,用于遍历所述虚拟机堆中的内存块,建立内存块与N个标记线程的对应关系。
具体地,所述建立模块15用于:
为每个内存块指定对应的标记线程;或者,
为每个标记线程指定负责标记的内存块。
其中,在一个具体的示例中,所述建立模块15包括:
分配单元151,用于遍历虚拟机堆中的内存块,为每个内存块分配编号;
确定单元152,用于根据内存块的编号和标记线程总数N,确定与每个内存块编号对应的标记线程编号。
具体地,所述确定单元152用于:
获取标记线程总数N被内存块编号整除后的余数,确定与每个内存块
编号对应的标记线程编号。
具体地,所述第一标记模块12用于:
如果将所述第一指针成功压入与当前第一对象所在的内存块对应的标记线程的私有栈,则将当前第一对象所在内存块的位图中、与该第一对象对应的状态标记为压入状态;
如果未能将所述第一指针成功压入与当前第一对象所在的内存块对应的标记线程的私有栈,则将当前第一对象所在内存块的位图中、与该第一对象对应的状态标记为溢出状态。
需要说明的是,前述对用于垃圾回收的并行标记处理方法实施例的解释说明也适用于该实施例的用于垃圾回收的并行标记处理装置,此处不再赘述。
本实施例提供的用于垃圾回收的并行标记处理装置,通过申请N个标记线程,遍历虚拟机堆的所有内存块,为每个内存块分配编号;根据内存块编号和标记线程总数N,确定与每个内存块编号对应的标记线程编号,进而将当前处理的第一对象的第一指针压入与该第一对象所在的内存块对应的标记线程的私有栈,根据所述第一指针的压入情况对所述第一对象进行第一标记处理,对所述第一对象遍历完成后,向所述N个标记线程发送线程启动指令,以使所述N个标记线程根据各自私有栈中所述第一指针的压入情况,同步进行用于垃圾回收的标记处理。由此,利用有限的内存实现高效的并行标记,同时实现标记线程负载均衡,提高整个垃圾回收的性能。
图13是本申请另一个实施例的用于垃圾回收的并行标记处理装置的结构示意图。
参见图13,本实施例中预先申请的N个标记线程,以及N个标记线程所占用的内存容量。N个标记线程包括:Thread-1、Thread-2,…Thread-N。
其中,每个标记线程至少包括:1个私有栈(stack),经过上述处理,各个私有栈中存储有本线程负责标记的第一对象(Root Objects)的第一指针。本实施例中用于垃圾回收的并行标记处理装置包括:
获取模块21,用于根据线程启动指令,从第一私有栈中取出预先压入的第一对象的第一指针;
第二标记模块22,用于遍历所述第一指针指示的所述第一对象引用的第二对象,并根据预设的N个标记线程与虚拟机堆中内存块的对应关系对所述第二对象进行第二标记处理。
需要说明的是,前述对用于垃圾回收的并行标记处理方法实施例的解释说明也适用于该实施例的用于垃圾回收的并行标记处理装置,此处不再赘述。
本实施例提供的用于垃圾回收的并行标记处理装置,通过第一标记线程根据线程启动指令,从第一私有栈中取出预先压入的第一对象的第一指针,遍历所述第一指针指示的所述第一对象引用的第二对象,并根据预设的N个标记线程与虚拟机堆中内存块的对应关系对所述第二对象进行第二标记处理。由此,参照第一标记线程的标记处理过程,通过N个标记线程的并行标记处理,实现了利用有限的内存进行并行标记处理,提高整个垃圾回收的性能。
图14是本申请另一个实施例的用于垃圾回收的并行标记处理装置的结构示意图。
参见图14,基于图13所示实施例,所述第二标记模块22包括:
第一判断单元221,用于根据所述对应关系,判断是否负责对当前处理的第二对象所在的内存块P1进行标记处理;
第一处理单元222,用于如果所述第一标记线程负责对所述内存块P1进行标记处理,则将当前处理的第二对象的第二指针压入到所述第一私有
栈中;
第二判断单元223,用于判断是否成功将所述第二指针压入到所述第一私有栈中;
第二处理单元224,用于如果所述第一标记线程未能成功将所述第二指针压入到所述第一私有栈中,则将所述内存块P1的位图中、与该第二对象对应的状态标记为溢出状态。
进一步地,所述第二处理单元224还用于:
设置与所述内存块P1对应的溢出标志。
进一步地,在另一个实施例中,
所述第二处理单元224还用于:如果所述第一标记线程成功将所述第二指针压入到所述第一私有栈中,则继续对所述第一指针对应的下一个第二对象进行处理。
进一步地,在另一个实施例中,所述第二标记模块22还包括:
所述第一处理单元222,还用于如果所述第一标记线程不负责对所述内存块P1进行标记处理,确定标记线程M负责对所述内存块P1进行标记处理,将所述第二指针压入到所述第一标记线程中与所述标记线程M对应的公用输出队列M中;
第三判断单元225,用于判断是否成功将所述第二指针压入到所述公用输出队列M中;
第三处理单元226,用于如果所述第一标记线程成功将所述第二指针压入到所述公用输出队列M中,则继续对所述第一指针对应的下一个第二对象进行处理。
进一步地,在另一个实施例中,所述第二标记模块22还包括:
所述第三处理单元226,还用于如果所述第一标记线程未能成功将所述第二指针压入到所述公用输出队列M中,则把所述第二指针压入到所述
第一标记线程中的第一缓存队列中;
第四判断单元227,用于判断是否成功将所述第二指针压入到所述第一缓存队列中;
第四处理单元228,用于如果所述第一标记线程未能成功将所述第二指针压入到所述第一缓存队列中,则将所述内存块P1的位图中、与当前处理的第二对象对应的状态标记为溢出状态。
进一步地,在另一个实施例中,
所述第四处理单元228还用于:
设置与所述内存块P1对应的溢出标志。
进一步地,在另一个实施例中,
所述第四处理单元228,还用于如果所述第一标记线程成功将所述第二指针压入到所述第一缓存队列中,则继续对所述第一指针对应的下一个第二对象进行处理。
进一步地,在另一个实施例中,
所述第二处理单元224,还用于查询所述内存块P1的位图中与该第二对象对应的状态标记;如果与该第二对象对应的状态标记为未标记状态,则将与该第二对象对应的状态修改为压入状态。
需要说明的是,前述对用于垃圾回收的并行标记处理方法实施例的解释说明也适用于该实施例的用于垃圾回收的并行标记处理装置,此处不再赘述。
本实施例提供的用于垃圾回收的并行标记处理装置,通过第一标记线程根据线程启动指令,从第一私有栈中取出预先压入的第一对象的第一指针,遍历所述第一指针指示的所述第一对象引用的第二对象,并根据预设的N个标记线程与虚拟机堆中内存块的对应关系对所述第二对象进行第二标记处理。由此,参照第一标记线程的标记处理过程,通过N个标记线程
的并行标记处理,利用有限的内存实现高效的并行标记,同时实现标记线程负载均衡,从而减少CPU缓存一致性冲突,提高整个垃圾回收的性能。
图15是本申请另一个实施例的用于垃圾回收的并行标记处理装置的结构示意图。
参见图15,基于图13所示实施例,本实施例中预设的N个标记线程中每个标记线程还包括:1个缓存队列,以及与其他(N-1)个标记线程对应的(N-1)个公用输出队列;所述第二标记模块22还包括:
第五判断单元229,用于判断所述第一私有栈是否为空;
第六判断单元210,用于如果所述第一私有栈为空,判断第一标记线程的第一缓存队列是否为空;
第五处理单元211,用于如果所述第一缓存队列不为空,所述第一标记线程从所述第一缓存队列中取出预先压入的第三对象的第三指针,其中,所述第一标记线程不负责对当前处理的第三对象所在的内存块P2进行标记处理;根据所述对应关系,确定标记线程W负责对当前处理的第三对象所在的内存块P2进行标记处理;将所述第三指针压入到所述第一标记线程中与所述标记线程W对应的公用输出队列W中;
第七判断单元212,用于判断是否成功将当前处理的第三指针压入到所述公用输出队列W中;
第六处理单元213,用于如果所述第一标记线程成功将所述第三指针压入到所述公用输出队列W中,则继续对所述第一缓存队列中的下一个第三对象向对应的公用输出队列进行压入处理。
进一步地,在另一个实施例中,
所述第六处理单元213,还用于如果所述第一标记线程未能成功将所述第三指针压入到所述公用输出队列W中,则将所述第三指针重新压入所述第一缓存队列中。
需要说明的是,前述对用于垃圾回收的并行标记处理方法实施例的解释说明也适用于该实施例的用于垃圾回收的并行标记处理装置,此处不再赘述。
本实施例提供的用于垃圾回收的并行标记处理装置,在第一标记线程的第一私有栈为空时,且第一缓存队列不为空,从第一缓存队列中取出预先压入的第三对象的第三指针,向本线程中与对应标记线程的公用输出队列中进行压入处理,以供与第三对象对应的标记线程对其进行标记处理。由此,参照第一标记线程的标记处理过程,通过N个标记线程的进行协同并行的标记处理,利用有限的内存实现高效的并行标记,同时实现标记线程负载均衡,从而减少CPU缓存一致性冲突,提高整个垃圾回收的性能。
图16是本申请另一个实施例的用于垃圾回收的并行标记处理装置的结构示意图。
参见图16,基于图15所示实施例,所述第二标记模块22还包括:
第八判断单元214,用于如果所述第一缓存队列为空,判断其他(N-1)个标记线程中与所述第一标记线程对应的公用输出队列是否为空;
第七处理单元215,用于如果当前处理的标记线程T中与所述第一标记线程对应的公用输出队列不为空,所述第一标记线程从当前处理的公用输出队列中取出预先压入的第四对象的第四指针,其中,所述第四对象为所述标记线程T预先压入的、由所述第一标记线程负责对所述第四对象所在的内存块P3进行标记处理;将所述第四指针压入到所述第一私有栈中;
第九判断单元216,用于判断是否成功将所述第四指针压入到所述第一私有栈中;
第八处理单元217,用于如果所述第一标记线程未能成功将所述第四指针压入到所述第一私有栈中,则将所述内存块P3的位图中、与该第四对象对应的状态标记为溢出状态。
进一步地,在另一个实施例中,
所述第八处理单元217,还用于设置与所述内存块P3对应的溢出标志。
进一步地,在另一个实施例中,
所述第八处理单元217,还用于如果所述第一标记线程成功将所述第四指针压入到所述第一私有栈中,则继续对下一个第四对象向所述第一私有栈中进行压入处理。
需要说明的是,前述对用于垃圾回收的并行标记处理方法实施例的解释说明也适用于该实施例的用于垃圾回收的并行标记处理装置,此处不再赘述。
本实施例提供的用于垃圾回收的并行标记处理装置,第一标记线程在第一私有栈和第一缓存队列为空,且其他标记线程中与第一标记线程对应的公用输出队列不为空时,取出预先压入的第四对象的第四指针,向本线程中的第一私有栈压入处理。由此,参照第一标记线程的标记处理过程,通过N个标记线程的进行协同并行的标记处理,利用有限的内存实现高效的并行标记,同时实现标记线程负载均衡,从而减少CPU缓存一致性冲突,提高整个垃圾回收的性能。
图17是本申请另一个实施例的用于垃圾回收的并行标记处理装置的结构示意图。
参见图17,基于图16所示实施例,所述第二标记模块22还包括:
第十判断单元218,用于如果其他(N-1)个标记线程中与所述第一标记线程对应的公用输出队列都为空,所述第一标记线程判断本线程负责标记的内存块中是否有溢出状态的第五对象;
第九处理单元219,用于如果所述第一标记线程负责标记的内存块中具有溢出状态的第五对象,所述第一标记线程将当前处理的内存块P4中标记溢出状态的第五对象修改为压入状态,将当前第五对象的第五指针压
入到所述第一私有栈中;
第十一判断单元220,用于所述第一标记线程判断是否成功将所述第五指针压入到所述第一私有栈中;
第十处理单元221,用于如果所述第一标记线程未能成功将所述第五指针压入到所述第一私有栈中,则将所述内存块P4的位图中、与该第五对象对应的状态标记为溢出状态。
进一步地,在另一个实施例中,
所述第十处理单元221,还用于设置与所述内存块P5对应的溢出标志。
进一步地,在另一个实施例中,
所述第十处理单元221,还用于如果所述第一标记线程成功将所述第五指针压入到所述第一私有栈中,则继续对下一个第五对象进行处理。
进一步地,在另一个实施例中,
所述第九处理单元219,还用于如果所述第一标记线程负责标记的内存块中不具有溢出状态的第五对象,则标记结束,退出线程。
需要说明的是,前述对用于垃圾回收的并行标记处理方法实施例的解释说明也适用于该实施例的用于垃圾回收的并行标记处理装置,此处不再赘述。
本实施例提供的用于垃圾回收的并行标记处理装置,第一标记线程在第一私有栈、第一缓存队列、以及其他标记线程中与第一标记线程对应的公用输出队列都为空时,根据本线程负责标记的具有溢出状态的第五对象进行压入处理。由此,参照第一标记线程的标记处理过程,通过N个标记线程的并行的标记处理,利用有限的内存实现高效的并行标记,提高整个垃圾回收的性能。
在本说明书的描述中,参考术语“一个实施例”、“一些实施例”、“示例”、“具体示例”、或“一些示例”等的描述意指结合该实施例或示例描述的
具体特征、结构、材料或者特点包含于本申请的至少一个实施例或示例中。在本说明书中,对上述术语的示意性表述不必须针对的是相同的实施例或示例。而且,描述的具体特征、结构、材料或者特点可以在任一个或多个实施例或示例中以合适的方式结合。此外,在不相互矛盾的情况下,本领域的技术人员可以将本说明书中描述的不同实施例或示例以及不同实施例或示例的特征进行结合和组合。
此外,术语“第一”、“第二”仅用于描述目的,而不能理解为指示或暗示相对重要性或者隐含指明所指示的技术特征的数量。由此,限定有“第一”、“第二”的特征可以明示或者隐含地包括至少一个该特征。在本申请的描述中,“多个”的含义是至少两个,例如两个,三个等,除非另有明确具体的限定。
流程图中或在此以其他方式描述的任何过程或方法描述可以被理解为,表示包括一个或更多个用于实现特定逻辑功能或过程的步骤的可执行指令的代码的模块、片段或部分,并且本申请的优选实施方式的范围包括另外的实现,其中可以不按所示出或讨论的顺序,包括根据所涉及的功能按基本同时的方式或按相反的顺序,来执行功能,这应被本申请的实施例所属技术领域的技术人员所理解。
Claims (48)
- 一种用于垃圾回收的并行标记处理方法,其特征在于,包括以下步骤:根据虚拟机堆中的内存块与N个标记线程的对应关系,遍历所述虚拟机堆中的第一对象,其中,N为大于1的整数,N个标记线程占用的内存容量是预先设置的,每个标记线程至少包括:1个私有栈;将当前处理的第一对象的第一指针压入与该第一对象所在的内存块对应的标记线程的私有栈,根据所述第一指针的压入情况对所述第一对象进行第一标记处理;对所述第一对象遍历完成后,向所述N个标记线程发送线程启动指令,以使所述N个标记线程根据各自私有栈中所述第一指针的压入情况,同步进行用于垃圾回收的标记处理。
- 如权利要求1所述的方法,其特征在于,所述根据虚拟机堆中的内存块与N个标记线程的对应关系,遍历所述虚拟机堆中的第一对象之前,还包括:申请所述N个标记线程;遍历所述虚拟机堆中的内存块,建立内存块与N个标记线程的对应关系。
- 如权利要求2所述的方法,其特征在于,所述建立内存块与N个标记线程的对应关系,包括:为每个内存块指定对应的标记线程;或者,为每个标记线程指定负责标记的内存块。
- 如权利要求2所述的方法,其特征在于,所述遍历所述虚拟机堆中的内存块,建立内存块与N个标记线程的对应关系,包括:遍历虚拟机堆中的内存块,为每个内存块分配编号;根据内存块的编号和标记线程总数N,确定与每个内存块编号对应的标记线程编号。
- 如权利要求4所述的方法,其特征在于,所述根据内存块编号和标记线程总数N,确定与每个内存块编号对应的标记线程编号,包括:获取标记线程总数N被内存块编号整除后的余数,确定与每个内存块编号对应的标记线程编号。
- 如权利要求1所述的方法,其特征在于,所述根据所述第一指针的压入情况对所述第一对象进行第一标记处理,包括:如果将所述第一指针成功压入与当前第一对象所在的内存块对应的标记线程的私有栈,则将当前第一对象所在内存块的位图中、与该第一对象对应的状态标记为压入状态;如果未能将所述第一指针成功压入与当前第一对象所在的内存块对应的标记线程的私有栈,则将当前第一对象所在内存块的位图中、与该第一对象对应的状态标记为溢出状态。
- 一种用于垃圾回收的并行标记处理方法,其特征在于,预设的N个标记线程中的每个标记线程至少包括:1个私有栈,所述方法应用在每个标记线程中,其中,应用在第一标记线程中的所述方法包括以下步骤:第一标记线程根据线程启动指令,从第一私有栈中取出预先压入的第一对象的第一指针;所述第一标记线程遍历所述第一指针指示的所述第一对象引用的第二对象,并根据预设的N个标记线程与虚拟机堆中内存块的对应关系对所述第二对象进行第二标记处理。
- 如权利要求7所述的方法,其特征在于,所述根据N个标记线程与虚拟机堆中内存块的对应关系对所述第二对象进行第二标记处理,包括:所述第一标记线程根据所述对应关系,判断是否负责对当前处理的第二对象所在的内存块P1进行标记处理;如果所述第一标记线程负责对所述内存块P1进行标记处理,则将当前处理的第二对象的第二指针压入到所述第一私有栈中;所述第一标记线程判断是否成功将所述第二指针压入到所述第一私有栈中;如果所述第一标记线程未能成功将所述第二指针压入到所述第一私有栈中,则将所述内存块P1的位图中、与该第二对象对应的状态标记为溢出状态。
- 如权利要求8所述的方法,其特征在于,还包括:设置与所述内存块P1对应的溢出标志。
- 如权利要求8所述的方法,其特征在于,所述第一标记线程判断是否成功将所述第二指针压入到所述第一私有栈中之后,还包括:如果所述第一标记线程成功将所述第二指针压入到所述第一私有栈中,则继续对所述第一指针对应的下一个第二对象进行处理。
- 如权利要求8所述的方法,其特征在于,预设的N个标记线程中每个标记线程还包括:与其他(N-1)个标记线程对应的(N-1)个公用输出队列;所述判断是否负责对当前处理的第二对象所在的内存块P1进行标记处理之后,还包括:如果所述第一标记线程不负责对所述内存块P1进行标记处理,确定标记线程M负责对所述内存块P1进行标记处理;将所述第二指针压入到所述第一标记线程中与所述标记线程M对应的公用输出队列M中;所述第一标记线程判断是否成功将所述第二指针压入到所述公用输出队列M中;如果所述第一标记线程成功将所述第二指针压入到所述公用输出队列M中,则继续对所述第一指针对应的下一个第二对象进行处理。
- 如权利要求11所述的方法,其特征在于,预设的N个标记线程中每个标记线程还包括:1个缓存队列;所述第一标记线程判断是否成功将所述第二指针压入到所述公用输出队列M中之后,还包括:如果所述第一标记线程未能成功将所述第二指针压入到所述公用输出队列M中,则把所述第二指针压入到所述第一标记线程中的第一缓存队列中;所述第一标记线程判断是否成功将所述第二指针压入到所述第一缓存队列中;如果所述第一标记线程未能成功将所述第二指针压入到所述第一缓存队列中,则将所述内存块P1的位图中、与当前处理的第二对象对应的 状态标记为溢出状态。
- 如权利要求12所述的方法,其特征在于,还包括:设置与所述内存块P1对应的溢出标志。
- 如权利要求13所述的方法,其特征在于,所述第一标记线程判断是否成功将所述第二指针压入到所述第一缓存队列中之后,还包括:如果所述第一标记线程成功将所述第二指针压入到所述第一缓存队列中,则继续对所述第一指针对应的下一个第二对象进行处理。
- 如权利要求8-14任一所述的方法,其特征在于,所述第一标记线程根据所述对应关系,判断是否负责对当前处理的第二对象所在的内存块P1进行标记处理之前,还包括:查询所述内存块P1的位图中与该第二对象对应的状态标记;如果与该第二对象对应的状态标记为未标记状态,则将与该第二对象对应的状态修改为压入状态。
- 如权利要求7所述的方法,其特征在于,预设的N个标记线程中每个标记线程还包括:1个缓存队列,以及与其他(N-1)个标记线程对应的(N-1)个公用输出队列;所述方法还包括:判断本线程的第一私有栈是否为空;如果所述第一私有栈为空,所述第一标记线程判断本线程的第一缓存队列是否为空;如果所述第一缓存队列不为空,所述第一标记线程从所述第一缓存队列中取出预先压入的第三对象的第三指针,其中,所述第一标记线程不负责对当前处理的第三对象所在的内存块P2进行标记处理;所述第一标记线程根据所述对应关系,确定标记线程W负责对当前处理的第三对象所在的内存块P2进行标记处理;所述第一标记线程将所述第三指针压入到所述第一标记线程中与所述标记线程W对应的公用输出队列W中;所述第一标记线程判断是否成功将将当前处理的第三指针压入到所述公用输出队列W中;如果所述第一标记线程成功将所述第三指针压入到所述公用输出队列W中,则继续对所述第一缓存队列中的下一个第三对象向对应的公用输 出队列进行压入处理。
- 如权利要求16所述的方法,其特征在于,所述第一标记线程判断是否成功将将当前处理的第三指针压入到所述公用输出队列W中之后,还包括:如果所述第一标记线程未能成功将所述第三指针压入到所述公用输出队列W中,则将所述第三指针重新压入所述第一缓存队列中。
- 如权利要求16所述的方法,其特征在于,所述第一标记线程判断本线程的第一缓存队列是否为空之后,还包括:如果所述第一缓存队列为空,所述第一标记线程判断其他(N-1)个标记线程中与所述第一标记线程对应的公用输出队列是否为空;如果当前处理的标记线程T中与所述第一标记线程对应的公用输出队列不为空,所述第一标记线程从当前处理的公用输出队列中取出预先压入的第四对象的第四指针,其中,所述第四对象为所述标记线程T预先压入的、由所述第一标记线程负责对所述第四对象所在的内存块P3进行标记处理;所述第一标记线程将所述第四指针压入到所述第一私有栈中;所述第一标记线程判断是否成功将所述第四指针压入到所述第一私有栈中;如果所述第一标记线程未能成功将所述第四指针压入到所述第一私有栈中,则将所述内存块P3的位图中、与该第四对象对应的状态标记为溢出状态。
- 如权利要求18所述的方法,其特征在于,还包括:设置与所述内存块P3对应的溢出标志。
- 如权利要求18所述的方法,其特征在于,所述第一标记线程判断是否成功将所述第四指针压入到所述第一私有栈中之后,还包括:如果所述第一标记线程成功将所述第四指针压入到所述第一私有栈中,则继续对下一个第四对象向所述第一私有栈中进行压入处理。
- 如权利要求18所述的方法,其特征在于,所述第一标记线程判断其他(N-1)个标记线程中与所述第一标记线程对应的公用输出队列是否为空之后,还包括:如果其他(N-1)个标记线程中与所述第一标记线程对应的公用输出队列都为空,所述第一标记线程判断本线程负责标记的内存块中是否有溢出状态的第五对象;如果所述第一标记线程负责标记的内存块中具有溢出状态的第五对象,所述第一标记线程将当前处理的内存块P4中标记溢出状态的第五对象修改为压入状态,将当前第五对象的第五指针压入到所述第一私有栈中;所述第一标记线程判断是否成功将所述第五指针压入到所述第一私有栈中;如果所述第一标记线程未能成功将所述第五指针压入到所述第一私有栈中,则将所述内存块P4的位图中、与该第五对象对应的状态标记为溢出状态。
- 如权利要求21所述的方法,其特征在于,还包括:设置与所述内存块P5对应的溢出标志。
- 如权利要求21所述的方法,其特征在于,所述第一标记线程判断是否成功将所述第五指针压入到所述第一私有栈中之后,还包括:如果所述第一标记线程成功将所述第五指针压入到所述第一私有栈中,则继续对下一个第五对象进行处理。
- 如权利要求21所述的方法,其特征在于,所述第一标记线程判断本线程负责标记的内存块中是否有溢出状态的第五对象之后,还包括:如果所述第一标记线程负责标记的内存块中不具有溢出状态的第五对象,则标记结束,退出线程。
- 一种用于垃圾回收的并行标记处理装置,其特征在于,包括:遍历模块,用于根据虚拟机堆中的内存块与N个标记线程的对应关系,遍历所述虚拟机堆中的第一对象,其中,N为大于1的整数,N个标记线程占用的内存容量是预先设置的,每个标记线程至少包括:1个私有栈;第一标记模块,用于将当前处理的第一对象的第一指针压入与该第一对象所在的内存块对应的标记线程的私有栈,根据所述第一指针的压入情况对所述第一对象进行第一标记处理;启动模块,用于对所述第一对象遍历完成后,向所述N个标记线程发 送线程启动指令,以使所述N个标记线程根据各自私有栈中所述第一指针的压入情况,同步进行用于垃圾回收的标记处理。
- 如权利要求25所述的装置,其特征在于,还包括:申请模块,用于申请所述N个标记线程;建立模块,用于遍历所述虚拟机堆中的内存块,建立内存块与N个标记线程的对应关系。
- 如权利要求26所述的装置,其特征在于,所述建立模块用于:为每个内存块指定对应的标记线程;或者,为每个标记线程指定负责标记的内存块。
- 如权利要求26所述的装置,其特征在于,所述建立模块包括:分配单元,用于遍历虚拟机堆中的内存块,为每个内存块分配编号;确定单元,用于根据内存块的编号和标记线程总数N,确定与每个内存块编号对应的标记线程编号。
- 如权利要求28所述的装置,其特征在于,所述确定单元用于:获取标记线程总数N被内存块编号整除后的余数,确定与每个内存块编号对应的标记线程编号。
- 如权利要求25所述的装置,其特征在于,所述第一标记模块用于:如果将所述第一指针成功压入与当前第一对象所在的内存块对应的标记线程的私有栈,则将当前第一对象所在内存块的位图中、与该第一对象对应的状态标记为压入状态;如果未能将所述第一指针成功压入与当前第一对象所在的内存块对应的标记线程的私有栈,则将当前第一对象所在内存块的位图中、与该第一对象对应的状态标记为溢出状态。
- 一种用于垃圾回收的并行标记处理装置,其特征在于,预设的N个标记线程中的每个标记线程至少包括:1个私有栈,所述装置应用在每个标记线程中,其中,应用在第一标记线程中的所述装置包括:获取模块,用于根据线程启动指令,从第一私有栈中取出预先压入的第一对象的第一指针;第二标记模块,用于遍历所述第一指针指示的所述第一对象引用的第 二对象,并根据预设的N个标记线程与虚拟机堆中内存块的对应关系对所述第二对象进行第二标记处理。
- 如权利要求31所述的装置,其特征在于,所述第二标记模块包括:第一判断单元,用于根据所述对应关系,判断是否负责对当前处理的第二对象所在的内存块P1进行标记处理;第一处理单元,用于如果所述第一标记线程负责对所述内存块P1进行标记处理,则将当前处理的第二对象的第二指针压入到所述第一私有栈中;第二判断单元,用于判断是否成功将所述第二指针压入到所述第一私有栈中;第二处理单元,用于如果所述第一标记线程未能成功将所述第二指针压入到所述第一私有栈中,则将所述内存块P1的位图中、与该第二对象对应的状态标记为溢出状态。
- 如权利要求32所述的装置,其特征在于,所述第二处理单元还用于:设置与所述内存块P1对应的溢出标志。
- 如权利要求32所述的装置,其特征在于,所述第二处理单元还用于:如果所述第一标记线程成功将所述第二指针压入到所述第一私有栈中,则继续对所述第一指针对应的下一个第二对象进行处理。
- 如权利要求32所述的装置,其特征在于,预设的N个标记线程中每个标记线程还包括:与其他(N-1)个标记线程对应的(N-1)个公用输出队列;所述第二标记模块还包括:所述第一处理单元,还用于如果所述第一标记线程不负责对所述内存块P1进行标记处理,确定标记线程M负责对所述内存块P1进行标记处理,将所述第二指针压入到所述第一标记线程中与所述标记线程M对应的公用输出队列M中;第三判断单元,用于判断是否成功将所述第二指针压入到所述公用输出队列M中;第三处理单元,用于如果所述第一标记线程成功将所述第二指针压入到所述公用输出队列M中,则继续对所述第一指针对应的下一个第二对象进行处理。
- 如权利要求35所述的装置,其特征在于,预设的N个标记线程中每个标记线程还包括:1个缓存队列;所述第二标记模块还包括:所述第三处理单元,还用于如果所述第一标记线程未能成功将所述第二指针压入到所述公用输出队列M中,则把所述第二指针压入到所述第一标记线程中的第一缓存队列中;第四判断单元,用于判断是否成功将所述第二指针压入到所述第一缓存队列中;第四处理单元,用于如果所述第一标记线程未能成功将所述第二指针压入到所述第一缓存队列中,则将所述内存块P1的位图中、与当前处理的第二对象对应的状态标记为溢出状态。
- 如权利要求36所述的装置,其特征在于,所述第四处理单元还用于:设置与所述内存块P1对应的溢出标志。
- 如权利要求36所述的装置,其特征在于,所述第四处理单元,还用于如果所述第一标记线程成功将所述第二指针压入到所述第一缓存队列中,则继续对所述第一指针对应的下一个第二对象进行处理。
- 如权利要求31-38任一所述的装置,其特征在于,所述第二处理单元,还用于查询所述内存块P1的位图中与该第二对象对应的状态标记;如果与该第二对象对应的状态标记为未标记状态,则将与该第二对象对应的状态修改为压入状态。
- 如权利要求31所述的装置,其特征在于,预设的N个标记线程中每个标记线程还包括:1个缓存队列,以及与其他(N-1)个标记线程对应的(N-1)个公用输出队列;所述第二标记模块还包括:第五判断单元,用于判断所述第一私有栈是否为空;第六判断单元,用于如果所述第一私有栈为空,判断第一标记线程的 第一缓存队列是否为空;第五处理单元,用于如果所述第一缓存队列不为空,所述第一标记线程从所述第一缓存队列中取出预先压入的第三对象的第三指针,其中,所述第一标记线程不负责对当前处理的第三对象所在的内存块P2进行标记处理;根据所述对应关系,确定标记线程W负责对当前处理的第三对象所在的内存块P2进行标记处理;将所述第三指针压入到所述第一标记线程中与所述标记线程W对应的公用输出队列W中;第七判断单元,用于判断是否成功将当前处理的第三指针压入到所述公用输出队列W中;第六处理单元,用于如果所述第一标记线程成功将所述第三指针压入到所述公用输出队列W中,则继续对所述第一缓存队列中的下一个第三对象向对应的公用输出队列进行压入处理。
- 如权利要求40所述的装置,其特征在于,所述第六处理单元,还用于如果所述第一标记线程未能成功将所述第三指针压入到所述公用输出队列W中,则将所述第三指针重新压入所述第一缓存队列中。
- 如权利要求40所述的装置,其特征在于,所述第二标记模块还包括:第八判断单元,用于如果所述第一缓存队列为空,判断其他(N-1)个标记线程中与所述第一标记线程对应的公用输出队列是否为空;第七处理单元,用于如果当前处理的标记线程T中与所述第一标记线程对应的公用输出队列不为空,所述第一标记线程从当前处理的公用输出队列中取出预先压入的第四对象的第四指针,其中,所述第四对象为所述标记线程T预先压入的、由所述第一标记线程负责对所述第四对象所在的内存块P3进行标记处理;将所述第四指针压入到所述第一私有栈中;第九判断单元,用于判断是否成功将所述第四指针压入到所述第一私有栈中;第八处理单元,用于如果所述第一标记线程未能成功将所述第四指针压入到所述第一私有栈中,则将所述内存块P3的位图中、与该第四对象对应的状态标记为溢出状态。
- 如权利要求42所述的装置,其特征在于,所述第八处理单元,还用于设置与所述内存块P3对应的溢出标志。
- 如权利要求42所述的装置,其特征在于,所述第八处理单元,还用于如果所述第一标记线程成功将所述第四指针压入到所述第一私有栈中,则继续对下一个第四对象向所述第一私有栈中进行压入处理。
- 如权利要求42所述的装置,其特征在于,所述第二标记模块还包括:第十判断单元,用于如果其他(N-1)个标记线程中与所述第一标记线程对应的公用输出队列都为空,所述第一标记线程判断本线程负责标记的内存块中是否有溢出状态的第五对象;第九处理单元,用于如果所述第一标记线程负责标记的内存块中具有溢出状态的第五对象,所述第一标记线程将当前处理的内存块P4中标记溢出状态的第五对象修改为压入状态,将当前第五对象的第五指针压入到所述第一私有栈中;第十一判断单元,用于所述第一标记线程判断是否成功将所述第五指针压入到所述第一私有栈中;第十处理单元,用于如果所述第一标记线程未能成功将所述第五指针压入到所述第一私有栈中,则将所述内存块P4的位图中、与该第五对象对应的状态标记为溢出状态。
- 如权利要求45所述的装置,其特征在于,所述第十处理单元,还用于设置与所述内存块P5对应的溢出标志。
- 如权利要求45所述的装置,其特征在于,所述第十处理单元,还用于如果所述第一标记线程成功将所述第五指针压入到所述第一私有栈中,则继续对下一个第五对象进行处理。
- 如权利要求45所述的装置,其特征在于,所述第九处理单元,还用于如果所述第一标记线程负责标记的内存块中不具有溢出状态的第五对象,则标记结束,退出线程。
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| US16/144,624 US11003578B2 (en) | 2016-03-29 | 2018-09-27 | Method and system for parallel mark processing |
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201610187840.2 | 2016-03-29 | ||
| CN201610187840.2A CN107239406B (zh) | 2016-03-29 | 2016-03-29 | 用于垃圾回收的并行标记处理方法及装置 |
Related Child Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| US16/144,624 Continuation-In-Part US11003578B2 (en) | 2016-03-29 | 2018-09-27 | Method and system for parallel mark processing |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2017167061A1 true WO2017167061A1 (zh) | 2017-10-05 |
Family
ID=59963487
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2017/077446 Ceased WO2017167061A1 (zh) | 2016-03-29 | 2017-03-21 | 用于垃圾回收的并行标记处理方法及装置 |
Country Status (3)
| Country | Link |
|---|---|
| US (1) | US11003578B2 (zh) |
| CN (1) | CN107239406B (zh) |
| WO (1) | WO2017167061A1 (zh) |
Families Citing this family (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US11775543B1 (en) * | 2022-04-19 | 2023-10-03 | Sap Se | Heapsort in a parallel processing framework |
| CN118312309B (zh) * | 2024-04-12 | 2025-12-12 | 福建天泉教育科技有限公司 | 一种垃圾回收的动态调整方法及服务端 |
Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20090248766A1 (en) * | 2005-03-28 | 2009-10-01 | Sun Microsystems, Inc. | Method and apparatus for improving parallel marking garbage collectors that use external bitmaps |
| CN102023891A (zh) * | 2010-12-20 | 2011-04-20 | 复旦大学 | 基于Java虚拟机的并发垃圾收集器框架 |
| CN102722415A (zh) * | 2012-05-22 | 2012-10-10 | 广州晶锐信息技术有限公司 | 基于堆栈体系结构Java SoC系统的垃圾收集方法 |
| US20150058381A1 (en) * | 2013-08-21 | 2015-02-26 | Oracle International Corporation | System and method for dynamically selecting a garbage collection algorithm based on the contents of heap regions |
Family Cites Families (9)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US5920876A (en) | 1997-04-23 | 1999-07-06 | Sun Microsystems, Inc. | Performing exact garbage collection using bitmaps that identify pointer values within objects |
| US6209066B1 (en) * | 1998-06-30 | 2001-03-27 | Sun Microsystems, Inc. | Method and apparatus for memory allocation in a multi-threaded virtual machine |
| US6826583B1 (en) | 2000-05-15 | 2004-11-30 | Sun Microsystems, Inc. | Local allocation buffers for parallel garbage collection |
| US7293051B1 (en) * | 2004-07-01 | 2007-11-06 | Sun Microsystems, Inc. | Collection-set selection using a small priority queue |
| US7512745B2 (en) * | 2006-04-28 | 2009-03-31 | International Business Machines Corporation | Method for garbage collection in heterogeneous multiprocessor systems |
| US8776032B2 (en) * | 2009-01-29 | 2014-07-08 | Microsoft Corporation | Automatic region-based verification of garbage collectors |
| US9501331B2 (en) * | 2012-08-09 | 2016-11-22 | Fujitsu Limited | Satisfiability checking |
| US9692813B2 (en) * | 2014-08-08 | 2017-06-27 | Sas Institute Inc. | Dynamic assignment of transfers of blocks of data |
| US9501637B2 (en) * | 2014-09-26 | 2016-11-22 | Intel Corporation | Hardware shadow stack support for legacy guests |
-
2016
- 2016-03-29 CN CN201610187840.2A patent/CN107239406B/zh active Active
-
2017
- 2017-03-21 WO PCT/CN2017/077446 patent/WO2017167061A1/zh not_active Ceased
-
2018
- 2018-09-27 US US16/144,624 patent/US11003578B2/en active Active
Patent Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20090248766A1 (en) * | 2005-03-28 | 2009-10-01 | Sun Microsystems, Inc. | Method and apparatus for improving parallel marking garbage collectors that use external bitmaps |
| CN102023891A (zh) * | 2010-12-20 | 2011-04-20 | 复旦大学 | 基于Java虚拟机的并发垃圾收集器框架 |
| CN102722415A (zh) * | 2012-05-22 | 2012-10-10 | 广州晶锐信息技术有限公司 | 基于堆栈体系结构Java SoC系统的垃圾收集方法 |
| US20150058381A1 (en) * | 2013-08-21 | 2015-02-26 | Oracle International Corporation | System and method for dynamically selecting a garbage collection algorithm based on the contents of heap regions |
Non-Patent Citations (2)
| Title |
|---|
| WU, MING ET AL.: "Task-Pushing: a Scalable Parallel GC Marking Algorithm without Synchronization Operations", PARALLEL AND DISTRIBUTED PROCESSING SYMPOSIUM, 2007, 11 June 2007 (2007-06-11), XP055426727, ISSN: 1530-2075 * |
| ZHANG, SHIJUN ET AL.: "Improved Garbage Collection Algorithm for Incremental JVM", COMPUTER ENGINEERING, vol. 38, no. 1, 31 January 2012 (2012-01-31), XP055426732, ISSN: 1000-3428 * |
Also Published As
| Publication number | Publication date |
|---|---|
| CN107239406A (zh) | 2017-10-10 |
| US11003578B2 (en) | 2021-05-11 |
| US20190129843A1 (en) | 2019-05-02 |
| CN107239406B (zh) | 2021-03-09 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US10996858B2 (en) | Method and device for migrating data | |
| JP2002529849A (ja) | データ処理リソースを供給された内蔵システムにおいて実行可能な中間オブジェクトコードプログラムのためのデータ圧縮方法、および、この方法に対応しかつマルチアプリケーションを備えた内蔵システム | |
| CN103559020A (zh) | 一种dna读序数据fastq文件并行压缩和解压缩方法 | |
| CN117033002B (zh) | 一种内存管理方法、装置、设备及存储介质 | |
| CN105677904B (zh) | 基于分布式文件系统的小文件存储方法及装置 | |
| US10558566B2 (en) | Garbage collection of non-pinned objects within heap | |
| CN107748794A (zh) | 一种空间数据存储方法 | |
| CN114880138B (zh) | 一种基于共享内存池的高性能数据模型访问方法和装置 | |
| WO2017167061A1 (zh) | 用于垃圾回收的并行标记处理方法及装置 | |
| CN101770504B (zh) | 数据存储、读取方法及设备 | |
| CN112506813B (zh) | 一种内存管理方法和系统 | |
| CN109062880B (zh) | 电子书文件的制作方法、电子设备、服务器、存储介质 | |
| CN111414339B (zh) | 一种文件的处理方法、系统、装置、设备及介质 | |
| CN108446110A (zh) | Lua脚本生成方法、装置、终端及计算机可读介质 | |
| CN103984655A (zh) | 数据访问的处理方法和装置 | |
| CN113835852B (zh) | 任务数据的调度方法及装置 | |
| CN110795247A (zh) | 一种应用于mcu的高效动态内存管理方法 | |
| JP6772883B2 (ja) | 読込プログラム、読込方法および情報処理装置 | |
| US9032178B2 (en) | Electronic apparatus for memory allocation and reorganization | |
| CN108874994A (zh) | 一种分块读取数据的方法、装置及计算机存储介质 | |
| CN101295239A (zh) | Java卡虚拟机的指令执行方法 | |
| CN108874798A (zh) | 一种大数据排序方法和系统 | |
| CN107329833A (zh) | 一种利用链表实现内存连续的方法和装置 | |
| US20160055609A1 (en) | Graphics processing method, system, and apparatus | |
| CN115328656B (zh) | 动态内存智能化扩展方法、装置、设备及存储介质 |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| NENP | Non-entry into the national phase |
Ref country code: DE |
|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 17773091 Country of ref document: EP Kind code of ref document: A1 |
|
| 122 | Ep: pct application non-entry in european phase |
Ref document number: 17773091 Country of ref document: EP Kind code of ref document: A1 |



