Skip to content

Commit

Permalink
Delete logTopLevelRenders flag and console timing (facebook#9825)
Browse files Browse the repository at this point in the history
This was mostly used for timing of initial mounts. However, we haven't
implemented that in Fiber and yet nobody has complained despite running
without it. Further more the update tracks any update within the tree,
not just updates to the props of the top level. This is much less useful
due to the variation.

I could make this track initial mounts too but it's a bit awkward so I'd
rather just delete it if possible. We can run the full profiling mode if
we want more coverage.
  • Loading branch information
sebmarkbage authored Jun 1, 2017
1 parent f3dd489 commit 9dcc60a
Show file tree
Hide file tree
Showing 8 changed files with 0 additions and 121 deletions.
3 changes: 0 additions & 3 deletions scripts/fiber/tests-failing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,3 @@ src/renderers/dom/shared/__tests__/ReactDOMTextComponent-test.js
* can reconcile text merged by Node.normalize()
* can reconcile text arbitrarily split into multiple nodes
* can reconcile text arbitrarily split into multiple nodes on some substitutions only

src/renderers/dom/shared/__tests__/ReactMount-test.js
* marks top-level mounts
1 change: 0 additions & 1 deletion scripts/fiber/tests-passing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,6 @@ src/renderers/__tests__/ReactUpdates-test.js
* should queue updates from during mount
* calls componentWillReceiveProps setState callback properly
* does not call render after a component as been deleted
* marks top-level updates
* throws in setState if the update callback is not a function
* throws in forceUpdate if the update callback is not a function
* does not update one component twice in a batch (#2410)
Expand Down
34 changes: 0 additions & 34 deletions src/renderers/__tests__/ReactUpdates-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -825,40 +825,6 @@ describe('ReactUpdates', () => {
expect(renderCount).toBe(1);
});

it('marks top-level updates', () => {
var ReactFeatureFlags = require('ReactFeatureFlags');

class Foo extends React.Component {
render() {
return <Bar />;
}
}

class Bar extends React.Component {
render() {
return <div />;
}
}

var container = document.createElement('div');
ReactDOM.render(<Foo />, container);

try {
ReactFeatureFlags.logTopLevelRenders = true;
spyOn(console, 'time');
spyOn(console, 'timeEnd');

ReactDOM.render(<Foo />, container);

expect(console.time.calls.count()).toBe(1);
expect(console.time.calls.argsFor(0)[0]).toBe('React update: Foo');
expect(console.timeEnd.calls.count()).toBe(1);
expect(console.timeEnd.calls.argsFor(0)[0]).toBe('React update: Foo');
} finally {
ReactFeatureFlags.logTopLevelRenders = false;
}
});

it('throws in setState if the update callback is not a function', () => {
spyOn(console, 'error');

Expand Down
31 changes: 0 additions & 31 deletions src/renderers/dom/shared/__tests__/ReactMount-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,35 +310,4 @@ describe('ReactMount', () => {

expect(calls).toBe(5);
});

it('marks top-level mounts', () => {
var ReactFeatureFlags = require('ReactFeatureFlags');

class Foo extends React.Component {
render() {
return <Bar />;
}
}

class Bar extends React.Component {
render() {
return <div />;
}
}

try {
ReactFeatureFlags.logTopLevelRenders = true;
spyOn(console, 'time');
spyOn(console, 'timeEnd');

ReactTestUtils.renderIntoDocument(<Foo />);

expect(console.time.calls.count()).toBe(1);
expect(console.time.calls.argsFor(0)[0]).toBe('React mount: Foo');
expect(console.timeEnd.calls.count()).toBe(1);
expect(console.timeEnd.calls.argsFor(0)[0]).toBe('React mount: Foo');
} finally {
ReactFeatureFlags.logTopLevelRenders = false;
}
});
});
15 changes: 0 additions & 15 deletions src/renderers/dom/stack/client/ReactMount.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ var React = require('react');
var ReactDOMComponentTree = require('ReactDOMComponentTree');
var ReactDOMContainerInfo = require('ReactDOMContainerInfo');
var ReactDOMFeatureFlags = require('ReactDOMFeatureFlags');
var ReactFeatureFlags = require('ReactFeatureFlags');
var ReactInstanceMap = require('ReactInstanceMap');
var ReactInstrumentation = require('ReactInstrumentation');
var ReactMarkupChecksum = require('ReactMarkupChecksum');
Expand Down Expand Up @@ -99,16 +98,6 @@ function mountComponentIntoNode(
shouldReuseMarkup,
context,
) {
var markerName;
if (ReactFeatureFlags.logTopLevelRenders) {
var wrappedElement = wrapperInstance._currentElement.props.child;
var type = wrappedElement.type;
markerName =
'React mount: ' +
(typeof type === 'string' ? type : type.displayName || type.name);
console.time(markerName);
}

var markup = ReactReconciler.mountComponent(
wrapperInstance,
transaction,
Expand All @@ -118,10 +107,6 @@ function mountComponentIntoNode(
0 /* parentDebugID */,
);

if (markerName) {
console.timeEnd(markerName);
}

wrapperInstance._renderedComponent._topLevelWrapper = wrapperInstance;
ReactMount._mountImageIntoNode(
markup,
Expand Down
17 changes: 0 additions & 17 deletions src/renderers/shared/fiber/ReactFiberScheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ var ReactFiberCompleteWork = require('ReactFiberCompleteWork');
var ReactFiberCommitWork = require('ReactFiberCommitWork');
var ReactFiberHostContext = require('ReactFiberHostContext');
var ReactFiberHydrationContext = require('ReactFiberHydrationContext');
var ReactFeatureFlags = require('ReactFeatureFlags');
var {ReactCurrentOwner} = require('ReactGlobalSharedState');
var getComponentName = require('getComponentName');

Expand Down Expand Up @@ -793,18 +792,6 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
nextUnitOfWork = findNextUnitOfWork();
}

let hostRootTimeMarker;
if (
ReactFeatureFlags.logTopLevelRenders &&
nextUnitOfWork !== null &&
nextUnitOfWork.tag === HostRoot &&
nextUnitOfWork.child !== null
) {
const componentName = getComponentName(nextUnitOfWork.child) || '';
hostRootTimeMarker = 'React update: ' + componentName;
console.time(hostRootTimeMarker);
}

// If there's a deadline, and we're not performing Task work, perform work
// using this loop that checks the deadline on every iteration.
if (deadline !== null && priorityLevel > TaskPriority) {
Expand Down Expand Up @@ -851,10 +838,6 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
}
}
}

if (hostRootTimeMarker) {
console.timeEnd(hostRootTimeMarker);
}
}

function performWork(
Expand Down
16 changes: 0 additions & 16 deletions src/renderers/shared/stack/reconciler/ReactUpdates.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
'use strict';

var PooledClass = require('PooledClass');
var ReactFeatureFlags = require('ReactFeatureFlags');
var ReactReconciler = require('ReactReconciler');
var Transaction = require('Transaction');

Expand Down Expand Up @@ -131,26 +130,11 @@ function runBatchedUpdates(transaction) {
// that performUpdateIfNecessary is a noop.
var component = dirtyComponents[i];

var markerName;
if (ReactFeatureFlags.logTopLevelRenders) {
var namedComponent = component;
// Duck type TopLevelWrapper. This is probably always true.
if (component._currentElement.type.isReactTopLevelWrapper) {
namedComponent = component._renderedComponent;
}
markerName = 'React update: ' + namedComponent.getName();
console.time(markerName);
}

ReactReconciler.performUpdateIfNecessary(
component,
transaction.reconcileTransaction,
updateBatchNumber,
);

if (markerName) {
console.timeEnd(markerName);
}
}
}

Expand Down
4 changes: 0 additions & 4 deletions src/renderers/shared/utils/ReactFeatureFlags.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@
'use strict';

var ReactFeatureFlags = {
// When true, call console.time() before and .timeEnd() after each top-level
// render (both initial renders and updates). Useful when looking at prod-mode
// timeline profiles in Chrome, for example.
logTopLevelRenders: false,
prepareNewChildrenBeforeUnmountInStack: true,
disableNewFiberFeatures: false,
enableAsyncSubtreeAPI: false,
Expand Down

0 comments on commit 9dcc60a

Please sign in to comment.