■
$ curl -L git.io/nodebrew | perl - setup
$ vi ~/.bash_profile export PATH=/usr/local:$PATH export PATH=$HOME/.nodebrew/current/bin:$PATH
$ nodebrew install-binary v4.1.1
$ nodebrew use v4.1.1
$ npm update -g npm
■
メモっす
interface IEntry{
getMessage(): string;
}
class A implements IEntry{
getMessage() {
return 'hello a.';
}
}
class B implements IEntry{
getMessage() {
return 'hello b.';
}
}
class C implements IEntry{
getMessage() {
return 'hello c.';
}
}
class D {
getMessage() {
return 'hello d.';
}
}
var arry: Array<IEntry> = [
new A(),
new B(),
new C(),
new D(),
];
for (var index in arry){
var entry: IEntry = arry[index];
console.log(entry.getMessage());
}あれ、コレはコンパイル通るんだ。
[D言語],Go,C,PHPベンチマーク
#include <stdio.h>
int fib(int n) {
if (n < 2) return n;
return fib(n - 2) + fib(n - 1);
}
int main(int argc, char *argv[]) {
printf("%d\n", fib(45));
return 0;
}
$ time ./a.out
1134903170
real 0m16.715s
user 0m16.583s
sys 0m0.025s#!/usr/bin/rdmd
import std.stdio;
int fib(int n) {
if (n < 2) return n;
return fib(n - 2) + fib(n - 1);
}
void main() {
printf(" %d\n", fib(45));
}
$ time ./fib
1134903170
real 0m13.871s
user 0m13.755s
sys 0m0.022s
$ time ./fib.d
1134903170
real 0m13.952s
user 0m13.808s
sys 0m0.026spackage main
import "fmt"
func fib(n int) int {
if n < 2 {
return n
}
return fib(n - 2) + fib(n - 1)
}
func main() {
var n int = 45
fmt.Printf("fib(%d) = %d\n", n, fib(n))
}
$ time ./fib
fib(45) = 1134903170
real 0m11.332s
user 0m11.224s
sys 0m0.019s<?php
function fib($n) {
if ($n < 2) {return $n;}
return fib($n - 2) + fib($n - 1);
}
print(fib(45) . "\n");
$ time php fib.php
1134903170
real 16m23.613s
user 16m7.627s
sys 0m2.503sC:
久々[D言語]を揉む
import std.stdio;
void main() {
Node n1 = new Node(1);
Node n2 = new Node(2);
Node n3 = new Node(3);
Node n4 = new Node(4);
Node n5 = new Node(5);
Node n6 = new Node(6);
n2.push(n1);
n2.push(n6);
n2.push(n4);
n2.push(n5);
n2.search(4);
}
class Node
{
public:
int key;
Node left = null;
Node right = null;
public:
this(int _key) {
key = _key;
}
void search(int _key) {
if (key is _key) {
printf("hit.\n");
}
else if (key >= _key) {
if (left is null) {
} else {
left.search(_key);
}
}
else if (key < _key) {
if (right is null) {
} else {
right.search(_key);
}
}
}
void push(Node node) {
if (key >= node.key) {
if (left is null) {
left = node;
} else {
left.push(node);
}
}
if (key < node.key) {
if (right is null) {
right = node;
} else {
right.push(node);
}
}
}
}
test
redis_version:2.4.14 redis_git_sha1:00000000 redis_git_dirty:0 arch_bits:64 multiplexing_api:epoll gcc_version:4.4.5 process_id:15010 uptime_in_seconds:73 uptime_in_days:0 lru_clock:1866474 used_cpu_sys:0.34 used_cpu_user:0.31 used_cpu_sys_children:0.00 used_cpu_user_children:0.00 connected_clients:1 connected_slaves:0 client_longest_output_list:0 client_biggest_input_buf:0 blocked_clients:0 used_memory:5236304 used_memory_human:4.99M used_memory_rss:6426624 used_memory_peak:5244800 used_memory_peak_human:5.00M mem_fragmentation_ratio:1.23 mem_allocator:jemalloc-2.2.5 loading:0 aof_enabled:0 changes_since_last_save:0 bgsave_in_progress:0 last_save_time:1339870435 bgrewriteaof_in_progress:0 total_connections_received:6 total_commands_processed:6 expired_keys:0 evicted_keys:0 keyspace_hits:0 keyspace_misses:0 pubsub_channels:0 pubsub_patterns:0 latest_fork_usec:0 vm_enabled:0 role:master db0:keys=28229,expires=0 $1601 # Server redis_version:2.5.11 redis_git_sha1:00000000 redis_git_dirty:0 os:Linux 2.6.32-5-amd64 x86_64 arch_bits:64 multiplexing_api:epoll gcc_version:4.4.5 process_id:15196 run_id:e2ef0af8b263fe68ad303d2de0755928ec82aea4 tcp_port:6379 uptime_in_seconds:16904 uptime_in_days:0 lru_clock:1868576 # Clients connected_clients:2 client_longest_output_list:0 client_biggest_input_buf:0 blocked_clients:0 # Memory used_memory:2017736 used_memory_human:1.92M used_memory_rss:3538944 used_memory_peak:2053912 used_memory_peak_human:1.96M used_memory_lua:30720 mem_fragmentation_ratio:1.75 mem_allocator:jemalloc-3.0.0 # Persistence loading:0 rdb_changes_since_last_save:3441 rdb_bgsave_in_progress:0 rdb_last_save_time:1339874616 rdb_last_bgsave_status:ok rdb_ last_bgsave_time_sec:-1 rdb_current_bgsave_time_sec:-1 aof_enabled:1 aof_rewrite_in_progress:0 aof_rewrite_scheduled:0 aof_last_rewrite_time_sec:-1 aof_current_rewrite_time_sec:-1 aof_current_size:1329499 aof_base_size:1329499 aof_pending_rewrite:0 aof_buffer_length:0 aof_rewrite_buffer_length:0 aof_pending_bio_fsync:0 aof_delayed_fsync:0 # Stats total_connections_received:23662 total_commands_processed:23660 instantaneous_ops_per_sec:0 rejected_connections:0 expired_keys:0 evicted_keys:0 keyspace_hits:0 keyspace_misses:0 pubsub_channels:0 pubsub_patterns:0 latest_fork_usec:0 # Replication role:master connected_slaves:0 # CPU used_cpu_sys:180.58 used_cpu_user:129.54 used_cpu_sys_children:0.00 used_cpu_user_children:0.00 # Keyspace db0:keys=3441,expires=0
if 15 < time.time() - metric_handler.timestamp:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((metric_handler.host, metric_handler.port))
s.settimeout(5) # set socket timeout as to not block gmond
# if the password is set from parameters
if metric_handler.password != None:
s.send("AUTH {0}\r\n".format(metric_handler.password))
s.recv(4096) # TODO check if auth is valid
s.send("INFO\r\n")
info = s.recv(4096)
if "$" != info[0]:
return 0
len = int(info[1:info.find("\n")])
if 4096 < len:
info += s.recv(len - 4096)
metric_handler.info = {}
for line in info.splitlines()[1:]:
#if "" == line:
# continue
n, v = line.split(":")
if n in metric_handler.descriptors:
metric_handler.info[n] = int(v) # TODO Use value_type.
s.close()
metric_handler.timestamp = time.time()
return metric_handler.info.get(name, 0)
- 出版社/メーカー: やなぎプロダクツ
- メディア: ホーム&キッチン
- 購入: 3人 クリック: 3回
- この商品を含むブログを見る

