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

perf: pull log attributes from test instead of storing log attrs multiple times #23738

Merged
merged 6 commits into from
Sep 9, 2022

Conversation

emilyrohrbough
Copy link
Member

Apart of #23391
Apart of #21135

While profile Cypress to determine the memory impact we have, I noticed we are collecting all of the logs by id to easily pull the log attributes when a reporter command is hovered/clicked to show the console props in the devtools console and to show the associated snapshot.

We keep a reference of all log attributes on each test as well, which we need to store on the server-side when a test navigate to a new origin (thus we update top) and have to re-normalized the test runnables, determine where we left off in the spec run and repopulate the reporter with all of the logs for the spec.

This change updates to pull these log attributes from the test itself instead of storing these attributes again.

Some examples:

Screen Shot 2022-09-08 at 5 05 48 PM

Screen Shot 2022-09-08 at 5 06 50 PM

Screen Shot 2022-09-08 at 5 03 52 PM

User facing changelog

Lump under overall perf updates to reduce memory footprint.

Steps to test

Since this change is related to interactions with the reporter, it's best to pull this down and verify this behavior has been maintained. I've verified in several places and everything seems to check out.

PR Tasks

  • Have tests been added/updated?
  • [n/a] Has the original issue (or this PR, if no issue exists) been tagged with a release in ZenHub? (user-facing changes only)
  • [n/a] Has a PR for user-facing changes been opened in cypress-documentation?
  • [n/a] Have API changes been updated in the type definitions?

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Sep 8, 2022

Thanks for taking the time to open a PR!

@cypress
Copy link

cypress bot commented Sep 8, 2022



Test summary

40019 0 3346 0Flakiness 3


Run details

Project cypress
Status Passed
Commit d3ad5bf
Started Sep 9, 2022 8:51 PM
Ended Sep 9, 2022 9:06 PM
Duration 15:03 💡
OS Linux Debian - 11.3
Browser Multiple

View run in Cypress Dashboard ➡️


Flakiness

config_env.cy.ts Flakiness
1 cy.origin- Cypress.config() > serializable > overwrites different values in secondary, even if the Cypress.config() value does not exist in the primary
2 cy.origin- Cypress.config() > serializable > overwrites different values in secondary if one exists in the primary
user_agent_override.cy.ts Flakiness
1 user agent override > persists modified user agent after cy.go

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

@@ -181,27 +181,27 @@ export class EventManager {
})
})

const logCommand = (logId) => {
const consoleProps = Cypress.runner.getConsolePropsForLogById(logId)
const logCommand = (logIds) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logIds / commandIds are pretty unclear to me - I kept reading this as "an array of log IDs" and an "array of command IDs". I think, since it has just two props, it might be better to split them out as (testId, logId) - or if not, at least rethink the variable name.

const existing = _logsById[attrs.id]
const { instrument } = attrs

// test = getTestById(testId)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of commented out lines here?

// test = getTestById(testId)

// if (test) {
// pluralize the instrument as a property on the runnable
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's an example of 'instrument' that we're pluralizing?

Copy link
Member Author

@emilyrohrbough emilyrohrbough Sep 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be command, route, hook or agent. Sessions is the odd ball instrument to date and is tied to command.

We are storing these on the test as commands, routes, agents, and hooks: https://github.com/cypress-io/cypress/blob/develop/packages/driver/src/cypress/runner.ts#L24

# Conflicts:
#	packages/driver/src/cypress/runner.ts
@@ -20,9 +20,9 @@ class Sessions extends React.Component<SessionsProps> {
}

printToConsole = (name) => {
const logId = this.props.model[name].id
const { id, testId } = this.props.model[name]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this need to be type safe?

Suggested change
const { id, testId } = this.props.model[name]
const { id, testId } = this.props.model[name] || {}

@emilyrohrbough emilyrohrbough merged commit 499c0d1 into develop Sep 9, 2022
@emilyrohrbough emilyrohrbough deleted the store-logs-once branch September 9, 2022 21:38
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Sep 13, 2022

Released in 10.8.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v10.8.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Sep 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants