Archive

Author Archive

ProcessOne releases OneCached 很好的学习Erlang的材料

July 27th, 2010 2 comments

July 05, 2010
ProcessOne has just released OneCached, a Memcached server and client implementation written in Erlang.
OneCached is released under the Erlang Public License (EPL),.

OneCached supports the set, add, replace, get, incr, decr, delete, flush_all and quit commands. It doesn’t handle expiration time.

You call pull the source code from the public repository at: https://git.process-one.net/onecached

git clone git://git.process-one.net/onecached/mainline.git

To compile, just run make, and to start, just type:
bin/onecachedctl start

这个项目是非常简单的一个memcached的模仿, 亮点在于底层用ets, dest, mnesia这样的erlang特有的存储。这个项目的意义在于演示了如何编写一个严肃的Erlang工程,以及需要掌握的技能。对于初学者来讲,这是很好的一个切入点。 你可以在上面修修改改, 打造出你自己的版本。

玩的开心!

Erlang 64位虚拟机halfword版本

July 27th, 2010 2 comments

在即将发布的R14B版本中,包括了64位机器下用的Halfword版本。 我们知道在64位Linux下,指针和size_t都变成64位的, 而Erlang的基础数据结构Eterm都是用的和体系相同的数据结构,那么在64位机器下,虽然CPU运算的速度增加了,但是内存的访问速度不会随着CPU的加快而加快。反而是在64位系统下,比如Erlang的List,访问的内存加倍了,总体的速度下降了百分几十。

为了解决这个问题,Erlang的团队推出了halfword-emulator, 通过修改Etrem指针的长度, 来达到节省内存,加速的目的。
我们可以在编译的时候通过 configure –enable-halfword-emulator 来启用这个VM.

half word 64-bit Erlang VM有以下特性
– 4 Gbytes process heaps (in total)
–max size of Erlang term 4 Gbytes
– ets tables and binaries in separate space can utilize the full 64 bit address space

但是需要注意的是,这个patch推出的时间不长,可能存在风险。 在提高速度的同时,也有不稳定的风险。 用户需要自己去评估。

Categories: Erlang探索 Tags: , ,

sysbench(系统性能基准)介绍

July 27th, 2010 Comments off

SysBench is a modular, cross-platform and multi-threaded benchmark tool for evaluating OS parameters that are important for a system running a database under intensive load.
Current features allow to test the following system parameters:
* cpu性能
* file I/O performance
* scheduler performance
* mutex的性能
* memory allocation and transfer speed, 支持hugepage
* POSIX threads implementation performance
* database server performance (OLTP benchmark) 支持mysql,pgsql, oracle

项目地址是:http://sysbench.sourceforge.net/

从源码来看这个项目做的非常的模块化。 sysbench提供了诸如读取配置, 创建线程, 日志, 计时和模块化框架,支持的测试模式都是通过插件方式加入到框架去的。

用户很容易扩展相应的模块, 通常模块只需要关注自己要实现的测试功能,其他的事情由框架来做,很大的方便用户自己编写特定的测试模块。其他的如多线程什么的都无需自己去考虑。

在数据库的驱动方面,目前提供了mysql,pgsql, oracle的驱动。在数据库抽象方面也是模块的,用户自己也能容易加入自己的数据库支持。

作为一个轻量级别的bench工具,在系统的系统测量方面,可以了解到对系统运行产生很大影响的性能,如内存,cpu,磁盘,锁,线程调度,数据库等方面的信息,是一个得心应手的工具。

在ubuntu下可以用apt-get install sysbench来安装,具体的使用参看 man sysbench。

玩的开心!

Categories: 工具介绍 Tags: , , , ,

来自RHEL系统调优手册的几张经典图

July 20th, 2010 4 comments

调优手册在这里下载: http://www.redbooks.ibm.com/redpapers/pdfs/redp4285.pdf
看图不说话:)

IO架构图:

内存管理图:

很容易误解的socket buffer:

Categories: 杂七杂八, 网络编程 Tags:

Tsung压力测试工具介绍PPT

July 14th, 2010 3 comments

准备为测试部门的同学作个Tsung的讲座, 点击下载Tsung

需要进一步了解Tsung的同学 点这里看官方的文档!
想了解如何使用的还可以到Erlang china这里看看!

