View gist:d4e0350834220d57995e
........................................
......... ..........
....... ........
..... ......
.... .....
... ....... ....
.. ....... .. ...
. .......... .. ..
. ....... .... .. .
. ..... ..... .
View 2014-09-21-the-8-byte-two-step-redux.md

Over on Hacker News, Z posted a fantastic article called The 8-Byte Two-Step where the concept of aligning to byte boundaries was explored.

I thought this was a fantastic post, it goes right down to binary and logical operators then back up again.

After understanding the alignment, Z then writes three other ways of doing the same thing, disassembles them and benchmarks them.

Discussing this on HN, I said:

I have banned myself from using printfs to figure out things like this. Instead I would use a debugger and breakpoints to view the live variables in their different data formats.

View SLF.+zdss.patch
Purpose: To prevent scheduler collapse by disabling scheduler sleep periods.
This patch is relative to R16B01 pre-release but may be applied (with "fuzz")
on R15B01 and R15B03-1 without difficulty.
The new flag, "+zdss", must be used with "+scl false" flag to be successful.
See the erl.xml document for a description. Example use:
erl +scl false +zdss 500:500
Note that this flag used to be called "+zdnfgtse"
View bench.erl
-module(bench).
-export([run_suite/3, run/1]).
run_suite(Name, Passes, Messages) ->
Results = run_suite1(Passes, Messages, []),
Avg = lists:sum(Results) / Passes,
StdDev = math:sqrt(lists:sum([math:pow(X - Avg, 2) || X <- Results]) / Passes),
Summary = [{avg, Avg}, {stddev, StdDev}, {min, lists:min(Results)},
{max, lists:max(Results)}],
View fd_setsize_on_osx.md

When you build Erlang/OTP on OS X, it unfortunately defaults to handling a maximum of 1024 file descriptors. You can get around this limitation with the right combination of configuration options and manual changes to a generated config file.

First, go into your unpacked Erlang/OTP source directory and run the following command, replacing the value 10000 with whatever value you want for max file descriptors:

perl -i -pe 's/(define\s+FD_SETSIZE\s+)\d+/\1 10000/' erts/config.h.in 

Next, when you run configure in your Erlang/OTP source directory, be sure to include the right CFLAGS setting, as shown below:

CFLAGS='-DREDEFINE_FD_SETSIZE -DFD_SETSIZE=15000 -D_DARWIN_UNLIMITED_SELECT' ./configure --enable-kernel-poll <other options>
View gist:3933039
projdel node
projadd -c "node settings" -U admin -G staff -K "process.max-file-descriptor=(basic,65535,deny)" node
svccfg -s node-nodestack-service setprop 'method_context/project=node'
svcadm disable node-nodestack-service
svcadm enable node-nodestack-service
pgrep node
View app_deps.erl
%%% Run with 'escript app_deps.erl'
%%% Change the path in filelib:wildcard/1 as required to capture all
%%% your dependencies.
%%%
%%% Rectangular nodes will represent library apps (no processes involved)
%%% and the circular nodes will represent regular apps. An arrow going from
%%% 'A -> B' means 'A depends on B'.
%%%
%%% This script depends on graphviz being present on the system.
-module(app_deps).
View zone-clone.markdown

on the guest SmartOS VM

pkg_add http://pkgsrc.joyent.com/sdc6/2012Q1/i386/All/smtools
# note this is going to shut down the VM
sm-prepare-image

on the global zone

View erl_factor.markdown

I've been playing more with this Erlang factoring technique. As an exercise, I've been trying to force myself to adopt the method, by writing functions that are 3 or less lines long (function clauses actually, so multiple pattern-matched claues are OK).

Death to receive expressions

One place I noticed was causing myself

View gist:2776028
license LICENSE license=Apache2
group gid=98 groupname=riak
user ftpuser=false gcos-field="Riak Server" group=riak login-shell=/usr/bin/bash password=NP uid=98 username=riak home-dir=/opt/riak/etc
<transform dir path=opt/riak/data.* -> set owner riak>
<transform dir path=opt/riak/data.* -> set group riak>
<transform dir path=opt/riak/log.* -> set owner riak>
<transform dir path=opt/riak/log.* -> set group riak>
<transform dir path=opt/riak/etc -> set owner riak>
<transform dir path=opt/riak/etc -> set group riak>
<transform file path=opt/riak/etc/.* -> set owner riak>