Work-stealing for concurrent marking of garbage collection with finger pointers

JP7651241B2Active Publication Date: 2025-03-26INTERNATIONAL BUSINESS MACHINE CORPORATION
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
JP2023507594
Authority / Receiving Office
JP · JP
Patent Type
Patents
Current Assignee / Owner
Priority Date
2020-08-26
Filing Date
2021-08-09
Publication Date
2025-03-26
Estimated Expiration
2041-08-09

Smart Images

  • Figure 0007651241000001
    Figure 0007651241000001
  • Figure 0007651241000002
    Figure 0007651241000002
  • Figure 0007651241000003
    Figure 0007651241000003
Patent Text Reader

Abstract

A computer-implemented method, system, and computer program product are provided. The approach includes popping a first task from a queue of a garbage collection thread. The approach further includes identifying a second task from the popped first task, the second task being associated with a bit in a bitmap, the bit being located in the bitmap at a location not yet passed by the finger pointer. The approach further includes pushing the second task onto the queue of the garbage collection thread.
Need to check novelty before this filing date? Find Prior Art

Description

[Technical field]

[0001] The present invention relates generally to garbage collection, and more specifically to an approach for maintaining work-stealing load balancing for concurrent marking during garbage collection. [Background technology]

[0002] The garbage collection (GC) process attempts to reclaim memory occupied by garbage, i.e. objects that are no longer in use. GC frees the programmer from manual memory management of specifying which objects to deallocate and return to the memory system, and when to do so.

[0003] Work-stealing is a scheduling strategy for multithreaded computer applications. In a work-stealing scheduler, each processor in a computer system has a queue of work items (computational tasks, threads) to execute. Each work item consists of a sequence of instructions that are executed sequentially, but in the course of its execution, a work item may further spawn new work items that can be executed in a feasible manner in parallel with other work. When a processor finishes work, it looks at the queues of other processors or threads and steals their work items.

