You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Building project takes a *long* time (esp compilation time for datafusion core crate) #13814
However, I think it will not help CI where the use of such caching doesn't help (and since the intermediate rust files are so large trying to use cargo cache wasn't effective in the past when we tried)
I would love to figure out how to break the datafusion core crate into smaller pieces / crates that can be compiled in parallel
FWIW the only reliable mechanism I've found to measure this is to comment out modules and measure the impact on compilation time. Llvm-lines and cargo-bloat can be informative, but not all lines are created equal. This is especially true for code with complex lifetimes and/or async.
Anything making extensive use of macros is likely a good place to start
IIRC that relates to type checking expressions, and therefore this would suggest the compiler is spending a lot of time resolving generics. At least historically non-boxed async has been a good source of this, as async "desugars" to quite complex generic code, and often has quite complex Send / lifetime constraints.
using following command on release 42.0.0, 45.0.0, and current main.
cargo build -p datafusion-cli --timings -j 10
[42.0.0]
[45.0.0]
[46.0.0]
There is some improvement in build time (201sec -> 190 sec-->183sec), for datafusion crate(65->65->49).(some progress!!)
also, this article and the issue mentioned above by @tustvold(rust-lang/rust#87012) looks promising. The problem cause also seems to be similar between evaluate_obligation[1] and async_trait. Though I am not sure if we can apply the same tricks in our usecase. Is it technically possible[2] and worth a try?
[1]: I think evaluate_obligation and process_obligation are same, correct me if I am wrong.
[2]: I am guessing it should be possible but not too sure.
There is some improvement in build time (201sec -> 190 sec-->183sec), for datafusion crate(65->65->49).(some progress!!)
Pulling stuff out of core helped! Thank you !
I was wondering recently if the the probably could be related to all the re-exports (pub use ....) we do in DataFusion. Maybe we could see if reducing them helped 🤔
I think before we spend a lot of time engineering some solution we should try and do something quick and dirty to prove it will help. If it does then we can figure out how to make it work reasonably / get it in chunks
@crepererum pointed out recently that there is a Rust blog post about the new solver in the Rust compiler (and it mentions that datafusion specifically as something that gets 10x faster with the new solver):
@crepererum pointed out recently that there is a Rust blog post about the new solver in the Rust compiler (and it mentions that datafusion specifically as something that gets 10x faster with the new solver):
I am not sure if this will be in addition to what @Dandandan did in #13814 (comment), but it is pretty cool to see the shoutout
Yes - it is the same issue, so this will probably no longer give any speed up - in fact I measured compilation to be a bit slower in the next gen trait solver (I guess it probably will be optimized a bit further before stabilization).
10x (or 4x in the linked article) refers to optimizing the new solver (which was slower than the old one first), also it probably cargo check or something on that module only (i.e. not all dependent crates). The 10x happens to correspond with perf(core): cut datafusion core compile time ~10x #24329 as well.
I think we should close this issue and open a new one for additional build time issues so that we can start a clean slate. I think the root cause here was fixed, and we can always improve build times
Activity
Omega359 commentedon Dec 17, 2024
install sccache and tell rust to use it
With the above two options I see a full build on my machine taking 100.8s (1m 40.8s).
https://corrode.dev/blog/tips-for-faster-rust-compile-times/
alamb commentedon Dec 17, 2024
This makes sense -- thank you @Omega359
However, I think it will not help CI where the use of such caching doesn't help (and since the intermediate rust files are so large trying to use cargo cache wasn't effective in the past when we tried)
I would love to figure out how to break the datafusion core crate into smaller pieces / crates that can be compiled in parallel
Omega359 commentedon Dec 17, 2024
fwiw I tried to gather a bit more info with llvm-lines:
cargo llvm-lines -p datafusion --lib | head -20findepi commentedon Dec 18, 2024
yes! and move around sqlparser dependency when doing so :)
tustvold commentedon Dec 19, 2024
FWIW the only reliable mechanism I've found to measure this is to comment out modules and measure the impact on compilation time. Llvm-lines and cargo-bloat can be informative, but not all lines are created equal. This is especially true for code with complex lifetimes and/or async.
Anything making extensive use of macros is likely a good place to start
alamb commentedon Mar 10, 2025
BTW I did some profiling on this today and it seems a non trivial amount of time is spent type checking / resolving functions somehow...
comphead commentedon Mar 10, 2025
might be compiler related?
tustvold commentedon Mar 10, 2025
IIRC that relates to type checking expressions, and therefore this would suggest the compiler is spending a lot of time resolving generics. At least historically non-boxed async has been a good source of this, as async "desugars" to quite complex generic code, and often has quite complex Send / lifetime constraints.
Edit: rust-lang/rust#87012 is the related issue I was thinking of
comphead commentedon Mar 10, 2025
Thanks @tustvold it was nice attempt to solve it 3 years ago, hopefully someone is planning to close it out one day
alamb commentedon Mar 11, 2025
One thing that is strange is that we have moved most of the code out of datafusion-core now.
I am still hoping we can get https://github.com/apache/datafusion/tree/main/datafusion/core/src/datasource/physical_plan out of the core somehow (I know @AdamGS is thinking about that)
However, I don't think that is the problem either as all the formts are feature gated and when I build with no default feaatures
When I build with no default features:
I get
And then adding parquet (by far the largest / most complex), it goes up by only 1 seconds
alamb commentedon Mar 11, 2025
I also tried removing all the doctests from lib.rs and that didn't help (I didn't expect it to but I wanted to try)
alamb commentedon Mar 11, 2025
I also tried cutting out (ablating) the contents of b/datafusion/core/src/physical_planner.rs but that diidn't seem to make any difference either
logan-keede commentedon Mar 14, 2025
using following command on release 42.0.0, 45.0.0, and current main.
[42.0.0]






