Giter Club home page Giter Club logo

v8-perf's Introduction

v8-perf

Notes and resources related to V8 and thus Node.js performance.

Table of Contents generated with DocToc

Topics

Data Types

The data types document explains what data types V8 uses under the hood to store JavaScript data and how it relates to the performance of your code.

Compiler

The V8 compiler document outlines the V8 compiler pipeline including the Ignition Interpreter and TurboFan optimizing compiler. It explains how information about your code is executed to allow optimizations, how and when deoptimizations occur and how features like the CodeStubAssembler allowed reducing performance bottlenecks found in the older pipeline.

Language Features

The language features document lists JavaScript language features and provides info with regard to their performance mainly to provide assurance that performance of most features is no longer an issue as it was with the previous compiler pipeline.

Garbage Collector

The V8 garbage collector document talks about how memory is organized on the V8 heap, how garbage collection is performed and how it was parallelized as much as possible to avoid pausing the main thread more than necessary.

Memory Profiling

The memory profiling document explains how JavaScript objects are referenced to form a tree of nodes which the garbage collector uses to determine collectable objects. It also outlines numerous techniques to profile memory leaks and allocations.

Inspection and Performance Profiling

Inside the inspection document you will find techniques that allow you to profile your Node.js or web app, how to produce flamegraphs and what flags and tools are available to gain an insight into operations of V8 itself.

Snapshots and Code Caching

This document includes information as to how V8 uses caching techniques in order to avoid recompiling scripts during initialization and thus achieve faster startup times.

Runtime Functions

The runtime functions document gives a quick intro into C++ functions accessible from JavaScript that can be used to provide information of the V8 engine as well as direct it to take a specific action like optimize a function on next call.

V8 source and documentation

It's best to dig into the source to confirm assumptions about V8 performance first hand.

source

source documentation

Documented V8 source code for specific versions of Node.js can be found on the v8docs page.

LICENSE

MIT

v8-perf's People

Contributors

chayimfriedman2 avatar golopot avatar juanarbol avatar mathiasbynens avatar thlorenz avatar

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  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

v8-perf's Issues

Is Mach-O JIT info generated correctly

Trying to gain information here WRT to a bug I filed with lldb originally.

Basically I just want to make sure I understand the problem correctly in order to file a helpful bug report with the v8 team. I created a step by step guide to help reproduce the problem.

The latest from the mentioned bug report is that some information seems to be missing from the DWARF that is generated by v8 (I wrote the memory indicated to contain the JIT info to disk to be able to dwarfdump it).

Quoting Greg Clayton from the lldb team:

There is just a __TEXT.__text segment and a __TEXT.eh_frame section:

% dwarfdump -R /Volumes/work/gclayton/Downloads/jit.o 
----------------------------------------------------------------------
 File: /Volumes/work/gclayton/Downloads/jit.o (x86_64)
----------------------------------------------------------------------
Header
magic:      0xfeedfacf
cputype:    0x01000007
cpusubtype: 0x00000003
filetype:   0x00000001
ncmds:      0x00000001
sizeofcmds: 0x000000e8
flags:      0x00000000


Segments
Segment Name     vmaddr           vmsize           fileoff          filesize         maxprot  initprot nsects   flags
---------------- ---------------- ---------------- ---------------- ---------------- -------- -------- -------- --------
                 000008c6762a0760 00000000000003d4 0000000000000108 0000000000000068 00000007 00000007 00000002 00000000

Sections
Section Name     Segment Name     addr             size             offset   align    reloff   nreloc   flags    reserv1  reserv2  reserv3  size     size %
---------------- ---------------- ---------------- ---------------- -------- -------- -------- -------- -------- -------- -------- -------- ======== ======
__text           __TEXT           000008c6762a0760 00000000000003d4 00000000 00000005 00000000 00000000 80000400 00000000 00000000 cdcdcdcd  980       nan%
__eh_frame       __TEXT           0000000000000000 0000000000000068 00000108 00000003 00000000 00000000 00000000 00000000 00000000 cdcdcdcd  104       nan%

You might need to tell the JIT memory manager to load the DWARF somehow. It doesn't seem like the DWARF is making it into the final memory mach-o where it probably is for ELF.


@mraleph gave some pointers on twitter

if it does - debug section should be called __debug_info not .debug_info

In the above dwarfdump I see neither of those mentioned debug sections. So seems like it's just missing completely?

Greg Clayton from the lldb team suggested:

get the JIT team to help you to be able to get a the DWARF into the __DWARF segment

indicating that a huge portion of the information is missing.

I personally just started diving into the land of dwarfs, elfs and machos so any help to clarify things or pointers where to look, what to read up on, etc. to figure this out is greatly appreciated.

