brouillon

by Louis-Philippe Gauthier

Director, Platform Engineering @ AdGear

Read this first

Disabling erl_crash.dump

To disable erl_crash.dump you can use the ERL_CRASH_DUMP environment variable. You need to give it a path that doesn’t exists so that open returns a value < 0.

export ERL_CRASH_DUMP=/disable/crash/dump

https://github.com/erlang/otp/blob/maint/erts/emulator/beam/break.c#L757

Continue reading →


Strcmp

strcmp(<<>>, <<>>) -> 0;
strcmp(<<>>, <<_A:1/binary, _Rest/binary>>) -> -1;
strcmp(<<_A:1/binary, _Rest/binary>>, <<>>) -> 1;
strcmp(<<A:1/binary, Rest/binary>>, <<A:1/binary, Rest2/binary>>) -> strcmp(Rest, Rest2);
strcmp(<<A:1/binary, _Rest/binary>>, <<B:1/binary, _Rest2/binary>>) when A < B -> - 1;
strcmp(<<_A:1/binary, _Rest/binary>>, <<_B:1/binary, _Rest2/binary>>) -> 1.

Continue reading →


Performance Optimization 101 - Erlang Factory SF 2014

In order to scale AdGear’s real-time bidding (RTB) platform, we’ve been optimizing system and application performance. In this talk, I’ll share all my findings, from basic tips to advanced topics. I’ll cover coding patterns, metric collection, tracing and much more!

Talk objectives:

  • Share basic tips, common pitfalls, efficient coding patterns
  • Introduce tooling for metric collection (statsderl, vmstats, system-stats, riak_sysmon)
  • Highlight erlang trace (fprof, flame graphs)
  • Expose advanced topics (VM tuning, lock-counter, systemtap, cpuset)

Target audience:

  • Anyone looking to improve the performance of their Erlang application.

Video -
Slides

Continue reading →


Fast Tuple Shuffle (Fisher-Yates)

Fisher–Yates shuffle

shuffle(Tuple) ->
    shuffle(Tuple, size(Tuple)).

shuffle(Tuple, 1) ->
    Tuple;
shuffle(Tuple, N)->
    Random = erlang:phash2(os:timestamp(), N) + 1,
    A = element(N, Tuple),
    B = element(Random, Tuple),
    Tuple2 = setelement(N, Tuple, B),
    Tuple3 = setelement(Random, Tuple2, A),
    shuffle(Tuple3, N - 1).

Continue reading →