Monthly Archives: November 2013

ncq depth on linux

Linux NCQ (SATA native command queueing) support is enabled automatically, if your SATA drive supports it. At boot, you will see a line in dmesg (or kernel log) like

cat /sys/block/sda/device/queue_depth
31

to disable ncq:

echo 1 > /sys/block/sda/device/queue_depth

dmesg | grep depth
ata1.00: 234441648 sectors, multi 16: LBA48 NCQ (depth 31/32), AA

about ncq:

Native Command Queuing (NCQ) is a technology designed to improve performance and reliability as the transactional workload increases on SATA hard disk drives. When multiple read and write commands are sent to the SATA drive, NCQ steps in to optimize the completion of these commands by grouping the commands in order of processing efficiency, thereby reducing the mechanical workload and increase performance from the drive. Without NCQ, the drive would process and complete each command one at a time in the order in which it was received.

ncq benefits:

Works in all systems where host controllers support the SATA NCQ feature including desktop PCs, workstations, digital media content servers, entry servers, as well as high performance PCs and mobile/notebook systems
Provides 100% backward compatibility with non-NCQ supporting systems
Allows the reordering of commands by the storage device to increase the efficiency of its data transfers
Improves seek time performance from hard drives and allows solid state drives to access the stored command queue to boost performance
NCQ is a feature that is designed into the Serial ATA interface. To take advantage of NCQ, both the host controller/chipset and hard drive need to support the feature.

The NCQ-enabled hard drive on the left can execute four commands (A, B, C, and D) in a total of one and a quarter complete rotations due to proper ordering of the operations. The non-NCQ hard drive on the right requires a full two and three quarters rotations to execute the same four commands (A, B, C, and D) as a result of poor ordered operations.

NCQ provides higher performance in heavy transactional workloads traditionally found in high performance workstations, network servers, multi-media servers and editing workstations. NCQ also contributes to improved overall system performance in various computing operations including system booting to file copying.

java GCJ

OpenJDK’s native Java compiler is, itself, written in Java; as a consequence, you need a working previous version of Java in order to build a new version.

If you’re starting from scratch on a platform for which no existing JDK binaries are readily available (or if you’re working within certain Free Software projects whose charters prohibit the use of proprietary build dependencies), then GCJ (or some of its underlying components) can be one potential solution to the chicken-and-egg problem of getting a working, albeit somewhat inefficient bootstrap Java in place, in order to move on to build the more desirable OpenJDK.

In fact, back when OpenJDK was first announced, significant effort (via the IcedTea project) was spent in fixing up GCJ to get it to the point where it was up to the task.

GCJ is obsolete. It was started a long time ago because people wanted an open-source alternative to the Sun JDK, and it was never particularly good. Now that Sun open-sourced their JDK, there’s absolutely no reason to use GCJ (but it still lurks in some Linux distros).

linux irq balancing – affinity

IRQs have an associated “affinity” property, smp_affinity, which defines the CPU cores that are allowed to execute the ISR for that IRQ. This property can be used to improve application performance by assigning both interrupt affinity and the application’s thread affinity to one or more specific CPU cores. This allows cache line sharing between the specified interrupt and application threads.

egrep em. /proc/interrupts
cat /proc/irq/47/smp_affinity

the default value for smp_affinity is f, meaning that the IRQ can be serviced on any of the CPUs in the system. Setting this value to 1, as follows, means that only CPU 0 can service this interrupt.

echo 1 > /proc/irq/47/smp_affinity

python usefull bundle installer

cd ~/.vim/bundle
git clone https://github.com/gmarik/vundle.git
vim +BundleInstall +qall

git clone https://github.com/tpope/vim-fugitive.git
git clone https://github.com/klen/python-mode.git
git clone https://github.com/davidhalter/jedi-vim.git

vim +BundleInstall +qall

vimrc:
set nocompatible
filetype off

set rtp+=~/.vim/bundle/vundle/
call vundle#rc()

” let Vundle manage Vundle
” required!
Bundle ‘gmarik/vundle’

” The bundles you install will be listed here
Bundle ‘davidhalter/jedi-vim’
Bundle ‘tpop/vim-pathogen’
Bundle ‘klen/python-mode’

filetype plugin indent on

” The rest of your config follows here
syntax on

” Python-mode
” ” Activate rope
” ” Keys:
” ” K Show python docs
” ” Rope autocomplete
” ”
g Rope goto definition
” ”
d Rope show documentation
” ”
f Rope find occurrences
” ” b Set, unset breakpoint (g:pymode_breakpoint enabled)
” ” [[ Jump on previous class or function (normal, visual, operator modes)
” ” ]] Jump on next class or function (normal, visual, operator modes)
” ” [M Jump on previous class or method (normal, visual, operator modes)
” ” ]M Jump on next class or method (normal, visual, operator modes)

” Change this to 1 to enable python-mode code completion; we are using jedi for this, so it is 0
let g:pymode_rope = 0

” Documentation
let g:pymode_doc = 1
let g:pymode_doc_key = ‘K’

“Linting
let g:pymode_lint = 1
let g:pymode_lint_checker = “pyflakes,pep8″
” Auto check on save
let g:pymode_lint_write = 1

” Support virtualenv
let g:pymode_virtualenv = 1

” Enable breakpoints plugin
let g:pymode_breakpoint = 1
let g:pymode_breakpoint_key = ‘b’

” syntax highlighting
let g:pymode_syntax = 1
let g:pymode_syntax_all = 1
let g:pymode_syntax_indent_errors = g:pymode_syntax_all
let g:pymode_syntax_space_errors = g:pymode_syntax_all

” Don’t autofold code
let g:pymode_folding = 0

create rsync incremental backups with hardlinking

Quite short and simple bash script:

#!/bin/bash
# Simple weekly bash backup script all variables explain themselves
# Version 1.03

what=”/ka”
where=”/ba”
set -e

today=$(date +’%Y-%m-%d’)
last=$(ls -r $where | head -1)
delete=$(ls -r $where | tail -n +7)

cd $where
nice -n 19 rsync –bwlimit=10000 –info=progress2 –link-dest=$where/$last $what $where/$today

[ -z “$delete” ] || rm -rf $delete