Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How does monitoring the event loop works? #1

Open
goldbergyoni opened this issue Mar 11, 2018 · 3 comments
Open

How does monitoring the event loop works? #1

goldbergyoni opened this issue Mar 11, 2018 · 3 comments

Comments

@goldbergyoni
Copy link

Thanks for the great work. I'm just curious, where/how is the event loop monitoring happens? couldn't find that in the code, any reference will be appreciated

@vicanso
Copy link
Owner

vicanso commented Mar 11, 2018

@i0natan In the performance function, there is a setInterval.

function performance() {
  /* eslint prefer-rest-params: 0 */
  const args = Array.from(arguments);
  const interval = get(args, isNumber, 100);
  const fn = get(args, isFunction, noop);
  const unitInfo = convertUnit(get(args, isString, 'B').toUpperCase());
  let start = process.hrtime();
  let cpuUsage = process.cpuUsage && process.cpuUsage();
  const timer = setInterval(() => {
    let result = {
      lag: getDelay(start, interval),
      heap: getHeapStatistics(unitInfo),
      memoryUsage: getMemoryUsage(unitInfo),
    };
....

@goldbergyoni
Copy link
Author

got it, so you assume that a basic interval tells the status of the loop? Node prioritize io based operations, so in theory, it can process many io based items from the queue efficiently but the items in the timers (interval) queues will get delayed (which not necessarily imply a problem)

@vicanso
Copy link
Owner

vicanso commented Mar 12, 2018

Yes, if the applcation is too busy, the performance function will be delayed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants