Last.FM: Recently listened

Sunday, May 21, 2006

[L4] Speeding up L4Linux task creation

It's L4Linux once again. As mentioned the last time, L4Linux gets performance leaks when it is in need of services provided by other L4 services, since it then needs to call these services. One example for this is task creation, which I tried to improve recently. Let's first have a look at what L4Linux is doing upon a user-space application calling fork():
  1. Allocate an L4 task from the task server. The task server upon initialization got all available tasks from the resource manager (RMGR). However it does all these requests only to get informed about how many tasks are in the system. It then returns these tasks to RMGR immediately.
  2. Setup Linux-internal task data.
  3. Call the task server once again to start the task.
  4. The task server now calls RMGR to really start the task.
The same goes for terminating a task. Once again RMGR is called to kill the task using the task server as a proxy. So what is this task server good for anyway? - Well, it provides ownership management for tasks. This could also be included to RMGR thereby saving this indirection, but no one has done so up to now.

Having a look at what is done in task server and RMGR to startup a task shows, that it is simply some l4_task_new() system call. The first idea to improve the situation is to let L4Linux do so itself. I therefore added a new allocate_chief() call to the task server interface. This allocates a task for the client and makes this client become the task's chief. This is necessary, because only a task's chief is allowed to start and stop it.

This alone speeds up task creation and termination by around 10%, since we save one L4Linux -> task server -> RMGR call chain for both, starting and stopping a task. Another improvement can be made by caching unused tasks. If a task is terminated, we do not need to return it to the task server, but can put it into a cache instead. It can then later be restarted as a new L4Linux task. This removes every interaction with L4 servers from the start/stop process of a task. All in all new task management and task caching do result in 20% performance increase for task creation.

No comments: