Optimising for fast builds with GHC
Comments
Transcript
Machine-transcribed by YouTube. Expect errors in names, commands and version numbers.
Yeah. Yeah. So, I'm Tio. I work at Circuit Hub, which is a company that makes circuit boards. Uh, where we use Haskell. Uh, and I love using Haskell. All right. You we you can write abstract code that gets compiled to fast machine code. Uh, the type checker gives you really helpful feedback. Uh, and if you're lucky, you get this really nice feedback loop where uh, if you make a mistake, you get a type error, you fix your type error, it's all great. But as your project grows in size, so do so do your compile times. And suddenly your compile times take a lot of of time and you end up just waiting a lot for for the compiler to run. So this is about improving that, right? And so this is a performance property of your project.
And like any performance property, you have to take care about it. If you just let things slide, then it will just get worse over time. So if you want to make things better, you have to take a systematic approach. So the first step in doing that is benchmarking. So you want to figure out why your project is being slow to compile. For instance, what you might do is figure out which which are the top 10 slowest modules, right? That's a step you can take. Then you want to figure out why these statistics um lead to a certain bottleneck. For instance, you might notice that all those top 10 modules have large data types that use generics for instance.
Right? So now you've got a theory going as to why your project is slow. And then
you experiment, figure out if changing
something about that is going to make things better. You might think about replacing generics with handwritten instances. And then the a really
important step is actually to reflect on whether that's something you want to do, right? So software development is all about trade-offs. So you might find that you don't really want to replace your generics with handwritten instances. Maybe you want to use template Haskell instead. or maybe you're just happy taking the compile time hit. And then
you repeat and hopefully you've got a better understanding of your project at this point and you're in a better position to benchmark again, find out what's slow, what's not. And the important thing about this process is that it doesn't only make your project faster to build, it also means that you have a better understanding of the structure of your project. the technical decisions you're making and why things are slow or not. I
think it's very um it's very easy to come out away from a a talk like this with a bunch of suggestions and try to apply them all to your codebase. And I think quite often that will lead to bad results if you don't do things rigorous rigorously and try to figure out why things work or not. And what this talk
is trying to give is help going through this process. Right? So we're going to go through some of the tools you can use for benchmarking and we're going to try to build an understanding of the structure of projects and the theory behind why things might be slow. So there's a lot of factors that go into the time taken to build a project. There's your code, there's GHC, the compiler, there's your build tools, right? compile stack so on the compiler options that you give to your compiler but also you know the options you give to your tools and then of course the hardware of the machines you run on and there's also some randomness or entropy from the environment in this talk we will focus mainly on your source code right the other things are things you can improve as well but that's not what we're going to talk about um it's a lot easier to explain
your s uh the structure of code to you than to explain the entire priority of GHC or how build tools work. Uh, in terms of compiler options, I think people tend to have pretty good compiler options anyway. And one thing that's worth saying is you can always just buy faster machines and that will just mean that things run faster, but that's not particularly interesting. So, in terms of the things I'm going to take to be fixed, I'm going to give you two scenarios. And these are the scenarios I'm familiar with. Uh, so they're what I'm going to be assuming you're doing as well. So when developing locally, I'm going to assume you have like a standard work laptop maybe with 16 cores and it has enough RAM to compile your projects, which might be a lot. Um, I'm also going to assume that you're using at most eight of those cores for compiling each package. I found that that tends to work best on my laptop. Your usage will vary. Please benchmark. Don't just take my word for it. Uh that you use something like Cabal install or stack, not like a fancy build tool like Buck uh or Basel or something like that. And that when you're developing locally, you're using no optimizations and maybe you're even passing no code or something. And that you're using HLS or GHC ID, something that kind of takes your project as a whole. And then the other scenario is that you're running builds in CI and there I'm going to assume you use Nyx. I know not everyone uses Nyx, but I think it's pretty common in HASLL companies.
Uh, and when you're using Nyx, I'm going to assume you have one derivation per package. There's some niche Nyx things that do one per module, but I'm going to assume per package. And that you have a lot of CI runners that can do remote build. So you have a lot of parallelism there, but still we're going to assume that one of those packages still only gets about eight cores. And that is because it's it's difficult to scale above that. There's a lot of reasons for that. Uh part of it is things to do with GHC. Part of it is to do with just how computers work nowadays where a lot of the time your bottleneck isn't actually your CPUs but the memory subsystem. Um,
and also with HA hasll projects in general, as they um as they get bigger, they take more RAM to compile and the more cores you're running with, the more memory it takes. So memory can also be a bottleneck there. And I'm going to assume that when you're running things in CI that you are running with optimizations, you presumably want to test in kind of like a productionesque environment. So let's split let's spill up what we
mean by a project right at the highest level got a project. A project is composed of packages. Packages can have dependencies between each other and that forms a directed asyclic graph. Then within each package you have a set of modules and modules also have dependencies between each other and that also forms a directed asyclic graph. You can have module loops in HASLL but those are broken by HS boot files. So in practice you do actually have an asyclic graph and at the lowest level you have a module. So you have you know this these layers of graphs and that lets us have some level of parallelism but at the module level you can only compile one module at a time.
So let's look at what it looks like to compile one package. Right? So we've got a package here with six modules and we're going to assume each of them takes one second to compile. So if we're just running with one core, the entire thing is going to take six seconds, right? Um now you might assume, okay, well if I have two cores, it'll take 3 seconds half the time. Well, that's not really the case here, right? because you can compile a and then you can compile either b1 or b2 in parallel but then none of the rest can really go in parallel. So you end up really only saving one second and you can do this in 5 seconds, right? So in general [clears throat] why doesn't that work and we've already explored one of the reasons. It's because of the shape of the module graph, right? It might mean that our effect of parallelism is less than how many cores we have. And the other the reason is because we can only compile a module on a single core.
Right? So if you have a package that contails contains one huge 30-cond module, then it doesn't matter how many cores you have, that will take 30 seconds nonetheless. So if you wanted an accurate understanding of that, you need to do some sort of bin packing. So this idea that you can just increase the amount of cores and then you'll have a corresponding decrease in compile times doesn't really work. And it's pretty obvious when we look at a package like this and we can see the entire graph. But I think in production
situations you people tend to assume that that will work for them because they're not looking at the module graph. And what you should be looking at and and yeah the issue is that in a production scenario a module graph is so big it's not easy to see this type of thing. So what you should be looking at is the critical path and that's the path here from A to B1 to C to D to E and that's determining how much time it will take with infinite parallelism. Right? So in practice um if you have a certain
amount of cores, the amount of time it takes will be somewhere between perfect parallelism and your critical path. And if you're hitting the critical path, it means you've maxed out your parallelism.
So the critical path is also really important for caching, right? So GHC implements recompilation avoidance which means that when your project recompiles,
it will decide whether each module needs to recompile based on if uh based on some rules depending on the dependencies of that module. And the worst case there
is that any change in any transitive dependency recompiles it. It's less bad than that. But whenever we're talking about performance, it's helpful to think about the worst case. And in general, you know, caching will help with your average case, but won't help too much with the worst case. And the critical path will also determine the worst case behavior here. Not just in terms of parallelism but also in terms of caching where the critical path is the maximum time it can take to recompile your project if one module is changed. Now that's when you're running locally. But when you're using nyx in CI then the story is slightly different right because you're not caching at the module level you're only caching at the package level. So there you care about the critical path of packages rather than modules.
So now we're going to look at our project divided into modules
um well individual modules, graphs of modules and then packages. Graphs of packages. So let's start with modules. So what we care about here is the sum total of compiling all of your modules. So what helpful there is looking at the worst offenders. So we have lots of tools we can use for figuring that out. There's GHC build stats which is a tool I have just published yesterday um that we'll go into in a second that you can use and we will use in a couple of the other scenarios as well. There's time GC modules which is really popular. Uh, and then there's also a bunch of other tools that analyze the dump timings output of GHC. I feel like this is kind of um a
coming of age thing that where every developer will write a parser for the dump timings output and then graph it. Um, what I like about my tool is that it gives few less information than the other things. Mainly what it gives is just the time it takes to compile the module. it doesn't break it down into phases or anything like that. Um it's also important to note that if you use dump timings uh you should only compile one core because currently there's a bug where um it will give you the CPU time rather than the elapse time. So if you have so that will just be wrong if you use multiple cores.
So how do you use GHC build stats? Uh right now it's implemented as a plugin. I've implemented it as a plugin because I don't want to patch GHC. Uh because then you'll only be able to use it on master. Uh so using it as a plug-in means that you can use it on any version of GHC above and above and including
910. So I've tested those. So you make use of it like this. You add this to your cabal file. You know, you build depends the plugin. Then GC options you
you get it to use the plugin. Um that's how plugins work in general. And then so you run your build as normal and then it will build create these build stats new new line delimited JSON files. Um and then you can use this executable
called GC build stats to analyze it. So
you find those files by using the find command and that'll give you the paths to them. Uh and then you run GC build stats and it will tell you the slowest modules. It'll also tell you some other things that we'll get to in a minute. So now you have the slowest modules to compile. You you take a look at the top one and the qu question you should always ask yourself is do I actually need this module? A lot of the time um I'll look
at these really slow modules and I'll realize oh this is there to implement a feature that we removed 10 years ago or something like that. And the reason it's really slow to compile is because nobody really recompiles it locally. So nobody notices it's slow. So yeah, before trying to optimize something, spend a little time trying to figure out if you actually need it. So you can use maybe Weeder to do this, right? Which is a tool by Oliver Trolls who I work with. Um but sometimes that won't catch things, right? Because you might have an endpoint that is defined that uses it, but the endpoint never gets hit. So yeah, think about deleting it. Uh the next thing you can do is analyze core. I think if you've if you're familiar with core, it's a great thing to do. If you're not super familiar with core, uh you can still do it. Uh but if you find even the prospect of looking at a a huge file scary, then you don't really need to do this. Um but this is how you do it. You add this to your file. You find the core output, which is called dump simple because it's the output of the simplifier. And one really nice thing you can look at even if you don't understand anything about core is this little summary of the size of things which I find very helpful. So for each definition it will say how many terms, how many types, how many coercions it has. And often if you look at the thing with lots of these things going on that might point you to something that's going wrong where things are getting too big. And in general what you will find
is that um uh what you will find is that things getting too big cause problems. So that's one thing you can do that'll point you to maybe some definitions in your file. Another and then the I think the most effective but also quite heavy hammer to figure out what is actually making your file slow to compile is to binary search through your file and delete everything except for the things you care about. So you, you know, comment out half the file or stub out half the file with undefined for all of your definitions and then you rerun it and you see, okay, is this still slow to compile? And that goes pretty quickly and you find something that is minimal and is very slow to compile. Um, and
yeah, that that works surprisingly well. Now you've got, you know, something pretty small and you want to figure out,
well, okay, why is this slow to compile? So there's lots of reasons why that might be the case. I think there's two
reasons that are quite common. One of them is that you have excessive type level programming going on, right? Type level programming is like any other sort of programming. You can make it very slow by doing things that are quadratic or worse. very often why this is slow uh a very
common example of why this is slow is generics right generics themselves can be pretty okay but then deriving that user generics can be a problem higher kind of data can also be a problem that can also yeah lead to a lot of type level work going on and these are the thing these are things that the compiler should do better at some stage but currently is suboptimal that
uh and what can you do with those? Well, it it's pretty tough, right? You can try to get rid of those usages. Um and that's pretty much the best thing you can do right now. Uh at work, we use this library called relate which does SQL and it has a lot of higher kind of data going on and I'm trying to improve it and it's it's pretty fiddly work making uh higher kind of data uh perform
well. Then you also have code size explosions. Uh, a lot of the time what happens here is somebody a few years ago added inline pragmas to all the all the files in a all the definitions in a module and now they're all getting inlined. Uh, and you get this huge huge code. Um, and that's
something that looking at the core can really point you to. Um, and then what do you do about that? Well, maybe get rid of the inline pragmas, right? You should take a look. Do these inline pragmas actually improve performance or are they just making things get really slow. Uh I think quite often they don't
have a huge benefit.
You also have specialization going on, right? And so I think quite a lot of time people add inline pragmas because they want specialization to fire. Maybe inlinable is better there. But also quite often structuring your code in a way where you are a bit less reliant on specialization is good. It's good to avoid having um abstract monads where we
don't specify the type of the monad because that will mean that the only way to have efficient code is to specialize all of your monadatic code at a later stage. Derived instances can also lead to really large code size. Right? So uh even simple things like show and read and stuff like that can lead to a lot of code um and that mostly happens when you have really large data types um which themselves have uh super linear effects. So there's the large records library to help with that but really I think having really large data types is a bit of a code smell. So if you see that maybe you could just try to improve that break things down a little bit. Template hasll can sometimes cause code size explosion.
And that's not template hasll's fault itself. It's the it's the fault of badly written template hasll that doesn't think about the code it's generating. And maybe when it was written, they only thought about some small cases and not how we'll work with bigger code. But if you've eliminated these, I think what remains is quite often that it's some type of GHC bug. Uh, and that's something you shouldn't be um worried about saying. I have reported many GC
performance bugs. Um, and if you've done the the binary search from before, you will end up with something that is very close to what you would need to make a GC bug report, which is a nice standalone reproducer because you've eliminated most of your code. You're left with something that very easily could be modified to not be part of maybe your corporate codebase. Um, and yeah, then you should go to the GHC GitLab, report it, say, "Okay, I've I've got this code. If um if I compile it, it's really slow. I think this might be a GC bug." Um, and then that'll hopefully get fixed and then it'll be added to the test suite so it'll never happen again.
So that's that's a single module, right?
So improving a single module will improve the sum total but it's limited in some ways right maybe you don't want to get rid of generics maybe you you are really reliant on specialization and in llining but even if you can't improve that you can still improve on parallelism and caching by improving the shape of your packages so how can you analyze this I a a great
tool is graph mod which creates a dot graph of a package. The issue with that is that if you have anything maybe above like I don't know 50 modules, it quickly turns into something that's just a spider's web of lines that you can't really make head or tail of. So I think that is quite useful for like small packages but not for bigger ones. So JC build stats is very helpful here because it can just let you focus in on the critical paths. Um so it will write down the critical path for you which modules are on it and how long they take to compile. Um and it can also give you this output which is this trace diagram
um that you can feed into profetto.dev which is the um replacement for Google's
Chrome tracing uh viewer. So this is actually the cabal
library. um the critical path is 23 seconds and
the total time is 55 seconds. So that's really that's basically the same as what we had before where uh well no um
it's it's similar to what we had before where the critical path means that you
won't get a lot of performance improvements by increasing the core count, right? Because it's basically half of the total time. So if you have two cores that'll h half it, but then after two cores, you won't really get much benefit at all. Um, and you can see why that is because of the shape, right? You've got all of these big gaps here, and that's not good at all. So what what
do you want to do with this? You want to move things to the left to get rid of those gaps, right? So you might think about this distribution um simple setup thing that might be a
good thing to look at and say okay why is it at this stage of the path maybe I
can move it left and then everything above it will also move left and then you can make much better use of parallelism and this and this I think this is a really good example of what projects tend to look like. they have at the start some nice parallelism and then you have a a long run where you can't get much parallelism and then it branches out and then comes back in again, branches out, comes back in again. Um, yeah.
So, what are the specific things? If you're looking at a module on the critical path, what can you do to make that better? A really really common case is that you will look at it and you see, oh, okay, it's doing a lot of reexports. And reexports are really bad for this sort of thing. Because if you have a module um that just imports something
just to get it reexported from a different module. So if you have um if
you're importing A and A is just reexporting things from B, A will have more dependencies in general than B, right? And those dependencies also have to get compiled before A can be compiled before your package can get compiled uh before your module can get compiled. So if you depend on B directly, you are only depending on B's dependencies and not the dependencies of A also. So that can lead to a pretty big speed up. HLS
has this refine imports action. So if you open one of these files and you see a lot of refine imports coming up, you can just try running those and seeing if that improves things. Um I also have a ticket on the GHC tracker to add a warning for when you could refine imports. So that would make these things easier to catch.
So if you re if you go through it and
get rid of all the reexports in that path, the next thing you can do is split modules. And I think people get really excited about splitting modules uh and then sometimes do it without thought. What's really important about splitting modules is that you don't create linear chains, right? So if you split, you know, you have this A depends on B and you split B into B1 and B2, but B1 still
depends on B2 and A depends on B1, you haven't really improved anything and you've likely actually made things worse because now you've got more modules and each module has an overhead. Um,
so you have to be very careful with about things like that. Look at the module. Why are we depending on this module? Which part of the module are we depending on? what's the structure of the module? What is it trying to do? And
a lot of the time you'll look at it and you'll figure out that it doesn't really have a clear purpose. And that's why we're depending on just a small part of a larger module. Uh so you what's helpful is to just make your modules be defined better and to give them a clear purpose. So think about whether is this module trying to define an interface or is it trying to define an implementation. If you're combining those two things, you will in general be making things less parallel and more sequential because the implementation will depend on more things than the interface. So if you can split out the interface and the implementation, that can be a big win.
Another thing that happens really really often is maybe you have a test suite and you in a specific test case you define a helper and you have that defined in your module and then somebody else wants to use that helper so they import your test suite module and then they define a helper and a third module comes along it's like okay that's a really helpful helper and you build this long chain of of test suites that all depend on each other and then you have lots of rebuilds for for no reason. Um, and that and so
what you want to do there is say, okay, this is part of the test suite harness that should go in a different module. And if you're consistently doing that, then you won't have this problem to begin with. And what's helpful when analyzing modules is to use this calligraphy library, which gives you a dot graph of how all of the definitions are interrelated. that can be quite helpful because you can see okay well this subgraph doesn't really depend on the rest maybe I can modify things a little and then they're well defined and I can just split things up and then one last thing I'm going to say about this is that what people like to do is they like to when splitting things out they like to create types modules uh and I find types modules really annoying because it doesn't tell me what types they are right we we have lots of types in hasll
and types doesn't tell me any information whatsoever. I think what people want to do a lot of the time instead of defining a types module is to just say what type of type it is, right? Is it am I defining an effect? Am I defining some options? Am I defining an
interface? Am I defining the presentation type? Right? Am I defining a database schema? You know, all of these words are a lot more descriptive than types. And the other thing is that often they don't just include types. They also include helpers. Um, so types isn't even accurate.
Um, I a special case of splitting things out is dependency inversion, which I know is a scary I think oopy concept for a
Haskell developer to think about, but it can be very helpful. So if you have A depending on B, right? What you can do is split things. So a depends only on
the interface and that's in B1 and then the implementation is in B2 and a lot of the time the implementation will be a lot more code. So how can you do dependency inversion? One thing you can do is which is really just standard Haskell is records of functions or type classes, right? So you define a record for all of the things you want. You define a type class for all the things you want and then when you use it, you take that as an argument or have that on the have that as a constraint. You can also use effects and I think that's one way I really like to think about effect systems like effectful and blue fin is that they're really ways of getting this sort of dependency inversion. um as a coral area of that like you want to whenever you're defining effects I think you want the effect definition and the effect implementation to be in different files or different packages otherwise you you tend to depend on a lot of extra code sometimes that's okay right some effects don't have a lot of code um but it is helpful to split these things out if you want to maximize a parallelism and yeah those are pretty much the things for optimizing packages you you're looking at your critical path.
You're asking how can I take this thing off the critical path. A lot of the time it's reexports. Sometimes it's splitting modules. Um sometimes it's more more
widespread refactors of your codebase. The important thing is to think about it to look at the critical path and to iterate. And then you've got projects which are composed of packages. And I find that you don't need to have the sort of tooling I had for looking at um module
graphs when you're looking at package graphs mostly because you tend not to have as many packages. I think it is quite doable to look at a dot graph or to get a sense of which packages are on the critical path from looking at your CI logs. So cabal plan and stack dot can
give you these dot graphs. Um, and then why do you want to actually improve the package stuff, right? If you've already improved modules, there's still the critical path of packages. And if you're running things in CI, um, then
you will only have with Nyx, you will only have package level dependency caching. So you will, if anything changes in a specific package, then everything that depends on that package will recompile. So you still care about the cool path quite a lot. And also because you can get better parallelism between packages than you can in a single package. If you are in the very rare case that your bottleneck is um
just the amount of cores that you have available as I was saying before you will hit a limit where adding more cores won't make a difference even though theoretically given perfect parallelism you could you could be better. Um, and in that case, what's very helpful is to just split into multiple packages and then you can build it on multiple machines and then you don't have limits from the cores on a single machine.
A really common shape for a project's
dependency tree is something like this. You have a util package or maybe you have a bunch of utils packages. you have a database schema and on top of a the database schema you have some sort of business logic package and at the very top you have a web service or web services and the issue with this is that you will change your DB schema quite often and then it will invalidate everything on top of it in CI locally it's less bad right especially if you use um multireppel and stuff like that which kind of ignores the package structure uh but even if you're running it locally with Cabal test or something, you still get a lot of overhead from having to rebuild packages even if nothing has changed to them according to GHC.
So people look at this and they say, "Okay, I should split things out." So this is what they do. They'll split out a small business logic package. And now I want I
want to be clear that this makes things worse. Now what happens is business
logic changes and that means that small business logic has to change has to be rebuilt before web service can even start to be built and that's that's really annoying. You've made the critical path worse. The critical path doesn't go the same way anymore. It goes through small business logic now. And because this is a small package you can't really make much use of parallelism. So you've got something on the critical path that'll just make things worse. So you
have to be very careful when doing these changes that you're not just splitting for the sake of splitting. You're thinking about your critical path. And in order to do that, what you want to do is not split like this where you're sequentializing things but split split out from the bottom. So what sort of shape you want is something like this, right? So you want things that get modified together to live together. Um you want to be splitting by theme or team. So for instance, if you have a foo
and a baz theme or team, maybe you would split your package uh your package graph like this where they're largely independent. Um and it's good to think about it in terms of layers, right? do you have I've I've already made things so that you have this clear split into layers but um sometimes that's not the case and you have to massage things into it but you want to enforce invariance like business logic can depend on schema stuff but it can't depend on services right and that means that there is a limit to the depth of your graph so at the bottom you want things that are completely independent of your things like utilities that could be in base or in in an external library, data structures, things like that. And you want to be careful not to make those depend on any other package. You want all of your utility packages to be completely independent. And that means that they very rarely change. And if and
if one of the utility packages changes, then it won't cause all the other utility packages to be rebuilt like dominoes. And then everything else can depend on your utility packages. You want your schema things which is I think one of the few place cases where you can actually make use of perfect parallelism um to be relatively refined and have a
clear purpose. Uh and if they do need to depend on each other, what's helpful is to split out the foreign keys into a different package. And then hopefully your foreign keys don't change all that often. Um, so they don't depend on each other on the same layer. And then you do that again and again as you go up the layers. You can depend on layers below you, but you can't depend on the same level.
It's also important to avoid tiny packages because there's an overhead for each package you have. So if you're having lots of packages that are just one module, maybe you want to avoid that and to group them into a larger semantic category. Another thing that is helpful to consider so you
can get rid of external dependencies, right? Those also add overhead. Um, I
think it's easy to forget about them because you only really rebuild them when your version of the package index or stackage changes. But do you need five XML parsers, some of which haven't been updated in 10 years time? Probably not. And by reducing the amount of say XML parses you depend on, you can really reduce the amount of total code your codebase is depending on. Um, and that can make a big difference as well because that is also part of the file size of your pro
of like your cabal cache and stuff like that. It also makes a difference when loading stuff into GHCI. Just because these things are pre-ompiled, it still means that they have to be loaded, right? uh it also makes a difference for linking and stuff like that which can also be a really bad bottleneck. So yeah, just think about getting rid of external dependencies. Dependencies always easy to add but then very hard to remove. Okay. Um so what you want to do
[clears throat] is put care into your build times, right? You want to benchmark them. Use the tooling I've talked about to figure out how long builds take. Ideally, you would put this stuff on CI and have like a nightly CI job that profiles your build and writes
down a CSV file with maybe your worst
modules, the critical paths for each of your main packages. And then it becomes really easy to see when things regress. And I think to begin with at least that's a really good way of approaching this. You can just say we will try not to regress build times and then incrementally you can improve build times. The main thing you want to do is improve your critical path. This is a really simple metric to look at it. It's very easy to work on it in kind of a blackbox way where you don't think about the internals of GHC. You can just think about individual modules, why they relate on each other and how you can improve that and that will improve your parallelism. It will improve your caching. And then also you
can think about getting rid of the worst offenders in your packages that take the
longest time to compile and figuring out how not to make that the case. And if you do all of this, then you should get really quick builds builds of your projects. Yeah, that's that's me done. Thank you. [applause]
>> Cool. So, questions?
>> Um, >> yeah, please. >> Yeah.
>> I'll I'll repeat. So you talked about splitting interfaces and implementations as one >> trick. >> Yeah. >> Which reminds me of C. >> Yeah. >> And C sort of has almost perfect parallelism. Yeah. The compilation level because >> like every every C file is independent
of every other C file. It just hash includes all the other >> and then they take a very different approach to them. They do achieve cross moduling later by using link optimization. >> Yeah. I just wondering if there's anything that we can uh >> JC has a very different strategy. >> I was actually talking to and >> your thoughts on that. >> Yeah, I was talking to Andreas about this on the train that one thing we can do is uh we can use HS boot files a lot more aggressively. Um >> did you repeat the question? >> Oh sorry [laughter] the first question yeah so um the question was C does this really well.
they have a a good uh split between interface interfaces and implementations and allows them to achieve perfect parallelism and then they have a different approach to doing inlinining where they do it at link time. Um and like have have I thought about stuff like that? Yeah. And um yeah, so we can
do some of that with HS boot files and Andreas has been thinking about doing that in GHC in some places. And you can use HS boot files in a similar way to see header files where you can say okay this is the interface of a module. You can compile this first um and you do and
you compile the implementation later but yeah it would be good to have like yeah a more general solution maybe doing some some of those things automatically. I definitely agree >> cross module inlining >> that defeat cross module inlining. >> Yeah, I I think that's the the tradeoff you make, but I'm not really sure about how HS boot files work. But maybe that's something we want to do if you're compiling without optimizations anyway. Something like that, right? Uh and I think for a long time there's been this this thinking of like can we split type checking and compiling a module into two steps. I think there was some work from Matthew Pickering to do that a long time ago. There was some more recent work from Mark Schlottton on that. So maybe maybe that is worthwhile. And I think in the past we've thought maybe that's not worthwhile. But maybe that's just because we haven't been looking at the structure of packages enough.
>> Yeah. >> Just a quick >> Yeah. >> In the original spec for Haskell, the HI
files were supposed to be written by hand, >> not spit out by the compiler. So in the original hasll spec the the hi
files were written by hand once put out by the compiler. I'm just repeating for the the recording. >> Yes. >> Yeah. Next question. >> Ggo. >> So what is just a comment? So you had the in module. >> Yeah. >> Performance problems and you had three items on it, right? You had program, you had code explosion and you have JC bus. And it would just be a shame not to mention something that's in the intersection of all three which is the application. >> Yeah. >> Because it is programming and the problem is because GC and so my question is >> okay let me just repeat that one first.
Yeah G was just saying that yeah type family applications are an intersection of all three of these. They're excessive type level programming. They lead to code size explosion and they're a GHC bug. Yeah. Go on. And then what's the >> So, so my my question was was going to be about the the inter package >> in Yeah. >> So in your example, it was the different packages that are all in, right? Like this had nothing to do with your really external dependencies in your example with the database schema. >> Yeah. Yeah. >> And so my question is what do you even get from having mult packages for your inhouse stuff because it seems that >> killing off some sharing and opportunity.
>> Yeah, that's a good question. So the you know the the question was what what's actually the point of splitting like this because it's you're killing off some sharing opportunities and the the point is like in some sense you you kind of want just one huge package, right? So but then there's reasons you don't want that. One of the reasons is because it it is helpful for reasoning about code to have multiple packages. I at least I find that very helpful to have a package and hav





