Home / File/ SchedulerProfiling.js — react Source File

SchedulerProfiling.js — react Source File

Architecture documentation for SchedulerProfiling.js, a javascript file in the react codebase. 2 imports, 2 dependents.

File javascript BabelCompiler 2 imports 2 dependents

Entity Profile

Dependency Diagram

graph LR
  9e15a95e_7c6b_d823_cd2d_9868d5c3ee4e["SchedulerProfiling.js"]
  0c4003c2_7bcb_0f8f_2e9c_0802d60fa754["SchedulerPriorities.js"]
  9e15a95e_7c6b_d823_cd2d_9868d5c3ee4e --> 0c4003c2_7bcb_0f8f_2e9c_0802d60fa754
  e9a9f488_f0d1_a417_639a_de1cacedce2a["SchedulerFeatureFlags.js"]
  9e15a95e_7c6b_d823_cd2d_9868d5c3ee4e --> e9a9f488_f0d1_a417_639a_de1cacedce2a
  ddd23dfb_c95d_b046_b4f3_3904daada6f0["Scheduler.js"]
  ddd23dfb_c95d_b046_b4f3_3904daada6f0 --> 9e15a95e_7c6b_d823_cd2d_9868d5c3ee4e
  33032601_e035_ce2b_3676_f59ce614c2e5["SchedulerMock.js"]
  33032601_e035_ce2b_3676_f59ce614c2e5 --> 9e15a95e_7c6b_d823_cd2d_9868d5c3ee4e
  style 9e15a95e_7c6b_d823_cd2d_9868d5c3ee4e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

/**
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 * @flow
 */

import type {PriorityLevel} from './SchedulerPriorities';
import {enableProfiling} from './SchedulerFeatureFlags';

let runIdCounter: number = 0;
let mainThreadIdCounter: number = 0;

// Bytes per element is 4
const INITIAL_EVENT_LOG_SIZE = 131072;
const MAX_EVENT_LOG_SIZE = 524288; // Equivalent to 2 megabytes

let eventLogSize = 0;
let eventLogBuffer = null;
let eventLog = null;
let eventLogIndex = 0;

const TaskStartEvent = 1;
const TaskCompleteEvent = 2;
const TaskErrorEvent = 3;
const TaskCancelEvent = 4;
const TaskRunEvent = 5;
const TaskYieldEvent = 6;
const SchedulerSuspendEvent = 7;
const SchedulerResumeEvent = 8;

function logEvent(entries: Array<number | PriorityLevel>) {
  if (eventLog !== null) {
    const offset = eventLogIndex;
    eventLogIndex += entries.length;
    if (eventLogIndex + 1 > eventLogSize) {
      eventLogSize *= 2;
      if (eventLogSize > MAX_EVENT_LOG_SIZE) {
        // Using console['error'] to evade Babel and ESLint
        console['error'](
          "Scheduler Profiling: Event log exceeded maximum size. Don't " +
            'forget to call `stopLoggingProfilingEvents()`.',
        );
        stopLoggingProfilingEvents();
        return;
      }
      const newEventLog = new Int32Array(eventLogSize * 4);
      // $FlowFixMe[incompatible-call] found when upgrading Flow
      newEventLog.set(eventLog);
      eventLogBuffer = newEventLog.buffer;
      eventLog = newEventLog;
    }
    eventLog.set(entries, offset);
  }
}

export function startLoggingProfilingEvents(): void {
  eventLogSize = INITIAL_EVENT_LOG_SIZE;
// ... (120 more lines)

Domain

Frequently Asked Questions

What does SchedulerProfiling.js do?
SchedulerProfiling.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain.
What does SchedulerProfiling.js depend on?
SchedulerProfiling.js imports 2 module(s): SchedulerFeatureFlags.js, SchedulerPriorities.js.
What files import SchedulerProfiling.js?
SchedulerProfiling.js is imported by 2 file(s): Scheduler.js, SchedulerMock.js.
Where is SchedulerProfiling.js in the architecture?
SchedulerProfiling.js is located at packages/scheduler/src/SchedulerProfiling.js (domain: BabelCompiler, directory: packages/scheduler/src).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free