OTP R14A今天正式发布了

June 17th, 2010 Comments off

点击这里下载R14A
以下是这次发布的亮点,没有太大的性能改进, 主要是修理了很多BUG!

— HIGHLIGHTS ———————————————————-

OTP-8217 == erts stdlib compiler ==

The module binary from EEP31 (and EEP9) is implemented.

OTP-8485 == common_test ==

It is now possible for the user to provide specific callback
modules that handle test configuration data, so that data on
arbitray form can be accessed (e.g. by reading files or by
communicating with a configuration server process). Two
default callback modules have been introduced in Common Test:
ct_config_plain and ct_config_xml. The former is used to
handle the traditional Common Test configuration files (with
terms on key-value tuple form) and the latter to handle
configuration data on XML representation.

OTP-8555 == erts ==

New NIF features:

Send messages from a NIF, or from thread created by NIF, to
any local process (enif_send)

Store terms between NIF calls (enif_alloc_env,
enif_make_copy)

Create binary terms with user defined memory management
(enif_make_resource_binary)

And some incompatible changes made to the API. For more
information see the warning text in erl_nif(3).

OTP-8623 == compiler erts hipe stdlib ==

Receive statements that can only read out a newly created
reference are now specially optimized so that it will execute
in constant time regardless of the number of messages in the
receive queue for the process. That optimization will benefit
calls to gen_server:call(). (See gen:do_call/4 for an example
of a receive statement that will be optimized.)

OTP-8650 == common_test ==

The run_test script has been replaced by a program (with the
same name) which can be executed without explicit
installation. The start flags are the same as for the legacy
start script.

OTP-8706 == erts hipe tools ==

eprof has been reimplemented with support in the Erlang
virtual machine and is now both faster (i.e. slows down the
code being measured less) and scales much better. In
measurements we saw speed-ups compared to the old eprof
ranging from 6 times (for sequential code that only uses one
scheduler/core) up to 84 times (for parallel code that uses 8
cores).

Note: The API for the eprof has been cleaned up and extended.
See the documentation.

期待R14B有大的动作!

Categories: Erlang探索 Tags:

我的emacs配置

May 26th, 2010 1 comment

贴上来方便有用emacs的同学。配置部分是从网上淘来的,忘记出处了,见谅!

;;(keyboard-translate ?\C-h ?\C-?) 
(defalias 'yes-or-no-p 'y-or-n-p)

(setq time-stamp-active t)
(setq time-stamp-warn-inactive t)
(setq time-stamp-format "%:y-%02m-%02d %3a %02H:%02M:%02S")
(add-hook 'write-file-hooks 'time-stamp)

