Skip to content

Instantly share code, notes, and snippets.

View lpgauth's full-sized avatar
😄
busy building cool stuff

Louis-Philippe Gauthier lpgauth

😄
busy building cool stuff
View GitHub Profile
lpgauth ~ $ sudo strace -p 1144 -f
Process 1181 attached with 36 threads - interrupt to quit
[pid 1181] futex(0x934380, FUTEX_WAIT_PRIVATE, 4294967295, NULL <unfinished ...>
[pid 1180] futex(0x934340, FUTEX_WAIT_PRIVATE, 4294967295, NULL <unfinished ...>
[pid 1179] futex(0x934300, FUTEX_WAIT_PRIVATE, 4294967295, NULL <unfinished ...>
[pid 1178] futex(0x9342c0, FUTEX_WAIT_PRIVATE, 4294967295, NULL <unfinished ...>
[pid 1177] futex(0x934280, FUTEX_WAIT_PRIVATE, 4294967295, NULL <unfinished ...>
[pid 1176] futex(0x934240, FUTEX_WAIT_PRIVATE, 4294967295, NULL <unfinished ...>
[pid 1175] futex(0x934200, FUTEX_WAIT_PRIVATE, 4294967295, NULL <unfinished ...>
[pid 1173] futex(0x934180, FUTEX_WAIT_PRIVATE, 4294967295, NULL <unfinished ...>
(function ($) {
var Encrypt = {
getTime: function (millis) {
var secs = Encrypt.varToByteArray(millis / 1000);
var micros = Encrypt.varToByteArray((millis - (secs * 1000)) * 1000);
var ret = new Array(8);
for (var i = 0; i < 8; i++) {
ret[i] = (i < 4) ? secs[i] : micros[i - 4];
}
return ret;
@lpgauth
lpgauth / gist:1713011
Created January 31, 2012 21:26
ab / cowboy 0.5 / poolboy 0.6
~ [1.8.7]$ ab -k -t 30 -c 10 http://127.0.0.1:9090/poolboy
This is ApacheBench, Version 2.3 <$Revision: 1139530 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 127.0.0.1 (be patient)
Completed 5000 requests
Completed 10000 requests
Completed 15000 requests
Completed 20000 requests
diff --git a/src/cowboy_acceptor.erl b/src/cowboy_acceptor.erl
index 4cb9fa7..705c5ed 100644
--- a/src/cowboy_acceptor.erl
+++ b/src/cowboy_acceptor.erl
@@ -38,10 +38,7 @@ acceptor(LSocket, Transport, Protocol, Opts, MaxConns, ListenerPid, ReqsSup) ->
{ok, Pid} = supervisor:start_child(ReqsSup,
[ListenerPid, CSocket, Transport, Protocol, Opts]),
Transport:controlling_process(CSocket, Pid),
- {ok, NbConns} = cowboy_listener:add_connection(ListenerPid,
- default, Pid),
@lpgauth
lpgauth / gist:2472877
Created April 23, 2012 18:23
TCP_DEFER_ACCEPT
diff --git a/src/cowboy_tcp_transport.erl b/src/cowboy_tcp_transport.erl
index c1dad62..5c16c39 100644
--- a/src/cowboy_tcp_transport.erl
+++ b/src/cowboy_tcp_transport.erl
@@ -48,16 +48,8 @@ messages() -> {tcp, tcp_closed, tcp_error}.
-spec listen([{port, inet:ip_port()} | {ip, inet:ip_address()}])
-> {ok, inet:socket()} | {error, atom()}.
listen(Opts) ->
- {port, Port} = lists:keyfind(port, 1, Opts),
- Backlog = proplists:get_value(backlog, Opts, 1024),
diff --git a/src/dispcount_watcher.erl b/src/dispcount_watcher.erl
index 708cd20..c3bb67a 100644
--- a/src/dispcount_watcher.erl
+++ b/src/dispcount_watcher.erl
@@ -149,6 +149,8 @@ is_free(Tid, Id) ->
%% which should cause no overhead but be fine to deal
%% with short spikes.
case ets:update_counter(Tid, Id, {2,1}) of
+ 3 -> true;
+ 2 -> true;
@lpgauth
lpgauth / gist:3131991
Created July 17, 2012 20:50
Strace VM
strace -f -p 7493
Process 7493 attached with 37 threads - interrupt to quit
[pid 7530] futex(0x94f380, FUTEX_WAIT_PRIVATE, 4294967295, NULL <unfinished ...>
[pid 7529] futex(0x94f340, FUTEX_WAIT_PRIVATE, 4294967295, NULL <unfinished ...>
[pid 7528] futex(0x94f300, FUTEX_WAIT_PRIVATE, 4294967295, NULL <unfinished ...>
[pid 7527] futex(0x94f2c0, FUTEX_WAIT_PRIVATE, 4294967295, NULL <unfinished ...>
[pid 7525] futex(0x94f240, FUTEX_WAIT_PRIVATE, 4294967295, NULL <unfinished ...>
[pid 7524] futex(0x94f200, FUTEX_WAIT_PRIVATE, 4294967295, NULL <unfinished ...>
[pid 7523] futex(0x94f1c0, FUTEX_WAIT_PRIVATE, 4294967295, NULL <unfinished ...>
[pid 7522] futex(0x94f180, FUTEX_WAIT_PRIVATE, 4294967295, NULL <unfinished ...>
@lpgauth
lpgauth / gist:3151052
Created July 20, 2012 14:35
lcnt:conflicts()
lock id #tries #collisions collisions [%] time [us] duration [%]
----- --- ------- ------------ --------------- ---------- -------------
proc_tab 1 12869 5933 46.1030 343822 114.2133
run_queue 24 172468 9301 5.3929 73889 24.5450
port_lock 3971 61326 288 0.4696 62224 20.6700
pollset 1 23543 2568 10.9077 33272 11.0525
pix_lock 256 106471 602 0.5654 20412 6.7806
drv_ev_state 16 21854 503 2.3016 20380 6.7700
proc_link 10512 58810 843 1.4334 8518 2.8296
proc_msgq 10512 83228 524 0.6296 4972 1.6516
log_event(Message, TS) when is_binary(Message) ->
log_event(binary_to_list(Message), TS);
log_event(Message, TS) when is_list(Message) ->
{{Y, M, D}, {H, _M, _S}} = calendar:now_to_universal_time(TS),
Name = {Y, M, D, H},
case disk_log:balog(Name, unicode:characters_to_binary([Message, "\n"])) of
ok ->
ok;
{error, no_such_log} ->
{ok, Path} = application:get_env(adgear_delivery, log_path),
@lpgauth
lpgauth / gist:3762013
Created September 21, 2012 15:03
cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 26
model name : Intel(R) Xeon(R) CPU X5550 @ 2.67GHz
stepping : 5
cpu MHz : 2660.334
cache size : 8192 KB
physical id : 1
siblings : 8