bisecting_regressions.rst 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. .. _doc_bisecting_regressions:
  2. Bisecting regressions
  3. =====================
  4. .. highlight:: shell
  5. Bisecting is a way to find regressions in software. After reporting a bug on the
  6. `Godot repository on GitHub <https://github.com/godotengine/godot>`__, you may
  7. be asked by a contributor to *bisect* the issue. Bisecting makes it possible for
  8. contributors to fix bugs faster, as they can know in advance which commit caused
  9. the regression. Your effort will be widely appreciated :)
  10. The guide below explains how to find a regression by bisecting.
  11. What is bisecting?
  12. ------------------
  13. Godot developers use the `Git <https://git-scm.com/>`__ version control system.
  14. In the context of Git, bisecting is the process of performing a manual
  15. `binary search <https://en.wikipedia.org/wiki/Binary_search_algorithm>`__
  16. to determine when a regression appeared. While it's typically used for bugs,
  17. it can also be used to find other kinds of unexpected changes such as
  18. performance regressions.
  19. Using official builds to speed up bisecting
  20. -------------------------------------------
  21. Before using Git's ``bisect`` command, we strongly recommend trying to reproduce
  22. the bug with an older (or newer) official release. This greatly reduces the
  23. range of commits that potentially need to be built from source and tested.
  24. You can find binaries of official releases, as well as alphas, betas,
  25. and release candidates `here <https://downloads.tuxfamily.org/godotengine/>`__.
  26. For example, if you've reported a bug against Godot 3.2, you should first try to
  27. reproduce the bug in Godot 3.1 (not a patch release, see below for the reason).
  28. If the bug doesn't occur there, try to reproduce it in Godot 3.2 *beta 1* (which
  29. is roughly in the middle of all test builds available). If you can't reproduce
  30. the bug with Godot 3.2 beta 1, then try newer betas and RC builds. If you do
  31. manage to reproduce the bug with Godot 3.2 beta 1, then try older alpha builds.
  32. .. warning::
  33. For bisecting regressions, don't use patch releases such as Godot 3.1.2.
  34. Instead, use the minor version's first release like Godot 3.1. This is
  35. because patch releases are built from a separate *stable branch*. This kind
  36. of branch doesn't follow the rest of Godot's development, which is done in
  37. the ``master`` branch.
  38. The Git bisect command
  39. ----------------------
  40. If you've found a build that didn't exhibit the bug in the above testing
  41. process, you can now start bisecting the regression. The Git version control
  42. system offers a built-in command for this: ``git bisect``. This makes the
  43. process semi-automated as you only have to build the engine, run it and try to
  44. reproduce the bug.
  45. .. note::
  46. Before bisecting a regression, you need to set up a build environment to
  47. compile Godot from source. To do so, read the
  48. :ref:`Compiling <toc-devel-compiling>` page for your target platform.
  49. (Compiling Godot from source doesn't require C++ programming knowledge.)
  50. Note that compiling Godot can take a while on slow hardware (up an hour for
  51. each full rebuild on a slow dual-core CPU). This means the full process can
  52. take up to several hours. If your hardware is too slow, you may want to stop
  53. there and report the results of your "pre-bisecting" on the GitHub issue so
  54. another contributor can continue bisecting from there.
  55. To start bisecting, you must first determine the commit hashes (identifiers) of
  56. the "bad" and "good" build. "bad" refers to the build that exhibits the bug,
  57. whereas "good" refers to the version that doesn't exhibit the bug. If you're
  58. using a pre-release build as the "good" or "bad" build, browse the `download
  59. mirror <https://downloads.tuxfamily.org/godotengine/>`__, go to the folder that
  60. contains the pre-release you downloaded and look for the ``README.txt`` file.
  61. The commit hash is written inside that file.
  62. If you're using a stable release as the "good" or "bad" build, use one of the
  63. following commit hashes depending on the version:
  64. .. code-block:: none
  65. 3.2-stable
  66. 3.1-stable
  67. 3.0-stable
  68. To refer to the latest state of the master branch, you can use ``master``
  69. instead of a commit hash.
  70. :ref:`Get Godot's source code using Git <doc_getting_source>`. Once this
  71. is done, in the terminal window, use ``cd`` to reach the Godot repository
  72. folder and enter the following command:
  73. .. code-block:: shell
  74. # <good commit hash> is hash of the build that works as expected.
  75. # <bad commit hash> is hash of the build exhibiting the bug.
  76. $ git bisect start
  77. $ git bisect good <good commit hash>
  78. $ git bisect bad <bad commit hash>
  79. Compile Godot. This assumes you've set up a build environment:
  80. .. code-block:: shell
  81. # <platform> is the platform you're targeting for regression testing,
  82. # like "windows", "x11" or "osx".
  83. $ scons platform=<platform> -j4
  84. Since building Godot takes a while, you want to dedicate as many CPU threads as
  85. possible to the task. This is what the ``-j`` parameter does. Here, the command
  86. assigns 4 CPU threads to compiling Godot.
  87. Run the binary located in the ``bin/`` folder and try to reproduce the bug.
  88. If the build **still** exhibits the bug, run the following command:
  89. .. code-block:: shell
  90. $ git bisect bad
  91. If the build **does not** exhibit the bug, run the following command:
  92. .. code-block:: shell
  93. $ git bisect good
  94. After entering one of the commands above, Git will switch to a different commit.
  95. You should now build Godot again, try to reproduce the bug, then enter ``git
  96. bisect good`` or ``git bisect bad`` depending on the result. You'll have to
  97. repeat this several times. The longer the commit range, the more steps will be
  98. required. 5 to 10 steps are usually sufficient to find most regressions; Git
  99. will remind you of the number of steps remaining (in the worst case scenario).
  100. Once you've completed enough steps, Git will display the commit hash where the
  101. regression appeared. Write this commit hash as a comment to the GitHub issue
  102. you've bisected. This will help in solving the issue. Thanks again for
  103. contributing to Godot :)
  104. .. note::
  105. You can read the full documentation on ``git bisect``
  106. `here <https://git-scm.com/docs/git-bisect>`__.