Skip to content

Instantly share code, notes, and snippets.

Trevor Norris trevnorris

Block or report user

Report or block trevnorris

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
trevnorris /
Last active Oct 7, 2019
Quick steps of how to create a flame graph using perf

The will setup the latest Node and install the latest perf version on your Linux box.

When you want to generate the flame graph, run the following (folder locations taken from install script):

sudo sysctl kernel.kptr_restrict=0
# May also have to do the following:
# (additional reading )
sudo sysctl kernel.perf_event_paranoid=0
trevnorris / uv-loop-notes.txt
Last active Jul 29, 2019
rough notes on the linux side of the libuv event loop
View uv-loop-notes.txt
- uv__update_time(): Update time with millisecond precision.
- uv__run_timers(): Loop through "heap" and run timers whose timeout > time.
- uv__run_pending(): Run all callbacks on the pending_queue. Remove each item
from the queue when run.


  • Text in [[ ]] are the internal libuv function call.
  • Text in {{ }} are the Node functions that are affected.
  • Text in ( ) are notes about what is happening.
  • While the Windows event loop has minor variations, I don't believe any of those affect Node.

On process.nextTick():

trevnorris / watched-anime_2017-10.txt
Created Apr 24, 2019
List of all anime I've watched
View watched-anime_2017-10.txt
In the online RPG know as "The World," Haseo and his guild mates are on the search for a legendary item. When a rival team challenges them, the conflict has deep repercussions both inside and outside the game, and threatens to change the players forever.
Tsukasa wakes up inside The World, a massive online role-playing game full of magic and monsters, and finds himself unable to log out. How did he end up stuck in this digital realm, and what, exactly, is going on in the real world?
A Certain Magical Index
In a world where magic is as real as science, high-school student Kamijo comes to the aid of a young nun named Index. She's on the run from a magic society that covets the massive library of forbidden knowledge stored in her memory.
A Certain Scientific Railgun
trevnorris / build_steps.txt
Last active Aug 10, 2018
How to build node with shared libuv
View build_steps.txt
$ ./ -f make -Dlibrary=shared_library
$ BUILDTYPE=Release make -j6 -C out
$ ./configure --shared-libuv --shared-libuv-includes=$LIBUV_PATH/include --shared-libuv-libpath=$LIBUV_PATH/out/Release
$ make -j6
binary build:
$ CONFIG_FLAGS="--shared-libuv --shared-libuv-includes=$LIBUV_PATH/libuv/include --shared-libuv-libpath=$LIBUV_PATH/out/Release" DISTTYPE=custom CUSTOMTAG="$(date +'%s')" make -j6 binary
View .tmux.conf
# basic configs #
setw -g mode-keys vi
set -g default-terminal "xterm-256color"
set -g history-limit 10000
# C-a is escape sequence #
unbind C-b
set -g prefix C-a
bind C-a last-window
bind a send-prefix
View exp.txt
native-stream.js uses the reference implementation, compiled with babel to run
on latest io.js.
stream-bluebird.js is exactly the same as native-stream.js except it uses the
latest bluebird Promise implementation.
node-stream.js uses the node stream implementation and forced to be async by
using process.nextTick() (which is functionally equivalent to the microtask
trevnorris /
Last active Dec 9, 2017
Here's a rundown of everything I use to do performance analysis in Node.


Here is a collection of tips and tricks I've picked up about doing performance analysis on Node. Included is a build script that should get a base install of Ubuntu fully functional and ready for all the things we'll be going through.

The script pulls a lot of code from the latest master of each repository. So it's possible that something may fail, but to date I haven't had any issues.

First, go ahead and run the script. Then go take a nice long break. It'll

trevnorris /
Created Feb 5, 2016
Run a callback when an object is GC'd
#include <v8.h>
#include <node.h>
using namespace v8;
typedef void (*FreeCallback)(Local<Object> object, Local<Function> fn);
class CallbackStuff {
View sem-simple.c
#include <stdio.h>
#include <assert.h>
#include "uv.h"
#define ITER 1e6
#define ACCESS_ONCE(type, var) \
(*(volatile type*) &(var))
static uv_mutex_t mutex;
You can’t perform that action at this time.