(global-set-key [f2] 'rgrep) 
(global-set-key [(f5)] 'eshell)
(global-set-key [C-f5] 'shell)
(global-set-key (kbd "M-3") 'capitalize-word)

(global-set-key [f6] 'find-file)
(global-set-key [C-Z] nil)
(global-set-key [C-f4] 'kill-this-buffer)

(global-set-key [(f4)] 'ibuffer)
(global-set-key [(f8)] 'other-window)

(require 'color-theme)
;;(color-theme-initialize)
(color-theme-dark-blue2)
(setq font-lock-verbose t)
;;(set-default-font "Bitstream Vera Sans Mono-12")
(global-font-lock-mode t)
(tool-bar-mode -1)
(setq column-number-mode t)
(setq display-battery-mode t)
(setq size-indication-mode t)
(setq default-major-mode 'outline-mode)
(add-hook 'outline-mode-hook 'turn-off-auto-fill)

(setq transient-mark-mode t)
(setq-default shell-cd-regexp nil)
(setq-default shell-pushd-regexp nil)
(setq-default shell-popd-regexp nil)
(setq inhibit-startup-message t)
(setq visible-bell t)
(setq mouse-yank-at-point t)
(setq kill-ring-max 100)
(setq default-fill-column 60)

(global-set-key (kbd "M-g") 'goto-line)
(global-set-key (kbd "M-o") 'ff-find-related-file)

(setq require-final-newline t)


(setq track-eol t)

(setq gnus-inhibit-startup-message t)

(setq enable-recursive-minibuffers t)
(setq auto-save-mode nil)
(setq Man-notify-method 'pushy)

(display-time-mode 1)
(setq display-time-24hr-format t)
(setq display-time-day-and-date t)
(setq display-time-use-mail-icon t)
(setq display-time-interval 10)

(tool-bar-mode -1)
(customize-set-variable 'scroll-bar-mode 'right)


(setq speedbar-show-unknown-files t)
(setq speedbar-update-flag nil)
(setq speedbar-use-images nil)
(setq speedbar-verbosity-level 0)
(global-set-key [f9] 'speedbar)

;; set paren mode
(show-paren-mode t)
(setq show-paren-style 'parentheses)
(mouse-avoidance-mode 'animate)

;; set the default username and email
(setq user-full-name "yufeng")
(setq user-mail-address "mryufeng@gmail.com")

;; set the title name
(setq frame-title-format "Emacs - %f")

;;-------------------------Shell 使用 ansi color-------------
(autoload 'ansi-color-for-comint-mode-on "ansi-color" nil t)
(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)

(require 'uniquify) 
(setq 
  uniquify-buffer-name-style 'post-forward
  uniquify-separator ":")

;;
(require 'ibuffer)
(global-set-key (kbd "C-x C-b") 'ibuffer)
(require 'ido)
(ido-mode t)

;;-------------------------让Emacs拥有tabs-------------------
(require 'tabbar)
(setq tabbar-buffer-groups-function
          (lambda ()
            (list "All")))

(tabbar-mode)
(global-set-key [(control shift tab)] 'tabbar-backward)
(global-set-key [(control tab)] 'tabbar-forward)
(global-set-key (kbd "M-1") 'tabbar-backward)
(global-set-key (kbd "M-2") 'tabbar-forward) 

;;(require 'session)
;;(add-hook 'after-init-hook 'session-initialize)
;;(load "desktop")
;;(desktop-load-default)
;;(desktop-read)
;;(setq desktop-save-mode t)

(require 'browse-kill-ring)
(global-set-key [(control c)(k)] 'browse-kill-ring)
(browse-kill-ring-default-keybindings)


;;erlang
;;(require 'erlang-eunit)
;;(load "erlang_appwiz" t nil)
(global-set-key [f3] 'erlang-next-error)
(global-set-key [C-f7] 'erlang-compile)
(global-set-key [f7] 'compile)
(global-set-key [f10] 'linum-mode)

;;distel
(add-to-list 'load-path "/usr/local/share/distel/elisp")
(require 'distel)
(distel-setup)
;; Some Erlang customizations
(add-hook 'erlang-mode-hook
	    (lambda ()
	          ;; when starting an Erlang shell in Emacs, default in the node name
`	          (setq inferior-erlang-machine-options '("-sname" "emacs"))
		      ;; add Erlang functions to an imenu menu
		      (imenu-add-to-menubar "imenu")))

;; A number of the erlang-extended-mode key bindings are useful in the shell too
(defconst distel-shell-keys
  '(("\C-\M-i"   erl-complete)
    ("\M-?"      erl-complete)
    ("\M-."      erl-find-source-under-point)
    ("\M-,"      erl-find-source-unwind) 
    ("\M-*"      erl-find-source-unwind) 
    )
  "Additional keys to bind when in Erlang shell.")

(add-hook 'erlang-shell-mode-hook
	    (lambda ()
	          ;; add some Distel bindings to the Erlang shell
	          (dolist (spec distel-shell-keys)
		          (define-key erlang-shell-mode-map (car spec) (cadr spec)))))


;wrangler
(add-to-list 'load-path "/usr/local/share/wrangler/elisp") 
(require 'wrangler) 


;;ecb
(require 'xcscope)
(require 'cedet) ;;load cedet
(require 'ecb) ;;load ecb

(setq ecb-tip-of-the-day nil
inhibit-startup-message t
ecb-auto-compatibility-check nil
ecb-version-check nil)

(global-set-key [f12] 'ecb-activate)
(global-set-key [C-f12] 'ecb-deactivate)
(global-set-key [f11] 'delete-other-windows)
(global-set-key [(meta return)] 'semantic-ia-complete-symbol-menu) 
(global-set-key (kbd "C-c e") 'ecb-goto-window-edit-last) 
(global-set-key (kbd "C-c s") 'ecb-goto-window-sources) 
(global-set-key (kbd "C-c d") 'ecb-goto-window-directories)
(global-set-key (kbd "C-c m") 'ecb-goto-window-methods)
(global-set-key (kbd "C-c h") 'ecb-goto-window-history)
(global-set-key (kbd "C-c r") 'ecb-redraw-layout)
(global-set-key (kbd "C-.") 'cscope-find-global-definition-no-prompting)
(global-set-key (kbd "C-,") 'cscope-pop-mark)
(custom-set-variables
  ;; custom-set-variables was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
 '(ecb-options-version "2.32")
 '(safe-local-variable-values (quote ((erlang-indent-level . 2)))))
(custom-set-faces
  ;; custom-set-faces was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
 )

;;msf abbrev
(add-to-list 'load-path "~/emacs")
;; ensure abbrev mode is always on
(setq-default abbrev-mode t)
;; do not bug me about saving my abbreviations
(setq save-abbrevs nil)
;; load up modes I use
(require 'cc-mode)
;;(require 'perl-mode)
;;(require 'cperl-mode)
;;(require 'sh-script)
;;(require 'shell)
;;(require 'lua-mode)    
;;(require 'erlang)
;; load up abbrevs for these modes
(require 'msf-abbrev)
(setq msf-abbrev-verbose t) ;; optional
(setq msf-abbrev-root "~/emacs/mode-abbrevs")
(global-set-key (kbd "C-c l") 'msf-abbrev-goto-root)
(global-set-key (kbd "C-c a") 'msf-abbrev-define-new-abbrev-this-mode)
(msf-abbrev-load)

;;go mode
(require 'go-mode-load)
(require 'tramp)

;;gud
(add-hook 'gdb-mode-hook '(lambda ()
                            (define-key c-mode-base-map [(f5)] 'gud-go)
                            (define-key c-mode-base-map [(f7)] 'gud-step)
                            (define-key c-mode-base-map [(f8)] 'gud-next)))


(defvar no-easy-keys-minor-mode-map (make-keymap) 
  "no-easy-keys-minor-mode keymap.")
(let ((f (lambda (m)
           `(lambda () (interactive) 
              (message (concat "No! use " ,m " instead."))))))
  (dolist (l '(("<left>" . "C-b") ("<right>" . "C-f") ("<up>" . "C-p")
               ("<down>" . "C-n")
               ("<C-left>" . "M-f") ("<C-right>" . "M-b") ("<C-up>" . "M-{")
               ("<C-down>" . "M-}")
               ("<M-left>" . "M-f") ("<M-right>" . "M-b") ("<M-up>" . "M-{")
               ("<M-down>" . "M-}")
               ("<delete>" . "C-d") ("<C-delete>" . "M-d")
               ("<M-delete>" . "M-d") ("<next>" . "C-v") ("<C-next>" . "M-x <")
               ("<prior>" . "M-v") ("<C-prior>" . "M-x >") 
               ("<home>" . "C-a") ("<C-home>" . "M->")
               ("<C-home>" . "M-<") ("<end>" . "C-e") ("<C-end>" . "M->")))
    (define-key no-easy-keys-minor-mode-map
      (read-kbd-macro (car l)) (funcall f (cdr l)))))
(define-minor-mode no-easy-keys-minor-mode
  "A minor mode that disables the arrow-keys, pg-up/down, delete
  and backspace."  t " no-easy-keys"
  'no-easy-keys-minor-mode-map :global t)
(no-easy-keys-minor-mode 1)



(require 'smex)
(smex-initialize)

(global-set-key (kbd "M-x") 'smex)
(global-set-key (kbd "M-X") 'smex-major-mode-commands)

(require 'org-install)
(add-to-list 'auto-mode-alist '("\\.org$" . org-mode))
(define-key global-map "\C-cl" 'org-store-link)
(define-key global-map "\C-ca" 'org-agenda)
(setq org-log-done t)

(setq transient-mark-mode t) ; highlight text selection
(setq delete-selection-mode t) ; delete seleted text when typing

; highlight current line
(require 'hl-line)
(global-hl-line-mode t)
Categories: 杂七杂八 Tags: ,