Metrics data model notes

Some notes on the data models of various metrics collection systems. Performance Co-Pilot Performance Co-Pilot is a metrics collection and visualization system heavily inspired by SNMP. PCP originates in the systems monitoring world. PCP has a fairly rich vocabulary to describe metrics according to their type, semantics, dimensions and scale. type is the fundamental data type of the metric, eg. string, uint32, uint64, double, binary semantics describe the logical behaviour of a metric and can be counter, instant or discrete.
Read more...

Using Address Sanitizer with TrafficServer

Verifying Traffic Server with AddressSanitizer is fairly straight-forward. On Linux, you need recent gcc or clang and the libasan library. On OS X, libasan wasn’t present, so I just switched to Linux ;) You should give --enable-asan to configure when you build. The build system will enable ASAN on all the parts that should have it. Then, whenever you run you will get ASAN checking memory state. LeakSanitizer reports leaks from an atexit(3) handler, so you need to ensure that the program exits rather than calls _exit(2) or dumps core.
Read more...

Using wrk with proxies

Based on this extremely helpful post, a slight extension to make it easier to use wrk with a HTTP proxy. url = '' host = '' init = function(args) url = args[1] -- proxy needs absolute URL -- Capture the hostname from the target URL. _, _, host = string.find(url, 'http://([^/]+)/') end request = function() return wrk.format("GET", url, { Host = host }) end Usage is like this: $ wrk -s proxy.
Read more...

Python pip HTTPS proxying

I investigated an issue where pip fails to establish a TLS tunnel through a HTTP proxy because the proxy response with 400 (Bad Request). It turns out tht pip sends this CONNECT request: CONNECT pypi.python.org:443 HTTP/1.0 Now, HTTP/1.1 requires a Host header, so 400 would be the correct response in that case. CONNECT wasn’t defined in the original HTTP/1.0 RFC 1945, but Bryan Call pointed me to the draft-luotonen-web-proxy-tunneling so I guess at one point this was a thing.
Read more...

Loading the “rJava” package into RStudio

Poking around the interwebs, everyone seems to get into trouble loading the rJava package into RStudio. It seems like there are enough people trying to make this work that it should just work out of the box, but then again, what do I know? Here’s what worked for me: jdk <- system2("/usr/libexec/java_home", stdout=TRUE) dyn.load(paste(jdk, "jre/lib/server/libjvm.dylib", sep="/")) library("rJava") This manually figures out where libjvm.dylib is and loads it prior to opening the rJava library.
Read more...

Dealing with relative indices in Lua APIs

When you use the Lua C API to implement custom Lua bindings, you inevitably end up with internal helper functions that accept a Lua stack index. Lua stack indicies can be positive, which indicates an index from the bottom of the stack or negative, which is an index from the top of the stack. It is extremely common to pass -1 to functions to indicate they should operate on the value at the top of the stack.
Read more...

Updating go_resources in Homebrew

This is a quick note to myself about how to update the go_resources in a Homebrew formula. First, install godep and the Homebrew dev tools: $ cd $GOPATH $ go get -u github.com/tools/godep $ brew tap homebrew/dev-tools Next, generate a Godeps file in your Go project $ cd $GOPATH/src/github.com/me/my-project $ $GOPATH/bin/godep save . Now you can get brew to generated the go_resources that you can just paste into your formula:
Read more...

Miniature guide to building Clang from source

First checkout the sources: $ cd ~/src $ git clone http://llvm.org/git/llvm.git $ cd ~/src/llvm/projects $ git clone http://llvm.org/git/compiler-rt.git $ git clone http://llvm.org/git/libcxx.git $ git clone http://llvm.org/git/libcxxabi.git $ cd ~/src/llvm/tools $ git clone http://llvm.org/git/clang.git $ cd ~/src/llvm/tools/clang/tools $ git clone http://llvm.org/git/clang-tools-extra.git extra Next, do the build: $ mkdir -p ~/src/llvm/build $ cd ~/src/llvm/build $ cmake -DCMAKE_INSTALL_PREFIX=/opt/clang -DCMAKE_BUILD_TYPE=RelWithDebInfo .. $ make -j$(getconf _NPROCESSORS_ONLN) $ sudo make install On OS X you should also pass -DDEFAULT_SYSROOT=$(xcrun -show-sdk-path) to the cmake command.
Read more...

Disabling tmp on tempfs for Fedora23

Well, Fedora 23 seems to default to placing /tmp in a tiny tmpfs volume, which easily fills, breaking things you need, like dnf.

Fairly annoying, but the fix, from the wiki page is straightforward:

% sudo systemctl mask tmp.mount
% sudo reboot
Read more...

GNU make dependency generation

Although I would normally use automake, recently I needed to write a Makefile by hand, so I went down the path of figuring out how to get gcc to generate dependency files as a side-effect of compilation: # Build rule for compiling C++ with dependecy generation as a side-effect. The # dependencies go into a .deps directory at the same level as the source file. %.o: %.cpp @$(MKDIR) $(*D)/.deps $(CXX) $(CXXFLAGS) $(CPPFLAGS) -MP -MF $(*D)/.
Read more...