Skip to content

fs: initialize subsystems lazily - #90

Merged
thaJeztah merged 1 commit into
opencontainers:mainfrom
kolyshkin:fs-lazy-hybrid
Oct 14, 2026
Merged

thaJeztah merged 1 commit into
opencontainers:mainfrom
kolyshkin:fs-lazy-hybrid

Conversation

@kolyshkin

Copy link
Copy Markdown
Contributor

Package init calls IsCgroup2HybridMode, which does statfs(2) on /sys/fs/cgroup/unified. This happens on every start of any program which imports this package (e.g. runc, including runc init, which runs on every container start and exec), even when the fs cgroup manager is never used (as it is the case on cgroup v2 hosts).

Make subsystems a sync.OnceValue to only do this when needed.

This saves about 6.6µs of init time per runc invocation (measured with GODEBUG=inittrace=1).

Package init calls IsCgroup2HybridMode, which does statfs(2) on
/sys/fs/cgroup/unified. This happens on every start of any program
which imports this package (e.g. runc, including runc init), even
when the fs cgroup manager is never used (as it is the case on
cgroup v2 hosts).

Make subsystems a sync.OnceValue to only do this when needed.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
@kolyshkin
kolyshkin requested a review from a team as a code owner October 14, 2026 01:04

@thaJeztah thaJeztah left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@thaJeztah
thaJeztah merged commit 19a2413 into opencontainers:main Oct 14, 2026
15 checks passed
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.

3 participants