[45.0.0]
[46.0.0]
There is some improvement in build time (201sec -> 190 sec-->183sec), for datafusion crate(65->65->49).(some progress!!)
also, this article and the issue mentioned above by @tustvold(rust-lang/rust#87012) looks promising. The problem cause also seems to be similar between evaluate_obligation[1] and
async_trait. Though I am not sure if we can apply the same tricks in our usecase. Is it technically possible[2] and worth a try?[1]: I think evaluate_obligation and process_obligation are same, correct me if I am wrong.
[2]: I am guessing it should be possible but not too sure.
alamb commentedon Mar 15, 2025
Pulling stuff out of core helped! Thank you !
I was wondering recently if the the probably could be related to all the re-exports (
pub use ....) we do in DataFusion. Maybe we could see if reducing them helped 🤔I think before we spend a lot of time engineering some solution we should try and do something quick and dirty to prove it will help. If it does then we can figure out how to make it work reasonably / get it in chunks
36 remaining items
Docs: document manual catalog impls and how compilation got faster (a…
perf: Update `TableProvider` to take scan projection as `Option<&[usi…
perf(catalog): cut `datafusion-catalog` compile time ~6x (apache#24325)
perf(core): cut `datafusion` core compile time ~10x (apache#24329)
perf(catalog-listing): cut `datafusion-catalog-listing` compile time …
perf(session): cut `datafusion-session` compile time ~1.7x (apache#24326
perf(build): don't build the doc-generator binaries by default (apach…
perf(build): use line-tables-only debug info in the `dev` profile (ap…
Docs: document manual catalog impls and how compilation got faster (a…
perf: Update `TableProvider` to take scan projection as `Option<&[usi…
alamb commentedon Aug 24, 2026
@crepererum pointed out recently that there is a Rust blog post about the new solver in the Rust compiler (and it mentions that datafusion specifically as something that gets 10x faster with the new solver):
https://blog.rust-lang.org/2026/08/21/enabling-next-solver-on-nightly/
I am not sure if this will be in addition to what @Dandandan did in #13814 (comment), but it is pretty cool to see the shoutout
Dandandan commentedon Aug 24, 2026
Yes - it is the same issue, so this will probably no longer give any speed up - in fact I measured compilation to be a bit slower in the next gen trait solver (I guess it probably will be optimized a bit further before stabilization).
cargo checkor something on that module only (i.e. not all dependent crates). The 10x happens to correspond with perf(core): cutdatafusioncore compile time ~10x #24329 as well.Sendproofs per impl when an outlives where-bound is in scope rust-lang/rust#157595 (comment)alamb commentedon Aug 27, 2026
Possibly related: #24727 tracks reducing unnecessary monomorphization (generic functions that compile to many near-identical copies).
alamb commentedon Sep 10, 2026
I think we should close this issue and open a new one for additional build time issues so that we can start a clean slate. I think the root cause here was fixed, and we can always improve build times