Skip to main content

Binary Search

Binary searching is a method to easily find the source of an issue with, for instance with a server with many plugins.

Let's say you have a paper server with many plugins, and something is misbehaving. It's probably a plugin that's causing it, but it would take forever to try each plugin individually. This is where a binary search would be appropriate.

Requirementsโ€‹

Binary searching requires you to have a reproducible test for the problem. If you have no way of knowing if removing something fixed the problem, it doesn't work.

Methodโ€‹

  1. Disable half of your plugins.
  2. Test if the issue is still present. If it is, you know the culprit is in the enabled half, if not, the disabled half.
  3. Disable half of the set that contains the culprit. You should now only have a quarter of your plugins enabled.
  4. As before, test if the issue is still present
  5. Repeat until you're left with just one plugin: the culprit!

Exampleโ€‹

Let's say you have 32 plugins, and you've got an odd bug probably caused by a plugin. The source plugin is plugin 21, but you don't know that yet.

[01][02][03][04][05][06][07][08]
[09][10][11][12][13][14][15][16]
[17][18][19][20][21][22][23][24]
[25][26][27][28][29][30][31][32]

You'd start by disabling half of the plugins, let's do 1-16. When you test the issue, you'd find that the issue is still present. Thus, the culprit must be in the second half (17-32).

[01][02][03][04][05][06][07][08]
[09][10][11][12][13][14][15][16]
[17][18][19][20][21][22][23][24]
[25][26][27][28][29][30][31][32]

Leaving 1-16 disabled, let's now disable half of 17-32 (17-24). Testing the issue, you find the issue went away, thus the culprit must be in 17-24.

[01][02][03][04][05][06][07][08]
[09][10][11][12][13][14][15][16]
[17][18][19][20][21][22][23][24]
[25][26][27][28][29][30][31][32]

We'll disable 25-32, and re-enable half of 17-24 (21-24). The issue returns, and so the culprit must be in 21-24.

[01][02][03][04][05][06][07][08]
[09][10][11][12][13][14][15][16]
[17][18][19][20][21][22][23][24]
[25][26][27][28][29][30][31][32]

Almost done. Disabling 21 & 22, the issue goes away. It must be one of them.

[01][02][03][04][05][06][07][08]
[09][10][11][12][13][14][15][16]
[17][18][19][20][21][22][23][24]
[25][26][27][28][29][30][31][32]

Disabling 22, and the issue goes away. We have our culprit.

[01][02][03][04][05][06][07][08]
[09][10][11][12][13][14][15][16]
[17][18][19][20][21][22][23][24]
[25][26][27][28][29][30][31][32]

Confirm by enabling all but 21, and sure enough we got him.

21 was The Imposter...