[0004] Garbage-First Garbage Collection describes "a server-style garbage collector for large memory multiprocessors that achieves high throughput while meeting soft real-time goals with high probability" (Abstract, Garbage-First Garbage Collection, David Detlefts, et al., ISMM'04, October 24.-25, 2004). Garbage-First Garbage Collection describes "a 'finger' pointer that iterates through marked bits. Objects above the fingers are implicitly gray, and gray objects below the fingers are represented by a mark stack" (Section 2.5.2, Garbage-First Garbage Collection). When used in Garbage-First Garbage Collection, "gray" means that the object is "marked but not yet recursively scanned" (Section 2.5.1).

[0005] A drawback of current garbage collection processes that utilize finger pointers is that the finger pointers may prevent the pushing of tasks that are downstream of the finger pointer (i.e., associated with bits that the finger pointer has not yet passed). Load balancing can occur when the work-stealing mechanism does not have enough stealable tasks. Summary of the Invention

[0006] According to an embodiment of the present invention, a computer-implemented method, a computer program product, and a computer system are provided. The approach includes popping a first task from a garbage collection thread queue. The approach further includes identifying a second task from the popped first task, the second task being associated with a bit of a bitmap, the bit being located in the bitmap at a location not yet passed by the finger pointer. The approach further includes pushing the second task onto the garbage collection thread queue. Such an approach has the advantage of preventing load imbalance from adding a task to the garbage collection queue even if the task is associated with a bit in the bitmap at a location not yet passed by the finger pointer.

[0007] According to another embodiment of the present invention, a computer-implemented method, a computer program product, and a computer system are provided. The approach includes popping a first task from a garbage collection thread queue. The approach further includes identifying a second task and a third task from the popped first task, the second task being associated with a first bit of a bitmap, the first bit being located in a first location in the bitmap that has not yet been passed by the finger pointer, and the third task being associated with a second bit of the bitmap, the second bit being located in a second location in the bitmap that has been passed by the finger pointer. The approach further includes pushing the third task onto the garbage collection thread queue. The approach further includes determining that the number of the first tasks in the garbage collection thread queue is equal to or less than a first threshold number of tasks.

[0008] Embodiments of the invention optionally include an approach for determining that the number of first tasks in the garbage collection thread queue is equal to or less than a first threshold number of tasks, and pushing the second task into the garbage collection thread queue is responsive to determining that the number of first tasks in the garbage collection thread queue is equal to or less than the first threshold number of tasks. Such an approach has the advantage of maintaining load balancing by pushing tasks into the garbage collection queue when the number of remaining tasks in the garbage collection queue is low.

[0009] An embodiment of the present invention may optionally further include an approach for calculating a difference between (i) a number of first tasks in the garbage collection thread's queue after popping the first task and (ii) a number of second tasks in the garbage collection thread's queue after popping a task prior to popping the first task. The approach may further optionally determine that the difference matches or exceeds a second threshold number of tasks. The approach may further increase the first threshold number of tasks in response to the difference matching or exceeding the second threshold number of tasks. Such an approach has the advantage of adjusting the threshold based on load balancing of work stealing by the GC thread. [Brief description of the drawings]

[0010] [Figure 1] FIG. 1 is a functional block diagram illustrating a processing system, in accordance with one embodiment of the present invention. [Diagram 2] 1 is a block diagram illustrating a processor device according to one embodiment of the present invention. [Diagram 3] 4 is an exemplary set of objects including reference relationships and marking states according to one embodiment of the present invention. [Figure 4] 1 is an exemplary bitmap including finger pointers according to one embodiment of the present invention. [Diagram 5] 4 is a flowchart illustrating the operational steps of an approach for adding a reference object(s) to a queue of a garbage collector thread, according to one embodiment of the present invention. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS

[0011] An embodiment of the present invention recognizes that in garbage-first garbage collection (G1GC) and other concurrent garbage collection (GC) approaches that use finger pointers, load imbalances can occur due to finger pointers limiting pushable tasks for work stealing. An embodiment of the present invention discloses an approach that provides sufficient tasks that can be stolen by a thread even when the finger pointers limit pushable tasks. An embodiment of the present invention discloses an approach whereby a worker thread pushes a child task to the worker thread's queue when the number of remaining tasks is less than a threshold number of tasks, even if the child task is located downstream of the finger pointer (e.g., a location where the finger pointer has not yet passed). An embodiment of the present invention further provides for automatically adjusting the threshold based on task reduction per unit time to maintain load balance throughout the GC process.

[0012] The present invention will now be described in detail with reference to the drawings. Figure 1 illustrates a block diagram of components of a computing device 100 in accordance with an exemplary embodiment of the present invention. Figure 1 is only intended to provide an example of one implementation and is not intended to imply any limitation with respect to the environments in which different embodiments may be implemented. Many modifications to the illustrated environment may be made.

[0013] Computing device 100 includes a communications fabric 102 that provides communication between cache 116, memory 106, persistent storage 108, communications unit 110, and input / output (I / O) interface(s) 112. Communications fabric 102 may be implemented by any architecture designed to pass data or control information, or both, between a processor (e.g., a microprocessor, communications and network processor, etc.), system memory, peripheral devices, and any other hardware components in the system. For example, communications fabric 102 may be implemented using one or more buses or crossbar switches.

[0014] Memory 106 and persistent storage 108 are computer readable storage media. In this embodiment, memory 106 includes random access memory (RAM). In general, memory 106 may include any suitable volatile or non-volatile computer readable storage medium. Cache 116 is a high-speed memory that improves performance of computer processor(s) 104 by holding recently accessed data and data near recently accessed data from memory 106.

[0015] Programs, applications, or other data, or a combination thereof, may be stored in persistent storage 108 and memory 406 for execution and / or access by one or more of the respective computer processors 104 via cache 116. In one embodiment, persistent storage 108 includes a magnetic hard disk drive. Alternatively, or in addition to a magnetic hard disk drive, persistent storage 108 may include a solid state hard drive, a semiconductor storage device, a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, or any other computer-readable storage medium capable of storing program instructions or digital information.

[0016] The media used by persistent storage 108 may also be removable. For example, a removable hard drive may be used as persistent storage 108. Other examples include optical and magnetic disks, thumb drives, and smart cards that are inserted into a drive for transfer to another computer-readable storage medium that is also part of persistent storage 108.

[0017] In these examples, the communications unit 110 provides for communication with other data processing systems or devices. In these examples, the communications unit 110 includes one or more network interface cards. The communications unit 110 may provide for communication through the use of either or both physical and wireless communications links. Programs, applications, or other data, or a combination thereof, may be downloaded to the persistent storage 108 through the communications unit 110.

[0018] The I / O interface(s) 112 allow for input and output of data with other devices that may be connected to the computing device 100. For example, the I / O interface 112 may provide a connection to an external device 118, such as a keyboard, a keypad, a touch screen, or any other suitable input device or combination thereof. The external device 118 may further include a portable computer-readable storage medium, such as, for example, a thumb drive, a portable optical or magnetic disk, and a memory card. Software and data used to implement embodiments of the present invention may be stored within such a portable computer-readable storage medium and loaded into the persistent storage 108 via the I / O interface(s) 112. The I / O interface(s) 112 also connects to a display 120.

[0019] Display 120 provides a mechanism for displaying data to a user and may be, for example, a computer monitor.

[0020] The programs described herein are identified based on the applications for which they are implemented in particular embodiments of the invention, but it should be understood that any particular program nomenclature herein is used merely for convenience, and thus the invention should not be limited to use in any particular application specified or implied, or both, by the nomenclature.

[0021] Figure 2 illustrates the same processor(s) 104 as shown in Figure 1, according to one embodiment of the present invention. The processor(s) 104 may be, for example, a graphics processing unit (GPU), an application specific instruction set processor (ASIP), a virtual processor (vCPU), a digital signal processor (DSP), an image processor, a physical processing unit (PPU), or a central processing unit for a computer, server, tablet, internet connected device, or phone.

[0022] In one embodiment, the processor(s) 104 may include a control unit 220, an arithmetic logic unit 230, and memory / registers 240. The control unit 220 of the processor(s) 104 controls the processor(s) 104 and controls which instructions are processed by the processor(s) 104. The control unit 220 may include a thread management process 222. The thread management process 222 may include rules for manipulating memory / registers 240, cache 116, memory 106, or persistent storage 108 occupied by objects not in use by any thread 232. The thread management process 222 may manage the threads 232 and any memory locations utilized by the threads 232 (e.g., memory / registers 240, cache 116, memory 106, persistent storage 108). Managing the threads 232 may include grouping the threads 232 together to form thread clusters 233. Using thread clusters 233, larger processes can be accomplished together.

[0023] The arithmetic logic unit 230 may include threads 232. The threads 232 may process tasks to be executed on the processor(s) 104. The threads 232 may be grouped into thread clusters 233 by the thread management process 222 or by the arithmetic logic unit 230. The threads 232 or thread clusters 233 may pop a task from memory (e.g., memory / registers 240) and process the task by duplicating objects from the task and modifying the object references. After processing the task, the threads 232 or thread clusters 233 create child tasks from the processed task according to the duplicated object references. The threads 232 or thread clusters 233 push the created child tasks to memory (e.g., memory / registers 240). After the threads 232 or thread clusters 233 push all created child tasks to memory (e.g., memory / registers 240), they pop the next task for processing.

[0024] The memory / registers 240 may include different sections, including queues 242. The queues 242 may be divided into different sections that may be accessed by different threads 232 or thread clusters 233.

[0025] The term object refers to a data structure represented in the memory of a computer system. Other terms that are sometimes used for the same concept are record and structure. An object can be identified by a reference, which is a relatively small amount of information that can be used to access the object. A reference can be represented, for example, as a pointer or a machine address.

[0026] Programs running on a system such as computing device 100 with many processor(s) 104 dynamically create objects that are stored in a portion of memory called the heap. The heap is a shared memory that is managed by automatic garbage collection. The garbage collector has control and / or direct access and / or knowledge of addresses, classes, roots, and other such detailed information about objects created on computing device 100.

[0027] After an object is no longer needed, it may be necessary to reclaim the memory allocated to that object (e.g., memory / registers 240, cache 116, memory 106, persistent storage 108) to prevent the system from running out of memory as more temporary objects fill the heap. Such memory reclamation is called garbage collection (GC).

[0028] Garbage collectors work by reclaiming space that is no longer reachable. Statically allocated objects represented by a program's global variables are normally considered to be reachable throughout the life of the program. Such objects are not normally stored in the GC's managed memory space, but they may contain references to dynamically allocated objects stored in the GC's managed memory space, and such dynamically allocated objects are also considered to be reachable. Objects referenced in the call stack of an execution thread are reachable, as are objects referenced by register contents. Furthermore, objects referenced by any reachable object are also reachable.

[0029] The use of an automatic garbage collector is advantageous because a programmer working on a particular sequence of code can reliably perform his task for the most part only with local knowledge of the application at any given time, whereas memory allocation and reclamation requires global knowledge of the program. Specifically, while it is easy for a programmer working on a given sequence of code to know if a piece of memory is still in use by that sequence of code, it is much harder for them to know what the rest of the application is doing with that memory. An automatic garbage collector systematically obtains global knowledge by tracking references from some idea of ​​a root set (e.g., global variables, registers, and the call stack). By using a garbage collector, the programmer is freed from having to worry about the global state of the application and can focus on more manageable local state issues.

[0030] An object is considered reachable if it is referenced by any reference in the roots. The root set includes, for example, reference values ​​stored in the call stacks of mutator threads, memory / registers 240, and global variables excluding the garbage-collected heap. An object is also considered reachable if it is referenced by other reachable objects. Objects that are not reachable no longer affect the program, and therefore it is safe to reallocate the memory space these objects occupy.

[0031] One approach to garbage collection is to identify all reachable objects and reclaim any previously allocated memory not occupied by reachable objects. The GC can identify reachable objects by tracking the objects pointed to from the roots, tracking the objects pointed to from those reachable objects, and so on, until all referenced or pointed to objects have been found and retained. Thus, the last object found will have no pointers to other untracked objects. In this way, the unreachable objects are effectively discarded and the associated memory space is made available for other uses.

[0032] Figure 3 shows an example of objects reachable by a concurrent garbage collection process such as G1GC, and the types of objects identified as the marking process takes place. The illustrated example shows the marking process over a period of time. During the garbage collection process, there are three categories of objects: (i) objects that have not yet been marked (see unshaded objects 301-304), (ii) objects that have been marked but whose direct children (i.e., reference objects) have not been marked (see objects 301 and 302 shaded with a first pattern), and (iii) objects that have been marked and whose direct children have also been marked (see objects 301-304 shaded with a second pattern).

[0033] In this example, initially, none of the objects 301-304 are marked, which is indicated in FIG. 3 by the initial lack of shading on any of the objects 301-304.

[0034] The first operation of concurrent marking for a garbage collector such as G1GC is a root scan. A root scan requires a stop-the-world. A stop-the-world garbage collector completely stops program execution to perform a collection cycle, thus ensuring that no new objects are allocated and objects do not suddenly become unreachable while the collector is running. A concurrent garbage collector such as G1GC does not generally stop program execution except temporarily when the program's execution stack is scanned. More specifically, in the present example, to shorten the stop-the-world pause, a GC thread (e.g., thread 232) sets a bit for root objects in a bitmap. However, because pushing a root object such as root object 301 to a GC thread can be slow, G1GC avoids pushing root objects during the root scan phase. In the embodiment shown in FIG. 3, a GC thread (e.g., thread 232) sets a bit for root object 301 in a bitmap during a root scan. As discussed above, this bit indicates that root object 301 is marked, but the direct children of root object 301 (i.e., the reference objects) are not marked. Objects 302 and 303 are direct children of root object 301. As shown, reference object 301 is shaded with a first pattern, while objects 302-304 remain unshaded.

[0035] Then, during the marking phase, a GC thread (e.g., thread 232) identifies the marked bits in the bitmap and finds the corresponding objects from the marked bits. In the example of FIG. 3, the marked bits (not shown) correspond to object 301 when shaded with a first pattern. When the GC thread finds such an object, it scans the reference objects and sets the corresponding bits in the bitmap. In the illustrated example, the end result of this operation is that object 301 is shaded with a second pattern to indicate that object 301 is marked and that the direct children of object 301 are also marked. Furthermore, objects 302 and 303 are marked in the bitmap. As shown in FIG. 3, object 302 has unmarked children and is shaded with the first pattern, while object 303 has no unmarked children and is shaded with the second pattern. Thus, embodiments of the present invention recognize that two processes (i.e., the root scanning phase and the marking phase) may provide two meanings of a bit in a bitmap: (i) an object is marked, but its direct children are not yet marked (corresponding to the first pattern, see above), and (ii) an object is marked and its direct children are also marked (corresponding to the second pattern, see above).

[0036] As explained in more detail in connection with Figure 4 (see below), the G1GC using finger pointers is used to distinguish between the two possible meanings of a marked bit on the bitmap. As the marking phase progresses, eventually all objects and their direct children are scanned and marked, and the marking phase is complete. As shown in the example of Figure 3, upon completion of the marking phase, all objects are shaded with a second pattern, indicating that each object and each object's direct children have been marked.

[0037] FIG. 4 illustrates an exemplary bitmap 400 similar to the bitmap described in connection with FIG. 3. Bitmap 400 is depicted at two time instances. First, bitmap 400-1 is a depiction of bitmap 400 after an initial marking phase performed by G1GC during the process of root scanning, as previously described. Each of the marked bits 420 corresponds to a root object. Thus, during the marking phase, G1GC checks each marked bit, finds the corresponding object, scans the reference objects, and sets any additional corresponding bits in the bitmap, as previously described in connection with FIG. 3. A finger pointer 410 is used to distinguish between the two meanings of the bits, as previously described in connection with FIG. 3. Finger pointer 410 iterates through the marked bits, moving from one end of bitmap 400 (e.g., the beginning) to the other end of bitmap 400 (e.g., the end). In the illustrated example, the finger pointer moves from left to right. As shown, finger pointer 410 is at the beginning of bitmap 400-1 and moves to the right over time as shown in bitmap 400-2. Marked bits downstream of finger pointer 410 (e.g., in the illustrated embodiment, to the right of finger pointer 100 as finger pointer 100 moves to the right) are bits that still require a GC thread (e.g., thread 232) to check the bit during the marking phase. Marked bits downstream of finger pointer 410, such as marked bit 420, correspond to objects that have been marked but whose direct children have not yet been marked (see the first shaded object in FIG. 3). In general, marked bits upstream of a finger pointer (i.e., where finger pointer 410 has already passed), such as marked bit 430, correspond to objects that (i) have been marked and (ii) whose direct children are marked.However, during the marking phase, it is possible that a GC thread (e.g., thread 232) may identify a reference object that is upstream of a finger pointer (e.g., finger pointer 410) and corresponds to a bit in the bitmap that is marked but whose direct children are not marked. How a GC thread (e.g., thread 232) handles such a situation during the marking phase will be described below with reference to FIG. 5. When a marked bit, such as marked bit 420, is picked up by a GC thread (e.g., thread 232), finger pointer 410 moves to a location before the next marked bit. For example, the GC thread may move finger pointer 410 to a location before the next marked bit. When finger pointer 410 moves to the end of the bitmap, the marking phase is complete.

[0038] FIG. 5 illustrates a flowchart 500 showing the operation of a first GC thread, such as thread 232, operating in a garbage collector described herein. More specifically, flowchart 500 describes the operations performed by the first GC thread during an iteration of the marking phase of a G1 type garbage collector. Once the operations described in flowchart 500 are completed, the operations are performed again until no tasks remain in the queue of the first GC thread. The current flowchart description corresponds to an individual GC thread, thread 232, described herein as the first GC thread. However, multiple GC threads, such as thread 232, can simultaneously perform the operations described herein. Each of threads 232 owns a queue and processes tasks on a work-stealing mechanism. When an individual thread 232 becomes empty, the individual thread 232 attempts to steal tasks from the queues of other threads. Embodiments of the present invention describe an approach whereby work stealing, in conjunction with finger pointers 410, can prevent load imbalance by allowing thief threads to have enough stealable tasks.

[0039] The first GC thread pops a task from the first GC thread's queue (505). The popped task corresponds to an object marked in bitmap 400 that is to be scanned (see 530).

[0040] The first GC thread records the remaining tasks (510). More specifically, the first GC thread records the tasks that remain in the first GC thread's queue after the tasks are popped (see 505).

[0041] The first GC thread calculates the difference from the previous number of remaining tasks (i.e., the number of remaining tasks when the previous tasks were popped in the previous iteration) and records the difference as the reduction ratio (515). The reduction ratio is the number of tasks reduced per unit time. The reduction ratio indicates how often other GC threads steal work from the first GC thread due to the work-stealing mechanism of the garbage collection process. A small reduction ratio indicates little work stealing, and a large reduction ratio indicates that work stealing is occurring more frequently.

[0042] The first GC thread determines whether the reduction rate meets or exceeds a first threshold number. The first threshold is a predefined parameter that can be modified. For example, the first threshold can be 8. In such an example, the first GC thread will determine that the calculated reduction rate (see 515) meets or exceeds the first threshold if it is 8 or more tasks. An administrative user can set the first threshold based on the hardware, software, or workload requirements of the computing device 100, or a combination thereof. In general, various factors can be considered when setting the first threshold, such as, for example, the type of CPU, the type of workload typically running on the system, etc.

[0043] If the first GC thread determines that the reduction rate is less than the first threshold number (520, no branch), the first GC thread scans the popped object and obtains existing reference objects (see 530).

[0044] If the first GC thread determines that the reduction rate meets or exceeds the first threshold number (520, yes branch), the first GC thread increases the second threshold number (525). The second threshold number is also a predefined parameter that can be changed. For example, the initial value of the second threshold number can be 2. An administrative user can set the initial value of the second threshold number. The second threshold number represents whether the number of remaining tasks in the queue of the first GC thread is considered to be low. If the number of remaining tasks in the queue of the first GC thread meets or is less than the second threshold, the number of remaining tasks in the queue of the first GC thread is considered to be low for purposes of an embodiment of the present invention. If the number of remaining tasks in the queue of the first GC thread is more than the second threshold, the number of remaining tasks in the queue of the first GC thread is not considered to be low. The amount by which the first GC thread increases the second threshold can be a predefined number. For example, in each iteration, the first GC thread may increase the second threshold by 1 after determining that the reduction rate meets or exceeds the first threshold number (520, yes branch).

[0045] The first GC thread scans the popped object and retrieves any existing reference objects (530). Each identified reference object can create a child task from the processing task of scanning the popped object by following the popped object's references. As described above in connection with Figures 3-4, during the marking phase, the GC thread scans the objects marked in the bitmap 400 and identifies the reference objects. For example, if the first GC thread scanned object 302 in Figure 3, the first GC thread would retrieve reference object 304. If the first GC thread pops the object and identifies that there are no existing reference objects, the iteration is complete and the first GC thread pops another task or, if the queue is empty, attempts to steal a task from another GC thread. Assuming that the first GC thread identifies at least one reference object from the popped object, the first GC thread proceeds to operation 535.

[0046] The first GC thread marks the bitmap 400 with a compare and swap (CAS) for the first reference object identified from the scanned popped object (535). CAS is an atomic instruction used to achieve synchronization in multithreading. CAS compares the contents of a memory location with a given value and modifies the contents of the memory location to a new given value only if they are the same. CAS is a single atomic operation that ensures that the new value is calculated based on the latest information. If another thread has updated the value in the meantime, the write will fail. The result of this operation should indicate whether the operation performed is a replacement, which can be done by a Boolean response or by returning the value read from the memory location. The identified first reference object can correspond to a bit located either upstream or downstream of the location of the finger pointer 410 on the bitmap 400.

[0047] The first GC thread determines whether the CAS was successful (540). The first GC thread determines whether the CAS was successful based on whether an attempt to write to the bitmap to generate a marked bit corresponding to the first reference object was successful or unsuccessful. If the write attempt was successful, the CAS was successful. If the write attempt was unsuccessful, the CAS was unsuccessful.

[0048] If the first GC thread determines that the CAS failed (540, no branch), the first GC thread determines whether any additional referenced objects exist (see 560).

[0049] If the first GC thread determines that the CAS was successful (540, yes branch), the first GC thread determines whether the number of remaining tasks is at or less than a second threshold (545). The first GC thread previously recorded the remaining tasks (see 510). Thus, the first GC thread can determine whether the number of remaining tasks is at or less than the second threshold by comparing the recorded number of remaining tasks to the second threshold.

[0050] If the number of remaining tasks is greater than the second threshold (545, no branch), the first GC thread will push the reference object's task onto the first GC thread's queue (550) if the reference object corresponds to a marked bit in bitmap 400 that is upstream of the finger pointer (i.e., a location in the path that the finger pointer has moved towards and therefore has already passed). If the number of remaining tasks is greater than the second threshold, the first GC thread will not push the reference object's task onto the first GC thread's queue if the reference object corresponds to a marked bit downstream of finger pointer 410 (i.e., a location in the path that the finger pointer is moving towards but has not yet passed).

[0051] If the number of remaining tasks is at or below the second threshold (545, yes branch), the first GC thread pushes the reference object task to the first GC thread's queue (555). When the number of remaining tasks is at or below the second threshold, the first GC thread will push the reference object task regardless of the location of the corresponding marked bit in bitmap 400. When the number of remaining tasks is at or below the second threshold, the first GC thread will push the reference object to the first GC thread if the marked bit is located upstream or downstream of finger pointer 410.

[0052] The first GC thread determines (560) whether any additional reference objects identified during the scan remain.

[0053] If the first GC thread determines that additional reference objects exist (560, yes branch), the first GC thread attempts to mark the bitmap 400 for one of the additional reference objects (see 535).

[0054] If the first GC thread determines that there are no more additional reference objects, the iteration is complete. If there are any tasks remaining in the first GC thread's queue, the next iteration will be performed. If there are no more tasks in the first GC thread's queue, the first GC thread can attempt to steal a task from another GC thread.

[0055] An embodiment of the present invention recognizes that the described approach can allow for the presence of increased stealable tasks, which helps with load imbalance issues. An embodiment of the present invention further recognizes that while pushing tasks downstream of the finger pointer may result in additional scans for those pushed tasks as described herein, such an approach pays the small overhead of additional scans for the benefit of load balancing. In contrast to other approaches to load balancing, the small overhead of the possible additional scans does not require any additional memory fences or CAS. Furthermore, since the GC thread inherently counts the remaining tasks whenever the GC thread pops a task, there is no additional overhead associated with checking the remaining tasks in the GC thread queue.

[0056] The present invention may be embodied as a system, method, or computer program product, or combination thereof, at any possible level of technical detail. The computer program product may include a computer readable storage medium or media having computer readable program instructions for causing a processor to perform aspects of the present invention.

[0057] A computer readable storage medium may be any tangible device capable of holding and storing instructions for use by an instruction execution device. A computer readable storage medium may be, for example, but not limited to, an electronic storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the above. A non-exhaustive list of more specific examples of computer readable storage media includes the following: portable computer diskettes, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), static random access memory (SRAM), portable compact disk read-only memory (CD-ROM), digital versatile disk (DVD), memory sticks, floppy disks, mechanically encoded devices such as punch cards or ridge structures in grooves having instructions recorded thereon, and any suitable combination of the above. As used herein, a computer-readable storage medium is not to be construed as a transitory signal per se, such as an electric wave or other freely propagating electromagnetic wave, an electromagnetic wave propagating through a waveguide or other transmission medium (e.g., light pulses through a fiber optic cable), or an electrical signal sent through a wire.

