-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Remove usage of GetMounts from GetCgroupMounts #496
Conversation
LGTM |
1 similar comment
LGTM |
for scanner.Scan() { | ||
txt := scanner.Text() | ||
fields := strings.Split(txt, " ") | ||
if fields[len(fields)-3] != "cgroup" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use the post separator logic here as it will be more robust?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@LK4D4 ^.^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mrunalp what do you mean? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant that we can look for the separator -and then match the first word after instead of going minus 3 :) discretionary though :)
Sent from my iPhone
On Jan 30, 2016, at 4:43 AM, Alexander Morozov notifications@github.com wrote:
In libcontainer/cgroups/utils.go:
if mount.Fstype == "cgroup" {
- m := Mount{Mountpoint: mount.Mountpoint, Root: mount.Root}
for _, opt := range strings.Split(mount.VfsOpts, ",") {
if strings.HasPrefix(opt, cgroupNamePrefix) {
m.Subsystems = append(m.Subsystems, opt[len(cgroupNamePrefix):])
}
if allMap[opt] {
m.Subsystems = append(m.Subsystems, opt)
}
- var res []Mount
- scanner := bufio.NewScanner(f)
- for scanner.Scan() {
txt := scanner.Text()
fields := strings.Split(txt, " ")
@mrunalp what do you mean? :)if fields[len(fields)-3] != "cgroup" {
—
Reply to this email directly or view it on GitHub.
GetMounts is very cpu-expensive. I'll change other funcs in this package to reuse code from GetCgroupMounts later. Signed-off-by: Alexander Morozov <lk4d4@docker.com>
@mrunalp I added optimization with "-" and also added test and benchmark. |
Thanks. LGTM. |
Remove usage of GetMounts from GetCgroupMounts
Correction to User struct in specs-go/config.json
GetMounts is very cpu-expensive. I'll change other funcs in this package
to reuse code from GetCgroupMounts later.