Skip to content

Simplify ticks, as the value is a constant#2377

Merged
kolyshkin merged 1 commit into
opencontainers:masterfrom
thaJeztah:ticks_simplify
May 4, 2020
Merged

Simplify ticks, as the value is a constant#2377
kolyshkin merged 1 commit into
opencontainers:masterfrom
thaJeztah:ticks_simplify

Conversation

@thaJeztah
Copy link
Copy Markdown
Member

While checking dependencies, I stumbled on containerd/cgroups#12, which removes the CGO dependency from the containerd/cgroups package. Given that that code was based on the one in libcontainer, looks like we can make the same change here. See the discussion on that PR for further details

See for example in the Musl libc source code https://git.musl-libc.org/cgit/musl/tree/src/conf/sysconf.c#n29

This removes the cgo dependency for the system package.

@thaJeztah
Copy link
Copy Markdown
Member Author

ping @kolyshkin @AkihiroSuda PTAL

@AkihiroSuda
Copy link
Copy Markdown
Member

AkihiroSuda commented May 3, 2020

LGTM

Approved with PullApprove

@thaJeztah
Copy link
Copy Markdown
Member Author

@kolyshkin LGTY? 🤗

Comment thread libcontainer/cgroups/fs/cpuacct.go Outdated
)

var clockTicks = uint64(system.GetClockTicks())
var clockTicks = system.GetClockTicks()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'd rather drop system.GetClockTicks() entirely and have this as

const clockTicks = 100

(with a comment that explains where it is coming from)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Having it as const will help compiler to optimize the calculations, and I doubt there are any external users of system.GetClockTicks().

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It may still be used in some locations outside of runc, so we should probably be careful with removing system.GetClockTicks() altogether, but do you want me to put a const in this file (so that it doesn't depend on libnetwork/system ?

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.

Go API compatibility is not guaranteed across releases (at least until v1.0.0 GA), so we can safely remove system.GetClockTicks().

Copy link
Copy Markdown
Contributor

@kolyshkin kolyshkin left a comment

Choose a reason for hiding this comment

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

suggested to make it const

@thaJeztah
Copy link
Copy Markdown
Member Author

Removed the function, and defined a local const

Comment thread libcontainer/cgroups/fs/cpuacct.go Outdated
See for example in the Musl libc source code https://git.musl-libc.org/cgit/musl/tree/src/conf/sysconf.c#n29

This removes the cgo dependency for the system package.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@AkihiroSuda
Copy link
Copy Markdown
Member

AkihiroSuda commented May 4, 2020

LGTM

Approved with PullApprove

Copy link
Copy Markdown
Contributor

@kolyshkin kolyshkin left a comment

Choose a reason for hiding this comment

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

LGTM

@kolyshkin
Copy link
Copy Markdown
Contributor

kolyshkin commented May 4, 2020

LGTM

Approved with PullApprove

@kolyshkin kolyshkin merged commit 96310f0 into opencontainers:master May 4, 2020
@thaJeztah thaJeztah deleted the ticks_simplify branch May 4, 2020 22:52
@thaJeztah
Copy link
Copy Markdown
Member Author

Thanks!

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