Repository navigation
Interesting behavior with modules during parsing time #3640
Replies: 3 comments 2 replies
|
Another interesting question is: why are we not caching the entire compilation procedure so on recompilation to execute the already generated executable, if the code has not changed at all? Do we even memoize any of the phases' steps? |
|
I think it's important to remember that loading just io::printn would still require a lot of the backend functionality from std::io (it's just a macro over io::fprintn, which wraps io::fprint, which uses a bunch of file-related stuff). For std::io this would mean that a big chunk of the module would still have to be parsed, analyzed, and emitted even in the best case. I will say that this kind of optimization would be really nice to have, and I would love to see it added, but AFAIK the priority for c3c is to improve the language itself rather than compilation speed for now. Also at the bare minimum I'm pretty sure c3c would still have to parse the entire module to be able to figure out what to lazily evaluate, and handling this properly in the semantic analyzer and codegen would take a lot of refactoring. AFAIK nothing is really cached by c3c currently. Personally I think the biggest gains in this department would come from caching LLVM codegen for each module. It may also be possible to generate and cache .c3i header files for each module (and instance of generic modules) so that they don't have to be fully parsed and analyzed every time, but could still be linked in. All of this would take a lot of work though, and may not be technically feasible. As for caching the entire compilation procedure, that would probably be the easiest problem to solve (maybe you could open an issue for it?). The only trouble there is that if the compiler is updated the updated version could refuse to recompile a program (which would make compiler development difficult), but this is probably pretty solvable with either a flag or clever compiler version handling. |
|
The biggest cost is printing fully fleshed panics with formatted output. This pulls in the formatter. You can use If I turn off safety, backtrace and panic messages this is what I get: As you see what's left is from the compiler_rt module which we unfortunately can't separate out yet. Hopefully this explains why there is some binary bloat. |
Uh oh!
There was an error while loading. Please reload this page.
I have noticed an interesting behavior with modules and I wanted to ask.
The following demo code is a simple
hello world:When we execute it with
c3c run --run-once -vvthe output that caught my eye is this:Why are we forced to load the entire
std::iomodule and don't have something like Python'sfrom os import wait?All I need to load from
std::iomodule isio::printn(); plus, it would decrease the summed module time from getting parsed / loaded.Another question would be, why does the compiler not intelligently lazing loads only
io::printn()that is being used?All reactions