Object code optimizer

From HandWiki
Short description: Aspect of software compilation

A binary optimizer takes the existing output from a compiler and produces a better execution file with the same functionality.

An object code optimizer, sometimes also known as a post pass optimizer or, for small sections of code, peephole optimizer, forms part of a software compiler. It takes the output from the source language compile step - the object code or binary file - and tries to replace identifiable sections of the code with replacement code that is more algorithmically efficient (usually improved speed).

Examples

  • The earliest "COBOL Optimizer" was developed by Capex Corporation in the mid 1970s for COBOL. This type of optimizer depended, in this case, upon knowledge of 'weaknesses' in the standard IBM COBOL compiler, and actually replaced (or patched) sections of the object code with more efficient code. The replacement code might replace a linear table lookup with a binary 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 as strength reduction. For example, on the IBM/360 hardware the CLI instruction was, depending on the particular model, between twice and 5 times as fast as a CLC instruction for single byte comparisons.[1][2]

Advantages

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, reducing CPU resources at a fixed cost (the price of the proprietary 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 with hardware upgrades, the faster hardware would usually more than compensate for the application programs reverting to their pre-optimized versions (until a supporting optimizer was released).

Other optimizers

Some binary optimizers do executable compression, which reduces the size of binary files using generic data 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 utilize run-time metrics (profiling) to introspectively improve performance using techniques similar to JIT compilers.

Recent developments

More recently developed 'binary optimizers' for various platforms, some claiming novelty 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 a profile phase beforehand
  • Design and Engineering of a Dynamic Binary Optimizer — from IBM T. J. Watson Res. Center (February 2005)[6][7]
  • QuaC: Binary Optimization for Fast Runtime Code Generation in C[8] — (which appears to include some elements of JIT)
  • DynamoRIO
  • COBRA: An Adaptive Runtime Binary Optimization Framework for Multithreaded Applications[9]
  • Spike Executable Optimizer (Unix kernel)[10]
  • "SOLAR" Software Optimization at Link-time And Run-time[11]
  • Dynimize: CPU Performance Virtualization[12]
  • BOLT: post-link optimizer built on top of the LLVM framework. Utilizing sample-based profiling, BOLT improves the performance of real-world applications even for highly optimized binaries built with both Feedback Directed Optimization and Link-time optimization. For GCC and Clang 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]

See also

References

  1. "Archived copy". http://www.bitsavers.org/pdf/ibm/360/A22_6825-1_360instrTiming.pdf. 
  2. "Software engineering for the Cobol environment". Communications of the ACM 25 (12): 874–882. 1982-12-01. doi:10.1145/358728.358732. https://doi.org/10.1145/358728.358732. Retrieved 2021-10-27. 
  3. "IBM Automatic Binary Optimizer for z/OS - Overview". 2015. https://www.ibm.com/products/automatic-binary-optimizer-zos. 
  4. "IBM Automatic Binary Optimizer for z/OS Trial Cloud Service". 2020. https://optimizer.ibm.com/. 
  5. "The Binary Code Optimizer". http://developers.sun.com/solaris/articles/binopt.html. 
  6. "Design and Engineering of a Dynamic Binary Optimizer". Proceedings of the IEEE 93 (2): 436–448. 2005. doi:10.1109/JPROC.2004.840302. 
  7. "Metadata driven memory optimizations in dynamic binary translator". Proceedings of the 3rd international conference on Virtual execution environments - VEE '07. Association for Computing Machinery. 2007-06-13. pp. 148–157. doi:10.1145/1254810.1254831. ISBN 978-1-59593630-1. https://doi.org/10.1145/1254810.1254831. Retrieved 2021-10-27. 
  8. "Archived copy". http://www.eecs.berkeley.edu/Pubs/TechRpts/1994/CSD-94-792.pdf. 
  9. "COBRA: An Adaptive Runtime Binary Optimization Framework for Multithreaded Applications". 2007 International Conference on Parallel Processing (ICPP 2007). 2007. pp. 25. doi:10.1109/ICPP.2007.23. ISBN 978-0-7695-2933-2. 
  10. "Archived copy". http://www.cesr.ncsu.edu/fddo4/papers/spike_fddo4.pdf. 
  11. ""SOLAR" Software Optimization at Link-time And Run-time". http://www.cs.arizona.edu/solar/. 
  12. "Dynimize Product Overview". https://dynimize.com/product. 
  13. "BOLT: A Practical Binary Optimizer for Data Centers and Beyond". 2019 IEEE/ACM International Symposium on Code Generation and Optimization (CGO). 2019-02-16. pp. 2–14. doi:10.1109/CGO.2019.8661201. ISBN 978-1-7281-1436-1.