I also have a feeling that @indutny may know a lot more about this than I do at this point ;)

Add info about memory profiling

Tools and resources regarding Node.js and Performance Tools Integration

goal

I'm trying to gather resources and tools that make it easier to profile Node.js apps ideally by integrating with Chrome Dev tools and chrome://tracing.

what I found so far

Documentation of tools to analyse the data has been started here but the integration part with Node.js is still missing.

I tried to gather some free and open source tools that try to make this easier and would love to get some feedback and/or further tool suggestions. Pointers to any resources that document anything related are also greatly appreciated.

tools

Name In app initialization Instrumentation Description
memwatch Yes No Leak detection and heap usage and diffing.
heapdump Yes No Make a dump of the V8 heap for later inspection
profiler Yes Resume/Pause Access the V8 profiler from node.js DEPRECATED
v8-profiler Yes Start/Stop Provides node bindings for the v8 profiler and integration with node-inspector
node-gc Yes Handle Events Emits events from the V8 garbage collector to let you know when garbage collection occurs
gc-stats Yes Handle Events Emits GC stats events after GC occurred
webkit-devtools-agent Yes No Implementation of Chrome developer tools protocol. Only the heap and CPU profilers are working right now.
trace-viewer Yes Yes JavaScript frontend for Chrome about:tracing and Android systrace. It provides rich analysis and visualization capabilities for trace files, supporting both the linux kernel trace format and Chrome's base/trace_event
tracing-framework No Yes A set of libraries, tools, and visualizers for the tracing and investigation of complex web applications. It helps discover performance problems, track regressions, and build buttery-smooth 60fps web apps.
irhydra No No Tool that can display intermediate representations used by V8 and Dart VM optimizing compilers
cpu-profiler Yes Start/Stop Node bindings for the v8 cpu profiler
chrome-cpu-profiler Yes Start/Stop Allows viewing top down, bottom up and callgraphs of a node app in Google Chrome
perf-cpuprofile No No Converts linux perf tool output to .cpuprofile files readable by chromiums devtools

webkit-devtools-agent looks very promising, but doesn't show flamegraphs and has no time line support.

techniques

With a version of node that has a --log-timer-events as part of v8-options, run the app in profiling mode and load the resulting v8.log into Chrome at chrome://tracing.

Check for supported flag:

➝  node --v8-options | grep log_timer_events
  --log_timer_events (Time events including external callbacks.)

Profile app to generate v8.log including GC events.

node --prof --track_gc_object_stats --trace_gc_verbose --log_timer_events app.js

Loading into chrome://tracing will yield a flame chart similar to the below:

screen_shot_2014-06-17_at_9 08 24_pm

A detailed explanation is outlined in creating v8 profiling timeline plots although some of the information seems a bit outdated.

what I'm interested in

The idea is to find a way to use the built in Chrome tools to profile Node.js apps the same way as is currently possible
for JavaScript apps running in the browser.

Interesting metrics to gather:

Additionally integration with chrome://tracing by passing flags like --log_timer_events are of interest.

Both, CLI and GUI support would be nice to have as well as real-time and historical data.

Advice about array sizes could be misleading

The list at https://github.com/thlorenz/v8-perf/blob/master/data-types.md#fast-elements implies that fast elements have the characteristic of being smaller than 64k. But there is no such restriction, a single array or object can be any size (before causing oom error) and still have fast elements.

The considerations list at https://github.com/thlorenz/v8-perf/blob/master/data-types.md#considerations-1 says not to pre-allocate arrays with more than 64k elements, but this limit has always been 99999 and has never been changed (except when it was temporarily changed to 94999).

How do we provide line by line discussion

@mraleph I thought about what the best way would be to enable you to comment on/correct/add to the material here.

So I squashed all commits into one in order to facilitate a line by line discussion in the the diff.
This way we can go back and forth discussing the details if we want.

However I also created a disc-one branch and gave you commit access to the repo, so you can quickly jot down in that branch whatever needs to be added/corrected. I'll sort it out then to pull it into master.

Let me know if this setup works for you or if you prefer another way to contribute. I wanna make this as easy and efficient as possible.

I very much appreciate you taking the time to contribute to help get this information into a good state :)

Representation of int64 within JS

From discussion on irc -- we need links:

  • for 5.1: The value of Number.MAX_VALUE is the largest positive finite value of the Number type, which is approximately 1.7976931348623157 × 10^308.
  • well, 6 is a little different: The value of Number.MAX_SAFE_INTEGER is 9007199254740991 (2^53−1)
  • so here's the thing, JS only supports IEEE-754 FP... that does not "fit" an int64
  • some early work tootallnate did wrt core
    follows: "if it fits use number, otherwise use string" pattern

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.