@@ -254,14 +254,16 @@ function FiberNode(
254
254
this . alternate = null ;
255
255
256
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
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.
263
265
//
264
- // Learn more about this deopt here:
266
+ // Learn more about this here:
265
267
// https://github.com/facebook/react/issues/14365
266
268
// https://bugs.chromium.org/p/v8/issues/detail?id=8538
267
269
this . actualDuration = Number . NaN ;
@@ -270,7 +272,8 @@ function FiberNode(
270
272
this . treeBaseDuration = Number . NaN ;
271
273
272
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).
274
277
this . actualDuration = 0 ;
275
278
this . actualStartTime = - 1 ;
276
279
this . selfBaseDuration = 0 ;
0 commit comments