All Projects → NathanaelA → V8 Natives

NathanaelA / V8 Natives

Licence: mit
Access v8 Engine Natives easily in Chrome & Node

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to V8 Natives

Snappy
snAppy is a VS Code extension coupled with an interactive view to support your React front-end delivery.
Stars: ✭ 144 (-10.56%)
Mutual labels:  optimization
Yopo You Only Propagate Once
Code for our nips19 paper: You Only Propagate Once: Accelerating Adversarial Training Via Maximal Principle
Stars: ✭ 152 (-5.59%)
Mutual labels:  optimization
Structured Data Json Ld
Collection of structured data snippets in Google preferred JSON-LD format.
Stars: ✭ 157 (-2.48%)
Mutual labels:  optimization
Fantasy Basketball
Scraping statistics, predicting NBA player performance with neural networks and boosting algorithms, and optimising lineups for Draft Kings with genetic algorithm. Capstone Project for Machine Learning Engineer Nanodegree by Udacity.
Stars: ✭ 146 (-9.32%)
Mutual labels:  optimization
Cosmo.jl
COSMO: Accelerated ADMM-based solver for convex conic optimisation problems (LP, QP, SOCP, SDP, ExpCP, PowCP). Automatic chordal decomposition of sparse semidefinite programs.
Stars: ✭ 149 (-7.45%)
Mutual labels:  optimization
Swissarmylib
Collection of helpful utilities we use in our Unity projects.
Stars: ✭ 154 (-4.35%)
Mutual labels:  optimization
Soot
Soot - A Java optimization framework
Stars: ✭ 2,049 (+1172.67%)
Mutual labels:  optimization
Cpmoptimize
🚀 🐍 Optimizes Python bytecode calculating linear recurrences
Stars: ✭ 159 (-1.24%)
Mutual labels:  optimization
Webdnn
The Fastest DNN Running Framework on Web Browser
Stars: ✭ 1,850 (+1049.07%)
Mutual labels:  optimization
Ceviche
🦐 Electromagnetic Simulation + Automatic Differentiation
Stars: ✭ 157 (-2.48%)
Mutual labels:  optimization
Deep Learning Specialization Coursera
Deep Learning Specialization courses by Andrew Ng, deeplearning.ai
Stars: ✭ 146 (-9.32%)
Mutual labels:  optimization
Easyengine
Command-line control panel for Nginx Server to manage WordPress sites running on Nginx, PHP, MySQL, and Let's Encrypt
Stars: ✭ 1,881 (+1068.32%)
Mutual labels:  optimization
Galacticoptim.jl
Local, global, and beyond optimization for scientific machine learning (SciML)
Stars: ✭ 155 (-3.73%)
Mutual labels:  optimization
Georaptor
Python Geohash Compression Tool
Stars: ✭ 143 (-11.18%)
Mutual labels:  optimization
Mtuner
MTuner is a C/C++ memory profiler and memory leak finder for Windows, PlayStation 4 and 3, Android and other platforms
Stars: ✭ 2,007 (+1146.58%)
Mutual labels:  optimization
Nlopt.jl
Package to call the NLopt nonlinear-optimization library from the Julia language
Stars: ✭ 141 (-12.42%)
Mutual labels:  optimization
Core
Server core components which are a part of ONLYOFFICE Document Server
Stars: ✭ 152 (-5.59%)
Mutual labels:  v8
Far Ho
Gradient based hyperparameter optimization & meta-learning package for TensorFlow
Stars: ✭ 161 (+0%)
Mutual labels:  optimization
Router
⚡️ A lightning fast HTTP router
Stars: ✭ 158 (-1.86%)
Mutual labels:  optimization
Mesh Flow Video Stabilization
Online video stabilization using a novel MeshFlow motion model
Stars: ✭ 154 (-4.35%)
Mutual labels:  optimization

v8-Natives

npm npm npm Twitter Follow

Updated:

Last Tested on Node 8.7 & Chrome 66

Access v8 Engine Natives easily in Chrome & Node

I was reading a blog/wiki article at https://github.com/petkaantonov/bluebird/wiki/Optimization-killers and it presents some really low level diagnostic commands that I was totally unaware of; and so I found them to be totally awesome in scope for several things I do. The V8 engine has a large array of commands that you can call that can get and/or set status in the actual v8 engine. This library is my attempt to make my life a lot easier and eliminate the errors in trying to use the v8 native commands. These low level commands allow you access to tell the v8 engine to optimize a routine and then find out if a routine can/is optimized.

