Skip to content

Do not inline collinear_chaining into get_chains - #655

Merged
marcelm merged 1 commit into
mainfrom
chaining-noinline
Oct 14, 2026
Merged

marcelm merged 1 commit into
mainfrom
chaining-noinline

Conversation

@ksahlin

@ksahlin ksahlin commented Oct 11, 2026 •

Copy link
Copy Markdown
Owner

When collinear_chaining is inlined into get_chains, it seems the compiler
generates a slower DP loop. Marking it #[inline(never)] seems to make
chaining a tad faster.

Output is unchanged.

Speedup on an Apple M4 Max (rustc 1.97.0), -x, 1 thread, median of 3 runs:

  • chrY: chaining -2.6% to -3.2%, total mapping time -1.6% to -2.2%
  • CHM13: chaining -2.4% to -4.6%, total mapping time -0.5% to -1.2%
  • maize (B73): chaining -2.8% to -4.3%, total mapping time +0.7% to -2.1%
  • maize (Mo17): chaining -2.1% to -3.3%, total mapping time -0.6% to -0.8%
  • rye (Lo7 and Lo7_V3): chaining -3.9% to -5.2%, total mapping time -1.3% to -2.3%
  • fruit fly: chaining -3.1% to -4.0%, total mapping time -0.3% to -0.9%

The measurements are from one machine and compiler (Apple M4 Max, rustc 1.97.0),
so it may not hold across other environments.

@marcelm

marcelm commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator

I’ve spent too much time benchmarking this change now, so I’ll just merge it because the diff is small. The difference is minute, but there seems to be one. I’m generally not so keen on overriding compiler decisions because the compiler usually knows better, and even if it helps now, it is possible that this optimization turns into a pessimization when we upgrade the compiler. But for now, it does improve things a tiny bit. We just need to re-benchmark this when we update the compiler.

When collinear_chaining is inlined into get_chains, it seems the compiler
generates a slower DP loop. Marking it #[inline(never)] seems to make
chaining a tad faster.

Output is unchanged.

Speedup on an Apple M4 Max (rustc 1.97.0), -x, 1 thread, median of 3 runs:

- chrY, 20 kb reads: chaining -3.0%, total mapping time -2.6%
- fruit fly, 10 kb reads: chaining -3.6%, total mapping time -0.9%

The measurements are from one machine and compiler (Apple M4 Max, rustc 1.97.0),
so it may not hold across other environments.
@ksahlin

ksahlin commented Oct 14, 2026

Copy link
Copy Markdown
Owner Author

Sounds good!

@marcelm
marcelm merged commit 62cd178 into main Oct 14, 2026
7 checks passed
@marcelm
marcelm deleted the chaining-noinline branch October 14, 2026 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants