Skip to content
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

tk/export: introduce a configurable memory ballast #669

Merged
merged 2 commits into from
Feb 1, 2022
Merged
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
11 changes: 11 additions & 0 deletions cmd/tk/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package main

import (
"fmt"
"log"
"regexp"
"runtime"

"github.com/go-clix/cli"

Expand Down Expand Up @@ -38,13 +40,22 @@ func exportCmd() *cli.Command {
cachePath := cmd.Flags().StringP("cache-path", "c", "", "Local file path where cached evaluations should be stored")
cacheEnvs := cmd.Flags().StringArrayP("cache-envs", "e", nil, "Regexes which define which environment should be cached (if caching is enabled)")

ballastBytes := cmd.Flags().Int("mem-ballast-size-bytes", 0, "(Experimental) Size of memory ballast to allocate.")
if err := cmd.Flags().MarkHidden("mem-ballast-size-bytes"); err != nil {
log.Fatalf("Could not mark flag as hidden: %s", err)
}

vars := workflowFlags(cmd.Flags())
getJsonnetOpts := jsonnetFlags(cmd.Flags())
getLabelSelector := labelSelectorFlag(cmd.Flags())

recursive := cmd.Flags().BoolP("recursive", "r", false, "Look recursively for Tanka environments")

cmd.Run = func(cmd *cli.Command, args []string) error {
// Allocate a block of memory to alter GC behaviour. See https://github.com/golang/go/issues/23044
Copy link
Member

Choose a reason for hiding this comment

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

ballast := make([]byte, *ballastBytes)
defer runtime.KeepAlive(ballast)

filters, err := process.StrExps(vars.targets...)
if err != nil {
return err
Expand Down