[0058] The computer readable program instructions described herein may be downloaded from a computer readable storage medium to each computing / processing device or to an external computer or storage device over a network, such as the Internet, a local area network, a wide area network, or a wireless network, or a combination thereof. The network may include copper transmission cables, optical transmission fiber, wireless transmission, routers, firewalls, switches, gateway computers, or edge servers, or a combination thereof. A network adapter card or network interface in each computing / processing device receives the computer readable program instructions from the network and transfers the computer readable program instructions for storage in a computer readable storage medium in the respective computing / processing device.

[0059] The computer readable program instructions for carrying out the operations of the present invention may be assembler instructions, instruction set architecture (ISA) instructions, machine instructions, machine dependent instructions, microcode, firmware instructions, state setting data, configuration data for an integrated circuit, or source or object code written in any combination of one or more programming languages, including object oriented programming languages ​​such as Smalltalk, C++, and traditional procedural programming languages ​​such as the "C" programming language or similar programming languages. The computer readable program instructions may be executed entirely on the user's computer, partly on the user's computer as a stand-alone software package, partly on the user's computer and partly on a remote computer, or entirely on a remote computer or server. In the last scenario, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet Service Provider). In some embodiments, electronic circuitry including, for example, a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA) can execute computer readable program instructions to individualize the electronic circuitry by utilizing state information of the computer readable program instructions to perform aspects of the invention.

