Skip to content

Instantly share code, notes, and snippets.

@nihen
nihen / description
Last active Dec 26, 2015
perl で do & forkするとcowにのってるメモリがexit時に再消費?
View description
free -s 0.2 | grep Mem
を実行して眺めつつこのperl scriptを実行すると、子プロセスがexitする時に新たなメモリを消費するのがわかる。
CoWのメモリ分ではないかと思われる。
キモは do と fork の組み合わせ
perl 5.14.4, 5.18.1で確認
↓doは関係なかった
http://nihen.hatenablog.com/entry/2013/10/22/125410
@nihen
nihen / isucon3.psgi
Created Oct 6, 2013
これとpublicファイルがあればIsucon3アプリの完成です。 Plack ServerはFeersumで、front httpdはnginxでした。
View isucon3.psgi
use 5.14.0;
use utf8;
use Plack::Request;
use File::Basename;
use IO::Handle;
use Encode;
use List::Util qw/sum/;
use POSIX qw/strftime/;
use JSON::XS;
use Plack::Session::State::Cookie;
View gist:5684352
package MyCounter;
sub new { my $class = shift;bless {@_} => $class }
sub incr { shift->{count}++ }
sub decr { shift->{count}-- }
sub count { shift->{count} }
package main;
use Text::Xslate;
my $tx = Text::Xslate->new(
View gist:4350941
use strict;
use warnings;
use Test::More;
use SQL::Maker::Condition;
my $w1 = SQL::Maker::Condition->new();
$w1->add(1 => 1);
View hoge.pl
perl -MO=Deparse hoge.pl
# インライン展開される組
sub inline_q() {
q{myline}
}
sub inline_qq() {
qq{myline}
}
View isucon2.psgi
use 5.14.0;
use Plack::Request;
use IO::Handle;
use Encode;
use List::Util qw/sum/;
use POSIX qw/strftime/;
use JSON::XS;
my $json_encoder = JSON::XS->new->latin1;
my $json_decoder = JSON::XS->new->utf8;
View cpandupmetaclean
#!/usr/bin/env perl
use strict;
use warnings;
use 5.008001;
use Config qw(%Config);
use File::Find;
use File::Path;
use JSON;
use Getopt::Long;
use version 0.77;
@nihen
nihen / xslate_fork_cache.t
Created Oct 15, 2012
xslate and fork and cache
View xslate_fork_cache.t
#!perl
use strict;
use warnings;
use Fatal qw(open close);
use Test::More;
use File::Temp qw(tempdir);
use Text::Xslate;
{
@nihen
nihen / result
Created Sep 28, 2012
teng_vs_skinny_vs_dbic_vs_dbi
View result
# insert ok 1 - teng ok 2 - skinny ok 3 - dbi ok 4 - dbic # fast_insert ok 5 - teng ok 6 - skinny ok 7 - dbi ok 8 - dbic # single ok 9 - teng ok 10 - skinny ok 11 - dbi ok 12 - dbic # lookup ok 13 - teng ok 14 - skinny ok 15 - dbi ok 16 - dbic # search ok 17 - teng ok 18 - skinny ok 19 - dbi ok 20 - dbic # search_by_sql ok 21 - teng ok 22 - skinny ok 23 - dbi # dbic is not support search_by_sql # search_named ok 24 - teng ok 25 - skinny # dbi is not support search_named # dbic is not support search_named 1..25 DBI: 1.622 DBIx::Class version: 0.08200 Skinny version: 0.0742 Teng version: 0.15 --- insert --- Rate dbic teng skinny dbi dbic 941/s -- -17% -35% -45% teng 1131/s 20% -- -21% -34% skinny 1437/s 53% 27% -- -16% dbi 1706/s 81% 51% 19% -- --- fast_insert --- Rate dbic skinny teng dbi dbic 950/s -- -32% -38% -45% skinny 1399/s 47% -- -9% -19% teng 1540/s 62% 10% -- -11% dbi 172
@nihen
nihen / result
Created Sep 17, 2012
teng_vs_skinny
View result
ok 1
ok 2
ok 3
ok 4
ok 5
ok 6
ok 7
1..7
Teng version: 0.15