Tengo un servidor contratado en kimsufi que tiene las siguientes especificaciones:
Intel(R) Atom(TM) CPU N2800 @ 1.86GHz
MemTotal: 4018884 kB
MemFree: 1456208 kB
MemAvailable: 3512600 kB
El problema es que al ejecutar una tarea de gulp me tarda en acabarla sobre 29 segundos, muy diferente a los 3.5 segundos que me tarda la misma tarea en local. Los dos codigos son clon del mismo repositorio y la variable de entorno NODE_ENV también es la misma.
He instalado el modulo time-require de npm, y al pasarlo este es su output en el sevidor:
[11:37:20] Using gulpfile ~/trunk/gulpfile.js
[11:37:20] Starting 'js'...
[11:37:21] Starting 'sass'...
[11:37:39] Version: webpack 1.15.0
Asset Size Chunks Chunk Names
main.js 1.8 kB 0 [emitted] main
main.js.map 1.84 kB 0 [emitted] main
[11:37:39] Finished 'sass' after 18 s
[11:37:39] Finished 'js' after 19 s
[11:37:39] Starting 'build'...
[11:37:39] Finished 'build' after 124 μs
[11:37:39] Starting 'default'...
[11:37:39] Finished 'default' after 50 μs
Start time: (2017-07-21 09:37:17 UTC) [treshold=1%]
# module time %
1 ./lib/src (node_modules/vinyl-fs/lib/src/index.js) 248ms ▇▇ 1%
2 vinyl-fs (node_modules/vinyl-fs/index.js) 370ms ▇▇ 2%
3 gulp (node_modules/gulp/index.js) 404ms ▇▇ 2%
4 svgo (node_modules/svgo/lib/svgo.js) 282ms ▇▇ 1%
5 postcss-svgo (node_modules/postcss-svgo/dist/index.js) 294ms ▇▇ 1%
6 ../data/prefixes (node_modules/autoprefixer/data/prefixes.js) 321ms ▇▇ 1%
7 autoprefixer (node_modules/autoprefixer/lib/autoprefixer.js) 697ms ▇▇▇ 3%
8 cssnano (node_modules/cssnano/dist/index.js) 1.7s ▇▇▇▇▇▇▇ 7%
9 gulp-cssnano (node_modules/gulp-cssnano/index.js) 1.7s ▇▇▇▇▇▇▇▇ 7%
10 gulp-sourcemaps (node_modules/gulp-sourcemaps/index.js) 287ms ▇▇ 1%
11 ./Compiler (node_modules/webpack/lib/Compiler.js) 246ms ▇▇ 1%
12 ./WebpackOptionsApply (node_modules/webpack/lib/WebpackOptionsApply.js) 348ms ▇▇ 2%
13 ./validateSchema (node_modules/webpack/lib/validateSchema.js) 354ms ▇▇ 2%
14 webpack (node_modules/webpack/lib/webpack.js) 1s ▇▇▇▇▇ 4%
15 ./Compiler (node_modules/webpack-stream/node_modules/webpack/lib/Compiler.js) 340ms ▇▇ 1%
16 webpack (node_modules/webpack-stream/node_modules/webpack/lib/webpack.js) 561ms ▇▇▇ 2%
17 ./path (node_modules/babel-traverse/lib/path/index.js) 533ms ▇▇▇ 2%
18 babel-traverse (node_modules/babel-traverse/lib/index.js) 591ms ▇▇▇ 3%
19 babel-template (node_modules/babel-template/lib/index.js) 775ms ▇▇▇▇ 3%
20 ./helpers (node_modules/babel-helpers/lib/helpers.js) 806ms ▇▇▇▇ 4%
21 babel-helpers (node_modules/babel-helpers/lib/index.js) 817ms ▇▇▇▇ 4%
22 ../transformation/file (node_modules/babel-core/lib/transformation/file/index.js) 1.2s ▇▇▇▇▇▇ 5%
23 ./lib/api/node.js (node_modules/babel-core/lib/api/node.js) 1.2s ▇▇▇▇▇▇ 5%
24 babel-core (node_modules/babel-core/index.js) 1.2s ▇▇▇▇▇▇ 5%
25 /home/u13777/trunk/node_modules/babel-load...ex.js (node_modules/babel-loader/lib/index.js) 1.3s ▇▇▇▇▇▇ 6%
26 /home/u13777/trunk/node_modules/babel-pres...node_modules/babel-preset-es2015/lib/index.js) 262ms ▇▇ 1%
Total require(): 3750
Total time: 22.8s
En entorno local este es el output de la tarea:
[11:37:10] Using gulpfile ~/per/webs/fl/gulpfile.js
[11:37:10] Starting 'sass'...
[11:37:10] Starting 'js'...
[11:37:14] Version: webpack 1.15.0
Asset Size Chunks Chunk Names
main.js 1.8 kB 0 [emitted] main
main.js.map 1.85 kB 0 [emitted] main
[11:37:14] Finished 'sass' after 3.84 s
[11:37:14] Finished 'js' after 3.74 s
[11:37:14] Starting 'build'...
[11:37:14] Finished 'build' after 27 μs
[11:37:14] Starting 'default'...
[11:37:14] Finished 'default' after 12 μs
Start time: (2017-07-21 09:37:09 UTC) [treshold=1%]
# module time %
1 ./lib/src (node_modules/vinyl-fs/lib/src/index.js) 58ms ▇▇ 1%
2 vinyl-fs (node_modules/vinyl-fs/index.js) 95ms ▇▇ 2%
3 gulp (node_modules/gulp/index.js) 104ms ▇▇ 2%
4 svgo (node_modules/svgo/lib/svgo.js) 75ms ▇▇ 1%
5 postcss-svgo (node_modules/postcss-svgo/dist/index.js) 78ms ▇▇ 2%
6 ../data/prefixes (node_modules/autoprefixer/data/prefixes.js) 80ms ▇▇ 2%
7 autoprefixer (node_modules/autoprefixer/lib/autoprefixer.js) 182ms ▇▇▇▇ 4%
8 cssnano (node_modules/cssnano/dist/index.js) 444ms ▇▇▇▇▇▇▇▇▇ 9%
9 gulp-cssnano (node_modules/gulp-cssnano/index.js) 447ms ▇▇▇▇▇▇▇▇▇ 9%
10 ./src/init (node_modules/gulp-sourcemaps/src/init/index.js) 61ms ▇▇ 1%
11 gulp-sourcemaps (node_modules/gulp-sourcemaps/index.js) 78ms ▇▇ 2%
12 ./Compilation (node_modules/webpack/lib/Compilation.js) 52ms ▇ 1%
13 ./Compiler (node_modules/webpack/lib/Compiler.js) 79ms ▇▇ 2%
14 ./WebpackOptionsApply (node_modules/webpack/lib/WebpackOptionsApply.js) 115ms ▇▇▇ 2%
15 ./validateSchema (node_modules/webpack/lib/validateSchema.js) 102ms ▇▇ 2%
16 webpack (node_modules/webpack/lib/webpack.js) 316ms ▇▇▇▇▇▇ 6%
17 ./Compiler (node_modules/webpack-stream/node_modules/webpack/lib/Compiler.js) 97ms ▇▇ 2%
18 webpack (node_modules/webpack-stream/node_modules/webpack/lib/webpack.js) 161ms ▇▇▇ 3%
19 ./path (node_modules/babel-traverse/lib/path/index.js) 112ms ▇▇▇ 2%
20 babel-traverse (node_modules/babel-traverse/lib/index.js) 116ms ▇▇▇ 2%
21 babel-template (node_modules/babel-template/lib/index.js) 171ms ▇▇▇▇ 3%
22 ./helpers (node_modules/babel-helpers/lib/helpers.js) 178ms ▇▇▇▇ 3%
23 babel-helpers (node_modules/babel-helpers/lib/index.js) 181ms ▇▇▇▇ 3%
24 ../transformation/file (node_modules/babel-core/lib/transformation/file/index.js) 297ms ▇▇▇▇▇▇ 6%
25 ./lib/api/node.js (node_modules/babel-core/lib/api/node.js) 302ms ▇▇▇▇▇▇ 6%
26 babel-core (node_modules/babel-core/index.js) 303ms ▇▇▇▇▇▇ 6%
27 /home/cueva/per/webs/fl/node_modules/babel-loa...ex.js (node_modules/babel-loader/lib/index.js) 332ms ▇▇▇▇▇▇▇ 6%
28 /home/cueva/per/webs/fl/node_modules/babel-pre...node_modules/babel-preset-es2015/lib/index.js) 67ms ▇▇ 1%
Total require(): 3752
Total time: 5.2s
Y el gulpfile que estoy usando es este:
'use strict'
require('time-require')
var gulp = require('gulp')
var gutil = require('gulp-util')
var nano = require('gulp-cssnano')
var sass = require('gulp-sass')
var sourcemaps = require('gulp-sourcemaps')
var webpack = require('webpack-stream')
var wpOpt = require('webpack').optimize
var named = require('vinyl-named')
var sassTypes = require('node-sass').types
var Svgo = require('svgo')
var paths = require('./package.json').buildPaths
gulp.task('sass', function () {
var _svgo = new Svgo()
var svgOptimize = _svgo.optimize.bind(_svgo)
var sassOpts = {
functions: {
'uri-encode($val)': function uriEncode(val) {
return new sassTypes.String(encodeURIComponent(val.getValue()))
},
'svgo($val)': function svgo(val, done) {
svgOptimize(val.getValue(), function(result) {
done(new sassTypes.String(result.data))
})
},
},
}
if (process.env.NODE_ENV === 'production') {
return gulp.src(paths.sass.i)
.pipe(
sass(sassOpts).on('error', sass.logError)
)
.pipe(nano())
.pipe(gulp.dest(paths.sass.o))
} else {
return gulp.src(paths.sass.i)
.pipe(sourcemaps.init())
.pipe(
sass(sassOpts).on('error', sass.logError)
)
.pipe(nano())
.pipe(sourcemaps.write())
.pipe(gulp.dest(paths.sass.o))
}
})
gulp.task('sass:watch', function () {
gulp.watch('sass/**/*.s{c,a}ss', ['sass'])
})
gulp.task('js', function () {
var conf = require('./webpack.config.js')
if (process.env.NODE_ENV === 'production') {
delete conf.devtool
conf.plugins.push(new wpOpt.UglifyJsPlugin({
compress: {
warnings: false,
},
mangle: {
except: ['$', '$super', 'exports', 'require'],
},
}))
}
return gulp.src(paths.js.i)
.pipe(named())
.pipe(webpack(conf))
.pipe(gulp.dest(paths.js.o))
})
gulp.task('js:watch', function () {
var conf = require('./webpack.config.js')
conf.watch = true
// Webpack logs its own errors. Just swallow error to not break watch
var wp = webpack(conf).on('error', function handleWebpackError() {this.emit('end')})
return gulp.src(paths.js.i)
.pipe(named())
.pipe(wp)
.pipe(gulp.dest(paths.js.o))
})
gulp.task('watch', ['sass'], function () {
gulp.start('sass:watch')
gulp.start('js:watch')
})
gulp.task('build', ['sass', 'js'])
gulp.task('default', ['build'])
Teneis idea de por que puede ser? Siendo entornos con el mismo codigo lo unico que se me ocurre que pueda ser es tema de hardware, pero aunque es una castaña de servidor no creo que tuviese mucho problema para mover esa ejecución.