[0060] Aspects of the present invention are described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer readable program instructions.

[0061] These computer readable program instructions may be provided to a processor of a computer or other programmable data processing apparatus to produce a machine, whereby the instructions executed by the processor of the computer or other programmable data processing apparatus create means for performing the functions / operations specified in one or more blocks of the flowcharts or block diagrams, or both. These computer program instructions, which may direct a computer, programmable data processing apparatus, or other device, or combination thereof, to function in a particular manner, may also be stored in a computer readable medium, whereby the instructions stored in the computer readable medium may comprise an article of manufacture including instructions implementing aspects of the functions / operations specified in one or more blocks of the flowcharts or block diagrams, or both.

[0062] The computer readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device to cause a series of operational steps to be performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, such that the instructions executing on the computer or other programmable apparatus provide a process for performing the functions / operations specified in one or more blocks of the flowcharts or block diagrams or both.

[0063] The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in the flowcharts may represent a module, segment, or portion of code, including one or more executable instructions for implementing the specified logical functions. In some alternative implementations, the functions shown in the blocks may occur in a different order than that shown in the figures. For example, two blocks shown in succession may in fact be executed substantially simultaneously, or these blocks may sometimes be executed in the reverse order, depending on the functionality involved. It should also be noted that each block of the block diagrams and / or flowchart illustrations, and combinations of blocks in the block diagrams and / or flowchart illustrations, may be implemented by a dedicated hardware-based system that executes the specified functions or operations, or executes a combination of dedicated hardware and computer instructions.

