Friday, February 11, 2011

Way Back Home

Tuesday, February 8, 2011

Freedom

Monday, January 31, 2011

"Socialism" is the opposite of Capitalism

Anyone who uses the phrase "socialism" as a slur, or "knows" taxes are destructive to "growth", should be forced to discover how contrary their opinions are to established fact in most other developed countries.

It drives me so mad the hear the talking heads spend so much more time on rhetoric when the answer to their questions are only a plane ride (or an internet click) away.

The fact is I've lived in a number of these places, and seen directly how public policy affects peoples' daily lives; and all the number quoting of right-wing think-tanks doesn't remove the fact that societies that work towards social justice and equality are simply better places to live in all regards.

If the US has been successful at creating a dynamic, competitive economy, it's because of hungry, driven immigrant entrepreneurs; not any of the usual right-wing canards.

Thursday, January 20, 2011

User-space C++ application tracing on Fedora using Systemtap

Ever since DTrace came out I realized how much that was what I really wanted to do whenever my program was doing something other than what I assumed it was doing. "Tracing" -- I want that.

Debugging is fine; but you need to have debug symbols, you need to pick the right spot in the code to break at, you have to keep manual track if you're tracing a long-running execution, and real-time applications may not play nice when paused for arbitrary periods. Often I would want to not follow a thread of execution up and down its call stack -- rather I'd be interested in the "cross-cutting concerns" -- how a certain variable changes over time.

DTrace will never be coming to my favorite platform (GNU/Linux), but there is a similar library called SystemTap for Linux, which has had the Linux kernel instrumented for a while, but just recent has allowed tracing in user-space programs. I think you will need Fedora 14 to run user-space traces; at least that is what I am using. With the appropriate setup you can start tracing your own C++ applications without modifying the source.

SystemTap uses "static" (preprocessor macro-based source code) probes that are compatible with DTrace; so if you decide to mark-up your source with these macros (as Java, Python, MySQL, et al. are) you can use DTrace or SystemTap depending on your platform. These probes are turned into no-ops when not in use, so they are very fast. However the usage that I am interested in is ad-hoc tracing for the purpose of debugging or simple profiling. Thankfully for this case all you need is debug symbols.

Once you have SystemTap installed, and your program compiled with symbols, you can write your custom probes. The syntax of the probes is beyond our scope, but you can read about it here. Instead I will post a simple "hello world" demo as follows:


#include < iostream >
#include < vector >

using namespace std;

namespace Baz
{
struct Foo
{
int i; int n; float f;

Foo() : i (0), n (0), f (3.14) {}
Foo(int a, float b) : i (a), n (0), f (b) {}
Foo(Foo const &c) : i (c.i), n (c.n), f (c.f) {}
~Foo() {}

int dolart () { f += i; f /= 3.14; return 0; }
int dofizz (int a) { n = a; i += n; return n; }
};
}

int main()
{
vector < int > test;
vector < Baz::Foo > list;

for (int i=0; i<5; ++i)
{
test.push_back (i);
list.push_back (Baz::Foo (i, 1.1));
}

vector < Baz::Foo >::iterator i = list.begin();
vector < Baz::Foo >::iterator e = list.end();

for (int n=0; i != e; ++i)
i->dolart (), i->dofizz (++n);

return 0;
}

And if we use the following "tapset" on the code

global lart_count
global fizz_count
global push_back_count

probe process("a.out").function("Baz::Foo::do*").return
{ if ($return == 2) printf("Foo returned 2!\n"); }

probe process("a.out").function("Baz::Foo::dolart")
{ ++lart_count; }

probe process("a.out").function("Baz::Foo::dofizz")
{ ++fizz_count; }

probe process("a.out").function("vector < * >::push_back")
{ ++push_back_count; }

probe process("a.out").function("main").return
{
printf("dolart was called %d times.\n", lart_count);
printf("dofizz was called %d times.\n", fizz_count);
printf("vector::push_back was called %d times.\n", push_back_count);
}

And run it as follows:

$ g++ -g test.cpp
$ sudo stap probe.stp -c ./a.out

Then we should get the following result:

Foo returned a 2!
dolart was called 5 times.
dofizz was called 5 times.
vector::push_back was called 10 times.

A couple issues I noticed
  • You must run this as root. This is because stap has to compile and load a kernel module that has enormous power to probe your system.
  • Seems to run a bit slow on the simple example. This could be one-time start-up due to compiling a kernel module, or it could be a real-time overhead of not using the cheaper static probes.
  • It seems to spew a lot of strange mangled C++ names for an unknown reason.
  • Constantly respecifying process("a.out") seems redundant. There's probably a way to get around this overhead.

Monday, November 29, 2010

Thursday, November 11, 2010

Fuck AdSense

I had it turned on just to see if I could ever generate some spare change from my minor musings, and in the some 3 years I've had it on I think I've accrued no more than $20 revenue.

The unfortunate thing is each time I change countries, Google tells me I have to cancel my account and re-open a new one. Yet without a balance over $100, they won't bother sending you any money, and whatever it is you made just reverts to their general coffer.

The bottom line is, unless you intend to pursue blogging as a (part-time) job, there is no point whatsoever in having adsense turned on -- it just makes your blog look petty.

So I've turned it off, and I recommend you do the same.

Monday, November 1, 2010

Don't have kids?

