Record of some of the computer tech I deal with so that it's documented at least somewhere.

Friday, 30 April 2010

Mplayer using Nvidia Vdpau

I did a side by side projection last night. Two 1280x768 projectors pretending to be 1280x1024 (I can probably drive them dot for dot but I didn't have enough tinker time).

Instead of the MatroxDualHeadToGo I used mplayer with Jason Holt's udp-patch.

The playback machine has two Nvidia 8600GTs and I used one for each projector.

The mp4s were only 25Mb each, even so I played them from RAMdisk

# ls -l /dev/shm/LR
total 47164
-rw-r--r-- 1 maht maht 22602673 Apr 29 12:16 L.mp4
-rw-r--r-- 1 maht maht 25579796 Apr 29 12:16 R.mp4


With Vdpau

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
3884 maht 20 0 220m 45m 17m R 24 0.6 32:23.67 mpu
3886 maht 20 0 221m 45m 17m R 23 0.6 31:07.02 mpu

# cat /proc/3884/cmdline | tr '\0' ' '
mpu -vo vdpau -fs -zoom -fixed-vo -udp-master -loop 0 -input file=/dev/null /dev/shm/LR/R.mp4

# cat /proc/3886/cmdline | tr '\0' ' '
mpu -vo vdpau -framedrop -fs -zoom -fixed-vo -udp-slave -loop -0 -input file=/dev/null /dev/shm/LR/L.mp4


Without Vdpau

DISPLAY=:0.1 mpu -vo xv -framedrop -fs -zoom -fixed-vo -udp-slave -loop -0 -input 'file=/dev/null' /dev/shm/LR/L.mp4 &
DISPLAY=:0.0 mpu -vo xv -fs -zoom -fixed-vo -udp-master -loop 0 -input 'file=/dev/null' /dev/shm/LR/R.mp4

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
4252 maht 20 0 221m 47m 20m R 31 0.6 0:16.00 mpu
4253 maht 20 0 221m 47m 20m R 30 0.6 0:14.82 mpu
3860 root 20 0 114m 40m 26m R 15 0.5 0:16.31 X


So for this low bandwidth mp4 using vdpau saved me 25 %CPU points on the quad core, or even 1 whole CPU if you think about how it will get scheduled with > 2 cores. Looks tasty for the dual core player.

Wednesday, 28 April 2010

Exhausting FDs in Go-lang

Looks like the garbage collector is lazy when clearing away unused Fds so always call fd.Close()

Wednesday, 21 April 2010

Installing Go on Fresh Gentoo

Gentooed up the Quad Core.
On a fresh install, let's see what needs to be added for Go

# emerge mercurial
# emerge ed
# emerge syslog-ng # yes folks, Go has a dependency on syslog
# /etc/init.d/syslog-ng start # don't forget like I did

AoE client for Windows

StarWind's gone AoE client Free

You're supposed to reg

http://www.starwindsoftware.com/

Shame about the *AWFUL* UI

proper belongs in the Hall of Shame

Tuesday, 20 April 2010

Image Processing with Go

The usual story of aphid meets programming language is to see what it's like at image processing.

file.go from the Go Tutorial

package main

import (
"fmt"
"image"
png "image/png"
"./file"
"os"
)

var errn = 0
func abort(e os.Error) {
errn++
if e != nil {
fmt.Printf("ERR %s\n", e)
os.Exit(errn)
}
}

func main() {
fd, err := file.Open("in.png", 0, 0)
abort(err)
var img image.Image
img, err = png.Decode(fd)
fd.Close()
abort(err)
w, h := img.Width(), img.Height()
opng := image.NewNRGBA(w, h)
var c image.Color
for y := 0; y < h; y++ {
for x := 0; x < w; x++ {
c = img.At(x, y)
opng.Set(x, y, c)
}
}

fd, err = file.Open("create.png", os.O_RDWR | os.O_CREATE, 0644)
abort(err)
err = png.Encode(fd, opng)
abort(err)
fd.Close()
}


% cd /dev/shm; cp $home/1920x1440.png in.png; time /tmp/8.out
real 0m9.810s
user 0m12.425s
sys 0m0.072s


around 1s per 2000 pixels

Multicore Shell Scripting

Processing lots of files at once in a process level embarassingly parallel way is v. handy. I've been meaning to get round to doing this shell script spawner that will use a fixed number of processes launching, by default, one process for each CPU core the OS reports.

It reads one line at a time and executes it until N are running then it waits until they have all finished and then spawns N more.

It's the most horrible way of doing it from an I/O point of view, hotspot bonanza!!

So maybe it's best to echo 'sleep 2; gm mogrify -resize 5000x3000 foo.jpg bar.png'
I don't know, we'll see

#!/usr/local/plan9/bin/rc

fn os_cpus { # platform dependent, number of cpus, counting from 1
# Linux
grep '^processor' /proc/cpuinfo |
tail -n 1 |
sed 's/[^0-9]//g' |
awk '/./ {print $0 + 1; exit} {print "1"}'
}

fn cpus {
if(~ $#1 0)
os_cpus # default
if not
echo $1
}

cpuN = `{cpus $1}
while() {
for(i in `{seq 1 $cpuN}) {
if(cmd = `{read}) { # brace required :) clever rc parser
$cmd &
}
if not
kill $pid
}
wait
}




I just ran this

{ for(f in f*png) echo gm convert $f -interlace None i^$f } | conquer

Worked a treat

Sunday, 18 April 2010

Mac-Mini is booting Gentoo Linux

used these notes
Install 10.5 to the whole disk
run bootcamp from Applications/Utilities and make a Windows partition
install rEFIt
reboot, reboot again
boot gentoo x86, use parted to make root in the fat32 partition bootcamp made
reboot - run rEFIt partition utility to remake MBR
boot gentoo, make file system

parted output
Partition Table: gpt

Number Start End Size File system Name Flags
1 20.5kB 210MB 210MB fat32 EFI System Partition boot
2 210MB 23.7GB 23.5GB hfs+ Untitled
3 23.7GB 60.0GB 36.3GB ext2 boot


......... carry on with install

I used the make.conf from this useful page

mac_mini kernel config

Compiling away .....
come one, compilaroo

grub-install --no-floppy /dev/sda3

whee I now have Gentoo Linux booting on the mac mini

it's currently in VESA 1920x1440x32

added "directfb" to the use flags

emerge mplayer

I'm on 17 of 103 packages .....
80 of 103 ... come on giddy up

mplayer doesn't work using directfb 'initialization error' - maybe return to that later - intel 954gm is the device

works fine in fbdev mode but that doesn't do -fs -zoom properly. -xy 1024:768 works but goes a bit stuttery
fbdev2 doesn't work with -fixed-vo

so emerge xorg-x11

ideally I want to be in 1920x1440x32 and scale everything up to fs, fingers crossed that X11 will win !


.......


fail - X11 couldn't find its driver and I had to give up the MacMini

X -config /root/xorg.conf.new 

X.Org X Server 1.7.6
Release Date: 2010-03-17
X Protocol Version 11, Revision 0
Build Operating System: Linux 2.6.32-gentoo-r7 i686
Current Operating System: Linux mini1 2.6.32-gentoo-r7 #3 SMP Mon Apr 19 11:31:59 BST 2010 i686
Kernel command line: root=/dev/sda3 vga=0x318 video=uvesafb:1024x768-24@72,mtrr:3,ywrap
Build Date: 19 April 2010 12:47:20PM

Current version of pixman: 0.17.2
Before reporting problems, check http://wiki.x.org
to make sure that you have the latest version.
Markers: (--) probed, (**) from config file, (==) default setting,
(++) from command line, (!!) notice, (II) informational,
(WW) warning, (EE) error, (NI) not implemented, (??) unknown.
(==) Log file: "/var/log/Xorg.0.log", Time: Mon Apr 19 12:54:28 2010
(++) Using config file: "/root/xorg.conf.new"
FATAL: Module i915 not found.
xf86TokenToOptinfo: table is NULL
xf86TokenToOptinfo: table is NULL
error setting MTRR (base = 0x80000000, size = 0x10000000, type = 1) Inappropriate ioctl for device (25)
(EE) AIGLX error: dlopen of /usr/lib/dri/i915_dri.so failed (/usr/lib/dri/i915_dri.so: cannot open shared object file: No such file or directory)
(EE) AIGLX: reverting to software rendering
error setting MTRR (base = 0x80000000, size = 0x10000000, type = 1) Inappropriate ioctl for device (25)


it's right, there's not much in /usr/lib/dri/

maybe that MTRR thing is significant, I need to boot with a LiveCD and find oot, Sabayon Linux 5.2 is rather nice, that looked great (but no shell on the media centre version I booted)

so, until next time ........

Tuesday, 13 April 2010

MPlayer OSX Revisited - failed

The MPlayer OSX Extended tells you all you need to know about GUI oriented OSes. You can't launch it from the command line properly you have to tell it what to open with a series of pulleys.

So I'm trying to compile it using these instructions. I already tried using ./configure && make but that failed with _ff_eval2 missing symbol.

For extra points I have to avoid upgrading to 10.5 as there might be no going back.

I'm also a bit hungry, the chip shop is closed. Curse that Rocco and his real life, doesn't he know we researchers of the deep rely on his potato chipping and frying skills.

WTF does subversion need sqlite3 for !. Do they really need to express their data access in SQL ! We're always one step away from being Crystal Reports in the end.

Needed an extra : port install libtool. nah, did a MacPorts upgrade : sudo port -d selfupdate
and then port installed all the pre-requisites again! ages.

Try not to ever do this yourself without a big book to read while it takes forever with no guarantee of success, even if it works I know it won't do what I want. BUt what I will have is working source code, that's golden.

game over, updated subversion source doesn't compile

Mplayer framebuffer

Mplayer in the framebuffer seems to be best with DirectFB,

mplayer -quiet -vo directfb:buffermode=triple -zoom -fs -aspect 16:9 NSC_TV_ad_30s.avi

DirectFB also gives us buffermode={single, double, triple}
fieldparity={top, bottom, disabled}
layer=N
dfbopts=

stuff that works

-flip -x n -y n -xy n,m (set width, height to n,m) -vf rotate -vf scale -vf mirror

scale resamples the stream before outputting it -xy just hardware scales it

v happy

Monday, 12 April 2010

Why I love AoE

I'm using a 2GB flash card to boot from but as I build the system it uses /var/tmp as a place to build all the intermediate files.

We can get two wins for the price of one.
First off make a new vblade

daph:/# cd /dev/shm/
daph:/dev/shm# qemu-img create -f raw var_tmp 2G
Formatting 'var_tmp', fmt=raw, size=2097152 kB
daph:/dev/shm# ls -l var_tmp
-rw-r--r-- 1 root root 2147483648 2010-04-12 18:55 var_tmp
daph:/dev/shm# du -h var_tmp
0 var_tmp


This gives us a maximum size of 2G but until we use it, it's size is actually 0


By using # vblade 2 3 eth0 /dev/shm/var_tmp
pid 15913: e2.3, 4194304 sectors O_RDWR

run # fdisk /dev/etherd/e2.3
and create 1 primary partition covering the disk (or however you want!) surely you know how
In my case # mke2fs -T small /dev/etherd/e2.3p1
then mount it and importantly bind our memory based /tmp/var in place
mount /dev/etherd/e2.3p1 /mnt/boof
mkdir -p /mnt/boof/var/tmp
mount --bind /mnt/boof/var/tmp /var/tmp
emerge something


and emerge will use the vblade for tmp storage

of course Linux laughs in your face because binds are root level so once it's done, it's done, you can't pop to another window and keep looking in /var/tmp on your local disk, that's gone until you unbind it.

Of course you don't need to be using shm for the vblade you can use disk files or partitions. With a few machines donating RAM you're probably able to saturate your Gbit, with this new machine I'll finally be able to make some measurements.

% time dd if=/dev/zero of=/dev/null count=2000000 bs=512
1024000000 bytes (1.0 GB) copied, 1.22008 s, 839 MB/s
% time dd if=/dev/zero of=/mnt/boof/zeros count=2000000 bs=512
1024000000 bytes (1.0 GB) copied, 80.0547 s, 12.8 MB/s
% time dd if=/mnt/boof/zeros of=/dev/null count=2000000 bs=512
1024000000 bytes (1.0 GB) copied, 1.66719 s, 614 MB/s


This last one is pretty astonishing, I think it needs testing without zeros or something

Framebuffer fun

Getting the framebuffer splash page going was a fun day.

There's some not so secret sauce - that's the definitive one for me April 2010

% emerge splashutils
% emerge -av splash-themes-gentoo
% splash_geninitramfs --verbose --res 1280x1024 --generate /boot/splash gentoo


it uses /etc/splash/gentoo as the source Dir for the files

title Gentoo Vesa
root (hd0,0)
kernel /boot/vmlinuz root/dev/sda2 vga=0x31b video=nvidiafb:1280x1024-32@72,tty:12 splash=silent,theme:gentoo console=tty1
initrd (hd0,0)/boot/splash


various places claim you need 16bit vga but that's no longer true

make sure the bits in the kernel conf are set

my fb1 config

next stage I guess is making custom ones

CF Write Speed

I'm writing a whole partition at once and getting an interesting phenomena. The write speed is varying from 4.3-3.3MB/s which strikes me as quite a range 23% on a solid state disk. Ok It's a across a LAN but it's 1Gbit and only me on it.

Final figure was : 1883Mb 3.7MB/s 8m32s

Just to tickle me every time, the damn partition I backed up wasn't cleanly unmounted and I have to e2fsck the darn thing when I restore it thinking the install will be over before I need to do it again, the curse of the positive outlook.

Backing up is a bit quicker
dd if=/dev/sda | ssh 10.0.0.1 'cat > gentoo.sda'
...
2017419264 bytes (2.0 GB) copied, 181.301 s, 11.1MB/s


I did the whole partition this time so I can boot it in Qemu
% time ssh 10.0.0.1 'cat gentoo.sda' > /dev/sda
real 9m1.404s

Sunday, 11 April 2010

I'm now a Gentoon

I spent 5 hours on Friday installing Gentoo to my new playback PC
ASRock K10N78FullHD-hSLI motherboard with 2 GB DDR2 800Mhz RAM and Athlon X2 245 Dual Core 2.9 GHz 2MBL2 65W.

I'm booting it from a 2Gb Compact Flash card in a SATA <> CF device.

boof ~ # cat /etc/make.conf
ACCEPT_KEYWORDS="amd64"
CHOST="x86_64-pc-linux-gnu"
CFLAGS="-march=athlon64 -O2 -pipe"
CXXFLAGS="${CFLAGS}"
MAKEOPTS="-j3"
GENTOO_MIRRORS="ftp://gentoo.virginmedia.com/sites/gentoo http://gentoo.virginmedia.com/ http://www.mirrorservice.org/sites/www.ibiblio.org/gentoo/ ftp://ftp.mirrorservice.org/sites/www.ibiblio.org/gentoo/ "
SYNC="rsync://rsync.europe.gentoo.org/gentoo-portage"
USE="-hal -dbus -kde -qt3 -qt4 -gnome fbcon -apache2 -aqua -cairo directfb dri gimp -gnustep -handbook -innodb -kontact mmx -mono -mssql -mysql -oci8 openmp -oracle postgres scanner smp sse sse2 ssl vnc x264 -xemacs xvid"
FEATURES="userfetch parallel-fetch"



I dd'd the sda2 partition to use as a vblade but it complains that it has no partition table so I'm going to build it from scratch

read speed from the CF is pretty good

I'm using AOE for /var and /usr/{portage, src}

I've just done ACCEPT_KEYWORDS="~amd64" emerge plan9port
and it's dragging in the whole of X, which could well be a good thing

The vblade I'm using I made with qemu-img create so it uses sparse files, It has ballooned up to 1.1G. I can roll this back as I backed up sda{1,2} before doing it and have already rolled back once when I got caught out by umount.


warning casting double to int : I hope these people know what they are doing. I love Go's attitude : any errors - no build

bah, an error in libXtst and I'm SOL

reset from that, went back to text install pre plan9port, that obviously wants to go all XOrg on me. It locked up and the CF corrupted.

Got the framebuffer going, emerge cdrkit is wodim and friends, dvdauthor brought in imagemagick

Friday, 9 April 2010

Adding venti to an existing Fossil

Pretty simple but I had to look it up.

Here's where I started

cpu% fossil/conf /dev/sdC0/fossil
fsys main config /dev/sdC0/fossil
fsys main open -V -c 3000


and to change it

cpu% fossil/conf -w /dev/sdC0/fossil <{
echo fsys main config /dev/sdC0/fossil
echo fsys main open -c 3000
}


I just love <{}