Saturday, September 29, 2012

Btrfs is really slow

Knowing Btrfs is still not default file system in any mainstream distros, I have 2 machines using it. I just love the features of subvolume, snapshot and COW (copy-on-write).

I'm not talking about everyday operations here, which (except system boot though) are hard to tell the difference between Btrfs and Ext4. When you do a major update or distribution upgrade, be aware that it may take much longer time than you expect.

I'm doing the upgrade from Ubuntu 12.04 Precise Pangolin to 12.10 Quantal Quetzal Beta 2. It took about half an hour to download new packages, which totally depends on your network bandwidth. But it's been 5 hours and the progress bar is just over half in installing the upgrades step.

I can expect the upgrade to finish within another few hours, which is not as bad as another user's experience. I don't think this issue will get addressed before Btrfs becomes default in Fedora or something, but it definitely should be solved before it becomes default. The question is, chicken or egg?

Tuesday, September 18, 2012

Software imitates nature

In some software I participated, a web application is actually divided into two projects during development, and two deployable artifacts during runtime. This design addresses the idea that the UI of an application should only be the presentation of the application, while all the logic keeps the same in back-end even when front-end UI is changed. In this case, a lot of communication between front-end and back-end are required. And a lot of problems are also caused by this kind of communication. Let me give you an example.

There is a list of items in browser. User can make changes to the list, add items to the list or remove items from the list. Each time the list is changed, an asynchronized RESTful request is sent to back-end to update the model. Everything seems fine but sometimes it works strangely as the front-end and back-end have different items of the same list.

We finally figured it out that this is because the items in the list might change before the previous request is finished, and the change may or may not be sent to back-end and processed in order. Solving the problem is easy once we know the reason. Developers decided to temporarily disable the list from being modified until previous request is finished. Problem solved, well, for this specific front-end.

But if we turn to real life for such scenario, helmsman repeating verbal commands is one example to avoid misunderstanding between two parties. Back to the problem, to keep single source of truth, we can also return items in list as response and request any front-end to update the items in list to be the same.

You might wonder why bother doing the same thing twice. It's because they have different point of view. Disabling changes in front-end while waiting is a solution for a front-end not to have different state from back-end. Replying the state in back-end is telling any front-end what's in back-end is the only truth. Following the latter one is the key, while the former one is just a user-friendly add-on.

This is just an example that many software problems are really projections of real life problems that already got solved. Don't try to re-solve them when you can simply follow patterns that are already proved in nature.