Memeht has uploaded a new change for review.
https://gerrit.wikimedia.org/r/193068
Change subject: Amend timers to include Memory Usage reporting
......................................................................
Amend timers to include Memory Usage reporting
Included instrumentation in api/server.js to send heap usage stats using node-
txstatsd's timing method. Modified the node-txstatsd wrapper (in
lib/mediawiki.Util.js) to allow for non-timing specific stats. Amended timers
in api/routes.js and lib/mediawiki.Serializer.js to include changes to node-
txstatsd timing method. The api/server.js instrumentation allows for heap
(rss, total and used) statistics from child processes to be sent to Graphite
every five minutes.
Bug: T89932
Change-Id: I0dd0afb0f9e7b85906042b1b690eec8a5ef8d07f
---
M api/routes.js
M api/server.js
M lib/mediawiki.SelectiveSerializer.js
M lib/mediawiki.Util.js
4 files changed, 17 insertions(+), 9 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid
refs/changes/68/193068/1
diff --git a/api/routes.js b/api/routes.js
index 3ad436d..fd05aa7 100644
--- a/api/routes.js
+++ b/api/routes.js
@@ -317,7 +317,7 @@
}
if ( timer ) {
- timer.timing( 'html2wt.total', '', startTimers.get(
'html2wt.total' ) );
+ timer.timing( 'html2wt.total', '', ( startTimers.get(
'html2wt.total' ) - Date.now()) );
}
env.log("info", "completed serializing in",
env.performance.duration, "ms");
@@ -379,11 +379,11 @@
if ( timer ){
if ( startTimers.has( 'wt2html.parse.wt' ) ){
- timer.timing( 'wt2html.parse.wt', '',
startTimers.get( 'wt2html.parse.wt' ) );
+ timer.timing( 'wt2html.parse.wt', '', (
startTimers.get( 'wt2html.parse.wt' ) - Date.now()) );
} else if ( startTimers.has(
'wt2html.parse.pageWithOldid' ) ){
- timer.timing( 'wt2html.parse.pageWithOldid',
'', startTimers.get( 'wt2html.parse.pageWithOldid' ) );
+ timer.timing( 'wt2html.parse.pageWithOldid',
'', ( startTimers.get( 'wt2html.parse.pageWithOldid' ) - Date.now()) );
}
- timer.timing( 'wt2html.total', '', startTimers.get(
'wt2html.total' ) );
+ timer.timing( 'wt2html.total', '', ( startTimers.get(
'wt2html.total' ) - Date.now()) );
}
env.log("info", "completed parsing in",
env.performance.duration, "ms");
diff --git a/api/server.js b/api/server.js
index 39af966..b876082 100755
--- a/api/server.js
+++ b/api/server.js
@@ -182,6 +182,15 @@
heapdump.writeSnapshot();
});
+ if (parsoidConfig.performanceTimer){
+ setInterval(function(){
+ var heapUsage = process.memoryUsage();
+ parsoidConfig.performanceTimer.timing('heap.rss',
heapUsage.rss);
+ parsoidConfig.performanceTimer.timing('heap.total',
heapUsage.heapTotal);
+ parsoidConfig.performanceTimer.timing('heap.used',
heapUsage.heapUsed);
+ }, 5*6000 );
+ }
+
var app = new ParsoidService( parsoidConfig, logger );
}
diff --git a/lib/mediawiki.SelectiveSerializer.js
b/lib/mediawiki.SelectiveSerializer.js
index ba30f05..6cde536 100644
--- a/lib/mediawiki.SelectiveSerializer.js
+++ b/lib/mediawiki.SelectiveSerializer.js
@@ -69,7 +69,7 @@
this.wts.serializeDOM( body, cb, false, finalcb );
if ( this.timer ) {
- this.timer.timing( 'html2wt.serialize.full', '',
startTimers.get( 'html2wt.serialize.full' ) );
+ this.timer.timing( 'html2wt.serialize.full', '', (
startTimers.get( 'html2wt.serialize.full' ) - Date.now()) );
}
} else {
// Use provided diff-marked DOM (used during testing)
@@ -82,7 +82,7 @@
var diff = this.env.page.domdiff || new DOMDiff( this.env
).diff( body );
if ( this.timer ) {
- this.timer.timing( 'html2wt.domDiff', '',
startTimers.get( 'html2wt.domDiff' ) );
+ this.timer.timing( 'html2wt.domDiff', '', (
startTimers.get( 'html2wt.domDiff' ) - Date.now()) );
}
if ( !diff.isEmpty ) {
@@ -102,7 +102,7 @@
this.wts.serializeDOM( body, cb, true, finalcb );
if ( this.timer ) {
- this.timer.timing( 'html2wt.serialize.selser',
'', startTimers.get( 'html2wt.serialize.selser' ) );
+ this.timer.timing( 'html2wt.serialize.selser',
'', ( startTimers.get( 'html2wt.serialize.selser' ) - Date.now()) );
}
} else {
diff --git a/lib/mediawiki.Util.js b/lib/mediawiki.Util.js
index a426b68..b46a158 100644
--- a/lib/mediawiki.Util.js
+++ b/lib/mediawiki.Util.js
@@ -1516,8 +1516,7 @@
}
};
-Util.StatsD.prototype.timing = function timing(name, suffix, start) {
- var delta = Date.now() - start;
+Util.StatsD.prototype.timing = function timing(name, suffix, delta) {
name = this.makeName(name);
if (Array.isArray(suffix)) {
// Send several timings at once
--
To view, visit https://gerrit.wikimedia.org/r/193068
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0dd0afb0f9e7b85906042b1b690eec8a5ef8d07f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Memeht <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits