After writing about the processor sets and their role in computing the number of garbage collection threads recently, there were some questions about configuring processor sets. In this article i want to explain the usage of resource pools in Solaris in regard of CPU resources. You don’t configure the processor sets directly. Instead of this the pool facility does this for you.
I want to explain how to configure, how to use and how to monitor them. However i can just scratch the surface in such an article.
Prerequisites
When you want to demonstrate a feature of the OS that influences the way processes are dispatched on the CPUs it’s useful to have something that produces a lot of load. A normal household cpuhog will be sufficient, so i use the one from the resource manager tutorial.
This command creates a processor set that has at least one CPU and at most one cpu. Or to say it easier: It hast exactly one CPU all the time. In the next step we create a pool. You can think of the pool as the entity that poold use as a administative unit.
For my example I’ve created a pool called hog_pool. Okay … now we have to configure the connection between the pool and the processor set.
With the associate subcommand you configure this connection.
Okay, let’s have short look into the state of of pool facility.
</small>We see just one pool at the moment. We have to activate the currently configured configuration first. We have to do this by using the the pooladm command.
When you now recheck the persisting configuration, you will see that it’s equal to the configuration you get with the pooladm command. However you should do this step only when you are sure that the configuration matches your expectations. Let’s recheck the persistent configuration.
</small>
Using the the resource pools
Okay, now we have this nice processor set, but how do we use it. There are several possibilities, but i my example i will explain the usage of projects to use the resource pools.
At first i create a project.
The commands create a project with the name hog_project, the user jmoekamp is member of this project. The most interesting part is the -K project.pool=hog_pool part. This tells Solaris to use the pool hog_pool for everything executed within this project.
When you think about the Resource Manager tutorial you are already know how to start command under a dedicated project (and then you will know, you are already running your processes within a project called user.jmoekamp, too). You can do this by using the newtask command. I will start some the CPU hogs to demonstrate the impact of the CPU pool.
When you look at output of poolstat a little bit later, you will see an unloaded default set as well as an really hard working hog_pool
Just to check the behavior from a different perspective:
</small>Albeit there are at least two CPUs, there is just one cpuhog on a CPU and all other are runnable, but wait until they are dispatched on the cpu0.
Okay, we don’t need those hogs any longer …
With prstat 1 you will see that ./cpuhog.pl moves from CPU to CPU.
We can assign a project to a running process. We need the process id of the process for this task:
When you look at the output of prstat 1 you will recognize that, that the ./cpuhog.pl just stays on cpu0, the cpu of the hog_pool and doesn’t move away. So we have proofed that it’s under the control of the resource pool.
Another way to reach the same is to use the poolbind command. With the poolbind command you can assign tasks, projects or processes to a certain pool:
However i prefer the first method :)
This was just the surface
In this tutorial i barely touched the resource pool facility of Solaris. It has vastly more functions from dynamic resource pools based on load measurement and a rule set which pools and thus which applications are most important up to mechanisms to have several config files that could activate different pool configurations via cron (for example for dayshift and nightshift configurations) or mechanisms to force poold to obey locality rules (for example to prevent that poold chooses procs on seperate uniboards on a large server. You can even use it to configure different scheduling classes per pools on the CPU.
Conclusion
The pool facility is a really powerful feature to control the usage of CPU resources. However many people aren’t really aware of the possibibilties of the toolset. This may result from the point that most people use their server in a single task per server configuration or aren’t aware of possible performance advantages by forcing processes on certain CPUs leveraging the topology of a computer system.