add input filter for umem_cache bufctl stacks #8

Open
wants to merge 1 commit into from

2 participants

@tjfontaine

No description provided.

@davepacheco davepacheco commented on the diff Nov 2, 2013
lib/input-umem-cache.js
+ this.dsr_log = log;
+ this.dsr_linenum = 0;
+ this.dsr_sline = 0;
+ this.dsr_stack = [];
+ this.dsr_carrier = mod_carrier.carry(input);
+ this.dsr_carrier.on('line', this.onLine.bind(this));
+ this.dsr_carrier.on('end', this.onEnd.bind(this));
+
+ mod_events.EventEmitter.call(this);
+}
+
+mod_util.inherits(UmemStreamReader, mod_events.EventEmitter);
+
+UmemStreamReader.prototype.onLine = function (line)
+{
+ /* The first two lines are always ignored. */
@davepacheco
Joyent member

Are there actually two lines ignored in addition to the two lines you're ignoring with each stack?

right so there is a 2 line header for the file in general, and then each sample has a 2 line header

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@davepacheco davepacheco commented on the diff Nov 2, 2013
lib/input-umem-cache.js
+ */
+
+
+var mod_util = require('util');
+var mod_events = require('events');
+
+var mod_carrier = require('carrier');
+
+/* We always ignore the first 2 lines. */
+var NHEADERLINES = 2;
+
+exports.reader = UmemStreamReader;
+
+function UmemStreamReader(input, log)
+{
+ this.dsr_log = log;
@davepacheco
Joyent member

Change the prefix to "usr"?

indeed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@davepacheco
Joyent member

I'm pretty torn about whether it would be worthwhile to commonize some of this code with the code for the DTrace reader. Obviously a fair bit overlaps, but it's intertwined with a bunch of code that's legitimately different. You could extract a few utility functions for stripping function and template arguments and the like, but the complexity (and obfuscation) of an abstract base class to manage the overall control flow may not be worth saving the few LOC involved.

Could you document (even if just in a comment here) what inputs you tested, ideally with some example frames? I may one day refactor the code and it will be useful to have sample input to regression test against.

Thanks for the feature!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment