@samitouri / QOS-React / commits / 1dc108e582

Tweaked wording for v8 "performance cliff" issue

Brian Vaughn committed Dec 4, 2018 at 07:49 UTC 1dc108e5829bb8d84ffd39e2e932d798edd7ca8b
1 file changed +10 -7
packages/react-reconciler/src/ReactFiber.js
+10 -7
@@ -254,14 +254,16 @@ function FiberNode(
254 this.alternate = null;
255
256 if (enableProfilerTimer) {
257 - // Note: The following is done to avoid a v8 deopt.
257 + // Note: The following is done to avoid a v8 performance cliff.
258 //
259 - // It is important to initialize the fields below with doubles.
260 - // Otherwise Fibers will deopt and end up having separate shapes when
261 - // doubles are later assigned to fields that initially contained smis.
262 - // This is a bug in v8 having something to do with Object.preventExtension().
259 + // Initializing the fields below to smis and later updating them with
260 + // double values will cause Fibers to end up having separate shapes.
261 + // This behavior/bug has something to do with Object.preventExtension().
262 + // Fortunately this only impacts DEV builds.
263 + // Unfortunately it makes React unusably slow for some applications.
264 + // To work around this, initialize the fields below with doubles.
265 //
264 - // Learn more about this deopt here:
266 + // Learn more about this here:
267 // https://github.com/facebook/react/issues/14365
268 // https://bugs.chromium.org/p/v8/issues/detail?id=8538
269 this.actualDuration = Number.NaN;
@@ -270,7 +272,8 @@ function FiberNode(
272 this.treeBaseDuration = Number.NaN;
273
274 // It's okay to replace the initial doubles with smis after initialization.
273 - // This simplifies other profiler code and doesn't trigger the deopt.
275 + // This won't trigger the performance cliff mentioned above,
276 + // and it simplifies other profiler code (including DevTools).
277 this.actualDuration = 0;
278 this.actualStartTime = -1;
279 this.selfBaseDuration = 0;