- 出版社/メーカー: やなぎプロダクツ
- メディア: ホーム&キッチン
- 購入: 3人 クリック: 3回
- この商品を含むブログを見る
Debian6でGanglia入れてみた
apt-get install rrdtool librrds-perl librrd2-dev apt-get install php5-gd apt-get install ganglia-monitor gmetad telnet localhost 8649 apt-get install ganglia-webfrontend cp -p /etc/ganglia-webfrontend/apache.conf /etc/apache2/conf.d/ganglia.conf /etc/init.d/apache2 restart
Ganglia用マシンの作成と導入
http://www.is.doshisha.ac.jp/isreport/entry/1480
Gmond Python metric modules
http://sourceforge.net/apps/trac/ganglia/wiki/ganglia_gmond_python_modules
Redis2.6 リリースされたメモ
起動メッセージが変わりました
なんか絵があります
2.6といいつつ Redis 2.5.7と出ますw
persistenceで起動したい場合は「--appendonly yes」と指定すると「appendonly.aof」というファイルに追記式に保存される
mucc@mucc-VirtualBox:~/work/redis-2.6.0-rc1$ ./src/redis-server --appendonly yes
[4332] 30 Apr 00:56:22.844 # Unable to set the max number of files limit to 10032 (Operation not permitted), setting the max clients configuration to 3984.
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 2.5.7 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in stand alone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 4332
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
[4332] 30 Apr 00:56:22.849 # Server started, Redis version 2.5.7
[4332] 30 Apr 00:56:22.850 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
検証
Luaで簡単なサンプルデータを投入
UserIDしか入れてないけど、スペック上げても今のところ1台辺り1千万レコードが限界かな
eval "for i = 1, 100000 do redis.call('hset','user',i,'member_'..i) end" 0 1sec
eval "for i = 1, 1000000 do redis.call('hset','user',i,'member_'..i) end" 0 10sec 111,276Kbyte(約100byte)
eval "for i = 1, 10000000 do redis.call('hset','user',i,'member_'..i) end" 0 100sec 1,104,840Kbyte(約100byte)
eval "for i = 1, 100000000 do redis.call('hset','user',i,'member_'..i) end" 0 ※未検証
eval "for i = 1, 100000 do redis.call('SADD', 'user:1:follows', i) end" 0 1.2sec
eval "for i = 1, 1000000 do redis.call('SADD', 'user:1:follows', i) end" 0 10sec 110,540Kbyte(約100byte)
eval "for i = 1, 10000000 do redis.call('SADD', 'user:1:follows', i) end" 0 130sec 1,100,556Kbyte(約100byte)
運用の懸念点
AOFファイルをメモリ展開するため再起動後結構時間がかかる(1-5分程度)
AOFファイルを展開するのに1台のサーバーフルでメモリを使うとレプリケーションと同期するためのメモリが確保できなくなってしまう