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

Cache Go builds with rebuild: true runtime option #10473

Closed
2 of 6 tasks
Tracked by #11598
t0yv0 opened this issue Aug 23, 2022 · 1 comment
Closed
2 of 6 tasks
Tracked by #11598

Cache Go builds with rebuild: true runtime option #10473

t0yv0 opened this issue Aug 23, 2022 · 1 comment
Assignees
Labels
impact/performance Something is slower than expected kind/enhancement Improvements or new features language/go resolution/fixed This issue was fixed size/S Estimated effort to complete (1-2 days).
Milestone

Comments

@t0yv0
Copy link
Member

t0yv0 commented Aug 23, 2022

Hello!

  • Vote on this issue by adding a 👍 reaction
  • If you want to implement this feature, comment to let us know (we'll work with you on design, scheduling, etc.)

Issue details

Consider introducing a rebuild: true runtime option for Go programs.
The option is to be used in conjunction with binary: $dest option and
will instruct Pulumi to rebuild the binary with go build -o $dest
prior to executing:

name: mygoproject
description: A minimal Go Pulumi program
runtime:
  name: go
  options:
   binary: ./my-program
   rebuild: true

In version v3.38.0 Pulumi commands such as pulumi up used go run to execute Go code, but is going to use go build -o $tempfile with a temp file after #10375

Pulumi also supports binary option. If set, Pulumi does not build code at all but executes a prebuilt code at the location given by binary.

As it turns out, go build -o $dest can be much more efficient than go build -o $tempfile on repeat invocations. The rebuild: true opens a way to rebuild the binary efficiently as part of normal pulumi up.

It should be an error to specify rebuild: true without also specifying binary.

Alternatives

This feature requires explicit user opt-in to result in speedups. We
considered an alternative design that would speed up all user programs
transparently upon upgrade: a go compilation cache. Pulumi would
manage a LRU binary cache under ~/.pulumi. We decided against this
given some complexity in dealing with locking and managing disk space.

Rollout

Potential speedup

$ pulumi new azure-native-go
$ go build -o proj # initial build

$ hyperfine -i 'go run .'
Benchmark 1: go run .
  Time (mean ± σ):      1.276 s ±  0.036 s    [User: 1.732 s, System: 0.963 s]
  Range (min … max):    1.233 s …  1.333 s    10 runs

  Warning: Ignoring non-zero exit code.

$ hyperfine 'go build -o proj'
Benchmark 1: go build -o proj
  Time (mean ± σ):     228.1 ms ±   2.5 ms    [User: 762.7 ms, System: 782.0 ms]
  Range (min … max):   224.5 ms … 233.2 ms    12 runs

$ hyperfine -i './proj' -n 20
Benchmark 1: 20
  Time (mean ± σ):      12.3 ms ±   1.7 ms    [User: 7.0 ms, System: 3.3 ms]
  Range (min … max):    11.6 ms …  34.1 ms    175 runs

  Warning: Ignoring non-zero exit code.
  Warning: Statistical outliers were detected. Consider re-running this benchmark on a quiet PC without any interferences from other programs. It might help to use the '--warmup' or '--prepare' options.

So the new method would result in a warm start (after initial build)
of 250ms for a Pulumi project using azure-native compared to the 1.2s
baseline with go run. It's common for users to run several
operations that don't result in relinking the binary so these savings
can be meaningful.

Affected area/feature

Go provider.

@t0yv0 t0yv0 added kind/enhancement Improvements or new features needs-triage Needs attention from the triage team and removed needs-triage Needs attention from the triage team labels Aug 23, 2022
@t0yv0
Copy link
Member Author

t0yv0 commented Aug 23, 2022

Noting idea from @AaronFriel to add an option with the path to the binary so users can opt-in to a workspace-local binary path. This seems reasonable.

#10375 (review)

@t0yv0 t0yv0 added language/go impact/performance Something is slower than expected labels Aug 23, 2022
@t0yv0 t0yv0 changed the title Go build cache Cache Go builds with rebuild: true runtime option Aug 24, 2022
@t0yv0 t0yv0 added this to the 0.78 milestone Sep 2, 2022
@t0yv0 t0yv0 added the size/S Estimated effort to complete (1-2 days). label Sep 2, 2022
bors bot added a commit that referenced this issue Sep 21, 2022
10727: Fix incorrect import for non-pulumi owned package on convert r=aq17 a=aq17

<!--- 
Thanks so much for your contribution! If this is your first time contributing, please ensure that you have read the [CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md) documentation.
-->

# Description

<!--- Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. -->

Fixes `pulumi/yaml` [335](pulumi/pulumi-yaml#335)

## Checklist

<!--- Please provide details if the checkbox below is to be left unchecked. -->
- [x] I have added tests that prove my fix is effective or that my feature works
<!--- 
User-facing changes require a CHANGELOG entry.
-->
- [x] I have updated the [CHANGELOG-PENDING](https://github.com/pulumi/pulumi/blob/master/CHANGELOG_PENDING.md) file with my change
<!--
If the change(s) in this PR is a modification of an existing call to the Pulumi Service,
then the service should honor older versions of the CLI where this change would not exist.
You must then bump the API version in /pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi Service API version
  <!-- `@Pulumi` employees: If yes, you must submit corresponding changes in the service repo. -->


10731: add `buildTarget` option for pulumi go programs to compile/recompile to the specified path r=dixler a=dixler

<!--- 
Thanks so much for your contribution! If this is your first time contributing, please ensure that you have read the [CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md) documentation.
-->

# Description

<!--- Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. -->

Part of #10473 

This implements the `buildTarget` option(Pulumi.yaml) for Pulumi Go programs to write the pulumi program out to a file. It has some performance benefits as Go can build a program faster when an existing program is provided.

## Checklist

<!--- Please provide details if the checkbox below is to be left unchecked. -->
- [x] I have added tests that prove my fix is effective or that my feature works
<!--- 
User-facing changes require a CHANGELOG entry.
-->
- [x] I have updated the [CHANGELOG-PENDING](https://github.com/pulumi/pulumi/blob/master/CHANGELOG_PENDING.md) file with my change
<!--
If the change(s) in this PR is a modification of an existing call to the Pulumi Service,
then the service should honor older versions of the CLI where this change would not exist.
You must then bump the API version in /pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi Service API version
  <!-- `@Pulumi` employees: If yes, you must submit corresponding changes in the service repo. -->


10817: Add pulumi-analyzer-policy and pulumi-analyzer-policy-python to the list of bundled plugins r=Frassle a=Frassle

<!--- 
Thanks so much for your contribution! If this is your first time contributing, please ensure that you have read the [CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md) documentation.
-->

# Description

<!--- Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. -->

Fixes discovering these plugins if the directory "pulumi[.exe]" is in is not on PATH.

## Checklist

<!--- Please provide details if the checkbox below is to be left unchecked. -->
- [ ] I have added tests that prove my fix is effective or that my feature works
<!--- 
User-facing changes require a CHANGELOG entry.
-->
- [x] I have run `make changelog` and committed the `changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the Pulumi Service,
then the service should honor older versions of the CLI where this change would not exist.
You must then bump the API version in /pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi Service API version
  <!-- `@Pulumi` employees: If yes, you must submit corresponding changes in the service repo. -->


Co-authored-by: aq17 <aqiu@pulumi.com>
Co-authored-by: Kyle Dixler <kyle@pulumi.com>
Co-authored-by: Fraser Waters <fraser@pulumi.com>
bors bot added a commit that referenced this issue Sep 22, 2022
10731: add `buildTarget` option for pulumi go programs to compile/recompile to the specified path r=dixler a=dixler

<!--- 
Thanks so much for your contribution! If this is your first time contributing, please ensure that you have read the [CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md) documentation.
-->

# Description

<!--- Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. -->

Part of #10473 

This implements the `buildTarget` option(Pulumi.yaml) for Pulumi Go programs to write the pulumi program out to a file. It has some performance benefits as Go can build a program faster when an existing program is provided.

## Checklist

<!--- Please provide details if the checkbox below is to be left unchecked. -->
- [x] I have added tests that prove my fix is effective or that my feature works
<!--- 
User-facing changes require a CHANGELOG entry.
-->
- [x] I have updated the [CHANGELOG-PENDING](https://github.com/pulumi/pulumi/blob/master/CHANGELOG_PENDING.md) file with my change
<!--
If the change(s) in this PR is a modification of an existing call to the Pulumi Service,
then the service should honor older versions of the CLI where this change would not exist.
You must then bump the API version in /pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi Service API version
  <!-- `@Pulumi` employees: If yes, you must submit corresponding changes in the service repo. -->


10817: Add pulumi-analyzer-policy and pulumi-analyzer-policy-python to the list of bundled plugins r=Frassle a=Frassle

<!--- 
Thanks so much for your contribution! If this is your first time contributing, please ensure that you have read the [CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md) documentation.
-->

# Description

<!--- Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. -->

Fixes discovering these plugins if the directory "pulumi[.exe]" is in is not on PATH.

## Checklist

<!--- Please provide details if the checkbox below is to be left unchecked. -->
- [ ] I have added tests that prove my fix is effective or that my feature works
<!--- 
User-facing changes require a CHANGELOG entry.
-->
- [x] I have run `make changelog` and committed the `changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the Pulumi Service,
then the service should honor older versions of the CLI where this change would not exist.
You must then bump the API version in /pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi Service API version
  <!-- `@Pulumi` employees: If yes, you must submit corresponding changes in the service repo. -->


10821: ci: Updated test repo, check if Windows tests pass r=AaronFriel a=AaronFriel

The remote repo has been updated to use the latest Go & Pulumi SDK, so this ought to unblock these tests.

Resolves #8646.

Co-authored-by: Kyle Dixler <kyle@pulumi.com>
Co-authored-by: Fraser Waters <fraser@pulumi.com>
Co-authored-by: Aaron Friel <mayreply@aaronfriel.com>
bors bot added a commit that referenced this issue Sep 22, 2022
10731: add `buildTarget` option for pulumi go programs to compile/recompile to the specified path r=dixler a=dixler

<!--- 
Thanks so much for your contribution! If this is your first time contributing, please ensure that you have read the [CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md) documentation.
-->

# Description

<!--- Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. -->

Part of #10473 

This implements the `buildTarget` option(Pulumi.yaml) for Pulumi Go programs to write the pulumi program out to a file. It has some performance benefits as Go can build a program faster when an existing program is provided.

## Checklist

<!--- Please provide details if the checkbox below is to be left unchecked. -->
- [x] I have added tests that prove my fix is effective or that my feature works
<!--- 
User-facing changes require a CHANGELOG entry.
-->
- [x] I have updated the [CHANGELOG-PENDING](https://github.com/pulumi/pulumi/blob/master/CHANGELOG_PENDING.md) file with my change
<!--
If the change(s) in this PR is a modification of an existing call to the Pulumi Service,
then the service should honor older versions of the CLI where this change would not exist.
You must then bump the API version in /pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi Service API version
  <!-- `@Pulumi` employees: If yes, you must submit corresponding changes in the service repo. -->


Co-authored-by: Kyle Dixler <kyle@pulumi.com>
@t0yv0 t0yv0 added the resolution/fixed This issue was fixed label Sep 22, 2022
@t0yv0 t0yv0 closed this as completed Sep 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
impact/performance Something is slower than expected kind/enhancement Improvements or new features language/go resolution/fixed This issue was fixed size/S Estimated effort to complete (1-2 days).
Projects
None yet
Development

No branches or pull requests

2 participants