Skip to content

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.

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.

2 participants