[0064] The description of various embodiments of the present disclosure has been presented for illustrative purposes, but they are not intended to be exhaustive or limited to the disclosed embodiments. Many modifications and variations will be apparent to those skilled in the art without departing from the scope of the described embodiments. The terms used in this specification have been selected to best explain the principles of the embodiments, practical applications, or technical improvements over the art found in the market, or to enable those skilled in the art to understand the embodiments disclosed herein.

Claims

1. popping a first task from a garbage collection thread queue; identifying a second task from the popped first task, the second task being associated with a bit of a bitmap; the bit is located at a location in the bitmap that has not yet been passed by the finger pointer; Identifying a second task; pushing the second task onto the queue of the garbage collection thread; A computer-implemented method comprising:

2. determining that a first number of tasks in the queue of the garbage collection thread is equal to or less than a first threshold number of tasks; pushing the second task onto the queue of the garbage collection thread is in response to determining that the number of the first tasks in the queue of the garbage collection thread is equal to or less than the first threshold number of tasks.

2. The computer-implemented method of claim 1.

3. (i) calculating a difference between a number of the first tasks in the queue of the garbage collection thread after popping the first task and (ii) a number of a second task in the queue of the garbage collection thread after popping a task prior to popping the first task; determining that the difference meets or exceeds a second threshold number of tasks; increasing the first threshold number of tasks in response to the difference meeting or exceeding the second threshold number of tasks; and The computer-implemented method of claim 2 , further comprising:

