Giter Club home page Giter Club logo

v8-analytics's Introduction

中文版

npm version Package Quality license

v8-analytics/v8-cpu-analysis

Analysis the cpu & heap-memory log file which created by v8-profiler & heapdump,it can:

  • show you functions which are optimized failed by v8 engine
  • show you functions which exectime greater than your expected
  • show you suspicious memory leak point

Why Two Names?

v8-analytics is completely equivalent to v8-cpu-analysis, there is no difference between them.

Beacuse I want to introduce v8 engine's heap-memory analytics, so I think cpu in package name is not suitable. More, to be compatible with before, I chose them published comletely equivalent.

Installation

For Global

$ npm install v8-analytics -g

or

$ npm install v8-cpu-analysis -g

For Embedded JS code

$ npm install v8-analytics

or

$ npm install v8-cpu-analysis

Test

if you install -g, try:

//test bailout
$ va test bailout
$ va test bailout --only
//test timeout
$ va test timeout
$ va test timeout 200
$ va test timeout 200 --only
$ va test leak

va test bailout --only can list you all functions which are deoptimized, and it's deoptimization reason.

va test timeout 200 --only can list you all function which exectime > 200ms.

va test leak cans list you suspicious leak point in your project.

Quick Start

You can use this at the command line or embedded in your js code

I. Command Line

Find Function Bailout Reason

The xxx.cpu.json file created by v8-profiler:

$ va bailout xxx.cpu.json

This will list all Function, and turn the deoptimized function to red. You can also use like that:

$ va bailout xxx.cpu.json --only

This will only list the deoptimized functions.

Find Funtion Exectime Greater Than Expected

$ va timeout xxx.cpu.json

This will list all Function, and their exectime

$ va timeout xxx.cpu.json 200

This will list all Function ,and turn the functions which exectime > 200ms to red.

$ va timeout xxx.cpu.json 200 --only

This will only list the functions which exectime > 200ms.

Find suspicious memory leak point

$ va leak xxx.mem.json

This will show you suspicous leak ponit in your node.js project.

II. Embedded JS Code

'use strict';
const fs = require('fs');
const v8Analytics = require('v8-analytics');
//or you can use following, they're equival
//const v8Analytics = require('v8-cpu-analysis');

//list all js function and it's execTime
const json = JSON.parse(fs.readFileSync('./test.cpu.json'));
const str = v8Analytics(json);
console.log(str);

//list you heap memory info
const json = JSON.parse(fs.readFileSync('./test.mem.json'));
const {leakPoint, heapMap, statistics} = analysisLib.memAnalytics(allData)

v8-analytics's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

v8-analytics's Issues

堆内存heapdump分析出错

const fs = require('fs');
const v8Analytics = require('v8-analytics');

//list you heap memory info
const json = JSON.parse(fs.readFileSync('./heapdump-62589-20180306-110206.heapsnapshot'));
const {leakPoint, heapMap, statistics} = v8Analytics.memAnalytics(json)

console.log(leakPoint,heapMap)

stack:

let nodeDetail = nodes.slice(index * nodeFieldCount, index * nodeFieldCount + nodeFieldCount);
                                       ^

TypeError: Cannot convert a Symbol value to a number
    at heapNodeSerialize (/Users/young/github/Npids/node_modules/v8-analytics/lib/mem_analysis.js:142:40)
    at Object.get (/Users/young/github/Npids/node_modules/v8-analytics/lib/mem_analysis.js:210:40)
    at Object.get (/Users/young/github/Npids/node_modules/v8-analytics/lib/mem_analysis.js:219:26)
    at formatValue (util.js:423:37)
    at inspect (util.js:324:10)
    at format (util.js:191:12)
    at Console.log (console.js:130:21)
    at Object.<anonymous> (/Users/young/github/Npids/analyse/profiler.js:9:9)
    at Module._compile (module.js:643:30)
    at Object.Module._extensions..js (module.js:654:10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.