Skip to content

Instantly share code, notes, and snippets.

View kazeburo's full-sized avatar

Masahiro Nagano kazeburo

View GitHub Profile
@kazeburo
kazeburo / gist:20c29d05d4018c4e7688
Created November 17, 2014 06:38
infinite loop if header has multibyte characters
diff --git a/picohttpparser.c b/picohttpparser.c
index 10015b8..ee9904f 100644
--- a/picohttpparser.c
+++ b/picohttpparser.c
@@ -95,6 +95,7 @@ static const char* get_token_to_eol(const char* buf, const char* buf_end,
if ((likely((unsigned char)*buf < '\040') && likely(*buf != '\011')) || unlikely(*buf == '\177')) {
goto FOUND_CTL;
}
+ ++buf;
}
@kazeburo
kazeburo / gist:608fc2ba0748e6ab3663
Last active June 29, 2017 23:53
perl redis client benchmark
# perl memcached.pl
Rate pp fast
pp 21167/s -- -89%
fast 197745/s 834% --
# perl -Ilib -Iblib/arch eg/benchmark.pl
single get =======
Rate redis fast hiredis jet
redis 34841/s -- -56% -68% -71%
fast 80082/s 130% -- -27% -33%
03:39:48 UTC - mysqld got signal 11 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
We will try our best to scrape up some info that will hopefully help
diagnose the problem, but since we have already crashed,
something is definitely wrong and this may fail.
key_buffer_size=33554432
read_buffer_size=1048576
@kazeburo
kazeburo / gist:f52c2a962a7d821bac3f
Created September 19, 2014 07:14
simple Plack::Middleware::SizeLimit
use strict;
use warnings;
use Plack::Builder;
my $app = sub {
return [200,[],['OK']];
};
builder {
# ここから
use Kossy;
use Plack::Session;
sub Plack::Session::new {
my ($class, $env) = @_;
my $self = bless {
session => $env->{'psgix.session'},
options => $env->{'psgix.session.options'},
}, $class;
for my $flash_key ( grep { m/^__flash__/ } keys %{$self->session} ) {
user nobody nobody;
daemon off;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
worker_rlimit_nofile 200000;
worker_processes 1;
pcre_jit on;
events {
use epoll;
diff --git a/server/server.go b/server/server.go
index 0067cec..79e9ae0 100644
--- a/server/server.go
+++ b/server/server.go
@@ -62,7 +62,7 @@ func (self *Server) getAllJobs() {
}
func (self *Server) Start(addr string) {
- ln, err := net.Listen("tcp", ":4730")
+ ln, err := net.Listen("tcp", addr)
#!/usr/bin/perl
package OneSteam::Agent::Collector;
use strict;
use warnings;
my @func = qw/memory loadavg uptime sys_version processors cpu_usage tcp_established disk_usage disk_io/;

mroongaでクエリを投げる並列数をあげていくと、レスポンスが悪化する件

使用しているデータは http://blog.livedoor.jp/staff/ の記事データです。1500件ほどあります

環境は EC2 cc2.8xlarge 8コア 32コア

MySQL 5.6.15。オラクル公式MySQL rpmを使用
mroonga 4.0
groonga 4.0
our %EncodeMap;
for my $num ( 0 .. 255 ) {
my $chr = chr $num;
my $h = sprintf "%02X", $num;
$EncodeMap{$chr} = '%'. uc $h;
}
$EncodeMap{" "} = '+';
sub url_escape {
return '' unless defined $_[0];