Skip to content

Instantly share code, notes, and snippets.

View lestrrat's full-sized avatar

lestrrat lestrrat

View GitHub Profile
use strict;
use feature 'say';
use CGI;
main() unless caller();
sub main {
local $ENV{REQUEST_METHOD} = "GET";
qstring_is_not_empty();
qstring_is_empty();
@lestrrat
lestrrat / gist:9926190
Created April 2, 2014 01:08
P5-Xslate vs Go-Xslate as of April 2, 2014, commit 15d8ca69d3ecc8a46bf50e422d31d2f204415755
following shows that the Go version is MUCH faster parsing the templates, but the VM is slower.
see https://github.com/lestrrat/go-xslate/tree/master/bench
$ perl driver.pl
# p5-xslate (cache DISABLED)
iter (10)
* Elapsed: 0.05115 seconds
* Iter per sec: 195.503421309873 iter/sec
iter (100)
* Elapsed: 0.188323 seconds
# p5-xslate (cache DISABLED)
iter (10)
* Elapsed: 0.077450 seconds
* Secs per iter: 0.007745 secs/iter
* Iter per sec: 129.115558 iter/sec
iter (100)
* Elapsed: 0.175402 seconds
* Secs per iter: 0.001754 secs/iter
* Iter per sec: 570.118927 iter/sec
iter (1000)
@lestrrat
lestrrat / gist:9972037
Created April 4, 2014 10:37
p5-Text-Xslate vs go-xslate as of a9f2dea3df71f18966c7e86371dc7c334d3fef64
# p5-xslate (cache DISABLED)
iter (10)
* Elapsed: 0.058262 seconds
* Secs per iter: 0.005826 secs/iter
* Iter per sec: 171.638461 iter/sec
iter (100)
* Elapsed: 0.122816 seconds
* Secs per iter: 0.001228 secs/iter
* Iter per sec: 814.226159 iter/sec
iter (1000)
(pprof) top10
Total: 665 samples
417 62.7% 62.7% 425 63.9% syscall.Syscall
26 3.9% 66.6% 59 8.9% runtime.mallocgc
16 2.4% 69.0% 32 4.8% syscall.ByteSliceFromString
15 2.3% 71.3% 15 2.3% etext
15 2.3% 73.5% 15 2.3% scanblock
10 1.5% 75.0% 10 1.5% sweepspan
7 1.1% 76.1% 7 1.1% runtime.markallocated
6 0.9% 77.0% 110 16.5% github.com/lestrrat/go-xslate/loader.(*CachedByteCodeLoader).Load
@lestrrat
lestrrat / gist:9973302
Created April 4, 2014 12:10
p5-Text-Xslate vs go-xslate as of cbb88f01cc8a6ed24e3b5eaf77145f46019ce6f9
I disabled stat() on the cache file if the same file has been stat within the last second, and voila, go-xslate is FASTER!
# p5-xslate (cache DISABLED)
iter (10)
* Elapsed: 0.058350 seconds
* Secs per iter: 0.005835 secs/iter
* Iter per sec: 171.379606 iter/sec
iter (100)
* Elapsed: 0.132784 seconds
* Secs per iter: 0.001328 secs/iter
@lestrrat
lestrrat / gist:10952980
Last active August 29, 2015 13:59
trying out go wrapper + cpanm
# DockerでCPANインストール祭りを繰り返してたらいい加減cpanmとかに並列処理が欲しくなってきた。
# で、とりあえずgoでラッパーを作って、
# 1) 先にMETA.yamlを読み込み、依存関係を解析
# 2) キューに突っ込んで goroutineでそれぞれcpanmを起動してインストール
# という簡単な処理をしてみてどういう差が出るかやってみた
#
# 試すには go install github.com/lestrrat/go-cpan-maybe-faster/cli/go-cpan
# https://github.com/lestrrat/go-cpan-maybe-faster
$ time go-cpan --notest --local-lib-contained=local Moose
struct passwd {
char *pw_name; /* user name */
char *pw_passwd; /* encrypted password */
uid_t pw_uid; /* user uid */
gid_t pw_gid; /* user gid */
__darwin_time_t pw_change; /* password change time */
char *pw_class; /* user access class */
char *pw_gecos; /* Honeywell login info */
char *pw_dir; /* home directory */
char *pw_shell; /* default shell */
shoebill% go test -v .
=== RUN Test_appliance
--- PASS: Test_appliance (0.00 seconds)
=== RUN Test_blank
--- PASS: Test_blank (0.00 seconds)
=== RUN Test_crawler_google
--- PASS: Test_crawler_google (0.00 seconds)
=== RUN Test_crawler_nonmajor
--- PASS: Test_crawler_nonmajor (0.00 seconds)
=== RUN Test_crawler
@lestrrat
lestrrat / gist:f191277c2ad77bfc25f1
Last active August 29, 2015 14:04
q4m crash upon running DELETE FROM $queue
140725 09:41:39 ha_queue: /usr/local/src/mysql-5.6.19/storage/q4m/src/ha_queue.cc:2008: starting table compaction: ./XXXXXXX/queue_XXXXXXXX (begin: 491349793, end: 491349793, rows: 18446744073709551613)
140725 09:41:40 ha_queue: /usr/local/src/mysql-5.6.19/storage/q4m/src/ha_queue.cc:2134: finished table compaction: ./XXXXXXX/queue_XXXXXXXX (begin: 4096, end: 4096, rows: 0)
mysqld: /usr/local/src/mysql-5.6.19/storage/q4m/src/dllist.h:38: T* dllist<T, Cnt>::detach(T*&, size_t) [with T = queue_connection_t, long unsigned int Cnt = 1ul]: Assertion `_prev[idx] != __null' failed.
2014-07-25 09:41:40 4645 [ERROR] Got error 145 when reading table './XXXXXXX/queue_XXXXXXXX'
00:41:40 UTC - mysqld got signal 6 ;
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 prob