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

Revert "Decouple persist and display events (#15529)" #15705

Merged
merged 1 commit into from
Mar 15, 2024

Conversation

Frassle
Copy link
Member

@Frassle Frassle commented Mar 15, 2024

Description

This reverts commit ff7a7b4.

Fixes #15668.

@Frassle Frassle marked this pull request as ready for review March 15, 2024 20:14
@Frassle Frassle requested a review from a team as a code owner March 15, 2024 20:14
@pulumi-bot
Copy link
Contributor

pulumi-bot commented Mar 15, 2024

Changelog

[uncommitted] (2024-03-15)

Bug Fixes

  • [cli/display] Fix superfluous newlines being written during updates
    #15705

@Frassle Frassle enabled auto-merge March 15, 2024 20:26
@Frassle Frassle added this pull request to the merge queue Mar 15, 2024
Merged via the queue into master with commit c465c02 Mar 15, 2024
48 checks passed
@Frassle Frassle deleted the fraser/revert15529 branch March 15, 2024 21:32
github-merge-queue bot pushed a commit that referenced this pull request Mar 18, 2024
<!--- 
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

Retry #15529 with fix for the issue that required the revert in #15705 

This removes a scenario where events could not be persisted to the cloud
because they were waiting on the same event being displayed

Instead of rendering the tree every time a row is updated, instead, this
renders when the display actually happens in the the `frame` call. The
renderer instead simply marks itself as dirty in the `rowUpdated`,
`tick`, `systemMessage` and `done` methods and relies on the frame being
redrawn on a 60Hz timer (the `done` method calls `frame` explicitly).
This makes the rowUpdated call exceedingly cheap (it simply marks the
treeRenderer as dirty) which allows the ProgressDisplay instance to
service the display events faster, which prevents it from blocking the
persist events.

This requires a minor refactor to ensure that the display object is
available in the frame method

Because the treeRenderer is calling back into the ProgressDisplay object
in a goroutine, the ProgressDisplay object needs to be thread safe, so a
read-write mutex is added to protect the `eventUrnToResourceRow` map.
The unused `urnToID` map was removed in passing.

## Impact

There are scenarios where the total time taken for an operation was
dominated by servicing the events.

This reduces the time for a complex (~2000 resources) `pulumi preview`
from 1m45s to 45s

For a `pulumi up` with `-v=11` on a the same stack, where all the
register resource spans were completing in 1h6m and the
postEngineEventBatch events were taking 3h45m, this PR removes the time
impact of reporting the events (greatly inflated by the high verbosity
setting) and the operation takes the anticipated 1h6m


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

Fixes #15668 

This was happening because the renderer was being marked dirty once per
second in a tick event, which caused frame to redraw. There is a check
in the render method that `display.headerRow` is not nil that was
previously used to prevent rendering when no events had been added. This
check is now part of the `markDirty` logic

Some of the tests needed to be updated to make this work and have also
been refactored

## Checklist

- [X] I have run `make tidy` to update any new dependencies
- [X] I have run `make lint` to verify my code passes the lint check
  - [ ] I have formatted my code using `gofumpt`

<!--- 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.
-->
- [ ] 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 Cloud,
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
Cloud API version
<!-- @pulumi employees: If yes, you must submit corresponding changes in
the service repo. -->

---------

Co-authored-by: Paul Roberts <proberts@pulumi.com>
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.

CLI prints a bunch of whitespace between link and resource list
3 participants