Skip to content

Instantly share code, notes, and snippets.

View sreepurnajasti's full-sized avatar

sreepurna sreepurnajasti

View GitHub Profile
@sreepurnajasti
sreepurnajasti / cpu.js
Created April 27, 2017 06:21
This is a program which causes high cpu consumption of Node production anomaly
var obj;
var str = JSON.stringify(console);
while (true) {
obj = JSON.parse(str);
str = JSON.stringify(obj);
}
--log_gc (Log heap samples on garbage collection for the hp2ps tool.)
type: bool default: false
--expose_gc (expose gc extension)
type: bool default: false
--max_new_space_size (max size of the new generation (in kBytes))
type: int default: 0
--max_old_space_size (max size of the old generation (in Mbytes))
type: int default: 0
--max_executable_size (max size of executable memory (in Mbytes))
type: int default: 0
var http = require('http');
var fs = require('fs');
var data = fs.readFileSync('./data.in');
var server = http.createServer(function(req, res) {
console.log('connected');
res.end(data);
});
server.listen(25000);
@sreepurnajasti
sreepurnajasti / perf_modifiednode.txt
Created February 15, 2017 12:17
perf report for exp.js
25.40%node libc-2.17.so [.] memchr
16.84%node [kernel.kallsyms] [k] copy_user_enhanced_fast_string
10.57%node node [.] v8::internal::StringSearch<unsigned char, unsigned char>::LinearSearch(v8::internal::StringSearch<unsigned char, unsigned char>*, v8::internal::Vector<unsigned char const>, int)
10.40%node libc-2.17.so [.] __memcpy_ssse3_back
4.88%node node [.] v8::internal::Factory::NewStringFromUtf8(v8::internal::Vector<char const>, v8::internal::PretenureFlag)
1.95%node [kernel.kallsyms] [k] free_hot_cold_page
1.77%node [kernel.kallsyms] [k] put_page
1.05%node [kernel.kallsyms] [k] iowrite16
1.04%node perf-27128.map [.] Builtin:RegExpPrototypeExec
1.01%node [kernel.kallsyms] [k] __do_softirq
@sreepurnajasti
sreepurnajasti / exp.js
Last active February 15, 2017 12:15
A testcase which can holds to 128* 100 connections parllely and matching the data chunk with a specified word and storing its word count in a file.
var http = require('http');
var util = require('util');
var fs = require("fs");
var string = 'http://' + process.argv[2] + ':' + process.argv[3] + '/';
var out = fs.createWriteStream('./out.txt');
var start = process.hrtime();
@sreepurnajasti
sreepurnajasti / down.js
Created February 10, 2017 07:12
A test case which implements an multi-client download by calibrating the libuv loop
var app = require('appmetrics');
var mon = app.monitor();
var http = require('http');
var util = require('util');
mon.on('eventloop', function(d) {
console.log(Math.round(d.latency.avg));
});
var string = 'http://' + process.argv[2] + ':' + process.argv[3] + '/';