Nice, thanks for sharing the results! -- Benedikt
Wink Saville <[email protected]> schrieb am Do., 22. Juni 2017, 02:55: > I've now tested v8 6.1 using the Node V9 canary build, see the details > here <https://github.com/winksaville/test-nn-ts/tree/nodev9>. The summary > is that Nodev9 for both ES5 and ES6 run approximately the same speed at > 820,000 eps which is about *1.7x faster* than Nodev8 using ES5! > > Kudo's to the V8 team!! > > > On Monday, June 12, 2017 at 9:36:01 PM UTC-7, Benedikt Meurer wrote: > >> With V8 5.8, that sounds possible. In 5.8 modern JavaScript (i.e. ES2015 >> and later) is sent to the new compiler pipeline (based on Ignition and >> TurboFan), whereas classic JavaScript is sent to the old compiler pipeline >> (based on FullCodegen and Crankshaft). JavaScript code is strictly divided >> by this and so you have a two-world view problem. In your case you >> probably benefit from having the JIT inline the class constructor for you >> into call sites, but with ES6 classes and V8 5.8, that's only possible if >> the call site also lives in the Ignition+TurboFan world, which is probably >> not the case and hence you see a significant slowdown already. All of these >> problems disappear with V8 5.9/6.0, which is what Node 8 will upgrade to >> eventually. >> >> HTH, >> Benedikt >> >> On Tue, Jun 13, 2017 at 12:18 AM Wink Saville <[email protected]> wrote: >> > I've created a simple NeuralNet program >>> <https://github.com/winksaville/test-nn-ts> in TypeScript v2.3.4 >>> running on node v8.1.0 and v8 v5.8.283.41: >>> >>> $ npm version >>>> { 'test-nn-ts': '0.1.0', >>>> npm: '4.6.1', >>>> ares: '1.12.0', >>>> cldr: '31.0.1', >>>> http_parser: '2.7.1', >>>> icu: '59.1', >>>> modules: '57', >>>> node: '8.1.0', >>>> openssl: '1.0.2l', >>>> tz: '2017b', >>>> unicode: '9.0', >>>> uv: '1.12.0', >>>> v8: '5.8.283.41', >>>> zlib: '1.2.11' } >>> >>> >>> When I target es6 the program runs 6x slower than if target es5. >>> >>> Here is the output when targeting es5: >>> >>> $ yarn runit 1000000 >>>> yarn runit v0.24.6 >>>> $ yarn build && yarn doit 1000000 >>>> yarn build v0.24.6 >>>> $ tsc -p src/tsconfig.json >>>> Done in 2.02s. >>>> yarn doit v0.24.6 >>>> $ node build/test-nn.js 1000000 >>>> Epoch=1,000,000 Error=4.63e-7 time=2.06s eps=484,784 >>>> Pat Input0 Input1 Target0 Output0 >>>> 0 0 0 0 0.000448827454864753 >>>> 1 1 0 1 0.9995444354288804 >>>> 2 0 1 1 0.9995445564977191 >>>> 3 1 1 0 0.0005558910332638871 >>>> Done in 2.24s. >>>> Done in 4.63s. >>> >>> >>> And here is the output targeting es6: >>> >>> $ yarn runit 1000000 >>>> yarn runit v0.24.6 >>>> $ yarn build && yarn doit 1000000 >>>> yarn build v0.24.6 >>>> $ tsc -p src/tsconfig.json >>>> Done in 1.99s. >>>> yarn doit v0.24.6 >>>> $ node build/test-nn.js 1000000 >>>> Epoch=1,000,000 Error=4.63e-7 time=13.29s eps=75,239 >>>> Pat Input0 Input1 Target0 Output0 >>>> 0 0 0 0 0.000448827454864753 >>>> 1 1 0 1 0.9995444354288804 >>>> 2 0 1 1 0.9995445564977191 >>>> 3 1 1 0 0.0005558910332638871 >>>> Done in 13.47s. >>>> Done in 15.84s. >>> >>> >>> Here is a snippet of the beginning of the NeuralNet.js targeting es5: >>> >>> var Neuron_1 = require("./Neuron"); >>>> var DBG = false; >>>> var Debug_1 = require("./Debug"); >>>> var NeuralNet = (function () { >>>> function NeuralNet(num_in_neurons, num_hidden_layers, >>>> num_out_neurons) { >>>> if (DBG) >>>> Debug_1.default("ctor:+ in_neurons=" + num_in_neurons + " >>>> hidden_layers=" + num_hidden_layers + " out_neurons=" + num_out_neurons); >>>> this.max_layers = 2; // We always have an input and output layer >>>> this.max_layers += num_hidden_layers; // Add num_hidden layers >>>> this.out_layer = this.max_layers - 1; // last one is out_layer >>>> this.last_hidden = 0; // No hidden layers yet >>>> this.points = 0; // No points yet >>>> this.error = 0; // No errors yet >>>> this.learning_rate = 0.5; // Learning rate aka eta >>>> this.momentum_factor = 0.9; // momemtum factor aka alpha >>>> this.layers = new Array(this.max_layers); >>>> // Create the input and output layers >>>> this.create_layer(0, num_in_neurons); >>>> this.create_layer(this.out_layer, num_out_neurons); >>>> if (DBG) >>>> Debug_1.default("ctor:-"); >>>> } >>>> NeuralNet.prototype.create_layer = function (layer_index, >>>> num_neurons) { >>>> if (DBG) >>>> Debug_1.default("create_layer:+ layer_index=" + layer_index >>>> + " num_neurons=" + num_neurons); >>>> this.layers[layer_index] = new Array(num_neurons); >>>> if (DBG) >>>> Debug_1.default("create_layer:- layer_index=" + layer_index >>>> + " num_neurons=" + num_neurons); >>>> }; >>> >>> >>> >>> And here is a snippet targeting es6: >>> >>> const Neuron_1 = require("./Neuron"); >>>> const DBG = false; >>>> const Debug_1 = require("./Debug"); >>>> class NeuralNet { >>>> constructor(num_in_neurons, num_hidden_layers, num_out_neurons) { >>>> if (DBG) >>>> Debug_1.default(`ctor:+ in_neurons=${num_in_neurons} >>>> hidden_layers=${num_hidden_layers} out_neurons=${num_out_neurons}`); >>>> this.max_layers = 2; // We always have an input and output layer >>>> this.max_layers += num_hidden_layers; // Add num_hidden layers >>>> this.out_layer = this.max_layers - 1; // last one is out_layer >>>> this.last_hidden = 0; // No hidden layers yet >>>> this.points = 0; // No points yet >>>> this.error = 0; // No errors yet >>>> this.learning_rate = 0.5; // Learning rate aka eta >>>> this.momentum_factor = 0.9; // momemtum factor aka alpha >>>> this.layers = new Array(this.max_layers); >>>> // Create the input and output layers >>>> this.create_layer(0, num_in_neurons); >>>> this.create_layer(this.out_layer, num_out_neurons); >>>> if (DBG) >>>> Debug_1.default("ctor:-"); >>>> } >>>> create_layer(layer_index, num_neurons) { >>>> if (DBG) >>>> Debug_1.default(`create_layer:+ layer_index=${layer_index} >>>> num_neurons=${num_neurons}`); >>>> this.layers[layer_index] = new Array(num_neurons); >>>> if (DBG) >>>> Debug_1.default(`create_layer:- layer_index=${layer_index} >>>> num_neurons=${num_neurons}`); >>>> } >>> >>> >>> Have I done something wrong or is this expected? >>> >>> -- Wink >>> >>> -- >>> -- >>> v8-dev mailing list >>> >> [email protected] >> >> >>> http://groups.google.com/group/v8-dev >>> --- >>> You received this message because you are subscribed to the Google >>> Groups "v8-dev" group. >>> >> To unsubscribe from this group and stop receiving emails from it, send an >>> email to [email protected]. >> >> >>> For more options, visit https://groups.google.com/d/optout. >>> >> -- > -- > v8-dev mailing list > [email protected] > http://groups.google.com/group/v8-dev > --- > You received this message because you are subscribed to the Google Groups > "v8-dev" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- -- v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev --- You received this message because you are subscribed to the Google Groups "v8-dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
