mysql/5.0.45 …

August 12, 2009 2:09 pm UTC | In Tech | 6 Comments | hide

I recently did some performance testing with a few big tables on mysql/5.0.45 under CentOS and noticed a sharp drop in query speed a few minutes after restarting mysql. More tests showed mysql/5.0.51a or newer don’t have this problem. OK, I guess a picture is worth a thousand words… (SELECT queries only, and also mysql buffer size is huge, so disk I/O is minimal during test.)
mysql_performance
It’s most likely due to mysql bug 21075 (fixed in mysql/5.0.50). Unfortunately mysql/5.0.45 is the version that ships with CentOS 5.3 and some other Redhat-derived Linux distro. Consider upgrading if you are using mysql/5.0.45 and your mysql server appears to be heavily CPU-bound.

Tags: , ,

sort…

August 9, 2009 9:35 pm UTC | In Tech | 1 Comment | hide

I recently noticed CentOS 5.3′s sort is way slower than Ubuntu 9.04′s. Apparently the i18n patch used in coreutils-5.97 CentOS rpm is a performance killer:

$ LANG=C time -p sort --buffer-size=128M -n -k1 -k2 test.info > /dev/null
real 92.58
user 86.04
sys 6.52
$ time -p sort --buffer-size=128M -n -k1 -k2 test.info > /dev/null
real 463.04
user 456.01
sys 6.64

P.S. grep and other locale sensitive utilities have similar issue.

BTW, if your disk is slow, --buffer-size is a parameter you might want to play with to optimize performance. By default sort uses very conservative buffer size while your seemingly used memory is actually just used for cache. [ref]

Tags: , , ,

Oral Tradition

October 16, 2008 12:34 pm UTC | In Study | 2 Comments | hide

Mark A. Kasevich et al., rf Spectroscopy in an Atomic Fountain:

In the early 1950′s, Zacharias attempted to make a fountain of atoms by directing a thermal atomic beam upwards. [2]

[2] Knowledge of J. R. Zacharias’s work has been passed down in the oral tradition. …

Tags: ,

Convert video to iPod format

August 7, 2008 8:21 pm UTC | In Tech | 1 Comment | hide

Basic command:

ffmpeg -i input.avi -f mp4 -vcodec mpeg4 -b 1000kb \
-acodec aac -ab 192kb [-ac 2] output.mp4

-ac 2” may not work if the input file is in mkv format with 5.1 aac audio (if you don’t convert 5.1 to 2.0, playing the file crashes your iPod/iPhone). Here’s a possible way to convert:

  • Extract aac audio from the mkv file:
    ffmpeg -i input.mkv -vn -acodec copy audio.aac
  • Downmix 5.1 to 2.0:
    faad -d audio.aac -o audio-2ch.wav
  • Merge and convert to iPod format:
    ffmpeg -i input.mkv -i audio-2ch.wav -map 0.0:0 -map 1.0:1 -f mp4 \
    -vcodec mpeg4 -s 470x320 -b 1000kb -acodec aac -ab 192kb output.mp4
  • The output of the last command gives a little more info of what I am doing here:
    Input #0, matroska, from 'input.mkv':
    Duration: 01:24:42.5, start: 0.000000, bitrate: N/A
    Stream #0.0: Video: h264, yuv420p, 704x480, 24.39 fps(r)
    Stream #0.1: Audio: aac, 48000 Hz, 5:1
    Input #1, wav, from 'audio-2ch.wav':
    Duration: 01:24:42.5, start: 0.000000, bitrate: 1536 kb/s
    Stream #1.0: Audio: pcm_s16le, 48000 Hz, stereo, 1536 kb/s
    Output #0, mp4, to 'output.mp4':
    Stream #0.0: Video: mpeg4, yuv420p, 470x320, q=2-31, 1000 kb/s, 24.39 fps(c)
    Stream #0.1: Audio: aac, 48000 Hz, stereo, 192 kb/s
    Stream mapping:
    Stream #0.0 -> #0.0
    Stream #1.0 -> #0.1

