18201936fSGalina Kistanova=================================================================== 28201936fSGalina KistanovaHow To Add Your Build Configuration To LLVM Buildbot Infrastructure 38201936fSGalina Kistanova=================================================================== 48201936fSGalina Kistanova 58201936fSGalina KistanovaIntroduction 68201936fSGalina Kistanova============ 78201936fSGalina Kistanova 88201936fSGalina KistanovaThis document contains information about adding a build configuration and 9f0f76aeaSKonrad Kleinebuildbot-worker to private worker builder to LLVM Buildbot Infrastructure. 108201936fSGalina Kistanova 117457130fSDylan McKayBuildmasters 127457130fSDylan McKay============ 137457130fSDylan McKay 147457130fSDylan McKayThere are two buildmasters running. 157457130fSDylan McKay 16a70a5636SPhilip Reames* The main buildmaster at `<https://lab.llvm.org/buildbot>`_. All builders 17a70a5636SPhilip Reames attached to this machine will notify commit authors every time they break 18a70a5636SPhilip Reames the build. 19a70a5636SPhilip Reames* The staging buildmaster at `<https://lab.llvm.org/staging>`_. All builders 20a70a5636SPhilip Reames attached to this machine will be completely silent by default when the build 21a70a5636SPhilip Reames is broken. 22a70a5636SPhilip Reames 23a70a5636SPhilip ReamesIn order to remain connected to the main buildmaster (and thus notify 24a70a5636SPhilip Reamesdevelopers of failures), a builbot must: 25a70a5636SPhilip Reames 26a70a5636SPhilip Reames* Be building a supported configuration. Builders for experimental backends 27a70a5636SPhilip Reames should generally be attached to staging buildmaster. 28a70a5636SPhilip Reames* Be able to keep up with new commits to the main branch, or at a minimum 29a70a5636SPhilip Reames recover to tip of tree within a couple of days of falling behind. 30a70a5636SPhilip Reames 31a70a5636SPhilip ReamesAdditionally, we encourage all bot owners to point their bots towards the 32a70a5636SPhilip Reamesstaging master during maintenance windows, instability troubleshooting, and 33a70a5636SPhilip Reamessuch. 34a70a5636SPhilip Reames 35a70a5636SPhilip ReamesRoles & Expectations 36a70a5636SPhilip Reames==================== 37a70a5636SPhilip Reames 38a70a5636SPhilip ReamesEach buildbot has an owner who is the responsible party for addressing problems 39a70a5636SPhilip Reameswhich arise with said buildbot. We generally expect the bot owner to be 40a70a5636SPhilip Reamesreasonably responsive. 41a70a5636SPhilip Reames 42a70a5636SPhilip ReamesFor some bots, the ownership responsibility is split between a "resource owner" 43a70a5636SPhilip Reameswho provides the underlying machine resource, and a "configuration owner" who 44a70a5636SPhilip Reamesmaintains the build configuration. Generally, operational responsibility lies 45a70a5636SPhilip Reameswith the "config owner". We do expect "resource owners" - who are generally 46a70a5636SPhilip Reamesthe contact listed in a workers attributes - to proxy requests to the relevant 47a70a5636SPhilip Reames"config owner" in a timely manner. 48a70a5636SPhilip Reames 49a70a5636SPhilip ReamesMost issues with a buildbot should be addressed directly with a bot owner 50a70a5636SPhilip Reamesvia email. Please CC `Galina Kistanova <mailto:[email protected]>`_. 518201936fSGalina Kistanova 528201936fSGalina KistanovaSteps To Add Builder To LLVM Buildbot 538201936fSGalina Kistanova===================================== 54f0f76aeaSKonrad KleineVolunteers can provide their build machines to work as build workers to 558201936fSGalina Kistanovapublic LLVM Buildbot. 568201936fSGalina Kistanova 578201936fSGalina KistanovaHere are the steps you can follow to do so: 588201936fSGalina Kistanova 598201936fSGalina Kistanova#. Check the existing build configurations to make sure the one you are 608201936fSGalina Kistanova interested in is not covered yet or gets built on your computer much 618201936fSGalina Kistanova faster than on the existing one. We prefer faster builds so developers 628201936fSGalina Kistanova will get feedback sooner after changes get committed. 638201936fSGalina Kistanova 648201936fSGalina Kistanova#. The computer you will be registering with the LLVM buildbot 658201936fSGalina Kistanova infrastructure should have all dependencies installed and you can 668201936fSGalina Kistanova actually build your configuration successfully. Please check what degree 678201936fSGalina Kistanova of parallelism (-j param) would give the fastest build. You can build 688201936fSGalina Kistanova multiple configurations on one computer. 698201936fSGalina Kistanova 70f0f76aeaSKonrad Kleine#. Install buildbot-worker (currently we are using buildbot version 2.8.5). 71f0f76aeaSKonrad Kleine Depending on the platform, buildbot-worker could be available to download and 72fa9fbfe2SDylan McKay install with your package manager, or you can download it directly from 738201936fSGalina Kistanova `<http://trac.buildbot.net>`_ and install it manually. 748201936fSGalina Kistanova 75f0f76aeaSKonrad Kleine#. Create a designated user account, your buildbot-worker will be running under, 768201936fSGalina Kistanova and set appropriate permissions. 778201936fSGalina Kistanova 78f0f76aeaSKonrad Kleine#. Choose the buildbot-worker root directory (all builds will be placed under 79f0f76aeaSKonrad Kleine it), buildbot-worker access name and password the build master will be using 80f0f76aeaSKonrad Kleine to authenticate your buildbot-worker. 818201936fSGalina Kistanova 82f0f76aeaSKonrad Kleine#. Create a buildbot-worker in context of that buildbot-worker account. Point it 83*157d5655SPhilip Reames to the **lab.llvm.org** port **9994** (see `Buildbot documentation, 84f0f76aeaSKonrad Kleine Creating a worker 85f0f76aeaSKonrad Kleine <http://docs.buildbot.net/current/tutorial/firstrun.html#creating-a-worker>`_ 868201936fSGalina Kistanova for more details) by running the following command: 878201936fSGalina Kistanova 888201936fSGalina Kistanova .. code-block:: bash 898201936fSGalina Kistanova 90f0f76aeaSKonrad Kleine $ buildbot-worker create-worker <buildbot-worker-root-directory> \ 91*157d5655SPhilip Reames lab.llvm.org:9994 \ 92f0f76aeaSKonrad Kleine <buildbot-worker-access-name> \ 93f0f76aeaSKonrad Kleine <buildbot-worker-access-password> 948201936fSGalina Kistanova 95*157d5655SPhilip Reames This will cause your new worker to connect to the staging buildmaster 96*157d5655SPhilip Reames which is silent by default. Only once a new worker is stable, and 97*157d5655SPhilip Reames approval from Galina has been received (see last step) should it 98*157d5655SPhilip Reames be pointed at the main buildmaster. 990d1990e2SGalina Kistanova 100f0f76aeaSKonrad Kleine#. Fill the buildbot-worker description and admin name/e-mail. Here is an 101f0f76aeaSKonrad Kleine example of the buildbot-worker description:: 1028201936fSGalina Kistanova 1038201936fSGalina Kistanova Windows 7 x64 1048201936fSGalina Kistanova Core i7 (2.66GHz), 16GB of RAM 1058201936fSGalina Kistanova 1068201936fSGalina Kistanova g++.exe (TDM-1 mingw32) 4.4.0 1078201936fSGalina Kistanova GNU Binutils 2.19.1 1088201936fSGalina Kistanova cmake version 2.8.4 1098201936fSGalina Kistanova Microsoft(R) 32-bit C/C++ Optimizing Compiler Version 16.00.40219.01 for 80x86 1108201936fSGalina Kistanova 111f0f76aeaSKonrad Kleine#. Make sure you can actually start the buildbot-worker successfully. Then set 112f0f76aeaSKonrad Kleine up your buildbot-worker to start automatically at the start up time. See the 1138201936fSGalina Kistanova buildbot documentation for help. You may want to restart your computer 1148201936fSGalina Kistanova to see if it works. 1158201936fSGalina Kistanova 116f0f76aeaSKonrad Kleine#. Send a patch which adds your build worker and your builder to 117fa42620aSMircea Trofin `zorg <https://github.com/llvm/llvm-zorg>`_. Use the typical LLVM 118fa42620aSMircea Trofin `workflow <https://llvm.org/docs/Contributing.html#how-to-submit-a-patch>`_. 1198201936fSGalina Kistanova 120f20bb857SDouglas Yung * workers are added to ``buildbot/osuosl/master/config/workers.py`` 1218201936fSGalina Kistanova * builders are added to ``buildbot/osuosl/master/config/builders.py`` 1228201936fSGalina Kistanova 1233b42eb35SNico Weber Please make sure your builder name and its builddir are unique through the 1243b42eb35SNico Weber file. 1255fda6a90SGalina Kistanova 126ab4375e9SPhilip Reames All new builders should default to using the "'collapseRequests': False" 127ab4375e9SPhilip Reames configuration. This causes the builder to build each commit individually 128ab4375e9SPhilip Reames and not merge build requests. To maximize quality of feedback to developers, 129ab4375e9SPhilip Reames we *strongly prefer* builders to be configured not to collapse requests. 130ab4375e9SPhilip Reames This flag should be removed only after all reasonable efforts have been 131ab4375e9SPhilip Reames exhausted to improve build times such that the builder can keep up with 132ab4375e9SPhilip Reames commit flow. 133ab4375e9SPhilip Reames 134ae2fa770SEric Christopher It is possible to allow email addresses to unconditionally receive 1353b42eb35SNico Weber notifications on build failure; for this you'll need to add an 1363b42eb35SNico Weber ``InformativeMailNotifier`` to ``buildbot/osuosl/master/config/status.py``. 1373b42eb35SNico Weber This is particularly useful for the staging buildmaster which is silent 1383b42eb35SNico Weber otherwise. 1397457130fSDylan McKay 140f0f76aeaSKonrad Kleine#. Send the buildbot-worker access name and the access password directly to 1418201936fSGalina Kistanova `Galina Kistanova <mailto:[email protected]>`_, and wait till she 1428201936fSGalina Kistanova will let you know that your changes are applied and buildmaster is 1438201936fSGalina Kistanova reconfigured. 1448201936fSGalina Kistanova 145*157d5655SPhilip Reames#. Check the status of your buildbot-worker on the `Waterfall Display (Staging) 146*157d5655SPhilip Reames <http://lab.llvm.org/staging/#/waterfall>`_ to make sure it is 147*157d5655SPhilip Reames connected, and the `Workers Display (Staging) 148*157d5655SPhilip Reames <http://lab.llvm.org/staging/#/workers>`_ to see if administrator 149*157d5655SPhilip Reames contact and worker information are correct. 1508201936fSGalina Kistanova 151*157d5655SPhilip Reames#. At this point, you have a working builder connected to the staging 152*157d5655SPhilip Reames buildmaster. You can now make sure it is reliably green and keeps 153*157d5655SPhilip Reames up with the build queue. No notifications will be sent, so you can 154*157d5655SPhilip Reames keep an unstable builder connected to staging indefinitely. 15573d52ee7SPhilip Reames 156*157d5655SPhilip Reames#. (Optional) Once the builder is stable on the staging buildmaster with 157*157d5655SPhilip Reames several days of green history, you can chose to move it to the production 158*157d5655SPhilip Reames buildmaster to enable developer notifications. Please email `Galina 159*157d5655SPhilip Reames Kistanova <mailto:[email protected]>`_ for review and approval. 160*157d5655SPhilip Reames 161*157d5655SPhilip Reames To move a worker to production (once approved), stop your worker, edit the 162*157d5655SPhilip Reames buildbot.tac file to change the port number from 9994 to 9990 and start it 163*157d5655SPhilip Reames again. 16473d52ee7SPhilip Reames 16573d52ee7SPhilip ReamesBest Practices for Configuring a Fast Builder 16673d52ee7SPhilip Reames============================================= 16773d52ee7SPhilip Reames 16873d52ee7SPhilip ReamesAs mentioned above, we generally have a strong preference for 16973d52ee7SPhilip Reamesbuilders which can build every commit as they come in. This section 17073d52ee7SPhilip Reamesincludes best practices and some recommendations as to how to achieve 17173d52ee7SPhilip Reamesthat end. 17273d52ee7SPhilip Reames 17373d52ee7SPhilip ReamesThe goal 17473d52ee7SPhilip Reames In 2020, the monorepo had just under 35 thousand commits. This works 17573d52ee7SPhilip Reames out to an average of 4 commits per hour. Already, we can see that a 17673d52ee7SPhilip Reames builder must cycle in less than 15 minutes to have a hope of being 17773d52ee7SPhilip Reames useful. However, those commits are not uniformly distributed. They 17873d52ee7SPhilip Reames tend to cluster strongly during US working hours. Looking at a couple 17973d52ee7SPhilip Reames of recent (Nov 2021) working days, we routinely see ~10 commits per 18073d52ee7SPhilip Reames hour during peek times, with occasional spikes as high as ~15 commits 18173d52ee7SPhilip Reames per hour. Thus, as a rule of thumb, we should plan for our builder to 18273d52ee7SPhilip Reames complete ~10-15 builds an hour. 18373d52ee7SPhilip Reames 18473d52ee7SPhilip ReamesResource Appropriately 18573d52ee7SPhilip Reames At 10-15 builds per hour, we need to complete a new build on average every 18673d52ee7SPhilip Reames 4 to 6 minutes. For anything except the fastest of hardware/build configs, 18773d52ee7SPhilip Reames this is going to be well beyond the ability of a single machine. In buildbot 18873d52ee7SPhilip Reames terms, we likely going to need multiple workers to build requests in parallel 18973d52ee7SPhilip Reames under a single builder configuration. For some rough back of the envelope 19073d52ee7SPhilip Reames numbers, if your build config takes e.g. 30 minutes, you will need something 19173d52ee7SPhilip Reames on the order of 5-8 workers. If your build config takes ~2 hours, you'll 19273d52ee7SPhilip Reames need something on the order of 20-30 workers. The rest of this section 19373d52ee7SPhilip Reames focuses on how to reduce cycle times. 19473d52ee7SPhilip Reames 19573d52ee7SPhilip ReamesRestrict what you build and test 19673d52ee7SPhilip Reames Think hard about why you're setting up a bot, and restrict your build 19773d52ee7SPhilip Reames configuration as much as you can. Basic functionality is probably 19873d52ee7SPhilip Reames already covered by other bots, and you don't need to duplicate that 19973d52ee7SPhilip Reames testing. You only need to be building and testing the *unique* parts 20073d52ee7SPhilip Reames of the configuration. (e.g. For a multi-stage clang builder, you probably 20173d52ee7SPhilip Reames don't need to be enabling every target or building all the various utilities.) 20273d52ee7SPhilip Reames 20373d52ee7SPhilip Reames It can sometimes be worthwhile splitting a single builder into two or more, 20473d52ee7SPhilip Reames if you have multiple distinct purposes for the same builder. As an example, 20573d52ee7SPhilip Reames if you want to both a) confirm that all of LLVM builds with your host 20673d52ee7SPhilip Reames compiler, and b) want to do a multi-stage clang build on your target, you 20773d52ee7SPhilip Reames may be better off with two separate bots. Splitting increases resource 20873d52ee7SPhilip Reames consumption, but makes it easy for each bot to keep up with commit flow. 2091a76a3a7SPhilip Reames Additionally, splitting bots may assist in triage by narrowing attention to 2101a76a3a7SPhilip Reames relevant parts of the failing configuration. 21173d52ee7SPhilip Reames 21273d52ee7SPhilip Reames In general, we recommend Release build types with Assertions enabled. This 21373d52ee7SPhilip Reames generally provides a good balance between build times and bug detection for 2141a76a3a7SPhilip Reames most buildbots. There may be room for including some debug info (e.g. with 2151a76a3a7SPhilip Reames `-gmlt`), but in general the balance between debug info quality and build 2161a76a3a7SPhilip Reames times is a delicate one. 21773d52ee7SPhilip Reames 21873d52ee7SPhilip ReamesUse Ninja & LLD 21973d52ee7SPhilip Reames Ninja really does help build times over Make, particularly for highly 2201a76a3a7SPhilip Reames parallel builds. LLD helps to reduce both link times and memory usage 2211a76a3a7SPhilip Reames during linking significantly. With a build machine with sufficient 2221a76a3a7SPhilip Reames parallism, link times tend to dominate critical path of the build, and are 2231a76a3a7SPhilip Reames thus worth optimizing. 22473d52ee7SPhilip Reames 22573d52ee7SPhilip ReamesUse CCache and NOT incremental builds 22673d52ee7SPhilip Reames Using ccache materially improves average build times. Incremental builds 22773d52ee7SPhilip Reames can be slightly faster, but introduce the risk of build corruption due to 22873d52ee7SPhilip Reames e.g. state changes, etc... At this point, the recommendation is not to 22973d52ee7SPhilip Reames use incremental builds and instead use ccache as the latter captures the 23073d52ee7SPhilip Reames majority of the benefit with less risk of false positives. 23173d52ee7SPhilip Reames 23273d52ee7SPhilip Reames One of the non-obvious benefits of using ccache is that it makes the 23373d52ee7SPhilip Reames builder less sensitive to which projects are being monitored vs built. 23473d52ee7SPhilip Reames If a change triggers a build request, but doesn't change the build output 23573d52ee7SPhilip Reames (e.g. doc changes, python utility changes, etc..), the build will entirely 23673d52ee7SPhilip Reames hit in cache and the build request will complete in just the testing time. 23773d52ee7SPhilip Reames 23873d52ee7SPhilip Reames With multiple workers, it is tempting to try to configure a shared cache 23973d52ee7SPhilip Reames between the workers. Experience to date indicates this is difficult to 24073d52ee7SPhilip Reames well, and that having local per-worker caches gets most of the benefit 24173d52ee7SPhilip Reames anyways. We don't currently recommend shared caches. 24273d52ee7SPhilip Reames 2431a76a3a7SPhilip Reames CCache does depend on the builder hardware having sufficient IO to access 2441a76a3a7SPhilip Reames the cache with reasonable access times - i.e. a fast disk, or enough memory 2451a76a3a7SPhilip Reames for a RAM cache, etc.. For builders without, incremental may be your best 2461a76a3a7SPhilip Reames option, but is likely to require higher ongoing involvement from the 2471a76a3a7SPhilip Reames sponsor. 2481a76a3a7SPhilip Reames 24973d52ee7SPhilip ReamesEnable batch builds 25073d52ee7SPhilip Reames As a last resort, you can configure your builder to batch build requests. 25173d52ee7SPhilip Reames This makes the build failure notifications markedly less actionable, and 25273d52ee7SPhilip Reames should only be done once all other reasonable measures have been taken. 25373d52ee7SPhilip Reames 25473d52ee7SPhilip ReamesLeave it on the staging buildmaster 25573d52ee7SPhilip Reames While most of this section has been biased towards builders intended for 25673d52ee7SPhilip Reames the main buildmaster, it is worth highlighting that builders can run 25773d52ee7SPhilip Reames indefinitely on the staging buildmaster. Such a builder may still be 25873d52ee7SPhilip Reames useful for the sponsoring organization, without concern of negatively 25973d52ee7SPhilip Reames impacting the broader community. The sponsoring organization simply 26073d52ee7SPhilip Reames has to take on the responsibility of all bisection and triage. 26173d52ee7SPhilip Reames 26273d52ee7SPhilip Reames 263