-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
TLDR rather than fighting entropy lets just brute-force compilation
Is your feature request related to a problem or challenge? Please describe what you are trying to do.
The arrow crate is getting rather large, and is starting to show up as a non-trivial bottleneck when compiling code, see #2170. There have been some efforts to reduce the amount of generated code, see #1858, but this is going to be a perpetual losing battle against new feature additions.
I think there are a couple of problems currently:
- Limited build parallelism, especially if codegen-units is set low
- Upstream crates have to "depend" on functionality they don't need, e.g.
parquetdepending on compute kernels - Minor changes force large amounts of recompilation, with incremental compilation only helping marginally
- Codegen is rarely linear in complexity, consequently larger codegen units take longer than the same amount of code in smaller units
All these conspire to often result in an arrow shaped hole in compilation, where CPUs are left idle.
Some numbers from my local machine
- Release with default features: 232 seconds
- Release with default features without comparison kernels: 150 seconds
- Release with default features without compute kernels: 70 seconds
- Release without default features without compute kernels: 60 seconds
The vast majority of the time all bar a single core is idle.
Describe the solution you'd like
I would like to propose we split up the arrow crate, into a number of sub-crates that are then re-exported by the top-level arrow crate. Users can then choose to depend on the batteries included arrow crate, or more granular crates.
Initially I would propose the following split:
- arrow-csv: CSV reader support
- arrow-ipc: IPC support
- arrow-json: JSON support (related to Make JSON support Optional via Feature Flag #2300)
- arrow-compute: contents of compute module
- arrow-test: arrow test_utils (not published)
- arrow-core: everything else
There is definitely scope for splitting up the crates further after this, in particular the comparison kernels might be a good candidate to live on their own, but I think lets start small and go from there. I suspect there is a fair amount of disentangling that will be necessary to achieve this.
Describe alternatives you've considered
Feature flags are another way this can be handled, however, they have a couple of limitations:
- It is impractical to test the full combinatorial explosion of combinations, which allows for bugs to sneak through
- They are unified for a target which limits build parallelism, just because say DataFusion depends on arrow with CSV support, shouldn't force the
parquetcrate to wait for this to compile before it can start compiling - Poor UX:
- Discoverability is limited, it can be hard to determine what features gate what functionality
- Hard to determine if the feature flag set is minimal, no equivalent of cargo-udeps
- It can be a non-trivial detective exercise to determine why a given feature is being enabled
- Necessitate counter-intuitive hacks to play nicely in multi-crate workspaces - see workspace hack
Additional context
@jimexist recently drove an initiative to do something similar to DataFusion which has worked very well - apache/datafusion#1750