Posts

Showing posts from November, 2008

Premature Optimization - early load testing and profiling

Premature optimization applied broadly is often a bad thing, however, a good developer will utilize common sense and experience when selecting and applying design idioms and patterns. When you are dealing with a singleton shared resource like the highly utilized core database, it is absolutely necessary to be aware of best and bad practices and to design appropriately around them.

Every query either good or bad affects every other user of the system. With respect to the database, spending up front time to consider and design optimal access is warranted. Those choices pay off later as the system is enhanced and scaled.

One common theme I have experienced at the last few companies and on the last few projects is that lots of code was implement and deployed without early and regular load testing and profiling. By the time performance issues became apparent, bad selections had become embedded and bad practices had proliferated through the code base. At that point it was very time consuming,…

JavaServerFaces (JSF) excessive heap new generation objects

Observing 10s - 100s MB of Java heap growth on 10s - 100s KB JSF pages. Observeing > 100:1 ratio (heap growth / page response).

Creation or growing many Collections and/or the underlying arrays without knowing the necessary final size can generate excessive garbage. This is not to say that this is in any way expensive. In fact, quite to the contrary, testing has proven that this type of garbage is often quite cheaply created and reclaimed. However, if many or large objects of this type live beyond a young generation GC cycle, they might very well spill into the tenured generation. If this occurs often enough, they will adversely affect full GC (stop-the-world) time.

Ubuntu 8.10 Intrepid Ibex

Installs with Compiz Fusion, to install the configuration manager execute:

sudo apt-get install compizconfig-settings-manager

JBoss 4.2.x JConsole MyEclipse Java 1.6u10

To get JConsole to successfully connect to JBoss 4.2.2 under Java 1.6.0_10 started from MyEclipse 6.6.0 based upon Eclipse 3.3.2, I had to add the following to the VM arguments:


Don't load JBoss MBeans - reduced clutter
-Dcom.sun.management.jmxremote

JBoss
-Djavax.management.builder.initial=org.jboss.system.server.jmx.MBeanServerBuilderImpl
-Djboss.platform.mbeanserver
-Dcom.sun.management.jmxremote

Remote JConsole connection args
hostName:portNum
service:jmx:rmi:///jndi/rmi://hostName:portNum/jmxrmi

Remote config args
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=6002
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false

JVM Options

Comprehensive JVM options 1.3 - 1.6, has lots of links many about tuning
SDN JVM options

-Xms100M initial heap
-Xmx100M max heap
-Xmn100M young gen
-Xss1M max stack size
-XX:MaxPermSize=64m
-Xbootclasspath[/a|/p]:<path>

-XX:+DisableExplicitGC
-Xloggc:<file>
-XX:+PrintGC
-XX:+PrintGCDetails
-XX:NewSize=2.125m
-XX:SurvivorRatio=8

SEAM

Fixing grub MBR

How to fix grub MBR

fsck

Other disk utilities

smartmontools
command line tools is 'smartctl'
background monitoring daemon is 'smartd'

Strings and interning

String.substring does not copy or intern the substring, it points to the char array within the original base string, encumbering it so that it can't be garbage collected. The original base String is encumbered even if the substring is zero length.

As of Java 1.2 any interned String with no references may be garbage collected since they are weak references.

See post

The above site indicates String.inter stores utilizes Heap, some other sites indicate that interned Strings are stored in perm gen. Testing validates that interned Strings are stored in perm gen.

Fix windows XP MBR with Ubuntu Live CD

After I recovered a Windows XP partition with Acronis, I followed this posting to restore the MBR which previously had a GRUB loader from a dual-boot Ubuntu installation.

It worked perfectly however you have to download the ms-sys and manually install it from:

http://packages.ubuntu.com/gutsy/ms-sys


sudo fdisk -l

This gives you a list of partitions. Using the info from the windows partition you want to boot into execute the following, be sure not to include the number.


sudo ms-sys -m /dev/sda

Now reboot and windows should load.

Enterprise Architect on Ubuntu with CodeWeaver's Wine

Save yourself a lot of trouble and just run it on Windows under VirtualBox. It works perfectly.

It runs under WINE, but the help menus don't work and the ODBC for reverse engineering seems quite difficult to configure. Did get Sybase freeTDS to connect, but couldn't see the ODBC DSNs in EA. Gave up and decided to run it on Windows.

For forward/reverse engineering of databases, setup unixODBC

Setup unixODBC Wine integration by

sudo gedit /etc/profile
Add:
export LIB_ODBC_DRIVER_MANAGER=/usr/lib/libodbc.so.1.0.0

Follow EA on linux setup

CodeWeaver's Wine

Ubuntu ODBC

Via Applications : Add/Remove
Installed OpenOffice.org Database

Via System : Administration : Synaptic Package Manager

Installed tdsodbc, unixodbc, unixodbc-bin

Created a freetds.conf per freetds docs

cp /usr/share/libct3/freetds.conf ~/.freetds.conf

Added entry:

[arbitrary name for server/service]
host = 10.12.10.19
port = 1433
tds version = 5.0

