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

cmd: Generate packages in parallel #2026

Merged
merged 2 commits into from
Jan 19, 2023
Merged

cmd: Generate packages in parallel #2026

merged 2 commits into from
Jan 19, 2023

Conversation

kyleconroy
Copy link
Collaborator

Use errgroup to parallelize generating code for each SQL package. For configurations with many packages, this should dramatically speed up generation.

@@ -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
Copy link
Collaborator Author

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.

Comment on lines +234 to +239
m.Lock()
for n, source := range files {
filename := filepath.Join(dir, out, n)
output[filename] = source
}
m.Unlock()
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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.

@kyleconroy kyleconroy merged commit d64a68b into main Jan 19, 2023
@kyleconroy kyleconroy deleted the kyle/parallel-gen branch January 19, 2023 00:36
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.

1 participant