Dynamically set CPU offline on Linux

Linux provides a mechanism to hotplug a CPU (core) online or offline during the runtime, which is very convenient for me to dynamically adjust the CPU topology. As usual, I have written a python script (Link: gist:1331343) to make this manually task easy. This script accepts similar parameters as taskset(8):

# Set core 1,2,3,5,6,7,9,12 online, and other cores offline.
$ set_cpus.py 1-3,5-7,9,12
# Reset all cores to be online
$ set_cpus.py -r
Posted in Uncategorized | Leave a comment

HomeNAS reborn with ZFS

After came back from California, I bought a HP ProLiant MicroServer for its 4 hard drive bays. The machine was upgraded to 5(1+4) GB ECC RAMs, and added two more Seagate Barracuda Green 1.5TB 5900RPM HDDs. Without any confidence of storing important data (e.g family photos, research data and drafts) on the 3 years old LeCie 1TB USB disk, I decided to build a FreeBSD + ZFS solution this time for the sake of ZFS’s ultimately end-to-end integrations. The two seagate disks are configured as mirrored ZFS pool, and the LeCie 1T one is formatted as an individual ZFS pool without checksums (Because I do not really care about the data on it). Now I have 7+ TB hard drives at home! It is way to geeky!

The detailed NAS configurations are similar to my previous home NAS solution (e.g Netatalk, Avahi, Samba, Transmission and etc.), with the exception that there is no a decent Dropbox solution on FreeBSD, which actually adds the complexity for me and my wife to backup data around. I did look for building a Debian within VirtualBox, in which the home directory was mounted to the FreeBSD disks. Unfortunately, NFS clients lack the support of inotify that is required by Dropbox monitoring the local file changes. Though there is a potential solution: let the debian virtual machine using local file system (e.g Ext4) and rsyncing the Dropbox directory to FreeBSD every so often. But I just think that it is too much for a Dropbox application.

Posted in Uncategorized | Leave a comment

Google intern summary 1

Three busy weeks have passed by. For most of the time, I was attending tutorials, reading documents and at the end of this period, I was writing documents. Yes, no a single line of code I wrote.

Google has fantastic infrastructures for developments and a bunch of awesome people giving tutorials to us nooglers (a.k.a new googlers). Though there are plenty of stuffs that are confidential, I would like to write down some other public parts that I feels very useful here:

  1. Yeah, they use TDD as well! I personally transfer one of my most important projects at school from using cppuint to google test
  2. Unit tests should be as short/fast as possible. They should not rely on any other components, e.g file system, database, and so. Since once you have tens of thousands of test cases, those slow tests would kill the productively of the entire team.
  3. Do not implement the functions that not necessary for now. If you need this interface, then put an assert in this function in case someone mistakenly use it
  4. Automatic, Automatic, Automatic.
  5. Code is a piece of knowledge. Reuse it whenever is possible
Posted in Uncategorized | Tagged , | Leave a comment

Got google summer internship

I am so excited to get the google summer internship this year for a great matched team, the storage team for Google Apps. Two back-to-back tech phone screens were taken at the last Monday (March 21). I felt good about the most of the questions except the last one, for which my brain was shortcut due to a very bad sleep last night ( less than 2 hours, maybe I was too nervous). However, I still got an email to tell me I passed the tech interview at that Wed. . At the next Thus., I got a Host Interview with the target team. The process was very smooth. It was basically exchange the informations of their projects and my personal experiences, and I got the offer for just 10 minutes. Everything works more smoothly than I expected.

Posted in Uncategorized | 4 Comments

Reading: Cheap and Large CAMS for High Performance Data-Intensive Network Systems (NSDI’10)

This paper presents how to build cheap and large CAMs (what’s CAM?) using a combination of DRAM and flash memory(SSD) to balance the cost and query latency. The main approach of this work is building multiple small hash tables, which are stored on SSD, and holding a two-level bloom-filter in RAM to provide fast hash value lookup. As the author claimed, this work aims to improve the lookup latency but not throughput. By grouping hash values into small groups and flush them in batch mode, it reduces the latency of the costly in-place insert/delete on SSD devices.

Posted in Reading | Tagged , , , | Leave a comment

Developing environment for solo developer