I've read a couple on-line arguments about whether to have children or not; how the decision affects one's quality of life and whether or not there are moral implications to the decision.

Some felt children cause an undesirable revolution in one's entire lifestyle; others felt a life without children was shallow and unfulfilling. The most interesting part of the discussion, I felt, was the observation that people (couples) who had decided not to have children often felt they were somehow judged to be "selfish" for their decision, and countered that what was really selfish was insisting on bringing a bunch of new "mini-me"s into an already overcrowded world. What was interesting was I somehow agreed that there was some part of being electively childless that felt selfish, but couldn't immediately put my finger on why.

My choice is obvious. I have a daughter, and couldn't imagine a life without my family. However, I think if you really feel you don't want children, you shouldn't have some just to satisfy some reactionary outside pressure to conform; that's not doing anyone long-term good. So why then do I feel there's something "off" about couples choosing to be childless?

"Selfish" means making or taking advantage for one's own benefit. If anything, those who insist on making mini copies of themselves to have run about the world could be considered "selfish". Childless couples on the other hand are "self-centred": principally considering one's own point of view. They seek to avoid the sacrifice to their lifestyle involved in having kids.

Society is primarily defined as a network of responsibilities owed to one another that knits us together and makes us stronger as a group than as individuals. And responsibility is primarily a matter of sacrificing our individual desires to ensure our responsibility is met.

We begin this process from birth, where our most immediate need is immediately translated into a responsibility for someone else to satisfy -- our consciousness is only capable of comprehending and expressing our own self-need. As we grow older, we learn about sharing (suppressing our need for acquisition and ownership for the benefit of others), chores (suppressing our free playtime for necessary duties), discipline (suppressing immediate gratification for delayed gratification), work (exchange time in unrewarding tasks for money) etc. We learn about family (before our selves), make friends (before our family), have girlfriends (before our friends), get married (one mate before all others), raise kids (before our mate) and so on. Our entire lives are spent learning how to strip a piece of our soul and use it as mortar for the future of our shared society. And when children grow up, they will take the foundation we left them, and start the cycle over again.

In the end, this is what people instinctively react to: electively childless couples have decided contribute to and enjoy the benefits of present society, but have abstained from helping build our common future. They are not dedicating the next 20 years of their life energy making sure the next generation is healthy and well adjusted; they're dissipating it for their own benefit.

I can guarantee you, no one looks at a childless couple who invents the cure for cancer as "selfish". No one thinks the childless couple who volunteers to teach children in Africa are "selfish". But maybe, just maybe, if you're a hipster spending your dual income on lattes, studio apartments, and purse-sized "dogs", someone might look down their nose at you when they stayed awake all night wiping the snot from a sick child's nose. And I don't think the genetic origination of said child matters; only that the child represents the next generation of our society.

Thursday, August 12, 2010

You're wrong

Friday, July 16, 2010

Women in Technology

An opinion offered by an actual woman in technology (eponymously known as "Jessica Boxer"; taken from a blog post I otherwise disagree with).

Firstly, I think the main reason women are less inclined to work in tech is because, as a general rule, women are much more sociable than men. I am sure you are aware of the good, evolutionary reasons why that is so. I believe this is more than a nurture thing, I think it is also to do with the way their brains are wired, which is notably different than the way men are wired. (This isn’t some handwavy opinion, it is a physiological fact.)

Because they are more social, they tend to want to do things that involve sociability more. The scientist or programmer tends to be a lone wolf, spending most of his time talking to his computer or test tube, rather than interacting with people. This fits in considerably less well with the preferences of women. it is also why women who are in computing tend to drift toward the more social jobs, such as testing, tech support, management and GUI design.

Secondly, because computing has tended to be dominated by males, the systems and processes that are in place tend to be more male oriented. for example, design meetings tend to be confrontational rather than consensus oriented, aesthetic is eschewed for functional, individual preferred to group. None of these are intrinsic properties of programming, neither are death marches for that matter. But the dominant class has set the system to their preferences, and so there is a feedback loop that decreases the attractiveness of programming to the less dominant group.

Friday, June 4, 2010

Status and Navel-gazing

I never really knew what "self esteem" was supposed to mean. It always seemed to translate into "I think I'm better than others", and I regularly failed to see why that would be a good idea to be teaching that to kids. I guess this excellent discussion of status makes it clear that "better than others" is precisely what self esteem is.

I've often felt that modern society is somehow unhappier than a perceived simpler past, and this article helps explain why I feel so: If status is self-esteem, and status is relative, then how we feel about ourselves is relative to what we have. And modern humans have a lot.

We feel rewarded when we gain some relative improvement in our lives. In a simpler world, there is a more direct line to incremental status improvements. Being the best in your village means besting only dozens of challengers for esteem.

In a world where the simple achievements are common-place, we seek improving status in ever more circuitous, arduous routes. Even grand accomplishments seem hollow when you're comparing yourself to the global population. Even scaling the worlds highest mountain is blase -- a friend's brother is doing it right now!

This is what makes buddhist philosophy more relevant today than ever, because it teaches us to find "status" in the things that are already around us, and quit searching out "hollow" status in harmful pursuits. Given our current pace of exploitation, what was once the "high-status" of possessing a clean source of water may yet come back in fashion due to scarcity.

"Status" is a thing of our creation, and we can choose to find it where we will; if we can tame a relentless nature.