Skip to content

Commit

Permalink
separate gc/cc intervals
Browse files Browse the repository at this point in the history
  • Loading branch information
flotwig committed Jan 13, 2020
1 parent 1180379 commit 579ef3b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 22 deletions.
14 changes: 7 additions & 7 deletions packages/driver/src/cy/commands/window.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ module.exports = (Commands, Cypress, cy, state, config) ->

Cypress.on "test:before:run:async", (testAttrs) ->
{ order } = testAttrs
fmri = config("firefoxMemoryReductionInterval")

## TODO: add !isInteractive here too
if Cypress.isBrowser('firefox')
## TODO: add !isInteractive here too
shouldRunCc = (order % config("firefoxCcInterval") is 0)
shouldRunGc = (order % config("firefoxGcInterval") is 0)

if shouldRunCc or shouldRunGc
Cypress.backend("reduce:memory:pressure", { shouldRunCc, shouldRunGc })

## if we've enabled firefox memory reduction
## and the test order matches this interval
if fmri > 0 and order % fmri is 0 && Cypress.isBrowser('firefox')
Cypress.backend("reduce:memory:pressure")

Cypress.on "test:before:run:async", ->
## if we have viewportDefaults it means
## something has changed the default and we
Expand Down
25 changes: 11 additions & 14 deletions packages/server/lib/browsers/firefox-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ import util from 'util'
import Foxdriver from '@benmalka/foxdriver'
import { _connectAsync } from './protocol'

type CollectGarbageArgs = {
shouldRunGc: boolean
shouldRunCc: boolean
}

const debug = Debug('cypress:server:browsers')

const promisify = (fn) => {
Expand All @@ -28,7 +33,7 @@ const promisify = (fn) => {

let sendMarionette

let cb
let cb: (args: CollectGarbageArgs) => Promise<void>

let timings = {
gc: [] as any[],
Expand Down Expand Up @@ -96,8 +101,8 @@ module.exports = {
log()
},

collectGarbage () {
return cb()
collectGarbage (args: CollectGarbageArgs) {
return cb(args)
},

setup (extensions, url) {
Expand Down Expand Up @@ -168,12 +173,12 @@ module.exports = {
})
})

cb = () => {
cb = (args: CollectGarbageArgs) => {
let duration

const gc = (tab) => {
return () => {
if (process.env.CYPRESS_SKIP_GC) {
if (!args.shouldRunGc) {
return
}

Expand All @@ -191,7 +196,7 @@ module.exports = {

const cc = (tab) => {
return () => {
if (process.env.CYPRESS_SKIP_CC) {
if (!args.shouldRunCc) {
return
}

Expand All @@ -212,17 +217,9 @@ module.exports = {
return attach(tab)
.then(gc(tab))
.then(cc(tab))
// .then(() => {
// return tab.memory.measure()
// .then(console.log)
// })
// })
})
.tapCatch((err) => {
console.log('firefox RDP error', err.stack)

// eslint-disable-next-line no-debugger
debugger
})
}
},
Expand Down
6 changes: 6 additions & 0 deletions packages/server/lib/config.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ breakingConfigKeys = toWords """
# Internal configuration properties the user should be able to overwrite
systemConfigKeys = toWords """
browsers
firefoxGcInterval
firefoxCcInterval
"""

CONFIG_DEFAULTS = {
Expand Down Expand Up @@ -140,6 +142,8 @@ CONFIG_DEFAULTS = {
pluginsFile: "cypress/plugins"
nodeVersion: "default"
configFile: "cypress.json"
firefoxGcInterval: 1
firefoxCcInterval: 1

## deprecated
javascripts: []
Expand Down Expand Up @@ -181,6 +185,8 @@ validationRules = {
viewportWidth: v.isNumber
waitForAnimations: v.isBoolean
watchForFileChanges: v.isBoolean
firefoxCcInterval: v.isNumber
firefoxCcInterval: v.isNumber
}

convertRelativeToAbsolutePaths = (projectRoot, obj, defaults = {}) ->
Expand Down
2 changes: 1 addition & 1 deletion packages/server/lib/socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ class Socket {
case 'log:memory:pressure':
return firefoxUtil.log()
case 'reduce:memory:pressure':
return firefoxUtil.collectGarbage()
return firefoxUtil.collectGarbage(args[0])
case 'incoming:xhr':
return options.onIncomingXhr(args[0], args[1])
case 'get:fixture':
Expand Down

1 comment on commit 579ef3b

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 579ef3b Jan 13, 2020

Choose a reason for hiding this comment

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

Circle has built the linux x64 version of the Test Runner.

You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.

You will need to use custom CYPRESS_INSTALL_BINARY url and install Cypress using an url instead of the version.

export CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/3.8.3/linux-x64/circle-issue-1096-firefox-support-579ef3b3eaf0f9aefe4e7e903d7ef0f497e75086-230549/cypress.zip
npm install https://cdn.cypress.io/beta/npm/3.8.3/circle-issue-1096-firefox-support-579ef3b3eaf0f9aefe4e7e903d7ef0f497e75086-230537/cypress.tgz

Please sign in to comment.