Sam Gentle.com

Strace and self-consciousness

Have you ever noticed that thing where you're really in the zone – you're writing, or playing a game or a sport, and you have that magical flow feeling where it all just seems to be happening effortlessly – and then you become aware of that fact and suddenly lose it. Daniel Kahneman talks about the fast and the slow systems of thought, and to me it seems obvious that flow is rooted firmly in the fast system, until it gets bogged down in slow-system meta thoughts.

The best analogy I can think of is the Linux system utility strace, which allows you to inspect what a program is doing by tracing system calls that the program makes to the operating system. It's super useful, but it doesn't come for free. If I do something like copy 100GB of zeroes around:


$ dd if=/dev/zero of=/dev/null bs=1M count=100k
102400+0 records in
102400+0 records out
107374182400 bytes (107 GB) copied, 6.43048 s, 16.7 GB/s

And then I run it with strace:


$ strace -co/dev/null dd if=/dev/zero of=/dev/null bs=1M count=100k
102400+0 records in
102400+0 records out
107374182400 bytes (107 GB) copied, 10.5155 s, 10.2 GB/s

You can see it takes over one and a half times longer! We can run ps to make sure:


$ ps 21278
  PID TTY      STAT   TIME COMMAND
21278 pts/0    t+     0:12 dd if=/dev/zero of=/dev/null bs=1M count=100k

That STAT t+ means it's currently being interrupted for tracing. In fact, it's being interrupted on every single attempt to read and write data which, since that's all it's doing, is a lot of the time. Obviously this is a pathological case, but if there's anything we know about biology it tends to be pretty pathological! Strace was designed to be as efficient as possible, whereas the same is definitely not true for our own introspective abilities. Even so, it's usually considered a bad idea to use strace in production.

And I think we lose a lot when we can't turn off our own introspection for production. A simple exercise in speaking to a group of people becomes an endless cascade of "did I really just say that? Oh god I'm doing this all wrong". A simple game of tennis becomes an exercise in simultaneously trying to move a racket while being aware of every minor rule of good playing form. A simple writing exercise becomes a game of writer-vs-editor where you get bogged down in stylistic questions when you really should be just letting the words flow.

Introspection is important, of course. Judging and evaluating what you do is the only way you get better at it. However, to do your best work at something you have to be completely immersed in it, and that means leaving the introspection until later.