Video conversion can certainly be way fancier than what I am doing here, and faad is obviously not the best way to downmix audio from 5.1 to 2.0. You can also find quite a few iPod converters but personally I like command line. Anyway, happy converting! (ffmpeg ref)

[Also note that on MacOS, you may have to change "-acodec aac" to "-acodec libfaac".]

Tags: , , , , , ,

Google ads in Gmail

August 3, 2008 9:54 am UTC | In Misc | 3 Comments | hide

Google ads are “content-sensitive”. What does that mean?

  • Case 1: My colleague worked overnight, so I sent an email to him in the morning: “Great work, have some good sleep then.”. Gmail popped up a sponsored link: “Sleep Apnea Cure”. Oh come on, my colleague sleeps very well…
  • Case 2: My friend did not show up in a scheduled meeting, and he emailed me: “Sorry I screwed up today….  Could we meet late afternoon tomorrow”. The Google ads beside this email was “Date Hot Stanford Girls!”. ok, ok, I guess Google knows my geolocation, and “screw up” does have another meaning…

Tags: ,

Matlab under Ubuntu

June 27, 2008 10:17 pm UTC | In Tech | 1 Comment | hide

Some tips:

  • Q: Matlab desktop does not show up correctly.
    A: export MATLAB_JAVA=/usr/lib/jvm/java-6-sun/jre/ (requires Sun Java 6 Runtime)
  • Q: Matlab windows disappear in taskbar (Window List applet).
    A: minimizing all windows (show desktop button) seems to bring all windows back into taskbar. Or you can try to export AWT_TOOLKIT=MToolkit
  • Q: Printing in Matlab throws java exception.
    A: Go set all printers > Job Options > Orientation to something other than “Automatic Rotation”.

Links: 1, 2.

Tags: , ,

Microsoft Visio save as EPS

February 8, 2008 2:04 pm UTC | In Tech | 6 Comments | hide

I wrote the following procedure on 2008.02.08:

To convert a Microsoft Visio document to EPS without losing scalable vector format (and without installing 3rd-party software…):

  1. Install Microsoft Save as PDF or XPS Add-in for 2007 Microsoft Office programs (only available for Office 2007?).
  2. Save Visio document as PDF in Visio 2007.
  3. Convert PDF to Postscript (.ps) with pdf2ps utility.
  4. Open .ps file with gsview, and select File -> PS to EPS, be sure to check “Automatically calculate Bounding Box”.

Now you have an EPS file to be embedded into your LaTeX document. Many other converting methods exist, see also Visio and EPS.

Here are some updates (edited on 2009.01.30):

  1. In theory, you should be able to open that saved PDF directly in gsview and convert to EPS, but gsview either crashes or refuses to accept the PDF.
  2. In some cases, e.g. when you compile LaTeX directly to PDF using pdflatex, you just need a PDF figure with correct size. In that case, you can set the document size in Visio: File -> Page Setup -> Page Size (tab) -> Size to fit drawing contents, and then save the Visio document to PDF, which will then be in correct size ready to be embedded into LaTeX.
  3. To create a Postscript file, you don’t necessarily need to save as PDF and convert to .ps using pdf2ps. All you need to do is to use a postscript printer (most modern printers are, including most PDF writers) and print to file. That would create a postscript file which can then be passed to gsview and converted to EPS by adding a bounding box. Note: this is in fact a generic way of converting anything to (vector-format) EPS/PDF with bounding box.

Tags: , , , ,

TeraStation does not auto-mount USB disk

January 31, 2008 4:32 pm UTC | In Tech | 1 Comment | hide

Don’t know exactly why TeraStation does not automatically mount my external USB disk, but the fix is to manually fill in the USB disk GUID in /etc/melco/diskinfo. GUID can be obtained from /proc/scsi/usb-storage/*. Related script is possibly /etc/hotplug.d/scsi_device/usb-buffalo.hotplug.

Tags: ,

下一页 »

This weblog is licensed under a Creative Commons License.
Powered by WordPress. Theme based on Pool by Borja Fernandez.