Skip to content

Instantly share code, notes, and snippets.

View nhoriguchi's full-sized avatar
💭
working

Naoya Horiguchi nhoriguchi

💭
working
View GitHub Profile
@nhoriguchi
nhoriguchi / getopts_extended
Created September 6, 2012 19:10
Getopts Wrapper
#!/bin/bash
# Extended version of getopts, which cannot handle both optional/non-optional
# parameters in a combined manner (non-optional ones can't come first.)
# This function allows us to do it and we can parse all of the followings:
# ./cmd -a optarg_for_a -b arg1
# ./cmd -a optarg_for_a arg1 -b
# ./cmd arg1 -a optarg_for_a -b
#
# The usage of getopts_extended is similar to that of getopts like:
@nhoriguchi
nhoriguchi / emopen
Created July 12, 2013 22:48
emacs wrapper to keep sets of opened files
#!/bin/bash
# emopen: emacs wrapper to keep sets of opened files
#
# Author: Naoya Horiguchi <nao.horiguchi@gmail.com>
#
# Before using this, you need add the following elisp code on your .emacs:
#
# (defun get-list-opened-files ()
# "Get the list of opend files to recover in next open."
@nhoriguchi
nhoriguchi / gist:6026438
Last active December 19, 2015 22:18
emopen ver.0.2.1 # exclude files sized over 1MB
#!/bin/bash
# emopen: emacs wrapper to keep sets of opened files
#
# Author: Naoya Horiguchi <nao.horiguchi@gmail.com>
#
# Before using this, you need add the following elisp code on your .emacs:
#
# (defun get-line-with-buffer (bufname)
# (with-current-buffer bufname (count-lines 1 (point))))
@nhoriguchi
nhoriguchi / virsh_start_wait.sh
Last active August 29, 2015 13:57
virsh_start_wait.sh
#!/bin/bash
TMPF=$(mktemp)
while getopts c: OPT
do
case $OPT in
"c" ) export LIBVIRT_DEFAULT_URI=$OPTARG ;;
esac
done
@nhoriguchi
nhoriguchi / virsh_exec_single_line.sh
Created March 8, 2014 04:34
virsh_exec_single_line.sh
#!/bin/bash
usage() {
echo "Usage: `basename $0` target password logfile <command>"
exit 0
}
while getopts c: OPT
do
case $OPT in
@nhoriguchi
nhoriguchi / test_git_bundle.sh
Created November 12, 2014 16:22
git-bundle test
#!/bin/bash
TMPF=$(mktemp -d)
SDIR=$TMPF/src
DDIR=$TMPF/dst
mkdir $SDIR $DDIR
commit_num() {
local num=$1
echo "data $num" > file
@nhoriguchi
nhoriguchi / test_git_bundle_stgit.sh
Created November 12, 2014 17:06
git-bundle test for stgit
#!/bin/bash
TMPF=$(mktemp -d)
SDIR=$TMPF/src
DDIR=$TMPF/dst
mkdir $SDIR $DDIR
commit_num() {
local num=$1
echo "data $num" > file
@nhoriguchi
nhoriguchi / stg-bundle.sh
Last active August 29, 2015 14:09
stg-bundle.sh
#!/bin/bash
#
# Author: Naoya Horiguchi <nao.horiguchi@gmail.com>
#
# Usage:
# stg-bundle.sh create [-b branch] [-d directory] [-f] [-h]
# stg-bundle.sh create [-a] [-d directory] [-f] [-h]
# stg-bundle.sh import [-d directory] [-n branchname] [-f] [-h]
# stg-bundle.sh test
#
@nhoriguchi
nhoriguchi / hugetlbfs_reserve.rst
Last active April 2, 2019 00:18
Hugetlb Reservation

概要

hugetlbfs の reservation は hugepage を preallocation の管理に使用される。 hugepage は使用前に free hugepage プールを作成し、page fault の際に実際にプロセスに割り当てられるが、preallocation というのはその前段階で mmap() はしたが、まだ fault in はしていない状態を指す。 mmap()MAP_NORESERVE フラグを渡すことによって reserve を回避することもできるが、その場合もし fault in までの間に他のプロセスによって hugepage を割り当てられてしまった場合、page fault に失敗して SEGSERV を受信してしまうことになる。 事前に reserve しておくことによって確実に fault in できるようにする、というのが reserve の基本的な役割と言える。

hugetlb はページサイズごと (x86 だと 2MB 以外に 1GB もサポートしている) のグローバル変数 hstate で管理されていて、その中の resv_huge_pages が reserve カウントを表す。 さらに、hugetlbfs 上のファイルを mmap() する場合は inode に resv_map 構造体を紐付けて reservation とオフセットの対応を管理している。

@nhoriguchi
nhoriguchi / gist:ec8ad21ade76838872198b7e636bce93
Created April 5, 2019 04:54
Fabric ブログ 2019/04/02
Chris Ferris のブログで開発動向が紹介されている。
https://www.ibm.com/blogs/blockchain/2019/04/does-hyperledger-fabric-perform-at-scale/
- スケーラビリティの話には 2 つの次元がある。
- 一つは channel 数、peer 数、organization 数に基づく性能のスケーラビリティ。
- もう一つはチャネルやチェーンコードの管理のスケーラビリティ。
- 後者も重要で、Fabric の channel は sharding として使うこともでき、あるチャネルのトランザクションのロードが限界に近づいたら、別のチャネルに分離する選択肢がある。
- しかし v1.4 時点でも運用管理ツールはまだ発展途上で、運用管理の手間は大きい。
- v2.0 のベータ版が 5 月に予定されている。
- chaincode lifecycle が改善され、チャネルの生成・管理の手間が軽減される予定である。