Now, you can call the v8 native commands directly (for example %CollectGarbage()); however if you forget to use the --allow-natives-syntax then the v8 engine will immediately stop parsing the file as the v8 commands all start with a '%' which is invalid JavaScript... What this library does is it is a simple wrapper that wraps those calls; so that I can do (v8.CollectGarbage()). If you forgot the --allow-natives-syntax it will still run your code fine; it just won't do anything.

In the examples folder is a browser example; to show you how it works in Chrome/Chromium (chrome --js-flags="--allow-natives-syntax" browser.html). You can run it in a non-v8 browser and it will just use the dummy shim.
In addition there is a NodeJS example to show you the same support in NodeJS. (node --allow-natives-syntax node.js)

Please note the examples and helper commands can show you how to use a good chunk of the optimization, general and Memory calls in the library. If someone wants to work up some examples using the variable/object information commands; they would gladly be accepted!

Installing V8 Natives

npm install v8-natives

Breaking changes

Removed from recent versions of V8

  • setFlags
  • getV8Version

Renamed in v8

  • functionGetName = getFunctionName

Usage

Browser:

<script src="v8-browser.js" onload="waitForV8(some_callback)"></script>
<script>function some_callback() { 
  v8.collectGarbage(); 
  /* more v8.commands */}
</script>

Node:

var v8 = require('v8-natives');   
v8.collectGarbage(); 
/* more v8 commands */

Commands

Helper Commands

  • helpers.testOptimization(func[, funcNames]) - This will automatically call the function once, call the optimizeOnNextCall; call the function again, and then call printStatus on the function. You can also do: testOptimization([func1, func2, func3]) this is so that if you have func1 which called func2 & func3 you can see if all three get optimized. It will automatically call func1, set the optimization flag on all three funcs, and then call func1 and then printStatus on all three funcs.
  • helpers.printStatus(func) - Prints the function optimization results to the console
  • helpers.benchmark(count, func) - Runs a func in a loop count times. This will automatically set the optimization flag; run it count times, run garbageCollection start the time; run func for count times; and then return the total time taken.
  • window.waitForV8(callback) - [Browser ONLY]; this will wait until the v8 namespace is loaded properly and then call your callback.

General Commands

  • isNative() - Is the Native Support mode enabled (i.e. true = uses real wrapper; false = use dummy wrapper)
  • functionGetName(func) - Gets the string name of a function

Memory Commands

  • getHeapUsage() - Shows how much heap is used
  • collectGarbage() - Force a full Garbage Collection

Optimization Commands

  • deoptimizeNow -
  • optimizeFunctionOnNextCall(func) - Tells v8 to optimizes the function the next time you call it
  • deoptimizeFunction(func) - De-optimize a function
  • neverOptimizeFunction(func) - Never Optimize a function
  • getOptimizationStatus(func) - Get the functions optimization status [1 = Optimized, 2 = Un-optimized, 3 = Always Optimized, 4 = Never Optimized, 5 = ?, 6 = Maybe Optimized] I've only seen 1 & 2 from my tests; but according to the blog/wiki article I read 3, 4 & 6 are valid also)

Variable/Object information Commands

  • hasFastProperties(obj)
  • hasFastSmiElements(obj)
  • hasFastObjectElements(obj)
  • hasFastDoubleElements(obj)
  • hasDictionaryElements(obj)
  • hasFastHoleyElements(obj)
  • haveSameMap(obj1, obj2)
  • isValidSmi(obj)
  • isSmi(obj)
  • hasFastSmiOrObjectElements(obj)
  • hasSloppyArgumentsElements(obj)

Notes

optimizedFunctionOnNextCall(func) needs the function ran before it can tag it for optimization. So the procedure is:

  • Run your function
  • Run your function (Have to do this TWICE)
  • Tag your function for optimization
  • Run your Function
  • Verify that the v8 Engine optimized it. If it did not optimized it; then that means you have code that can't be optimized in it.

ChangeLog

v8 Internal function list has changed the following functions have been removed:

  • getOptimizationCount

v8 Renamed:

  • ClearFunctionTypeFeedback to ClearFunctionFeedback
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].