Skip to content

Disable Go runtime GC for starter process #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Copyright (c) 2015-2017, Gregory M. Kurtzer. All rights reserved.
Copyright (c) 2016-2017, The Regents of the University of California. All right reserved.
Copyright (c) 2017, SingularityWare, LLC. All rights reserved.
Copyright (c) 2018-2019, Sylabs, Inc. All rights reserved.
Copyright (c) 2018-2021, Sylabs, Inc. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Expand Down
13 changes: 11 additions & 2 deletions cmd/starter/c/starter.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2018-2020, Sylabs, Inc. All rights reserved.
Copyright (c) 2018-2021, Sylabs, Inc. All rights reserved.

This software is licensed under a 3-clause BSD license. Please
consult LICENSE.md file distributed with the sources of this project regarding
Expand Down Expand Up @@ -986,6 +986,7 @@ static void cleanup_fd(fdlist_t *master, struct starter *starter) {
if ( starter->fds[i] == fd ) {
found = true;
/* set force close on exec */
debugf("Setting FD_CLOEXEC on starter fd %d\n", starter->fds[i]);
if ( fcntl(starter->fds[i], F_SETFD, FD_CLOEXEC) < 0 ) {
debugf("Can't set FD_CLOEXEC on file descriptor %d: %s\n", starter->fds[i], strerror(errno));
}
Expand Down Expand Up @@ -1139,9 +1140,17 @@ static void cleanenv(void) {
/*
* keep only SINGULARITY_MESSAGELEVEL for GO runtime, set others to empty
* string and not NULL (see issue #3703 for why)
*
* DCT - also keep any GOGC and GODEBUG vars for go runtime
* debugging purposes.
*/
for (e = environ; *e != NULL; e++) {
if ( strncmp(MSGLVL_ENV "=", *e, sizeof(MSGLVL_ENV)) != 0 ) {
if ( strncmp(MSGLVL_ENV "=", *e, strlen(MSGLVL_ENV "=")) == 0 ||
strncmp("GOGC" "=", *e, strlen("GOGC" "=")) == 0 ||
strncmp("GODEBUG" "=", *e, strlen("GODEBUG" "=")) == 0 ) {
debugf("Keeping env var %s\n", *e);
} else {
debugf("Clearing env var %s\n", *e);
*e = "";
}
}
Expand Down
4 changes: 3 additions & 1 deletion internal/pkg/util/starter/starter.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2019-2020, Sylabs Inc. All rights reserved.
// Copyright (c) 2019-2021, Sylabs Inc. All rights reserved.
// This software is licensed under a 3-clause BSD license. Please consult the
// LICENSE.md file distributed with the sources of this project regarding your
// rights to use or distribute this software.
Expand Down Expand Up @@ -89,6 +89,8 @@ func Exec(name string, config *config.Common, ops ...CommandOp) error {
if err := c.init(config, ops...); err != nil {
return fmt.Errorf("while initializing starter command: %s", err)
}
sylog.Debugf("Setting GOGC=off for starter")
c.env = append(c.env, "GOGC=off")
err := unix.Exec(c.path, []string{name}, c.env)
return fmt.Errorf("while executing %s: %s", c.path, err)
}
Expand Down