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

Reduce API docs generation time by 97% #620

Merged

Conversation

ironcladlou
Copy link
Contributor

Optimize the API docs generation by disabling the use of Go modules
when running the generation tool. This is a workaround for performance
issues in the upstream libraries:

Before this workaround:

make api-docs  93.87s user 171.98s system 426% cpu 1:02.30 total

After the workaround:

make api-docs  2.91s user 0.83s system 135% cpu 2.752 total

The hack seems worth the 97% improvement for iterating on docs.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Oct 28, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ironcladlou

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 28, 2021
Optimize the API docs generation by disabling the use of Go modules
when running the generation tool. This is a workaround for performance
issues in the upstream libraries:

- kubernetes/gengo#147
- kubernetes/code-generator#69

Before this workaround:

    make api-docs  93.87s user 171.98s system 426% cpu 1:02.30 total

After the workaround:

    make api-docs  2.91s user 0.83s system 135% cpu 2.752 total

The hack seems worth the 97% improvement for iterating on docs.
@enxebre
Copy link
Member

enxebre commented Oct 29, 2021

Which version of go are you using?
What would be the impact if we only to set GO111MODULE="off"? why is the fake go path needed?
FWIW Seems like the reporter managed to reduce performance penalty without the script kubernetes/code-generator#69 (comment)

/lgtm
/hold
To answer my questions above, otherwise feel free to cancel the hold.

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 29, 2021
@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Oct 29, 2021
@ironcladlou
Copy link
Contributor Author

Which version of go are you using?

1.16

What would be the impact if we only to set GO111MODULE="off"?

The tool doesn't work because we're outside GOPATH.

why is the fake go path needed?

Because the performance issues only manifest when running with GO111MODULE=on, and if you set GO111MODULE=off, the code needs to be in GOPATH, which nothing in our current tooling assumes (correctly). If I've got it wrong and there's another way please let me know and I'll refactor.

FWIW Seems like the reporter managed to reduce performance penalty without the script kubernetes/code-generator#69 (comment)

None of the changes they mention include fixing the tool. What exactly did the commenter change that would be applicable here? Nowhere in their explanation do I see any mention of fixing code-generator or gen-crd-api-reference-docs themselves.

/lgtm /hold To answer my questions above, otherwise feel free to cancel the hold.

I don't see any alternative being proposed and the current performance is unacceptable. We can always just remove the hack if somebody comes up with a better way.

@ironcladlou
Copy link
Contributor Author

/hold cancel

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 29, 2021
@openshift-merge-robot openshift-merge-robot merged commit 539a0aa into openshift:main Oct 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants