The //go:nosplit directive in Go prevents functions from performing stack overflow checks, making them faster but potentially dangerous. While nosplit functions avoid the ~2% performance overhead of stack growth checks and prevent preemption, they can cause linker errors, segfaults, and runtime livelocks if misused. The directive affects asynchronous preemption behavior and has undocumented side effects that make it a powerful but risky optimization tool for high-performance Go code.

10m read timeFrom mcyoung.xyz
Post cover image
Table of contents
Go Stack GrowthNosplit FunctionsBut It’s Harmless…?Other Side EffectsConclusion

Sort: