Faster Buck From Facebook
Written by Kay Ewbank   
Monday, 13 November 2017

Facebook has added  a new feature to Buck, its open-sourced fast build system. The addition can be used to get faster compile times for Android projects. 

 buck

 

Buck is a build system developed and used by Facebook. It is optimized for the creation of small, reusable modules consisting of code and resources, and supports a variety of languages and platforms. It was originally open sourced four years ago, and since then has been improved in small stages by both Facebook and community developers. However, those improvements were, according to Facebook's Jonathan Keijo:

"incremental in nature and based on long-standing assumptions about the way software development works."

When thinking about how to move Buck forward, the developers at Facebook looked at the wider picture and questioned their core assumptions, according to Keijo:

"which led us deep into the nuances of the Java language and the internals of the Java compiler. In the end, we completely reimagined the way Buck compiles Java code, unlocking performance gains unachievable through incremental improvements."

The improvement in speed was achieved by modifying the way that Buck ignores elements of code that haven't changed when carrying out incremental builds. Developers using Buck can set up build rules for the different parts of their application, with some rules being dependent on rules further up the chain. Buck caches the output of each rule, and when it detects a change in a rule's output it will identify and rebuild only the dependent rules.

Where a rule compiles Java code, Buck (until now) would do a basic comparison of the output JAR file, and if it was different to the cached one, would rebuild it along with any rules specified as being dependent. However, many changes to Java source code can result in a different JAR file but wouldn't actually affect the rules down the dependency line.  One common example of this is where the dependents don't use all the classes in the rule, but Buck would rebuild all dependents when any class in the higher level JAR changed.

The new version of Buck was trained to detect which classes are used by a rule by monitoring which classes are read by the Java compiler. Now Buck encodes that information in dependency files to look for changes in only those classes when deciding what to rebuild.  This feature is called "source-only stub generation", and it's one of the major things that makes the new version so much faster.

Another improvement is the avoidance of bottlenecks when building multiple rules. If a commonly-used rule takes a while to build, its dependents have to wait. However, as the Java compiler actually has all the information needed to build a stub JAR roughly halfway through its run, Buck can let dependent rules start compiling while the compiler is still finishing up their dependencies.

The new faster version is available on the BuckBuild website, as well as for instructions on making your code compatible, and an autofix script to do most of the work for you.


 buck


 

More Information

BuckBuild Website

Instructions on making code use the new Buck features

Related Articles

Facebook Announces Yarn

Facebook Relay Improves Mobile Performance

Facebook Open Sources RacerD For Android Race Detection

 

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.

 

Banner


Data Wrangler Gets Copilot Integration
11/11/2024

Microsoft has announced that Copilot is being integrated into Data Wrangler. The move will give data scientists the ability to use natural language to clean and transform data, and to get help with fi [ ... ]



Amazon Adds AWS Lambda Code Editing Tool
04/11/2024

Amazon has added a new code editing option for AWS Lambda in the AWS console based on the Code-OSS, Visual Studio Code Open Source code editor.


More News

 

espbook

 

Comments




or email your comment to: comments@i-programmer.info

Last Updated ( Tuesday, 14 November 2017 )