This module provides the best of both worlds of spawn and exec
It will simply return 2 strings containing stdout and stderr
(like child_process.exec), but will take an array of process arguments
(like child_process.spawn) to avoid any nasty shell expansion.
I wrote up a super small module to mimic clear on the command line for
Node.js. I was surprised when I didn’t find a module that already
did this in npm.
I wrote this module as a way to help organize my collection of flac
and mp3 files. It can automatically inspect your music files
metadata tags, and rename the files based on them.
I like to have both Chromium and Chrome installed on my mac, but installing Chromium
is not as easy as installing Chrome. Chromium required me to find the tarballs that
were generated from the Chromium source control, and to make sure that I was only pulling
the tarball if my Chromium version was out of date. Because of this, mac-chromium was born.
I wrote destruct to tackle the problem of unpacking binary buffers in Node easily.
Based off the unpack function in Perl, and inspired by prustat
by Brendan Gregg, this module makes it simple to take a binary buffer object, and a
format string to unpack values. There were other modules that claimed to have the same functionality,
but most of them were too poorly documented with the source code almost unreadable, while the
others were overcomplicated and didn’t support a simple format string.
This module does not handle all data types, it has only been tested on SmartOS,
and was built for making it easier to extend the proc Node module by @dshaw.
Easily and automatically cast common datatypes in JavaScript
I was working on parsing output from the command line while creating the
Node SMF module. This required me to inspect the elements individually
and write case statements to expect certain data types be returned.
What I mean by this is…
When you parse the command line, everything gets returned as a string.
So, you must do some post-processing to cast items that look like numbers
to numbers, strings that look like keywords to keywords, ie 'false' to false, etc.
So, autocast was born. This module will do all of that inspection for you
and return what it thinks the object should be.
The graph on the left shows read system call latency, and the graph on the
right shows write system call latency (syscall::read*:entry and
syscall::write*:entry respectively). The bottom portion is a modified oneliner
to show files opened by a process (excluding gnuplot) taken from Brendan
Gregg’s DTrace oneliners.
At 0:45, I induced latency by reading /usr/share/dict/words and writing the
contents out to the screen in a 1 second loop. This becomes visible in large
spikes on the graph showing write latency, but the read latency graph is almost
unaffected.
The X-axis on both graphs show time (ticking every second) in the form of
MM:SS. The Y-axis represents the time in milliseconds, and each point is a 1
second average aggregation of the latency.
Because of the nature of gnuplot in this experiment, the Y-axis adapts to the
visible metrics, so when the latency is induced, the Y-axis grows from ~.005ms
to ~2ms.
Working on performance analysis with an interpreted language poses some
interesting problems. Fortunately, Node.js has built in support
for DTrace thanks to the guys at Joyent. These built-in
facilities make it easy to trace Node.js, and profile its time on the CPU
to get an in-depth view of the execution of the program. Tools also exist
that use DTrace’s ability to profile Node.js to create visual representations
of the execution stack, such as Brendan Gregg’sFlame Graph
Tool.
However, when tracking latency from an application-aware point-of-view, it
is necessary to inject probes into the code itself, setting checkpoints, or
entry and return points. Using the DTrace Provider Node.js
Module written by Chris Andrews, I’ve created a
repository of examples on Github showing the DTrace provider in action.