brson · GitHub

The way tikv_alloc uses features makes it easy to silently break it's conditional compilation such that it's impossible to disable jemalloc.

tikv_alloc makes jemalloc a default feature that can be turned off by asking cargo to disable its default features. In order to make it possible to do so, the tikv create marks jemalloc as default-features = false and turns them back on by itself making jemalloc a default feature.

Unfortunately it is very easy to link crates together in a way that makes it impossible to turn off default features. For it to be possible to turn off default features, every crate that links to tikv_alloc or tikv must configure it as default-features = false. Features are additive, so if any crate in the dag requests the feature, including the default feature, then it will be on.

Someone adding a new crate is probably not going to to know this.

So I think the right way to organize the features is to not name "jemalloc" as a default feature. in either tikv or tikv_alloc. That way crates don't have to turn off the default feature. jemalloc is still used by default, there's just no feature named "jemalloc". Instead there is a feature named "system-alloc".

Need to wait for #4207, which itself is reorganizing the features to make tcmalloc work.

Read the original on github.com ↗