Re:If a Build Takes 4 Hours, Run It Every 4 Hours
by _ph_ on Sunday April 19, 2020 @06:10AM
(#22914744)
I don't know what the author is building that a build is taking 4 hours, but I am aware that there are huge software projects with build times like that and much longer. I agree that getting quick feedback to changes is vital for quick overall development. This shows the values of development stacks which reduce the build times a lot. As a resultmore incremental development can be done. For example, the build times were one of the architectural goals when designing the Go language.
Dynamic languages are also a great tool to fight build times. Even if it is unsuitable for large projects to be entirely built on dynamic languages, a great technique is using a mix of static and dynamic. Build the core of the application in a static language, but more as a set of libraries to be called from the dynamic layer. The dynamic layer is where most of the application logic resides, easy to be changed. And parts which have stabilized reasonably can still be moved over to the static part.
Re:If a Build Takes 4 Hours, Run It Every 4 Hours
by scarface74 on Sunday April 19, 2020 @08:36AM
(#22915494)
So by using a dynamic language, you trade the cost of a long build time with possible runtime errors that would have easily been caught by the build system? Instead of paying the cost once per build you are now inflicting runtime errors on your customers.
Re:If a Build Takes 4 Hours, Run It Every 4 Hours
by ken on Sunday April 19, 2020 @11:11AM
(#22916412)
No. In every large system I've ever seen, there's large dynamic components. Avoiding existing dynamic languages entirely simply means building your own ad-hoc one, which is neither more robust nor more efficient (at development time or at run time). You're trading "known, working dynamic system" for "unknown, homemade dynamic system". (In other words, Greenspun's Law holds true.) There isn't a third choice where users simply stop wanting features which are easily implemented in dynamic fashion.
Every web browser today includes lots of modules written in JavaScript. Every web browser today also has lots of bugs. But nobody believes that rewriting all their JS in C++ would improve the situation. For all the complaints I've ever had about Firefox/Safari/Chrome, "I got a JS TypeError" has somehow never once come up.
Re:If a Build Takes 4 Hours, Run It Every 4 Hours
by scarface74 on Sunday April 19, 2020 @03:08PM
(#22918041)
And how many ignored JS errors do you see when you look on the web console? Don’t you want a little more robustness on the backend?
I’ve never in 30 years of development needed to make an adhoc dynamic language for a large system. I use Python for simple scripts and JS because you have to for the browser.
Re:If a Build Takes 4 Hours, Run It Every 4 Hours
by tyingq on Sunday April 19, 2020 @09:36AM
(#22915782)
Is there a strong, real world correlation between heavy use of dynamic languages, and a poor user experience (versus competitors, for example)?
The theory that it would makes sense to me, but I suspect other factors outshadow any effect it might have.
For example, I haven't heard that Facebook, Instacart, Booking.com, WordPress.com, etc, have stability or experience issues worse than their competitors.
Re:If a Build Takes 4 Hours, Run It Every 4 Hours
by _ph_ on Sunday April 19, 2020 @09:42AM
(#22915820)
Well, the costs are once per every build, which can take many hours, as the author describes it, even be only available on the next day. Static typechecking is a valuable tool, but it shouldn't be as the solution for all correctness problems. Testing is another. And when the build times become too large, testing suffers. Finally, it is absoultely possible to have dynamic languages with type declarations which can be automatically checked.
Re:If a Build Takes 4 Hours, Run It Every 4 Hours
by scarface74 on Sunday April 19, 2020 @09:50AM
(#22915873)
So now you trade reduced build times for increase in the amount of developer time for creating extra tests that check for type correctness and you increase the “build” time by having your build system run more tests?
And once you have type declaration that can “automatically” be checked - something has to run against the same code base to check the correctness of your code and you’re back to increasing your build time?
Re:If a Build Takes 4 Hours, Run It Every 4 Hours
by _ph_ on Sunday April 19, 2020 @10:13AM
(#22916043)
No. With dynamic languages, one gets not only "reduced" build times, they are instant. Testing for correctness needs to be done with any kind of language. Type checking is not a replacement for that. But you can add the necessary type declarations to dynamic language to facilitate static type checking if desired. These checks don't influence the build time significantly.
As written in my first post, using dynamic languages is only one way of improving development times. The other of course is, use languages which allow for fast compilation.
Re:If a Build Takes 4 Hours, Run It Every 4 Hours
by enigmo on Sunday April 19, 2020 @08:56PM
(#22920182)
> But you can add the necessary type declarations to dynamic language to facilitate static type checking if desired. These checks don't influence the build time significantly.
Indeed, type checking is rarely the slowest compilation stage for most languages.
Re:If a Build Takes 4 Hours, Run It Every 4 Hours
by castratikron on Sunday April 19, 2020 @10:31AM
(#22916151)
I wrote physics simulation code some time ago. The build was fast, but since the simulation speed was about 10ns/day the tests would take several hours to run. And the only way to know if your change fixed something is if the tests passed.
So it took several hours to get feedback for a change. But it also took about that long to come up with a new idea to try. Eventually I had a pipeline running where I could fire off a few ideas throughout the day, keep track of the change in the build, and iterate that way.
Re:If a Build Takes 4 Hours, Run It Every 4 Hours
by dpc_pw on Sunday April 19, 2020 @03:48PM
(#22918281)
You're going to lose that gained time as soon as your "build" includes running tests. And you'll need more tests because in dynamic langueses generally nothing works until you check it with a test.
Mixing lanuages is a waste. It makes everything harder operationally, technically and business wise.
The solution to long builds is projects structure that supports caching and parallelism. No one ever changes more than couple thousands lines even in a multi million line project, so why would everything had to get rebuilt?
I've seen ci pipelines building millions of lines in under a minute, no sweat.
Re:If a Build Takes 4 Hours, Run It Every 4 Hours
by _ph_ on Sunday April 19, 2020 @07:29AM
(#22915100)
No, I have not. But wouldn't be those code bases which compile very slow because of being written in C++? C++ seems to baloon in building time for large code bases. On the other side, the big Threadripper manages to compile the Linux Kernel in 40s. I don't think those web browsers are that much bigger than Linux than the compile times differ.
Firefox is further slowed down by using more and more Rust based code - Rust is known to compile slowly. However I would say this is a good tradeoff, since Rust brings much more safety to one of the most safety-critical applications on a typical desktop.
Re:If a Build Takes 4 Hours, Run It Every 4 Hours
by zlynx on Sunday April 19, 2020 @05:25PM
(#22918920)
It is extremely easy to let your C++ code get into long build times. People get fond of putting code into the header, for example. This adds that compile time to every file that includes that file. And it prevents you from using forward declaration, which then requires including those definitions in your header.
With discipline and tracking the build time, and tools that record how long each build step takes, you can keep people from doing things like declaring a Boost multimap in a header file. They can go ahead and use it but hide it in a cpp source file behind a pointer or a virtual interface.
I've noticed that some people fall in love with C++11 move constructors, and they are pretty cool, but unlike a reference or pointer they require full type definitions in order to pass "by value." So that's annoying.
C code is definitely faster to build, unless you've got some crazy programmer who reimplemented C++ templates using five level deep nested macros.
Re:If a Build Takes 4 Hours, Run It Every 4 Hours
by rhoyerboat on Sunday April 19, 2020 @11:10AM
(#22916409)
the general issue is that the feature rich web browser contains libraries wrapped around basically every leaf and stem of windows, mac and *nix desktop interface family forests.
(if your building on say, a completely fresh stage3 gentoo system, that equals some pretty good linker load. cairo comes to mind as a huge culprit, whether its webkit or mozilla.)
Re:If a Build Takes 4 Hours, Run It Every 4 Hours
by thechao on Sunday April 19, 2020 @02:33PM
(#22917802)
Fast builds for C++ require unending diligence from day 1. Part of my team’s CI is a build time check. Our code base runs to 10mm lines of code; clean uncached builds are 3m; cached builds are 30s; incremental builds are in the 100s of ms range. The entire system is a single, short Makefile combined with ccache. There’s no fine-grain dependency tracking, so our builds never go wrong.
Re:If a Build Takes 4 Hours, Run It Every 4 Hours
by noisy_boy on Sunday April 19, 2020 @07:42AM
(#22915177)
We have Maven builds that complete in a few mins via Jenkins but I have been exploring if it can be done even faster. The builds are written using the Jenkins declarative pipeline with parallelization etc but feels like it is just not fast enough (the slowness is probably because of the whole lot of intermediate IO/back-and-forth between Jenkins master and slaves). Wish there was a build setup that was faster while being as feature rich as Jenkins while supporting Maven builds.
Re:If a Build Takes 4 Hours, Run It Every 4 Hours
by noisy_boy on Monday April 20, 2020 @04:21AM
(#22922124)
Yeah - I did try it + the other oft-recommended optimizations. I have arrived at the conclusion that the actual build is not taking the majority of the overall build time, it is the various before and after that happens (e.g. checkout git repo, deciding build parameters, sonar qube scans, creating git tags and so on). Since the Jenkins pipeline basically runs shell scripts to do these things in each stage, the overall build just feels slow. Collapsing the stages would make things more messy, keeping them separate is cleaner but means more per-stage overhead.
Re:If a Build Takes 4 Hours, Run It Every 4 Hours
by noisy_boy on Wednesday April 22, 2020 @08:15AM
(#22944696)
Thanks for the suggestions. We have very few multi-module projects. Most of the time, the time is spent in the various stages - almost all of them shell scripts. I guess there is overhead of initializing the stages/spawning etc. I also think that Jenkins could be doing some serialization to be able to resume a failed build - which we don't really need as we'll probably start a fresh build anyway. That's my next area to explore.
Re:If a Build Takes 4 Hours, Run It Every 4 Hours
by tedunangst on Sunday April 19, 2020 @06:22AM
(#22914788)
Tying your build frequency to build time and then using that as motivation to decrease build time is probably the important bit here, but only if you include the second part.
Re:If a Build Takes 4 Hours, Run It Every 4 Hours
by royosherove on Sunday April 19, 2020 @06:31AM
(#22914818)
That's a good way of putting it. In TOC terms, the build time becomes the new constraint to solve, but only after you solve the build frequency constraint.
Re:If a Build Takes 4 Hours, Run It Every 4 Hours
by teleforce on Monday April 20, 2020 @07:05AM
(#22922813)
If the long build time for static typing programming language is the concerns perhaps you can try have look at D programming language since it is optimized for fast compilation [1].
Around last year someone even managed to speed up its compilation time even further and it is also featured in Hacker News but cannot find the link now.
I think in the future most of the static typing programming languages will be mainly based on Single Static Assignment (SSA) technique then the compilation could really fly.
Re:If a Build Takes 4 Hours, Run It Every 4 Hours
by gregdoesit on Sunday April 19, 2020 @06:26AM
(#22914804)
Alternatively, you can parallelise parts of your build (eg the tests, static analysis etc) and speed it up. Then, if you have more changes coming in than you could parallelise is when you can start to do some advanced things like trying to predict which changes might break the build.
There was a longer discussion on one of these approaches done by Uber[1] on HN. Granted it’s a lot of investment, it’s interesting to explore ways of dealing with long builds that need to run frequently.
Re:If a Build Takes 4 Hours, Run It Every 4 Hours
by larrybud on Sunday April 19, 2020 @10:29AM
(#22916146)
Or, just parallelize the entire build. eg, if you have four build servers, you could kick off a build every hour. Easy using VM's, trivial in the cloud.
Re:If a Build Takes 4 Hours, Run It Every 4 Hours
by royosherove on Sunday April 19, 2020 @06:30AM
(#22914815)
True, but that type of optimization is quite moot if you're only running the build at night (i.e, that's not the first constraint to solve). In the article I mention that first get the builds to be tight one after another, then work on build times because that becomes the constraint.
Re:If a Build Takes 4 Hours, Run It Every 4 Hours
by eska on Sunday April 19, 2020 @07:10AM
(#22914995)
It's a bandwith vs latency issue.
Imagine you make 5 commits in 4 hours. You now have 5 builds queued up and 20 hours of latency. So one would probably prefer to only build the last commit, and maybe queue the older commits up for later. But if you make another change then you'd need to pause the build of the older commit, or you'd be at up to 8 hours of latency instead of 4..
Re:If a Build Takes 4 Hours, Run It Every 4 Hours
by bryanrasmussen on Sunday April 19, 2020 @05:58AM
(#22914702)
If a build takes 4 hours it argues that a build on that system is a pretty expensive operation, unless changes are very infrequent, which in most systems is not the case, a build run on every change would seem to be highly problematic.
Re:If a Build Takes 4 Hours, Run It Every 4 Hours
by tlarkworthy on Sunday April 19, 2020 @02:47PM
(#22917899)
Bingo it's expensive, which is why they set it to every 24 hours.
Also coz they don't want to add the queuing logic, so it takes 4 hours to run is an approximation. Also it messes with other systems so they prefer to run it overnight. This blog doesn't solve a real problem.
Re:If a Build Takes 4 Hours, Run It Every 4 Hours
by tlarkworthy on Tuesday April 21, 2020 @01:53PM
(#22937419)
That doesn't answer anything. Either you: minimize latency (run every change independent of build time) or run to minimize engineering (24 hours). I dunno why you couple build time to a static period, it does not make sense to me.
Dynamic languages are also a great tool to fight build times. Even if it is unsuitable for large projects to be entirely built on dynamic languages, a great technique is using a mix of static and dynamic. Build the core of the application in a static language, but more as a set of libraries to be called from the dynamic layer. The dynamic layer is where most of the application logic resides, easy to be changed. And parts which have stabilized reasonably can still be moved over to the static part.
Every web browser today includes lots of modules written in JavaScript. Every web browser today also has lots of bugs. But nobody believes that rewriting all their JS in C++ would improve the situation. For all the complaints I've ever had about Firefox/Safari/Chrome, "I got a JS TypeError" has somehow never once come up.
I’ve never in 30 years of development needed to make an adhoc dynamic language for a large system. I use Python for simple scripts and JS because you have to for the browser.
The theory that it would makes sense to me, but I suspect other factors outshadow any effect it might have.
For example, I haven't heard that Facebook, Instacart, Booking.com, WordPress.com, etc, have stability or experience issues worse than their competitors.
And once you have type declaration that can “automatically” be checked - something has to run against the same code base to check the correctness of your code and you’re back to increasing your build time?
As written in my first post, using dynamic languages is only one way of improving development times. The other of course is, use languages which allow for fast compilation.
Indeed, type checking is rarely the slowest compilation stage for most languages.
So it took several hours to get feedback for a change. But it also took about that long to come up with a new idea to try. Eventually I had a pipeline running where I could fire off a few ideas throughout the day, keep track of the change in the build, and iterate that way.
Mixing lanuages is a waste. It makes everything harder operationally, technically and business wise.
The solution to long builds is projects structure that supports caching and parallelism. No one ever changes more than couple thousands lines even in a multi million line project, so why would everything had to get rebuilt?
I've seen ci pipelines building millions of lines in under a minute, no sweat.
Firefox is further slowed down by using more and more Rust based code - Rust is known to compile slowly. However I would say this is a good tradeoff, since Rust brings much more safety to one of the most safety-critical applications on a typical desktop.
With discipline and tracking the build time, and tools that record how long each build step takes, you can keep people from doing things like declaring a Boost multimap in a header file. They can go ahead and use it but hide it in a cpp source file behind a pointer or a virtual interface.
I've noticed that some people fall in love with C++11 move constructors, and they are pretty cool, but unlike a reference or pointer they require full type definitions in order to pass "by value." So that's annoying.
C code is definitely faster to build, unless you've got some crazy programmer who reimplemented C++ templates using five level deep nested macros.
(if your building on say, a completely fresh stage3 gentoo system, that equals some pretty good linker load. cairo comes to mind as a huge culprit, whether its webkit or mozilla.)
You can still have nice stages separations, but try to avoid the pitfall of doing too much shell invocations.
A good trick is to create a fake "multi-module reactor" pom.xml and grouping all the modules logically there, then you build like
mvn clean install -f reactor-pom.xml -T 8C
Around last year someone even managed to speed up its compilation time even further and it is also featured in Hacker News but cannot find the link now.
I think in the future most of the static typing programming languages will be mainly based on Single Static Assignment (SSA) technique then the compilation could really fly.
[1]https://www.drdobbs.com/cpp/increasing-compiler-speed-by-ove...
[2]https://www.cs.princeton.edu/~appel/papers/ssafun.pdf
There was a longer discussion on one of these approaches done by Uber[1] on HN. Granted it’s a lot of investment, it’s interesting to explore ways of dealing with long builds that need to run frequently.
https://news.ycombinator.com/item?id=19692820
Provided that you can run multiple builds in parallel but each of them has somehow limited parallelization.
Imagine you make 5 commits in 4 hours. You now have 5 builds queued up and 20 hours of latency. So one would probably prefer to only build the last commit, and maybe queue the older commits up for later. But if you make another change then you'd need to pause the build of the older commit, or you'd be at up to 8 hours of latency instead of 4..
Also coz they don't want to add the queuing logic, so it takes 4 hours to run is an approximation. Also it messes with other systems so they prefer to run it overnight. This blog doesn't solve a real problem.