US20200026581A1 - Optimizing accesses to read-mostly volatile variables - Google Patents
Optimizing accesses to read-mostly volatile variables Download PDFInfo
- Publication number
- US20200026581A1 US20200026581A1 US16/038,557 US201816038557A US2020026581A1 US 20200026581 A1 US20200026581 A1 US 20200026581A1 US 201816038557 A US201816038557 A US 201816038557A US 2020026581 A1 US2020026581 A1 US 2020026581A1
- Authority
- US
- United States
- Prior art keywords
- read
- computer
- mostly
- stw
- variable
- 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.)
- Granted
Links
- 230000015654 memory Effects 0.000 claims abstract description 62
- 238000000034 method Methods 0.000 claims abstract description 43
- 239000003471 mutagenic agent Substances 0.000 claims abstract description 23
- 238000004590 computer program Methods 0.000 claims abstract description 18
- 238000003860 storage Methods 0.000 claims description 18
- 238000005457 optimization Methods 0.000 claims description 9
- 238000010586 diagram Methods 0.000 description 20
- 230000004888 barrier function Effects 0.000 description 9
- 230000006870 function Effects 0.000 description 7
- 230000005540 biological transmission Effects 0.000 description 4
- 230000008901 benefit Effects 0.000 description 3
- 238000004891 communication Methods 0.000 description 3
- 230000003287 optical effect Effects 0.000 description 3
- 238000003491 array Methods 0.000 description 2
- 230000008859 change Effects 0.000 description 2
- 230000002093 peripheral effect Effects 0.000 description 2
- 230000001902 propagating effect Effects 0.000 description 2
- RYGMFSIKBFXOCR-UHFFFAOYSA-N Copper Chemical compound [Cu] RYGMFSIKBFXOCR-UHFFFAOYSA-N 0.000 description 1
- 229910052802 copper Inorganic materials 0.000 description 1
- 239000010949 copper Substances 0.000 description 1
- 230000001419 dependent effect Effects 0.000 description 1
- 230000001627 detrimental effect Effects 0.000 description 1
- 239000000835 fiber Substances 0.000 description 1
- 230000010354 integration Effects 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
- 230000007246 mechanism Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000008569 process Effects 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
- 230000003068 static effect Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR 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/52—Program synchronisation; Mutual exclusion, e.g. by means of semaphores
- G06F9/526—Mutual exclusion algorithms
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
- G06F8/45—Exploiting coarse grain parallelism in compilation, i.e. parallelism between groups of instructions
- G06F8/458—Synchronisation, e.g. post-wait, barriers, locks
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/30—Creation or generation of source code
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
- G06F8/44—Encoding
- G06F8/443—Optimisation
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR 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/30—Arrangements for executing machine instructions, e.g. instruction decode
- G06F9/38—Concurrent instruction execution, e.g. pipeline or look ahead
- G06F9/3836—Instruction issuing, e.g. dynamic instruction scheduling or out of order instruction execution
- G06F9/3851—Instruction issuing, e.g. dynamic instruction scheduling or out of order instruction execution from multiple instruction streams, e.g. multistreaming
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR 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/45504—Abstract machines for programme code execution, e.g. Java virtual machine [JVM], interpreters, emulators
- G06F9/45516—Runtime code conversion or optimisation
- G06F9/4552—Involving translation to a different instruction set architecture, e.g. just-in-time translation in a JVM
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR 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
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR 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/52—Program synchronisation; Mutual exclusion, e.g. by means of semaphores
- G06F9/522—Barrier synchronisation
Definitions
- the present invention generally relates to memory devices, and more particularly to optimizing accesses to read-mostly volatile variables.
- a memory barrier also known as a memory fence, is a type of barrier instruction that causes a processor or compiler to enforce an ordering constraint on memory operations issued before and after the barrier instruction. Essentially this means that operations issued prior to the memory barrier are guaranteed to be performed before operations issued after the barrier.
- a computer-implemented method for eliminating a memory fence for reading a read-mostly volatile variable of a computer system.
- the read-mostly variable is read from more than written to.
- the method includes writing data to the read-mostly volatile variable only during a Stop-The-World (STW) state of the computer system.
- the method further includes executing the memory fence in any mutator threads and thereafter exiting the STW state.
- the method also includes reading the read-mostly volatile variable by the mutator threads without executing the memory fence after the STW state.
- STW Stop-The-World
- a computer program product for eliminating a memory fence for reading a read-mostly volatile variable of a computer system.
- the read-mostly variable is read from more than written to.
- the computer program product includes a non-transitory computer readable storage medium having program instructions embodied therewith.
- the program instructions are executable by a computer to cause the computer to perform a method.
- the method includes writing data to the read-mostly volatile variable only during a Stop-The-World (STW) state of the computer system.
- the method further includes executing the memory fence in any mutator threads and thereafter exiting the STW state.
- the method also includes reading the read-mostly volatile variable by the mutator threads without executing the memory fence after the STW state.
- a computer processing system for eliminating a memory fence for reading a read-mostly volatile variable of the computer processing system.
- the read-mostly variable is read from more than written to.
- the computer processing system includes a virtual machine, having a memory operatively coupled to a processing element, and being configured to write data to the read-mostly volatile variable only during a Stop-The-World (STW) state of the computer system.
- STW Stop-The-World
- the virtual machine is further configured to execute the memory fence in any mutator threads and thereafter exiting the STW state.
- the virtual machine is also configured to read the read-mostly volatile variable by the mutator threads without executing the memory fence after the STW state.
- FIG. 1 is a block diagram showing an exemplary processing system to which the present invention may be applied, in accordance with an embodiment of the present invention
- FIG. 2 is a flow diagram showing an exemplary method for optimizing accesses to a read-mostly volatile variable of a computer system, in accordance with an embodiment of the present invention
- FIG. 3 is a flow diagram showing an exemplary method for enabling optimization of accesses to a read-mostly volatile memory, in accordance with an embodiment of the present invention
- FIG. 4 is a diagram showing an exemplary original Java® program to which the present invention can be applied, in accordance with an embodiment of the present invention.
- FIG. 5 is a diagram showing an exemplary Java® program modified by application of the present invention, in accordance with an embodiment of the present invention.
- the present invention is directed to optimizing accesses to read-mostly volatile variables.
- read-mostly volatile variables refers to volatile variables that are read from more than they are written to (reads from >writes to), hence the descriptor “read-mostly”.
- the present invention eliminates memory fences for reading read-mostly volatile variables by only modifying them during a Stop-The-World (STW) period of a stop-the-world garbage collector.
- STW garbage collector completely halts execution of a computer program to run a collection cycle, thus guaranteeing that new objects are not allocated, and objects do not suddenly become unreachable while the STW garbage collector is running.
- GC STW Garbage Collection
- the present invention lets STW GC update the read-mostly volatile variables, so that a reader of the variables can access them without a memory barrier.
- an Application Programming Interface is added in the GC, and a new annotation is added for the JT compiler to limit instruction reordering so as not to move instructions across GC safe points.
- FIG. 1 is a block diagram showing an exemplary processing system 100 to which the present invention may be applied, in accordance with an embodiment of the present invention.
- the processing system 100 includes a set of processing units (CPUs) 101 , a set of GPUs 102 , a set of memory devices 103 , a set of communication devices 104 , and set of peripherals 105 .
- the CPUs 101 can be single or multi-core CPUs.
- the GPUs 102 can be single or multi-core GPUs.
- the one or more memory devices 103 can include caches, RAMs, ROMs, and other memories (flash, optical, magnetic, etc.). RAMs and ROMs can be considered as non-cache memories for the purposes of the present invention.
- the communication devices 104 can include wireless and/or wired communication devices (e.g., network (e.g., WIFI, etc.) adapters, etc.).
- the peripherals 105 can include a display device, a user input device, a printer, and so forth.
- Elements of processing system 100 are connected by one or more buses or networks (collectively denoted by the figure reference numeral 110 ).
- Elements of processing system 100 such as the memory devices 103 and/or processing elements ( 101 and/or 102 ) can form one or more Virtual Machines (VMs) for implementing various aspect of the present invention.
- VMs Virtual Machines
- processing system 100 may also include other elements (not shown), as readily contemplated by one of skill in the art, as well as omit certain elements.
- various other input devices and/or output devices can be included in processing system 100 , depending upon the particular implementation of the same, as readily understood by one of ordinary skill in the art.
- various types of wireless and/or wired input and/or output devices can be used.
- additional processors, controllers, memories, and so forth, in various configurations can also be utilized as readily appreciated by one of ordinary skill in the art.
- FIG. 2 is a flow diagram showing an exemplary method 200 for optimizing accesses to a read-mostly volatile variable of a computer system, in accordance with an embodiment of the present invention.
- Method 200 optimizes the accesses to the read-mostly volatile variable by eliminating a memory fence for reading the read-mostly volatile variable.
- a read-mostly volatile variable is a volatile variable that is read from more than it is written to.
- Block 210 stop any mutator threads to enter a Stop-The-World (STW) state of the computer system.
- Block 210 is performed to prevent the mutator threads from modifying the read-mostly volatile variable during the STW state.
- STW Stop-The-World
- the present invention is not limited to any particular method for identifying read-mostly volatile variables.
- existing techniques including, but not limited to the following, can be used to identify read-mostly volatile variables: profiling; explicitly adding annotations by programmers; and so forth.
- the present invention can be efficiently implemented by adding an API into the GC to modify the read-mostly volatile variable during the STW state because the GC already has a mechanism to request the STW state and to execute a memory fence when each thread resumes execution after completion of the STW state.
- a Java® Virtual Machine (JVM®) is modified to hold information to identify which fields are read-mostly volatile, so that the interpreter and the JIT compiler of the JVM® can use the information.
- JVM® Java® Virtual Machine
- the interpreter and the JIT compiler change the operation for accessing read-mostly volatile variables as follows:
- optimizations of the JIT compiler need to be disabled to ensure that the generated code reads the latest value of a read-mostly volatile variable from memory. These optimizations can include the following:
- FIG. 3 is a flow diagram showing an exemplary method 300 for enabling optimization of accesses to a read-mostly volatile memory, in accordance with an embodiment of the present invention.
- JVM® Java® Virtual Machine
- FIG. 4 is a diagram showing an exemplary original Java® program 400 to which the present invention can be applied, in accordance with an embodiment of the present invention.
- FIG. 5 is a diagram showing an exemplary Java® program 500 modified by application of the present invention, in accordance with an embodiment of the present invention.
- Java® program 500 is a version of Java® program 400 modified by an application of an embodiment of the present invention thereto.
- Java program 500 As can be seen in Java program 500 , relative to Java program 400 , Java program 500 now includes code directed to writing to the read-mostly volatile variable only during a STW state. In this way, the previous detrimental semantics of the Java memory model are overcome thereby reducing the significant overhead typically required to read volatile variables using a memory fence as per the prior art. This and other advantages of the present invention are readily determined by one of ordinary skill in the art, given the teachings of the present invention provided herein.
- the present invention may be a system, a method, and/or a computer program product at any possible technical detail level of integration
- the computer program product may include a computer readable storage medium (or media) having computer readable program instructions thereon for causing a processor to carry out aspects of the present invention
- the computer readable storage medium can be a tangible device that can retain and store instructions for use by an instruction execution device.
- the computer readable storage medium may be, for example, but is 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 foregoing.
- a non-exhaustive list of more specific examples of the computer readable storage medium includes the following: a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), a static random access memory (SRAM), a portable compact disc read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanically encoded device such as punch-cards or raised structures in a groove having instructions recorded thereon, and any suitable combination of the foregoing.
- RAM random access memory
- ROM read-only memory
- EPROM or Flash memory erasable programmable read-only memory
- SRAM static random access memory
- CD-ROM compact disc read-only memory
- DVD digital versatile disk
- memory stick a floppy disk
- a mechanically encoded device such as punch-cards or raised structures in a groove having instructions recorded thereon
- a computer readable storage medium is not to be construed as being transitory signals per se, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through a waveguide or other transmission media (e.g., light pulses passing through a fiber-optic cable), or electrical signals transmitted through a wire.
- Computer readable program instructions described herein can be downloaded to respective computing/processing devices from a computer readable storage medium or to an external computer or external storage device via a network, for example, the Internet, a local area network, a wide area network and/or a wireless network.
- the network may comprise copper transmission cables, optical transmission fibers, wireless transmission, routers, firewalls, switches, gateway computers and/or edge servers.
- a network adapter card or network interface in each computing/processing device receives computer readable program instructions from the network and forwards the computer readable program instructions for storage in a computer readable storage medium within the respective computing/processing device.
- Computer readable program instructions for carrying out 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, or either source code or object code written in any combination of one or more programming languages, including an object oriented programming language such as SMALLTALK, C++ or the like, and conventional procedural programming languages, such as the “C” programming language or similar programming languages.
- the computer readable program instructions may execute 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 the remote computer or server.
- the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet Service Provider).
- electronic circuitry including, for example, programmable logic circuitry, field-programmable gate arrays (FPGA), or programmable logic arrays (PLA) may execute the computer readable program instructions by utilizing state information of the computer readable program instructions to personalize the electronic circuitry, in order to perform aspects of the present invention.
- These computer readable program instructions may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions/acts specified in the flowchart and/or block diagram block or blocks.
- These computer readable program instructions may also be stored in a computer readable storage medium that can direct a computer, a programmable data processing apparatus, and/or other devices to function in a particular manner, such that the computer readable storage medium having instructions stored therein comprises an article of manufacture including instructions which implement aspects of the function/act specified in the flowchart and/or block diagram block or blocks.
- 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 apparatus or other device to produce a computer implemented process, such that the instructions which execute on the computer, other programmable apparatus, or other device implement the functions/acts specified in the flowchart and/or block diagram block or blocks.
- each block in the flowchart or block diagrams may represent a module, segment, or portion of instructions, which comprises one or more executable instructions for implementing the specified logical function(s).
- the functions noted in the blocks may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved.
- any of the following “/”, “and/or”, and “at least one of”, for example, in the cases of “A/B”, “A and/or B” and “at least one of A and B”, is intended to encompass the selection of the first listed option (A) only, or the selection of the second listed option (B) only, or the selection of both options (A and B).
- such phrasing is intended to encompass the selection of the first listed option (A) only, or the selection of the second listed option (B) only, or the selection of the third listed option (C) only, or the selection of the first and the second listed options (A and B) only, or the selection of the first and third listed options (A and C) only, or the selection of the second and third listed options (B and C) only, or the selection of all three options (A and B and C).
- This may be extended, as readily apparent by one of ordinary skill in this and related arts, for as many items listed.
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Multimedia (AREA)
- Devices For Executing Special Programs (AREA)
Abstract
Description
- The present invention generally relates to memory devices, and more particularly to optimizing accesses to read-mostly volatile variables.
- A memory barrier, also known as a memory fence, is a type of barrier instruction that causes a processor or compiler to enforce an ordering constraint on memory operations issued before and after the barrier instruction. Essentially this means that operations issued prior to the memory barrier are guaranteed to be performed before operations issued after the barrier.
- In the Java® memory model, accesses to volatile variables are used as a kind of memory barrier that controls the visibility of data in memory. For example, if a thread-A writes data to a volatile variable v and another thread-B reads the latest value of the volatile variable (=1), a Java® semantic guarantees that thread-B reads the latest values of all data written to memory by thread-A before it writes the data to the volatile variable v.
- The preceding semantic causes a large overhead on a POWER platform because reading volatile variables requires a memory fence. However, some volatile variables are rarely modified after they are initialized, and thus, memory fences are not needed in such cases. For example, java.lang.System.security holds a reference to the current security manager, and almost no program changes the security manager during execution. However, there is an Application Programming Interface (API) to change it, so the variable needs to be volatile. Since the API to get the current security manager (System.getSecurityManager( )) is frequently called, computer performance is detrimentally affected by the overhead of the memory fence.
- That is, in sum, some Java® volatile variables are rarely updated and mostly read from. However, accessing such variables still need a memory barrier because they are volatile, even though their values are almost runtime constants. Hence, there is a need for a way to safely remove memory barriers.
- According to an aspect of the present invention, a computer-implemented method is provided for eliminating a memory fence for reading a read-mostly volatile variable of a computer system. The read-mostly variable is read from more than written to. The method includes writing data to the read-mostly volatile variable only during a Stop-The-World (STW) state of the computer system. The method further includes executing the memory fence in any mutator threads and thereafter exiting the STW state. The method also includes reading the read-mostly volatile variable by the mutator threads without executing the memory fence after the STW state.
- According to another aspect of the present invention, a computer program product is provided for eliminating a memory fence for reading a read-mostly volatile variable of a computer system. The read-mostly variable is read from more than written to. The computer program product includes a non-transitory computer readable storage medium having program instructions embodied therewith. The program instructions are executable by a computer to cause the computer to perform a method. The method includes writing data to the read-mostly volatile variable only during a Stop-The-World (STW) state of the computer system. The method further includes executing the memory fence in any mutator threads and thereafter exiting the STW state. The method also includes reading the read-mostly volatile variable by the mutator threads without executing the memory fence after the STW state.
- According to yet another aspect of the present invention, a computer processing system is provided for eliminating a memory fence for reading a read-mostly volatile variable of the computer processing system. The read-mostly variable is read from more than written to. The computer processing system includes a virtual machine, having a memory operatively coupled to a processing element, and being configured to write data to the read-mostly volatile variable only during a Stop-The-World (STW) state of the computer system. The virtual machine is further configured to execute the memory fence in any mutator threads and thereafter exiting the STW state. The virtual machine is also configured to read the read-mostly volatile variable by the mutator threads without executing the memory fence after the STW state.
- These and other features and advantages will become apparent from the following detailed description of illustrative embodiments thereof, which is to be read in connection with the accompanying drawings.
- The following description will provide details of preferred embodiments with reference to the following figures wherein:
-
FIG. 1 is a block diagram showing an exemplary processing system to which the present invention may be applied, in accordance with an embodiment of the present invention; -
FIG. 2 is a flow diagram showing an exemplary method for optimizing accesses to a read-mostly volatile variable of a computer system, in accordance with an embodiment of the present invention; -
FIG. 3 is a flow diagram showing an exemplary method for enabling optimization of accesses to a read-mostly volatile memory, in accordance with an embodiment of the present invention; -
FIG. 4 is a diagram showing an exemplary original Java® program to which the present invention can be applied, in accordance with an embodiment of the present invention; and -
FIG. 5 is a diagram showing an exemplary Java® program modified by application of the present invention, in accordance with an embodiment of the present invention. - The present invention is directed to optimizing accesses to read-mostly volatile variables. As used herein, the term “read-mostly volatile variables” refers to volatile variables that are read from more than they are written to (reads from >writes to), hence the descriptor “read-mostly”.
- In an embodiment, the present invention eliminates memory fences for reading read-mostly volatile variables by only modifying them during a Stop-The-World (STW) period of a stop-the-world garbage collector. A STW garbage collector completely halts execution of a computer program to run a collection cycle, thus guaranteeing that new objects are not allocated, and objects do not suddenly become unreachable while the STW garbage collector is running. An advantage of STW Garbage Collection (GC) is that it is both simpler to implement and faster than incremental garbage collection.
- Hence, in an embodiment, the present invention lets STW GC update the read-mostly volatile variables, so that a reader of the variables can access them without a memory barrier. In an embodiment, an Application Programming Interface (API) is added in the GC, and a new annotation is added for the JT compiler to limit instruction reordering so as not to move instructions across GC safe points.
-
FIG. 1 is a block diagram showing anexemplary processing system 100 to which the present invention may be applied, in accordance with an embodiment of the present invention. Theprocessing system 100 includes a set of processing units (CPUs) 101, a set ofGPUs 102, a set ofmemory devices 103, a set ofcommunication devices 104, and set ofperipherals 105. TheCPUs 101 can be single or multi-core CPUs. TheGPUs 102 can be single or multi-core GPUs. The one ormore memory devices 103 can include caches, RAMs, ROMs, and other memories (flash, optical, magnetic, etc.). RAMs and ROMs can be considered as non-cache memories for the purposes of the present invention. Thecommunication devices 104 can include wireless and/or wired communication devices (e.g., network (e.g., WIFI, etc.) adapters, etc.). Theperipherals 105 can include a display device, a user input device, a printer, and so forth. Elements ofprocessing system 100 are connected by one or more buses or networks (collectively denoted by the figure reference numeral 110). Elements ofprocessing system 100 such as thememory devices 103 and/or processing elements (101 and/or 102) can form one or more Virtual Machines (VMs) for implementing various aspect of the present invention. - Of course, the
processing system 100 may also include other elements (not shown), as readily contemplated by one of skill in the art, as well as omit certain elements. For example, various other input devices and/or output devices can be included inprocessing system 100, depending upon the particular implementation of the same, as readily understood by one of ordinary skill in the art. For example, various types of wireless and/or wired input and/or output devices can be used. Moreover, additional processors, controllers, memories, and so forth, in various configurations can also be utilized as readily appreciated by one of ordinary skill in the art. These and other variations of theprocessing system 100 are readily contemplated by one of ordinary skill in the art given the teachings of the present invention provided herein. - Moreover, it is to be appreciated that various figures as described below with respect to various elements and steps relating to the present invention that may be implemented, in whole or in part, by one or more of the elements of
system 100. -
FIG. 2 is a flow diagram showing anexemplary method 200 for optimizing accesses to a read-mostly volatile variable of a computer system, in accordance with an embodiment of the present invention.Method 200 optimizes the accesses to the read-mostly volatile variable by eliminating a memory fence for reading the read-mostly volatile variable. As noted above, a read-mostly volatile variable is a volatile variable that is read from more than it is written to. - At
block 210, stop any mutator threads to enter a Stop-The-World (STW) state of the computer system.Block 210 is performed to prevent the mutator threads from modifying the read-mostly volatile variable during the STW state. - At
block 220, write data to the read-mostly volatile variable only during the STW state. - At
block 230, execute the memory fence in every mutator threads and then exit the STW state. - At
block 240, read the read-mostly volatile variable without executing a memory fence after the STW state. - It is to be appreciated that the present invention is not limited to any particular method for identifying read-mostly volatile variables. Hence, it is to be further appreciated that existing techniques including, but not limited to the following, can be used to identify read-mostly volatile variables: profiling; explicitly adding annotations by programmers; and so forth.
- In an embodiment, the present invention can be efficiently implemented by adding an API into the GC to modify the read-mostly volatile variable during the STW state because the GC already has a mechanism to request the STW state and to execute a memory fence when each thread resumes execution after completion of the STW state.
- In an embodiment, a Java® Virtual Machine (JVM®) is modified to hold information to identify which fields are read-mostly volatile, so that the interpreter and the JIT compiler of the JVM® can use the information.
- The interpreter and the JIT compiler change the operation for accessing read-mostly volatile variables as follows:
- (1) The bytecode handlers of putfield and getfield check if a field is read-mostly volatile. If so, then the putfield handler calls the added API, and the getfield handler reads the field without a memory fence.
- (2) The JIT compiler generates the code to call the API when a read-mostly volatile variable is modified.
- Some optimizations of the JIT compiler need to be disabled to ensure that the generated code reads the latest value of a read-mostly volatile variable from memory. These optimizations can include the following:
- (1) Never cache the value of read-mostly volatile variable but always read it from memory.
- (2) For reordering load instructions that appear after a load from the read-mostly volatile variable in program order, the compiler restricts the load instructions from being moved before a nearest GC safe point. That is, the compiler may move the load instruction just after nearest GC safe point, a few instructions after the nearest GC safe point, or leave it at the original location.
-
FIG. 3 is a flow diagram showing anexemplary method 300 for enabling optimization of accesses to a read-mostly volatile memory, in accordance with an embodiment of the present invention. - At
block 310, add an Application Programming Interface (API) into a STW GC to modify the read-mostly variable during a STW state. - At
block 320, modify a Java® Virtual Machine (JVM®) to hold information that identifies which fields are read-mostly, so that the interpreter and JIT compiler of the JVM® can use the information (to identify the read-mostly variable). - At
block 330, further modify the JVM® to have the interpreter and the JIT compiler use the following method to access the read-mostly variable: - (1) Configure bytecode handlers putfield and getfield to check if a field is read-mostly volatile; and
- (2) Configure the bytecode handler putfield to call the added API when a read-mostly variable is modified.
- At
block 340, still further modify the JVM® to disable one or more of the following JIT compiler optimizations: - (1) Never cache the value of read-mostly volatile variable but always read it from memory.
- (2) For reordering the load instructions that appear after the load from the read-mostly volatile variable in program order, the compiler restricts the load instructions from being moved before a nearest GC safe point. That is, the compiler may move the load instruction just after nearest GC safe point, a few instructions after the nearest GC safe point, or leave it at the original location.
-
FIG. 4 is a diagram showing an exemplary originalJava® program 400 to which the present invention can be applied, in accordance with an embodiment of the present invention. -
FIG. 5 is a diagram showing an exemplaryJava® program 500 modified by application of the present invention, in accordance with an embodiment of the present invention. In particular,Java® program 500 is a version ofJava® program 400 modified by an application of an embodiment of the present invention thereto. - As can be seen in
Java program 500, relative toJava program 400,Java program 500 now includes code directed to writing to the read-mostly volatile variable only during a STW state. In this way, the previous detrimental semantics of the Java memory model are overcome thereby reducing the significant overhead typically required to read volatile variables using a memory fence as per the prior art. This and other advantages of the present invention are readily determined by one of ordinary skill in the art, given the teachings of the present invention provided herein. - The present invention may be a system, a method, and/or a computer program product at any possible technical detail level of integration. The computer program product may include a computer readable storage medium (or media) having computer readable program instructions thereon for causing a processor to carry out aspects of the present invention.
- The computer readable storage medium can be a tangible device that can retain and store instructions for use by an instruction execution device. The computer readable storage medium may be, for example, but is 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 foregoing. A non-exhaustive list of more specific examples of the computer readable storage medium includes the following: a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), a static random access memory (SRAM), a portable compact disc read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanically encoded device such as punch-cards or raised structures in a groove having instructions recorded thereon, and any suitable combination of the foregoing. A computer readable storage medium, as used herein, is not to be construed as being transitory signals per se, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through a waveguide or other transmission media (e.g., light pulses passing through a fiber-optic cable), or electrical signals transmitted through a wire.
- Computer readable program instructions described herein can be downloaded to respective computing/processing devices from a computer readable storage medium or to an external computer or external storage device via a network, for example, the Internet, a local area network, a wide area network and/or a wireless network. The network may comprise copper transmission cables, optical transmission fibers, wireless transmission, routers, firewalls, switches, gateway computers and/or edge servers. A network adapter card or network interface in each computing/processing device receives computer readable program instructions from the network and forwards the computer readable program instructions for storage in a computer readable storage medium within the respective computing/processing device.
- Computer readable program instructions for carrying out 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, or either source code or object code written in any combination of one or more programming languages, including an object oriented programming language such as SMALLTALK, C++ or the like, and conventional procedural programming languages, such as the “C” programming language or similar programming languages. The computer readable program instructions may execute 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 the remote computer or server. In the latter scenario, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet Service Provider). In some embodiments, electronic circuitry including, for example, programmable logic circuitry, field-programmable gate arrays (FPGA), or programmable logic arrays (PLA) may execute the computer readable program instructions by utilizing state information of the computer readable program instructions to personalize the electronic circuitry, in order to perform aspects of the present invention.
- Aspects of the present invention are described herein 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.
- These computer readable program instructions may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions/acts specified in the flowchart and/or block diagram block or blocks. These computer readable program instructions may also be stored in a computer readable storage medium that can direct a computer, a programmable data processing apparatus, and/or other devices to function in a particular manner, such that the computer readable storage medium having instructions stored therein comprises an article of manufacture including instructions which implement aspects of the function/act specified in the flowchart and/or block diagram block or blocks.
- 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 apparatus or other device to produce a computer implemented process, such that the instructions which execute on the computer, other programmable apparatus, or other device implement the functions/acts specified in the flowchart and/or block diagram block or blocks.
- The flowchart 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 flowchart or block diagrams may represent a module, segment, or portion of instructions, which comprises one or more executable instructions for implementing the specified logical function(s). In some alternative implementations, the functions noted in the blocks may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems that perform the specified functions or acts or carry out combinations of special purpose hardware and computer instructions.
- Reference in the specification to “one embodiment” or “an embodiment” of the present invention, as well as other variations thereof, means that a particular feature, structure, characteristic, and so forth described in connection with the embodiment is included in at least one embodiment of the present invention. Thus, the appearances of the phrase “in one embodiment” or “in an embodiment”, as well any other variations, appearing in various places throughout the specification are not necessarily all referring to the same embodiment.
- It is to be appreciated that the use of any of the following “/”, “and/or”, and “at least one of”, for example, in the cases of “A/B”, “A and/or B” and “at least one of A and B”, is intended to encompass the selection of the first listed option (A) only, or the selection of the second listed option (B) only, or the selection of both options (A and B). As a further example, in the cases of “A, B, and/or C” and “at least one of A, B, and C”, such phrasing is intended to encompass the selection of the first listed option (A) only, or the selection of the second listed option (B) only, or the selection of the third listed option (C) only, or the selection of the first and the second listed options (A and B) only, or the selection of the first and third listed options (A and C) only, or the selection of the second and third listed options (B and C) only, or the selection of all three options (A and B and C). This may be extended, as readily apparent by one of ordinary skill in this and related arts, for as many items listed.
- Having described preferred embodiments of a system and method (which are intended to be illustrative and not limiting), it is noted that modifications and variations can be made by persons skilled in the art in light of the above teachings. It is therefore to be understood that changes may be made in the particular embodiments disclosed which are within the scope of the invention as outlined by the appended claims. Having thus described aspects of the invention, with the details and particularity required by the patent laws, what is claimed and desired protected by Letters Patent is set forth in the appended claims.
Claims (20)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
US16/038,557 US10528401B1 (en) | 2018-07-18 | 2018-07-18 | Optimizing accesses to read-mostly volatile variables |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
US16/038,557 US10528401B1 (en) | 2018-07-18 | 2018-07-18 | Optimizing accesses to read-mostly volatile variables |
Publications (2)
Publication Number | Publication Date |
---|---|
US10528401B1 US10528401B1 (en) | 2020-01-07 |
US20200026581A1 true US20200026581A1 (en) | 2020-01-23 |
Family
ID=69058571
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
US16/038,557 Expired - Fee Related US10528401B1 (en) | 2018-07-18 | 2018-07-18 | Optimizing accesses to read-mostly volatile variables |
Country Status (1)
Country | Link |
---|---|
US (1) | US10528401B1 (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20200110587A1 (en) * | 2018-10-04 | 2020-04-09 | Microsoft Technology Licensing, Llc | Memory ordering annotations for binary emulation |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US11449339B2 (en) * | 2019-09-27 | 2022-09-20 | Red Hat, Inc. | Memory barrier elision for multi-threaded workloads |
Family Cites Families (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6671707B1 (en) * | 1999-10-19 | 2003-12-30 | Intel Corporation | Method for practical concurrent copying garbage collection offering minimal thread block times |
US7818306B2 (en) | 2006-03-24 | 2010-10-19 | International Business Machines Corporation | Read-copy-update (RCU) operations with reduced memory barrier usage |
US20080082532A1 (en) | 2006-10-03 | 2008-04-03 | International Business Machines Corporation | Using Counter-Flip Acknowledge And Memory-Barrier Shoot-Down To Simplify Implementation of Read-Copy Update In Realtime Systems |
US9245371B2 (en) * | 2009-09-11 | 2016-01-26 | Nvidia Corporation | Global stores and atomic operations |
WO2014028871A1 (en) * | 2012-08-17 | 2014-02-20 | Twitter, Inc. | Search infrastructure |
US9880931B2 (en) * | 2015-10-15 | 2018-01-30 | Oracle International Corporation | Safepoints for guest languages on a virtual machine |
-
2018
- 2018-07-18 US US16/038,557 patent/US10528401B1/en not_active Expired - Fee Related
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20200110587A1 (en) * | 2018-10-04 | 2020-04-09 | Microsoft Technology Licensing, Llc | Memory ordering annotations for binary emulation |
US10884720B2 (en) * | 2018-10-04 | 2021-01-05 | Microsoft Technology Licensing, Llc | Memory ordering annotations for binary emulation |
Also Published As
Publication number | Publication date |
---|---|
US10528401B1 (en) | 2020-01-07 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US9665394B2 (en) | Sharing application objects among multiple tenants | |
US8543991B2 (en) | Profile driven multicore background compilation | |
KR20150141282A (en) | Method for sharing reference data among application programs executed by a plurality of virtual machines and Reference data management apparatus and system therefor | |
KR20200135718A (en) | Method, apparatus, device and storage medium for managing access request | |
US10528401B1 (en) | Optimizing accesses to read-mostly volatile variables | |
US9740597B2 (en) | Transactional execution of native methods | |
US9552223B2 (en) | Post-return asynchronous code execution | |
US9870240B2 (en) | Dynamic code injection | |
EP2511820A1 (en) | Bypassing user mode redirection | |
US20200065209A1 (en) | Performance of a system including a first processor and a second processor | |
US8856763B2 (en) | Compiler optimization based on collectivity analysis | |
US20190220294A1 (en) | Using lightweight jit compilation for short-lived jvms on parallel distributing computing framework | |
US11036528B2 (en) | Efficient profiling-based lock management in just-in-time compilers | |
US11662983B2 (en) | Bytecode verification using class relationship caching | |
US10379885B2 (en) | Enhanced local commoning | |
US20180047134A1 (en) | Automatically enabling a read-only cache in a language in which two arrays in two different variables may alias each other | |
US20190361805A1 (en) | Spin-less work-stealing for parallel copying garbage collection | |
US20190129846A1 (en) | Dynamic Resource Visibility Tracking to Avoid Atomic Reference Counting | |
US9460011B1 (en) | Memory reference estimation method and device based on improved cache | |
US10936290B2 (en) | Compile-time folding of assumed constant values | |
US10001979B2 (en) | Avoiding guard test invalidation for virtual and interface calls | |
US20170371627A1 (en) | Object-oriented container class callbacks | |
US11398004B2 (en) | Allocating device buffer on GPGPU for an object with metadata using access boundary alignment | |
US11182149B2 (en) | Just-in-time code patching | |
US9348621B2 (en) | Using hardware transactional memory for implementation of queue operations |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
AS | Assignment |
Owner name: INTERNATIONAL BUSINESS MACHINES CORPORATION, NEW YORK Free format text: ASSIGNMENT OF ASSIGNORS INTEREST;ASSIGNORS:OGATA, KAZUNORI;HORII, HIROSHI;REEL/FRAME:046383/0924 Effective date: 20180718 |
|
FEPP | Fee payment procedure |
Free format text: ENTITY STATUS SET TO UNDISCOUNTED (ORIGINAL EVENT CODE: BIG.); ENTITY STATUS OF PATENT OWNER: LARGE ENTITY |
|
ZAAA | Notice of allowance and fees due |
Free format text: ORIGINAL CODE: NOA |
|
ZAAB | Notice of allowance mailed |
Free format text: ORIGINAL CODE: MN/=. |
|
STCF | Information on status: patent grant |
Free format text: PATENTED CASE |
|
FEPP | Fee payment procedure |
Free format text: MAINTENANCE FEE REMINDER MAILED (ORIGINAL EVENT CODE: REM.); ENTITY STATUS OF PATENT OWNER: LARGE ENTITY |
|
LAPS | Lapse for failure to pay maintenance fees |
Free format text: PATENT EXPIRED FOR FAILURE TO PAY MAINTENANCE FEES (ORIGINAL EVENT CODE: EXP.); ENTITY STATUS OF PATENT OWNER: LARGE ENTITY |
|
STCH | Information on status: patent discontinuation |
Free format text: PATENT EXPIRED DUE TO NONPAYMENT OF MAINTENANCE FEES UNDER 37 CFR 1.362 |
|
FP | Lapsed due to failure to pay maintenance fee |
Effective date: 20240107 |