4. 2. The computer-implemented method of claim 1, wherein the first task is associated with a first object and the second task is associated with the second object by a reference to the second object in the first object.

5. 2. The computer-implemented method of claim 1, further comprising marking the bit in the bitmap based on identifying the second task from the popped first task.

6. 2. The computer-implemented method of claim 1, wherein the garbage collection thread is one of multiple garbage collection threads operating simultaneously.

7. 2. The computer-implemented method of claim 1, wherein the garbage collection thread is of a garbage-first garbage collector (G1GC).

8. popping a first task from a garbage collection thread queue; identifying a second task and a third task from the popped first task; the second task is associated with a first bit of a bitmap; the first bit is located at a first location in the bitmap that has not yet been passed by a finger pointer; the third task is associated with a second bit of the bitmap; the second bit is located at a second location in the bitmap that the finger pointer has passed through; identifying a second task and a third task; pushing the third task onto the queue of the garbage collection thread; determining whether a first number of tasks in the queue of the garbage collection thread is equal to or less than a first threshold number of tasks; A computer-implemented method comprising:

9. 9. The computer-implemented method of claim 8, further comprising: in response to determining that the number of the first tasks in the queue of the garbage collection thread is equal to or less than the first threshold number of tasks, pushing the second task onto the queue of the garbage collection thread.