Yes, I am still a computer science Ph.D student right now. Therefore, for my long-term research projects, there is nobody taking charge of building automatically test environments, document management, several platform configurations and so on. I have to build my own to fit my specific workloads: typically a project starts from collecting ideas (head storms), looking for solutions, prototyping and do some experiments. I know, normally, you will create several directories on you laptop, and put files into it. But I want more than that. As worked in giant internet company, software company and start-ups, I have learnt the importances of developing processes. Therefore I built my working environment as following:

  1. Version control: git. Git is powerful and light-weight. It does not require any centralized server, which makes it is super easy to create to use in my daily development and writing processes. One killer feature of git is its lightweight branch operation, which is great for you to prototyping a new experimental features. However, the official documents suck for newbies, if you wanna learn git, go Pro Git Book first.
  2. Trac, trac is a feature-rich SCM system written in Python with wiki, issue tracking, source browsing features. I have used Trac since 2005 for several projects. It is not as fancy as Github. But it is still a good choice if you have no willings to spend extra money on your private projects. Moreover, Trac has git plugin to observe local git repository.
  3. Continuous Integration(CI). I set up a C.I server in our research lab, because it has a public URL to access. For C.I server I chose Buildbot, and set up two build slaves on Ubuntu Server and Mac OSX , respectively. Since I use my macbook pro as the primary development platform, but do not expect to “accidentally” figure out my projects are not working on Ubuntu for months. Under such configuration, the buildbot runs a fully integration tests on the fresh checked out source codes for each commits. What is missing here is that there is no continuous performance tests here, which I am still looking for an elegant solution.
Posted in Computer Science, Programing | Tagged , , , , | Leave a comment

Note: Move MySQL database to another location

For the purpose to evaluate the performance of MySQL database on Ubuntu, I have to move it to an separated disk. I write the steps here for future use:

  1. mkdir /mnt/test/mysql

    and

    chmod -R mysql:mysql /mnt/test/mysql
  2. Stop mysql
  3. cp -rp /var/lib/mysql/mysql /var/lib/mysql/otherdb /mnt/test/mysql
  4. Modify /etc/mysql/my.cnf, find the line with
    datadir = /var/lib/mysql

    , then change it to

    datadir = /mnt/test/mysql
  5. Note: change
    /etc/apparmor.d/usr.sbin.mysqld

    to grant the execution privileges to

    /mnt/test/mysql
  6. Restart apparmor and mysql
Posted in Computer Science | Tagged , , , | Leave a comment

A sed script to extract file name from trace file

The following script is used to extract the full path from a file.

sed -En 's#^[^/]+(/([^ ])+).+#\1#gp' < trace.txt
Posted in Computer Science | Tagged , , | Leave a comment

Reading: Debunking the 100X GPU vs. CPU Myth

This paper comes from ISCA’10.

This paper re-evaluates the performance gap, especially for high throughput computing, between CPU and GPU. Contrast to the previous papers it mentioned claimed 100x performance differences between CPU and GPU, with appropriate optimizations, the performance gap between CPU (Intel Core i7 960) and Nvidia GTX280 narrows to only 2.5x on average. The main factors that impact performance differences between CPU and GPU are:

  1. Bandwidth
  2. Compute Flops
  3. Cache
  4. Gather/Scatter
  5. Reduction and Synchronization

CPUs have large cache but CPUs have higher bandwidth. Thus the average performance gaps between these two are not that extreme huge depended on the characteristics of workloads.

Posted in Reading | Tagged , , , | Leave a comment

Reading: Eraser: A Dynamic Data Race Detector for Multithreaded Programs

This paper is chosen from an advanced operating system course.

As a common programming technology, multithreading programing leads to potential data race that two threads may access same piece of data without synchronization guarantee. Thus the authors of this paper presented a mutex exclusion monitoring mechanism to detect the misbehaviors of shared data. The basic concept of this research is that: for each access to shared variable v, testing whether there is at lease one lock consistently protects v by intersecting the locks being held and the locks which have accessed v:

  1. Let
    locks_held(t)

    be the set of locks held by thread t

  2. For each v, initialize C(v) to the set of all locks
  3. For each access to v, set C(v) := C(v) intersect locks_held(t)
  4. If C(v) = {}, means no lock consistently protecting v, then issue a warning
Posted in Reading | Tagged , | Leave a comment