Using unixODBC

Configured Sybase tds driver
sudo ODBCconfig

selected Drivers tab and clicked Add
filled out the form based on tooltips
the drivers are in /usr/lib/odbc
the checkmark at the top is the save button
logged out and logged back in without sudo

The above created /etc/odbcinst.ini with the entry:

[arbitrary name for driver]
Description = Sybase tdsodbc
Driver = /usr/lib/odbc/libtdsodbc.so
Setup = /usr/lib/odbc/libtdsS.so
UsageCount = 1
CPTimeout =
CPReuse =

System DSN tab edits /etc/odbc.ini and creates an entry like:

[arbitrary name for system DSN]
Description = some desc
Driver = tdsodbc
Servername = somename entry from ~/.freetds.conf
Database =
UID =

Ubuntu create screencasts

Use xwininfo -frame to get any frames coordinates and size

Ubuntu Hardy Heron ssh server setup

sudo apt-get install openssh-server
sudo gedit /etc/ssh/sshd_config
PermitRootLogin no
sudo /etc/init.d/ssh restart

Followed this post to install ssh server

Ubuntu Hardy Eclipse too many open files

Followed this post and raised limits

To check maximum # fd in system

cat /proc/sys/fs/file-max

To count open fd for a process

lsof -p 460 | wc -l

460 is PID

To check shell level fd

ulimit -n

To change it

sudo gedit /etc/security/limits.conf

add

* soft nofile 65536
* hard nofile 65536
troy - nofile unlimited

sudo gedit /etc/pam.d/common-session

Then add the line: session required pam_limits.so Save the file logout and login to take affect

http://posidev.com/blog/2009/06/04/set-ulimit-parameters-on-ubuntu/

Oracle vs. PostreSQL vs. MySQL

Google search: database feature postgres mysql

Database market share graphs

Recent article - PostgreSQL looks best as a free alternative to Oracle

Non standard MySQL stuff

Why PostgreSQL Instead of MySQL: Comparing Reliability and Speed in 2007

Five Compelling Reasons to Use MySQL

History and Licensing Postgres vs. MySQL 2004

Why is MySQL more popular than PostgreSQL?


Josh Berkus: Two great open source databases: a comparison (2008-06-26) - While it seems to favor Postres, after reading it, I felt more confident in MySQL.

Summary:

The biggest gripe I have with MySQL is its deviation from standards. MySQL's acceptance and adoption by heavyweights are votes of confidence and proof of capability. Given that the cost, feature matrices, and performance are comparable, I would put my support behind the industry leader. Of course in the interest of full disclosure, I would pick Unix/Linux over Microsoft.

MySQL Customer list
PostreSQL Customer List

Sabre Holdings Corporation - a transactional example

&…

Vmware player windows sceen size

Trying to set MS Windows display running in VMware player to size of Ubuntu screen.

Custom screen resolutions

Knowledge base article 1003

Tried this, no luck

Trying this

Ubuntu mic on Lenova ThinkCentre

Had trouble getting it to work:

Opened volume control
File : Change Device : 3 Capture: Monitor Source of ALSA PCM on front:0(AD198x Analog) via DMA (PulseAudio Mixer)
On Recording tab adjust Master record volume up

File : Change Device : 0: HDA Itel (Alsa mixer)
Adjust as necessary, now the Recording tab Digital mic level will adjust the recording level

Right click on volume control and Preferences
Select HDA Intel (Alsa mixer)
Select PCM so volume bar will adjust volume


Not sure it this was necessary, but also followed the following post:

sudo gedit /etc/modprobe.d/alsa-base

added at end of file

options snd-hda-intel model=6stack-digout

then reboot.

After that you have to increase volume in MASTER, PCM, FRONT, FRONT MIC , SURROUND (nothing else, otherwise it won't work), and set input source to FRONT MIC, 8ch.

Windows VirtualBox in physical partition

Installed VirtualBox with this post, but used latest version Ubuntu deb package

Warning When launching a Virtual OS, don't ever boot into the current or host OS or corruption will occur.

Followed this link and it works
Initially mouse and keyboard were not capturing, click the do not show again checkbox on the popup message and it fixes the capture problem.

Create a new hardware profile for windows so VirtualBox dosn't alter the base profile
Be sure to set profile selection to manual or preferred, set the new profile ahead of the base profile so don't accidentally boot into the base from virtual boot

* Click Start : Control Panel : System
* On the hardware tab, select Hardware Profiles
* Click Copy, and name the new hardware profile Virtual
* Set the selection to manual
* Move the Virtual profile to the top

Add yourself to the disk group so when you run VirtualBox, it has permission to write to the disk
sudo usermod -G disk,vboxusers -a `whoami`

Create a new Virtual…

Editing MBR

The following forum post has links that discuss editing the MBR:

You can reinstall Ubuntu's grub IPL to the mbr, using the live cd

You could add a configfile entry to boot Xubuntu:
See the section on booting multiple linux distros...also, this link will explain everything you need to know about grub.