10. A computer program comprising computer readable program instructions causing a computer to carry out a method according to any one of claims 1 to 9.

11. 11. A computer readable storage medium having stored thereon the computer program product of claim 10.

12. 1. A computer system including one or more computer processors including one or more threads, one or more computer readable storage media, and program instructions collectively stored on the one or more computer readable storage media for execution by at least one of the one or more computer processors, comprising: The program instructions include: program instructions for popping a first task from a queue of a garbage collection thread; program instructions for identifying a second task from the popped first task, the program instructions comprising: the second task being associated with a bit of a bitmap; the bit is located at a location in the bitmap that has not yet been passed by the finger pointer; Program instructions; program instructions for pushing the second task onto the queue of the garbage collection thread; Including, Computer system.

13. further comprising program instructions collectively stored on the one or more computer readable storage media for execution by at least one of the one or more computer processors for determining that a first number of tasks in the queue of the garbage collection thread is equal to or less than a first threshold number of tasks; and program instructions for pushing the second task onto the queue of the garbage collection thread responsive to determining that the number of the first tasks in the queue of the garbage collection thread is equal to or less than the first threshold number of tasks.

13. The computer system of claim 12.

14. program instructions collectively stored on the one or more computer readable storage media for execution by at least one of the one or more computer processors for calculating a difference between (i) a number of the first tasks in the queue of the garbage collection thread after popping the first task and (ii) a number of a second task in the queue of the garbage collection thread after popping a task prior to popping the first task; program instructions collectively stored on the one or more computer readable storage media for execution by at least one of the one or more computer processors for determining when the difference meets or exceeds a second threshold number of tasks; and program instructions collectively stored on the one or more computer readable storage media for execution by at least one of the one or more computer processors for increasing the first threshold number of tasks in response to the difference meeting or exceeding the second threshold number of tasks; 14. The computer system of claim 13, further comprising:

15. 13. The computer system of claim 12, wherein the first task is associated with a first object and the second task is associated with the second object by a reference to the second object in the first object.

16. 13. The computer system of claim 12, further comprising: program instructions collectively stored on the one or more computer readable storage media for execution by at least one of the one or more computer processors for marking the bit of the bitmap based on identifying the second task from the popped first task.

17. 13. The computer system of claim 12, wherein the garbage collection thread is one of a plurality of garbage collection threads operating simultaneously.

18. 13. The computer system of claim 12, wherein the garbage collection thread is of a garbage-first garbage collector (G1GC).

Citation Information

Patent Citations

  • Modified JVM with multi-tenant application domain and memory management

    JP2015519646A