A binary optimizer takes the existing output from a compiler and produces a better execution file with the same functionality.
Anobject code optimizer, sometimes also known as apost pass optimizer or, for small sections of code,peephole optimizer, forms part of a softwarecompiler. It takes the output from the source language compile step - the object code orbinary file - and tries to replace identifiable sections of the code with replacement code that is morealgorithmically efficient (usually improved speed).
The earliest "COBOL Optimizer" was developed byCapex Corporation in the mid 1970s forCOBOL. This type of optimizer depended, in this case, upon knowledge of "weaknesses" in the standard IBM COBOL compiler, and actually replaced (orpatched) sections of the object code with more efficient code. The replacement code might replace a lineartable lookup with abinary search for example or sometimes simply replace a relatively slow instruction with a known faster one that was otherwise functionally equivalent within its context. This technique is now known asstrength reduction. For example, on theIBM/360 hardware theCLI instruction was, depending on the particular model, between twice and 5 times as fast as aCLC instruction for single byte comparisons.[1][2]
The main advantage of re-optimizing existing programs was that the stock of already compiled customer programs (object code) could be improved almost instantly with minimal effort, reducingCPU resources at a fixed cost (the price of theproprietary software). A disadvantage was that new releases of COBOL, for example, would require (charged) maintenance to the optimizer to cater for possibly changed internal COBOL algorithms. However, since new releases of COBOL compilers frequently coincided withhardwareupgrades, the faster hardware would usually more than compensate for the application programs reverting to their pre-optimized versions (until a supporting optimizer was released).
Some binary optimizers doexecutable compression, which reduces thesize of binary files using genericdata compression techniques, reducing storage requirements and transfer and loading times, but not improving run-time performance. Actual consolidation of duplicate library modules would also reduce memory requirements.
Some binary optimizers utilizerun-time metrics (profiling) to introspectively improve performance using techniques similar toJIT compilers.
More recently developed "binary optimizers" for various platforms, some claimingnovelty but, nevertheless, essentially using the same (or similar) techniques described above, include:
IBM automatic binary optimizer for z/OS (ABO) (2015)[3]
IBM automatic binary optimizer for z/OS (ABO) trial cloud service (2020)[4]
The Sun Studio binary code optimizer[5] — which requires aprofile phase beforehand
Design and Engineering of a Dynamic Binary Optimizer — fromIBM T. J. Watson Res. Center (February 2005)[6][7]
QuaC: binary optimization for fastruntime code generation inC[8] — (which appears to include some elements of JIT)
BOLT: post-link optimizer built on top of theLLVM framework. Utilizing sample-based profiling, BOLT improves the performance of real-world applications even for highly optimized binaries built with bothfeedback directed optimization andlink-time optimization. ForGCC andClang compilers, BOLT speeds up their binaries by up to 20.4% on top of FDO and LTO, and up to 52.1% if the binaries are built without FDO and LTO.[13]
^Panchenko, Maksim; Auler, Rafael; Nell, Bill; Ottoni, Guilherme (2019-02-16). "BOLT: A Practical Binary Optimizer for Data Centers and Beyond".2019 IEEE/ACM International Symposium on Code Generation and Optimization (CGO). pp. 2–14.arXiv:1807.06735.doi:10.1109/CGO.2019.8661201.ISBN978-1-7281-1436-1.S2CID49869552.