-
Notifications
You must be signed in to change notification settings - Fork 802
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
cmd: Generate packages in parallel #2026
Conversation
@@ -44,6 +44,7 @@ func Do(args []string, stdin io.Reader, stdout io.Writer, stderr io.Writer) int | |||
rootCmd.SetIn(stdin) | |||
rootCmd.SetOut(stdout) | |||
rootCmd.SetErr(stderr) | |||
rootCmd.SilenceErrors = true |
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.
When we moved to RunE
, we accidentally added some additional error output. Turning that off for now.
m.Lock() | ||
for n, source := range files { | ||
filename := filepath.Join(dir, out, n) | ||
output[filename] = source | ||
} | ||
m.Unlock() |
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.
Writing to a map isn't threadsafe, so put this in mutex. In the future might just use sync.Map
instead.
if failed { | ||
packageRegion.End() | ||
errored = true | ||
break |
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.
If parsing failed, we'd return early. Instead, return errors from every package.
Use
errgroup
to parallelize generating code for each SQL package. For configurations with many packages, this should dramatically speed up generation.