Bisection (software engineering)
Bisection is a method used in software development to identify change sets that result in a specific behavior change. It is mostly employed for finding the patch that introduced a bug. Another application area is finding the patch that indirectly fixed a bug.
Overview
The principle of locating the changeset that introduced a specific regression was described as "source change isolation" in 1997 by Brian Ness and Viet Ngo of Cray Research. Regression testing was performed on Cray's compilers in editions comprising one or more changesets. Editions with known regressions could not be validated until developers addressed the problem. Source change isolation narrowed the cause to a single changeset that could then be excluded from editions, unblocking them with respect to this problem, while the author of the change worked on a fix. Ness and Ngo outlined linear search and binary search methods of performing this isolation.[1]
Code bisection has the goal of minimizing the effort to find a specific change set. It employs a divide and conquer algorithm that depends on having access to the code history which is usually preserved by revision control in a code repository.
Bisection method
Code bisection algorithm
Code history has the structure of a directed acyclic graph which can be topologically sorted. This makes it possible to use a divide and conquer search algorithm which:
- splits up the search space of candidate revisions
- tests for the behavior in question
- reduces the search space depending on the test result
- re-iterates the steps above until a range with at most one bisectable patch candidate remains
Algorithmic complexity
Bisection is in LSPACE having an algorithmic complexity of with denoting the number of revisions in the search space, and is similar to a binary search.
Desirable repository properties
For code bisection it is desirable that each revision in the search space can be built and tested independently.
Support by revision control systems
Revision control systems like Git or Mercurial directly support[2][3] code bisection.
Other revision control systems like Bazaar or Subversion support it indirectly employing plugins[4] or external scripts.[5]
Support by other systems
- Phoronix Test Suite can do bisection automatically to find performance regressions
See also
- Delta debugging (generalization of finding a minimal cause of a bug)
- Annotation § Source control (determining changesets that edited a line in a file)
References
- ^ Ness, Brian; Ngo, Viet (1997). Regression containment through source change isolation. Computer Software and Applications Conference. IEEE. doi:10.1109/CMPSAC.1997.625082.
- ^ "git-bisect(1)". git-scm.com. Retrieved 2017-08-05.
- ^ "hg". Selenic.com. Retrieved 2017-01-09.
- ^ "bisect - Find the revision introducing a bug using a binary search — Bazaar 2.8.0dev1 documentation". Doc.bazaar.canonical.com. Retrieved 2017-01-09.
- ^ "svn-bisect". Metacpan.org. Retrieved 2017-01-09.