23 February 2008

This week I learned...

  • A shibboleth is language that sends cultural signals beyond its plain meaning. The word comes from a fairly amazing Bible story.

    Now I want a word for language invented to annoy, like “Democrat Party”.

  • Aristotle believed slavery to be “expedient and right”. All the best arguments by learned apologists for slavery in the U.S. South were from his writings, particularly in the Politics.

  • Incidentally, Aristotle thought democracy was a crummy form of government. And, in his ideal society, homeschooling would be banned.

  • There are expressions of the Golden Rule in the scriptures of many religions.

  • I don't understand what this means, exactly, but the x86 instruction set contains an FNOP instruction. The manual describes it as a floating-point no-operation instruction. How this might be different from a regular NOP I don't know.

  • So there's a widely known interview question: write a function to count the number of bits of a 32-bit int that are set to 1. This function is called the population count—that link describes a surprising use for it.

    The last time I tested this, summing 4 queries into a 256-value lookup table is fastest for 32-bit integers, faster than the awesomely clever bit-twiddling solution. I shouldn't have been surprised. The lookup table fits easily into cache. The bit-twiddling solution has a lot of dependencies; the CPU can't find any instruction-level parallelism there.

    Anyway, what I learned a week or two ago is that future Intel chips will have an SSE instruction, POPCNT, that does this, in parallel, for several words at a time. (Someone I mentioned this to commented that he doesn't want to be fired for pronouncing that.)

  • Often when I write these blog entries, I'm still unsure of the significance of some of the things I've just learned. For example, I learned something about Java monitors (or pthreads condition variables, which are the same thing). When thread 1 notifies, waking thread 2 on a separate CPU, the lock associated with the monitor ensures that CPU 1's writes are flushed to main memory and CPU 2 sees them before thread 2 starts running. There's no need for write-barrier magic in Object.notify itself.

  • Apple's Shark profiler has a feature that lets you compare two profiles. But the result is calculated by comparing percentages, not comparing the absolute number of samples. So, for my purposes, useless.

  • The .mshark files produced by Shark are gzipped binary property lists, but the actual samples are stored in there as raw binary data which I haven't tried to decipher.

3 comments:

Manuzhai said...

FWIW, there's a wonderful West Wing episode (season 2, episode 8) called Shibboleth, featuring Chinese christian fugitives. Well worth watching if you have some spare time.

djc

Anonymous said...

"I don't understand what this means, exactly, but the x86 instruction set contains an FNOP instruction. The manual describes it as a floating-point no-operation instruction. How this might be different from a regular NOP I don't know."

My guess is that the NOP is issued to the main processor and that the FNOP is issued to the floating point processor.

jto said...

"Issued"? I appreciate the comment, but... is this really how processors work? Can it possibly be that at some point the CPU sends a signal to the FPU saying "now hear this: do nothing"? What's the purpose of "issuing" a NOP? Is there some observable difference between the main processor not doing anything and the FPU not doing anything?

These questions, they haunt me.

The use cases I know of for the regular NOP involve debuggers and runtime-patchable code.