Sprinkle #[inline]
across scylla-cql
crate to allow inlining into scylla
crate
#949
Labels
Milestone
#[inline]
across scylla-cql
crate to allow inlining into scylla
crate
#949
Motivation
Having read the guidelines on inlining (highly recommended for everyone!), I've understood that adding
#[inline]
explicitly is required to allow inlining across crates.Even with recent
rustc
enhancements (related PR), the inlining policy is very conservative at the moment - requires that an (already optimized) function subject to cross-crate inlining does not contain any asserts nor calls.Problem
scylla-cql
crate's functions are largely short ones and, at the same time, are heavily called byscylla
crate's routines.Suggestion
Adding
#[inline]
toscylla-cql
short functions (as already done in e.g. recently addedRowSerializationContext
) can bring considerable performance benefits on the ser/de code path.Additionally, we can think about small functions in
scylla
that could make the driver's users benefit from their inlining.Note
Do not forget that
#[inline]
requires transitivity. In the following code:if
bar
is called from another crate, it won't be inlined (however, IIUC, it's probable that the call tofoo()
will be inlined intobar
body).In order to enable inlining
bar()
, it is mandatory* that bothfoo
andbar
functions are marked with#[inline]
.*not necessarily after the mentioned recent changes to
rustc
.The text was updated successfully, but these errors were encountered: