Thursday, August 30, 2012

Get rid of "3 more files to edit" warning in vim

The E173 "... more files to edit" error in vim drives me nuts.  To get rid of it, I added this to my .vimrc:


" Get rid of annoying 'more files to edit' error:
nno :q :qa

Saturday, August 11, 2012

Social status: the underground river


Status is a touchy subject in the West.  We spent a long time believing that nobles were fundamentally better than serfs, and nowadays most overt assertions of authority are considered gauche.  We don't bow to our president, and in most newer business settings we don't even use titles or honorifics: some companies take pride in everyone from janitor to CEO going by their first names.

But that doesn't mean that our society is an egalitarian utopia: parents are legally responsible for their kids, managers are responsible for their reports, police decide whether or not you get a ticket or go to jail.  And we expect people to be fair and judicious and limited in their exercise of authority, and to treat others as equals the rest of the time.  And overall I think that's a great way to operate.

More subtly, though, people also believe in respecting their elders, deferring to people with more experience, respecting "sweat equity", and special statuses like "I was here first".

This leads to a lot of ambiguity.  Should a rookie cop lecture a retired veteran about gun safety?  Should a new manager defer to a senior worker?  There are many stories about incautious Lieutenants trying to assert authority over salty old Sergeants.  Remember, all this has to be resolved without compromising our egalitarian ideals.
Contrast Asian languages, where you literally can't get through a sentence without expressing status!  

In Cambodian, for example, the generic word for "you" is only used in formal documents.  Otherwise it's always "older sibling", "younger sibling", "aunt/uncle", "grandma/grandpa", or a dozen other titles.

The very best leaders are good at keeping everyone pointed in the right direction without ever offending our sense of egalitarianism.  But it's a tough skill to cultivate: I've spent hours writing emails that try to balance a clear vision for how I think things can move forward, and what I need from other people, without sounding like I'm trying to order them around or subvert their own judgment.  Even in writing this article, it's hard to balance conveying my enthusiasm in a confident and engaging way, while still encouraging people to question my assertions and contribute their own insights.

Wednesday, August 08, 2012

Reflective street crystals

One of my favorite pieces of natural urban beauty are these "street rainbows" I see once in a while.



It's caused by a sandy powder on the roads.  I'm fairly sure it's a kind of retro-reflective crystal used to make white road lines shine brightly in car headlights, because as you can tell from my shadow in the photo, the effect only appears when the sun is almost directly behind my head.

Tuesday, August 07, 2012

Kingston v200 series SSDs have problems

From my research and testing, I'm going to be avoiding v200 series Kingston SSD disks.  (But I've had great success with the older v100 series disks).

Users complained about very slow write performance on the disks in the series smaller than 256GB, and Kingston released a firmware claiming to fix those issues, and also claiming that the 256GB disks are unaffected:
http://www.notebookreview.com/default.asp?newsID=6488&review=kingston+ssdnow+v200+ssd+7mm

I picked up a 256GB unit from newegg (SV200S3N/256G) for $199 and tested it today in several machines.

In my Dell T3500 workstation with an 82801JI (ICH10 Family) SATA controller, running Ubuntu Lucid (10.04) linux, I couldn't get the disk to come up at all.  I got this in dmesg:


[1129999.229709] ata3: irq_stat 0x00000040, connection status changed
[1129999.229712] ata3: SError: { DevExch }
[1129999.229719] ata3: limiting SATA link speed to 1.5 Gbps
[1129999.229722] ata3: hard resetting link
[1130001.452632] ata3: SATA link down (SStatus 1 SControl 310)
[1130001.452643] ata3: EH complete
[1130001.458368] ata3: exception Emask 0x10 SAct 0x0 SErr 0x4000000 action 0xe frozen

Then I switched to another machine running Ubuntu Precise (12.04) with a supermicro motherboard, plugging into one of the onboard SAS ports (looks like Intel ICH10 82801JI).  I tested writing to the bare block device:
$ dd if=/dev/zero of=/dev/sdb bs=8M count=128 oflag=direct

And got 115MB/sec.  On a second run adding a seek=128 flag I got only 54.5MB/sec.  A third run with seek=1024 gave me 91.2MB/sec.  So it's fairly bizarre to see such wildly varying numbers on an SSD, and this is very worrisome.  In dmesg I saw lots of messages like this:
[67334.890127] mpt2sas1: log_info(0x31120303): originator(PL), code(0x12), sub_code(0x0303)

Then I switched to a port on an LSI SAS2008 controller in the same machine, and consistently got 257MB/sec, which is excellent.

So from my brief testing, it looks like the disks may do okay if you put them on the right sata controller, but have significant and varied problems on other controllers.

Attempting to codify thought


I've been thinking lately that AI doesn't spend enough time trying to understand and emulate what it means to have a Train of Thought, or for that matter, what a Thought is.  So here's my best guess.  The next step is to try actually coding it up.

class Thought {
 public:
  Fire();
  // Rises when Fire()d, decays over time
  float activity;
  List(Association): associations;
  activate();
  randomly_activate_nearby_thoughts();
}

class Association {
  Thought other_thought;
  float association_strength;
}


And a specific type of Thought would be a SensoryMemory, a sort of leaf node that has not only associations with other Thoughts but also a certain sensation unique to that SensoryMemory: a particular smell or sound or visual feature.

Sensory input threads: a Sensor is a thread that takes in sensory input and calls Fire() on the corresponding SensoryMemorys.

Thought::Fire() {
  this.activate();
  wait_for_random_interval();
  randomly_activate_nearby_thoughts();
}


Thought::activate() {
  this.activity += approximately(1.0);
}

Thought::randomly_activate_nearby_thoughts() {
  related = choose_random_related_thought();  // Weighted by association_strength
  if ( related.active >= 1.0) {
    // Maybe the Association threads make this unnecessary?
    this.strengthen_association(related);
  }
}


Association Threads: an Associator looks at active Thoughts and makes new thoughts that tie together chains of thoughts that are all active right now, or associates active unrelated thoughts:

Associate() {
  thought = choose_random_active_thought();
  chain = recursively_find_all_connected_active_thoughts(thought);
  // Associate the new thought with the entire active chain:
  if (chain.length > 1)  create_new_thought(chain);
  else {
    // A lonely thought!  Find it a friend.
    other = choose_random_active_thought();
    add_association(thought, other);
  }
}

Decay threads reduce the activity level of thoughts over time.

Chaos threads (probabilistically) randomly activate Thoughts.

So your Train of Thoughts is the sequence of most active Thoughts over time.  What's missing?

TODO: perhaps we need some sort of global arousal level that treats pleasure and pain properly, causing us to shrink from pain and seek pleasure.  Or a notion of how much we are seeking: fatigue makes us sleepy, food increases our curiosity.

Thursday, June 21, 2012

Stop worrying about the "923-bit encryption" press release

The popular press usually gets crypto stuff wrong, but this time I can't find anybody within even a mile of the truth. Fujitsu et al released a press release a few days ago with the breathless title "Fujitsu Laboratories, NICT and Kyushu University Achieve World Record Cryptanalysis of Next-Generation Cryptography"

It's unfortunate that they chose to take this approach, because all their misleading yet juicy quotes are leading to a lot of popular press articles that mangle the truth even further, leading to the popular and mistaken impression that nobody actually knows how to keep anything safe using crypto, whereas the truth is that there are quite a few well-established and secure practices that work great and that most people just can't be bothered to follow.

Here's what's actually going on:

Pairing-based crypto is a tiny little branch of security that's interesting to researchers (it was needed for my dissertation), which is probably why it's so hard to get the story straight, and it's not in common use in any commercial product I'm aware of.

The most common thing the press gets wrong in these kinds of articles is making claims about security in terms of key lengths.  There are two main branches of modern crypto: private (symmetric) key and public (asymmetric) key.  They're usually used together, and while they both use keys, symmetric crypto uses much shorter keys than public-key crypto does.  For a secure symmetric cipher like AES, a 128-bit key is plenty long, and for a secure public key algorithm like RSA, 2048-bits is plenty long.

In this case, pairing-based crypto is a third kind of animal, and its security and key lengths don't have any bearing on either public or private key algorithms.

So the bottom line is that it's a very interesting research result, with absolutely no impact on the crypto people actually use (which is almost always what we can safely assume when the press gets breathless about some new research result).

Thursday, May 17, 2012

Understanding CPU, I/O and memory bandwidth choices (as of May 2012)


Every year or two I have to go catch up on the latest PC hardware so I can make reasonable decisions about what gear to buy.  Here's the result of my latest inquiry into high end Intel hardware.  Thanks to William over at Puget Systems for patiently explaining it.

CPUs:
  • Sandybridge is the latest intel CPU architecture.  Available in i3/i5/i7/xeon and more.  All of those CPU types were around before sandybridge, so for example, i7 does not necessarily imply sandybridge.
  • Sockets: Currently Intel mostly uses the LGA1155 and LGA 2011.  i5 and i7 use LGA1155, i7 and xeon use LGA2011.  i7 and xeon motherboards have different chipsets, so generally aren't interchangeable even though they share the LGA2011 socket.
  • There are only a few LGA2011 socket i7 chips, vs. many Xeon options.
  • "Server motherboard" typically means Xeon, and dual-socket boards are more common than single-socket (6 single vs. 27 dual mobos currently on newegg right now)
Memory:
  • i5 supports dual-channel memory (modules installed in pairs).  Sandybridge i7 and xeon support quad channel, which can double the memory bandwidth.
  • i5 and LGA1155 are limited to 32GB RAM.  i7 typically limited to 64GB RAM (although I see some 128GB MSI i7 mobos).  Dual-socket Xeon boards can do up to 768GB
  • ECC memory requires Xeon
PCI:
  • PCIe has 3 standards: 1.0, 2.0, and 3.0.  3.0 is brand new and mostly only used for video cards right now.  1.0 does 250MB/sec per lane, 2.0 does 500MB/sec per lane, 3.0 does 1GB/sec per lane.
  • Xeon has a built-in PCI controller