Erik@Grijjy 123 Posted April 5, 2021 Growing impatient while building your FireMonkey app for macOS, iOS or Android? This post shows a way to (significantly) decrease the amount of time it takes for your app to build on these platforms. https://blog.grijjy.com/2021/04/05/build-speed/ 5 1 Share this post Link to post
Stefan Glienke 2019 Posted April 5, 2021 (edited) While LLVM certainly is part of the situation it suffers from the same sickness that makes most C++ code compile terribly slow: templates - err, I should say generics. (precompiled headers anyone?) Especially FMX uses them like everywhere if it makes sense or not. Everything is a TList<something> and there are many generic types within FMX itself. So the compiler has to build all these generics for each and every unit. Yes, if you have 1000 units using TList<TComponent> then that code is being emitted into 1000 dcu files and in case of LLVM also .o files including all that RTTI and possibly gigantic debug information for that TList<T>. The linker later eliminates any duplicates so the final binary does contains the code and RTTI only once. I know this from refactoring spring4d where I redesigned the generic collections to produce as little code as possible and turned off RTTI for all the implementing classes which improvided compile time on some projects by a factor of 4. Unfortunately even with the new intrinsics introduced in XE7 that were for reducing binary size because it enables compiletime optimizations for the code (GetTypeKind and alike) there is some significant bloat happening as I reported some time ago. When you fancy and look into a map file for a typical FMX application you can see that a huge chunk alone is from system.generics.collections and most of that code is dead code because it's only in the binary because RTTI is turned on for those classes. Even if they are used as private fields in some classes and all that is ever called on them is Add and Delete the entire code is emitted by the compiler. So a significant part of the compiletime is being used producing garbage (emitting code into dcu/o files) that the linker later has to find and eliminate. Edit: To emphasize: generics alone are not bad - its the overuse of them and making them fatter than they need to be and having RTTI being turned on for them. Often in places where a class reference would have been enough instead of some fancy<T: TSomethingclass> Edited April 5, 2021 by Stefan Glienke 6 Share this post Link to post
Vincent Parrett 763 Posted April 6, 2021 Using precompiled dcu's is common sense really.. imagine if you had to build the rtl/vcl/fmx every time you build your application⏲️ In the dpm package manager I'm, working on, it compiles the packages/library when the library is installed (assuming its designed to do that) - so the first time you install the package it takes a bit longer, but then builds are a lot faster. Share this post Link to post
dummzeuch 1517 Posted April 6, 2021 Why should programmers care about building times? https://xkcd.com/303/ 3 Share this post Link to post
Wagner Landgraf 43 Posted April 6, 2021 17 hours ago, Stefan Glienke said: I know this from refactoring spring4d where I redesigned the generic collections to produce as little code as possible and turned off RTTI for all the implementing classes which improvided compile time on some projects by a factor of 4. Are you aware of any compilation of best practices to reduce code bloat and compilation size you are mentioning here ref your refactoring? Share this post Link to post