Tuesday, July 21, 2009
So today, I was playing around with memcached on OpenSolaris a bit. I have obviously used it before, but I have an idea which I may want to try to implement, and I wanted to just experiment a bit first.
For the idea to really work, I'll just need to fire probes when most operations come along, grabbing just a bit of data.
When Trond implemented the DTrace probes for memcached, he was quite thorough! Have a look:
ingenthr@green:~/src/memcached$ pfexec dtrace -l | grep memcached | wc -l 53
So, just to see if I could get the kinds of things I wanted, I whipped up a quick script which is similar to starting memcached verbose and watching the operations. It doesn't implement everything, but here's a quick sampling:
#!/usr/sbin/dtrace -Zqs
/*
* show memcached keys as they're retrieved via either an ascii
* or binary get operation
*/
memcached*::command-get
/ (signed int) arg3 != -1 /
{
printf("get %s, FOUND KEY\n", stringof(copyin(arg1, arg2)));
}
memcached*::command-get
/ (signed int) arg3 == -1 /
{
printf("get %s, NOT FOUND\n", stringof(copyin(arg1, arg2)));
}
memcached*::command-add
/ (signed int) arg3 != -1 /
{
printf("add %s, FOUND KEY\n", stringof(copyin(arg1, arg2)));
}
memcached*::command-add
/ (signed int) arg3 == -1 /
{
printf("add %s, NOT FOUND\n", stringof(copyin(arg1, arg2)));
}
memcached*::command-replace
/ (signed int) arg3 != -1 /
{
printf("replace %s, FOUND KEY\n", stringof(copyin(arg1, arg2)));
}
memcached*::command-replace
/ (signed int) arg3 == -1 /
{
printf("replace %s, NOT FOUND\n", stringof(copyin(arg1, arg2)));
}
memcached*::command-set
/ (signed int) arg3 != -1 /
{
printf("set %s length %d, FOUND KEY, STORED\n",
stringof(copyin(arg1, arg2)), arg2);
}
memcached*::command-set
/ (signed int) arg3 == -1 /
{
printf("set %s, NOT FOUND, STORED\n", stringof(copyin(arg1, arg2)));
}
memcached*::command-incr
{
printf("incr %s, FOUND KEY, %d\n", stringof(copyin(arg1, arg2)), arg3);
}
memcached*::command-decr
{
printf("decr %s, FOUND KEY, %d\n", stringof(copyin(arg1, arg2)), arg3);
}
This will give you output like:
set keytest, FOUND KEY, STORED get keytest, FOUND KEY get notfound, NOT FOUND incr keytest, FOUND KEY, 52 decr keytest, FOUND KEY, 51
Neat, huh? In case you don't see why this is interesting, the big advantage here is that I don't need to restart memcached, since the DTrace probes are dynamic. There is no penalty for probes which aren't enabled. This gives me a quick way to see what is happening if say I'm developing against memcached.
p.s.: astute readers may have noticed this isn't yet a proper blog. yeah... I want to set up roller but just haven't taken the time to do it in a secure way... will do that soon
Thursday, April 9, 2009
I owe an explanation in this quick inaugural entry, since some of you will no doubt be visiting because of a pointer from my former blog over on blogs.sun.com.
I'm in a transitional period, as my previous job at Sun (along with the rest of my whole organization) was eliminated. Obviously these are trying times, and I respect the way Sun is handling things even though I'm one of the affected ones and don't necessarily agree with some of the micro-decisions. What I mean by "handling things" is that Sun has been, it seems, eliminating entire groups rather than targeting individuals. Generally I see this as a good thing to do, since it will eliminate having groups with goals/objectives which are not achievable.
So, what's this about transitional? I'm still employed by Sun for a period of time and then have a longer period of time after that to work through what I want to do next. That assumes I do not find another position at Sun compatible with my interests and objectives.
Why would I go back to working with/for Sun? As Simon Phipps pointed out once (but I can't quote exactly since I can't find the reference), companies are really groups of people with similar interests, beliefs and goals. I believe that to be true in the ideal case. It was a lot of my early interests and beliefs that brought me to Sun. Josh Marinacci said something similar when he said it was because he liked Java Swing that he was working at Sun, not the other way around. Despite press articles which imply the contrary, not everyone at Sun agrees all of the time and I never encountered an evil overlord who told me what line to 'sell' to the customers, partners and communities I worked with. Despite that, I think you would find that generally folks at Sun have some common principles. I certainly have a lot in common with Sun's principles, and I hope those principles are understood and adopted by others (as they generally have been).
In any event, I'm in a transitional period and that means I may, or may not go back to blogging at Sun. I didn't want to leave it frozen for life like that, so this will be my personal home, and perhaps more depending on how things turn out.