bugbug 0.0.658__tar.gz → 0.0.660__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (191) hide show
  1. {bugbug-0.0.658 → bugbug-0.0.660}/PKG-INFO +2 -2
  2. bugbug-0.0.660/VERSION +1 -0
  3. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/db.py +41 -0
  4. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/models/testconfigdimensions.py +2 -4
  5. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/models/testconfigselect.py +57 -46
  6. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/repository.py +158 -1
  7. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/test_scheduling.py +83 -14
  8. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/tools/code_review/agent.py +12 -19
  9. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/tools/code_review/review_context.py +96 -15
  10. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/tools/code_review/review_context_schema.py +54 -4
  11. {bugbug-0.0.658 → bugbug-0.0.660}/pyproject.toml +1 -1
  12. {bugbug-0.0.658 → bugbug-0.0.660}/scripts/commit_classifier.py +6 -2
  13. {bugbug-0.0.658 → bugbug-0.0.660}/scripts/commit_retriever.py +8 -3
  14. {bugbug-0.0.658 → bugbug-0.0.660}/scripts/generate_landings_risk_report.py +6 -1
  15. {bugbug-0.0.658 → bugbug-0.0.660}/scripts/shadow_scheduler_stats.py +303 -13
  16. {bugbug-0.0.658 → bugbug-0.0.660}/scripts/testing_policy_stats.py +6 -1
  17. bugbug-0.0.658/VERSION +0 -1
  18. {bugbug-0.0.658 → bugbug-0.0.660}/.gitignore +0 -0
  19. {bugbug-0.0.658 → bugbug-0.0.660}/LICENSE +0 -0
  20. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/__init__.py +0 -0
  21. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/bug_features.py +0 -0
  22. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/bug_snapshot.py +0 -0
  23. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/bugzilla.py +0 -0
  24. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/build_platforms.py +0 -0
  25. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/code_search/__init__.py +0 -0
  26. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/code_search/function_search.py +0 -0
  27. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/code_search/mozilla.py +0 -0
  28. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/code_search/parser.py +0 -0
  29. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/code_search/searchfox_api.py +0 -0
  30. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/code_search/searchfox_data.py +0 -0
  31. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/code_search/searchfox_download.py +0 -0
  32. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/commit_features.py +0 -0
  33. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/feature_cleanup.py +0 -0
  34. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/github.py +0 -0
  35. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/issue_features.py +0 -0
  36. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/issue_snapshot.py +0 -0
  37. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/labels/annotateignore.csv +0 -0
  38. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/labels/bug_nobug.csv +0 -0
  39. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/labels/defect_enhancement_task.csv +0 -0
  40. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/labels/defect_enhancement_task_e.csv +0 -0
  41. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/labels/defect_enhancement_task_h.csv +0 -0
  42. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/labels/defect_enhancement_task_p.csv +0 -0
  43. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/labels/defect_enhancement_task_s.csv +0 -0
  44. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/labels/regression_bug_nobug.csv +0 -0
  45. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/labels/regressionrange.csv +0 -0
  46. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/labels/str.csv +0 -0
  47. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/labels/tracking.csv +0 -0
  48. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/labels.py +0 -0
  49. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/model.py +0 -0
  50. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/model_calibration.py +0 -0
  51. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/models/__init__.py +0 -0
  52. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/models/accessibility.py +0 -0
  53. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/models/annotate_ignore.py +0 -0
  54. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/models/assignee.py +0 -0
  55. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/models/backout.py +0 -0
  56. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/models/browsername.py +0 -0
  57. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/models/bugtype.py +0 -0
  58. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/models/component.py +0 -0
  59. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/models/component_specific.py +0 -0
  60. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/models/defect.py +0 -0
  61. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/models/defect_enhancement_task.py +0 -0
  62. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/models/devdocneeded.py +0 -0
  63. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/models/fenixcomponent.py +0 -0
  64. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/models/fixtime.py +0 -0
  65. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/models/invalid_compatibility_report.py +0 -0
  66. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/models/needsdiagnosis.py +0 -0
  67. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/models/perf_regression_predictor.py +0 -0
  68. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/models/performancebug.py +0 -0
  69. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/models/qaneeded.py +0 -0
  70. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/models/rcatype.py +0 -0
  71. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/models/regression.py +0 -0
  72. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/models/regressionrange.py +0 -0
  73. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/models/regressor.py +0 -0
  74. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/models/severity.py +0 -0
  75. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/models/spambug.py +0 -0
  76. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/models/stepstoreproduce.py +0 -0
  77. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/models/testfailure.py +0 -0
  78. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/models/testselect.py +0 -0
  79. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/models/tracking.py +0 -0
  80. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/models/uplift.py +0 -0
  81. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/models/worksforme.py +0 -0
  82. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/nlp.py +0 -0
  83. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/perf/__init__.py +0 -0
  84. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/perf/calibration.py +0 -0
  85. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/perf/commit_risk.py +0 -0
  86. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/perf/datasets.py +0 -0
  87. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/perf/extraction.py +0 -0
  88. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/perf/label_policy.py +0 -0
  89. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/perf/push_status.py +0 -0
  90. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/perf/regression_commits.py +0 -0
  91. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/perf/regression_labeling.py +0 -0
  92. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/perf/selection_pairs.py +0 -0
  93. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/perf/simulation/__init__.py +0 -0
  94. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/perf/simulation/capacity.py +0 -0
  95. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/perf/simulation/detection.py +0 -0
  96. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/perf/simulation/metrics.py +0 -0
  97. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/perf/simulation/optimize.py +0 -0
  98. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/perf/simulation/splits.py +0 -0
  99. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/perf/simulation/stats.py +0 -0
  100. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/perf/simulation/strategies.py +0 -0
  101. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/perf/simulation/timeline.py +0 -0
  102. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/perf/sql/__init__.py +0 -0
  103. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/perf/sql/perf_alerts.sql +0 -0
  104. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/perf/sql/perf_capacity_background.sql +0 -0
  105. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/perf/sql/perf_capacity_builds.sql +0 -0
  106. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/perf/sql/perf_capacity_eligible.sql +0 -0
  107. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/perf/sql/perf_capacity_labels.sql +0 -0
  108. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/perf/sql/perf_capacity_pools.sql +0 -0
  109. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/perf/sql/perf_capacity_workers.sql +0 -0
  110. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/perf/sql/perf_pushes.sql +0 -0
  111. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/perf/sql/perf_task_costs.sql +0 -0
  112. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/perf/sql/perf_task_filter.sql +0 -0
  113. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/perf/task_costs.py +0 -0
  114. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/perf/task_labels.py +0 -0
  115. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/phabricator.py +0 -0
  116. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/redash.py +0 -0
  117. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/rust_code_analysis_server.py +0 -0
  118. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/sklearn_utils.py +0 -0
  119. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/swarm.py +0 -0
  120. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/test_scheduling_features.py +0 -0
  121. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/tools/__init__.py +0 -0
  122. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/tools/base.py +0 -0
  123. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/tools/code_review/__init__.py +0 -0
  124. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/tools/code_review/data_types.py +0 -0
  125. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/tools/code_review/database.py +0 -0
  126. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/tools/code_review/langchain_tools.py +0 -0
  127. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/tools/code_review/prompts.py +0 -0
  128. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/tools/code_review/protocols.py +0 -0
  129. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/tools/code_review/scorer.py +0 -0
  130. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/tools/code_review/utils.py +0 -0
  131. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/tools/comment_matching/agent.py +0 -0
  132. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/tools/comment_matching/prompts.py +0 -0
  133. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/tools/comment_resolution/__init__.py +0 -0
  134. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/tools/comment_resolution/agent.py +0 -0
  135. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/tools/core/__init__.py +0 -0
  136. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/tools/core/connection.py +0 -0
  137. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/tools/core/data_types.py +0 -0
  138. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/tools/core/exceptions.py +0 -0
  139. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/tools/core/llms.py +0 -0
  140. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/tools/core/platforms/__init__.py +0 -0
  141. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/tools/core/platforms/base.py +0 -0
  142. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/tools/core/platforms/bugzilla.py +0 -0
  143. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/tools/core/platforms/patch_apply.py +0 -0
  144. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/tools/core/platforms/phabricator.py +0 -0
  145. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/tools/core/text.py +0 -0
  146. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/tools/core/validators.py +0 -0
  147. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/tools/patch_summarization/__init__.py +0 -0
  148. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/tools/patch_summarization/agent.py +0 -0
  149. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/tools/patch_summarization/prompts.py +0 -0
  150. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/tools/suggestion_filtering/__init__.py +0 -0
  151. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/tools/suggestion_filtering/agent.py +0 -0
  152. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/tools/suggestion_filtering/prompts.py +0 -0
  153. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/utils.py +0 -0
  154. {bugbug-0.0.658 → bugbug-0.0.660}/bugbug/vectordb.py +0 -0
  155. {bugbug-0.0.658 → bugbug-0.0.660}/scripts/__init__.py +0 -0
  156. {bugbug-0.0.658 → bugbug-0.0.660}/scripts/analyze_training_metrics.py +0 -0
  157. {bugbug-0.0.658 → bugbug-0.0.660}/scripts/backout_related_test_regressions.py +0 -0
  158. {bugbug-0.0.658 → bugbug-0.0.660}/scripts/bug_classifier.py +0 -0
  159. {bugbug-0.0.658 → bugbug-0.0.660}/scripts/bug_retriever.py +0 -0
  160. {bugbug-0.0.658 → bugbug-0.0.660}/scripts/check.py +0 -0
  161. {bugbug-0.0.658 → bugbug-0.0.660}/scripts/check_all_metrics.py +0 -0
  162. {bugbug-0.0.658 → bugbug-0.0.660}/scripts/ci_failures_matching.py +0 -0
  163. {bugbug-0.0.658 → bugbug-0.0.660}/scripts/comment_classifier.py +0 -0
  164. {bugbug-0.0.658 → bugbug-0.0.660}/scripts/comment_level_labeler.py +0 -0
  165. {bugbug-0.0.658 → bugbug-0.0.660}/scripts/comment_resolver_runner.py +0 -0
  166. {bugbug-0.0.658 → bugbug-0.0.660}/scripts/compatibility_report_classifier.py +0 -0
  167. {bugbug-0.0.658 → bugbug-0.0.660}/scripts/gcp_logs_retriever.py +0 -0
  168. {bugbug-0.0.658 → bugbug-0.0.660}/scripts/generate_sheet.py +0 -0
  169. {bugbug-0.0.658 → bugbug-0.0.660}/scripts/get_type_labels.py +0 -0
  170. {bugbug-0.0.658 → bugbug-0.0.660}/scripts/get_untriaged.py +0 -0
  171. {bugbug-0.0.658 → bugbug-0.0.660}/scripts/github_issue_classifier.py +0 -0
  172. {bugbug-0.0.658 → bugbug-0.0.660}/scripts/github_issue_retriever.py +0 -0
  173. {bugbug-0.0.658 → bugbug-0.0.660}/scripts/inline_comments_data_collection.py +0 -0
  174. {bugbug-0.0.658 → bugbug-0.0.660}/scripts/integration_test.sh +0 -0
  175. {bugbug-0.0.658 → bugbug-0.0.660}/scripts/maintenance_effectiveness_indicator.py +0 -0
  176. {bugbug-0.0.658 → bugbug-0.0.660}/scripts/microannotate_generator.py +0 -0
  177. {bugbug-0.0.658 → bugbug-0.0.660}/scripts/past_bugs_by_unit.py +0 -0
  178. {bugbug-0.0.658 → bugbug-0.0.660}/scripts/perf_alerts_retriever.py +0 -0
  179. {bugbug-0.0.658 → bugbug-0.0.660}/scripts/perf_commit_risk_scorer.py +0 -0
  180. {bugbug-0.0.658 → bugbug-0.0.660}/scripts/perf_regression_predictor.py +0 -0
  181. {bugbug-0.0.658 → bugbug-0.0.660}/scripts/perf_scheduling_simulator.py +0 -0
  182. {bugbug-0.0.658 → bugbug-0.0.660}/scripts/redundant_failures.py +0 -0
  183. {bugbug-0.0.658 → bugbug-0.0.660}/scripts/regressor_finder.py +0 -0
  184. {bugbug-0.0.658 → bugbug-0.0.660}/scripts/retrieve_ci_failures.py +0 -0
  185. {bugbug-0.0.658 → bugbug-0.0.660}/scripts/retrieve_training_metrics.py +0 -0
  186. {bugbug-0.0.658 → bugbug-0.0.660}/scripts/retrieve_try_pushes.py +0 -0
  187. {bugbug-0.0.658 → bugbug-0.0.660}/scripts/review_comments_retriever.py +0 -0
  188. {bugbug-0.0.658 → bugbug-0.0.660}/scripts/revision_retriever.py +0 -0
  189. {bugbug-0.0.658 → bugbug-0.0.660}/scripts/test_scheduling_history_retriever.py +0 -0
  190. {bugbug-0.0.658 → bugbug-0.0.660}/scripts/trainer.py +0 -0
  191. {bugbug-0.0.658 → bugbug-0.0.660}/scripts/trainer_extract_args.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: bugbug
3
- Version: 0.0.658
3
+ Version: 0.0.660
4
4
  Summary: ML tools for Mozilla projects
5
5
  Author-email: Marco Castelluccio <mcastelluccio@mozilla.com>
6
6
  License-Expression: MPL-2.0
@@ -30,7 +30,7 @@ Requires-Dist: markdown2~=2.5.5
30
30
  Requires-Dist: matplotlib<3.12.0,>=3.10.8
31
31
  Requires-Dist: mercurial~=7.2
32
32
  Requires-Dist: microannotate~=0.0.24
33
- Requires-Dist: mozci~=2.6.1
33
+ Requires-Dist: mozci~=2.6.2
34
34
  Requires-Dist: numpy<2.6.0,>=2.4.3
35
35
  Requires-Dist: orjson<3.14.0,>=3.11.7
36
36
  Requires-Dist: ortools~=9.15.6755
bugbug-0.0.660/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.660
@@ -22,6 +22,9 @@ DATABASES = {}
22
22
 
23
23
  logger = logging.getLogger(__name__)
24
24
 
25
+ # The size of the blocks read from the end of a DB by read_last.
26
+ READ_LAST_BLOCK_SIZE = 1024 * 1024
27
+
25
28
 
26
29
  class LastModifiedNotAvailable(Exception):
27
30
  pass
@@ -239,6 +242,44 @@ def read(path):
239
242
  yield from store.read()
240
243
 
241
244
 
245
+ def read_last_lines(path: str, count: int) -> list[bytes]:
246
+ """Read the last `count` serialized elements of an uncompressed JSON DB, from the oldest.
247
+
248
+ Only the end of the file is read, so it is fast also with very large DBs. The elements aren't
249
+ deserialized, so that callers can skip some of them cheaply.
250
+ """
251
+ assert path in DATABASES
252
+ assert str(path).endswith(".json"), "Only uncompressed JSON DBs are supported"
253
+
254
+ if not os.path.exists(path) or count <= 0:
255
+ return []
256
+
257
+ with open(path, "rb") as f:
258
+ pos = f.seek(0, os.SEEK_END)
259
+ blocks: list[bytes] = []
260
+ newlines = 0
261
+ # One more newline than elements is needed to be sure the oldest one is complete (unless
262
+ # the start of the file is reached).
263
+ while pos > 0 and newlines <= count:
264
+ read_size = min(READ_LAST_BLOCK_SIZE, pos)
265
+ pos -= read_size
266
+ f.seek(pos)
267
+ block = f.read(read_size)
268
+ blocks.append(block)
269
+ newlines += block.count(b"\n")
270
+
271
+ lines = b"".join(reversed(blocks)).splitlines()
272
+ if pos > 0:
273
+ # The first line can be partial.
274
+ lines = lines[1:]
275
+ return [line for line in lines[-count:] if line]
276
+
277
+
278
+ def read_last(path: str, count: int) -> list:
279
+ """Read the last `count` elements of an uncompressed JSON DB, from the oldest (see read_last_lines)."""
280
+ return [orjson.loads(line) for line in read_last_lines(path, count)]
281
+
282
+
242
283
  def size(path):
243
284
  assert path in DATABASES
244
285
 
@@ -336,10 +336,9 @@ class TestConfigSelectPooledModel(DimensionSelector, Model):
336
336
  Model.__init__(self, lemmatization)
337
337
  self.training_dbs = [test_scheduling.PUSH_DATA_CONFIG_GROUP_DB]
338
338
  self.history = DimensionHistory()
339
- self.known_configs: set[str] = set()
340
339
 
341
340
  def train(self, importance_cutoff=0.15, limit=None):
342
- regressions, self.known_configs, _ = load_regressions(with_patches=False)
341
+ regressions, _ = load_regressions(with_patches=False)
343
342
  split = split_push_index(regressions)
344
343
 
345
344
  self.history = DimensionHistory()
@@ -387,7 +386,6 @@ class _DimensionClassifierModel(DimensionSelector, Model):
387
386
  self.entire_dataset_training = True
388
387
 
389
388
  self.history = DimensionHistory()
390
- self.known_configs: set[str] = set()
391
389
  self._data: tuple | None = None
392
390
  self.row_weights: list[float] = []
393
391
  self.row_push_index: list[int] = []
@@ -419,7 +417,7 @@ class _DimensionClassifierModel(DimensionSelector, Model):
419
417
 
420
418
  def _load(self):
421
419
  if self._data is None:
422
- regressions, self.known_configs, patches = load_regressions()
420
+ regressions, patches = load_regressions()
423
421
  self._data = (regressions, patches, split_push_index(regressions))
424
422
  return self._data
425
423
 
@@ -24,13 +24,11 @@ groups of the push are cheaper, as their tasks run anyway.
24
24
  """
25
25
 
26
26
  import collections
27
- import fnmatch
28
27
  import functools
29
28
  import logging
30
29
  import math
31
30
  import os
32
31
  import random
33
- import re
34
32
  from typing import Any, Collection, Iterable, Iterator, Mapping, NamedTuple, Sequence
35
33
 
36
34
  import numpy as np
@@ -312,49 +310,66 @@ def generate_rows(
312
310
  history.add(regression)
313
311
 
314
312
 
315
- def _label_without_chunk(label: str) -> str:
316
- parts = label.split("-")
317
- return "-".join(parts[:-1] if parts[-1].isdigit() else parts)
313
+ class LiveTask(NamedTuple):
314
+ """A test task of the current task graph, by label without chunk number (see live_candidates)."""
318
315
 
316
+ # Its config, as mozci names it (see mozci.task.get_configuration).
317
+ config: str
318
+ # The manifests run by its chunks.
319
+ manifests: Sequence[str]
319
320
 
320
- def live_candidates(
321
- manifests_by_task: Mapping[str, Iterable[str]], known_configs: Iterable[str]
322
- ) -> dict[str, list[str]]:
323
- """The configs of the tasks in the current task graph that run each group.
324
321
 
325
- `manifests_by_task` maps the labels of the tasks scheduled on the push's project to the manifests
326
- they run (the decision task's manifests-by-task.json, restricted to its target tasks, as it comes
327
- from the full task graph, which also has tasks of other projects, e.g. shippable variants). The
328
- configs are patterns over task labels without their chunk number (e.g.
329
- test-macosx1500-aarch64/debug-*-swr), as the taskgraph matches them: each task is named after
330
- the most specific `known_configs` pattern it matches, or after its own label without the chunk
331
- number if none matches (e.g. for a new platform).
322
+ def live_tasks(tasks: Mapping[str, LiveTask]) -> dict[str, dict[str, list[str]]]:
323
+ """The tasks of the current task graph running each group, by config.
332
324
 
333
- As the candidates come from the current task graph, configs that don't exist anymore (e.g. after
334
- a platform migration) are never selected. Groups are named as by the models (see
325
+ `tasks` are the test tasks of the push's project among which configs are selected (see
326
+ bugbug_http.boot), by label without chunk number. Groups are named as by the models (see
335
327
  test_scheduling.normalize_group).
336
328
  """
337
- patterns = sorted(
338
- ((len(c), c, re.compile(fnmatch.translate(c))) for c in set(known_configs)),
339
- reverse=True,
329
+ result: dict[str, dict[str, set[str]]] = collections.defaultdict(
330
+ lambda: collections.defaultdict(set)
340
331
  )
332
+ for label, task in tasks.items():
333
+ for manifest in task.manifests:
334
+ result[test_scheduling.normalize_group(manifest)][task.config].add(label)
335
+
336
+ return {
337
+ group: {config: sorted(labels) for config, labels in configs.items()}
338
+ for group, configs in result.items()
339
+ }
340
+
341
+
342
+ def live_candidates(
343
+ tasks_by_group: Mapping[str, Mapping[str, Sequence[str]]],
344
+ ) -> dict[str, list[str]]:
345
+ """The configs of the tasks in the current task graph that run each group (see live_tasks).
341
346
 
342
- @functools.cache
343
- def config_of(label: str) -> str:
344
- for _, config, pattern in patterns:
345
- if pattern.match(label):
346
- return config
347
- return label
347
+ As the candidates come from the current task graph, configs that don't exist anymore (e.g. after
348
+ a platform migration) are never selected.
349
+ """
350
+ return {group: sorted(configs) for group, configs in tasks_by_group.items()}
348
351
 
349
- result: dict[str, set[str]] = collections.defaultdict(set)
350
- for label, manifests in manifests_by_task.items():
351
- if not label.startswith("test-"):
352
- continue
353
- config = config_of(_label_without_chunk(label))
354
- for manifest in manifests:
355
- result[test_scheduling.normalize_group(manifest)].add(config)
356
352
 
357
- return {group: sorted(configs) for group, configs in result.items()}
353
+ def task_labels(
354
+ tasks_by_group: Mapping[str, Mapping[str, Sequence[str]]],
355
+ group: str,
356
+ configs: Iterable[str],
357
+ new_tasks: Mapping[str, str] | None = None,
358
+ ) -> list[str]:
359
+ """The labels (without chunk number) of the tasks running a group on the given configs.
360
+
361
+ The taskgraph matches them with the labels of its tasks. `tasks_by_group` comes from live_tasks.
362
+ `new_tasks` are tasks whose manifests aren't known (e.g. renamed since the task graph the others
363
+ come from), by label, with their config: they are given for every group selected on their config,
364
+ as the taskgraph only runs a task for a group if the task runs it.
365
+ """
366
+ configs = set(configs)
367
+ tasks = tasks_by_group.get(group, {})
368
+ labels = {label for config in configs for label in tasks.get(config, ())}
369
+ labels |= {
370
+ label for label, config in (new_tasks or {}).items() if config in configs
371
+ }
372
+ return sorted(labels)
358
373
 
359
374
 
360
375
  class GroupCandidates(NamedTuple):
@@ -380,11 +395,9 @@ def _plainest_cheapest(configs: Iterable[str]) -> str:
380
395
 
381
396
  def load_regressions(
382
397
  with_patches: bool = True,
383
- ) -> tuple[
384
- list[test_scheduling.ConfigSelectRegression], set[str], dict[int, PatchInfo]
385
- ]:
386
- """The regressions of the push data, the configs seen recently, and the patch of each regression's push."""
387
- regressions, known_configs = test_scheduling.get_config_select_regressions(
398
+ ) -> tuple[list[test_scheduling.ConfigSelectRegression], dict[int, PatchInfo]]:
399
+ """The regressions of the push data, and the patch of each regression's push."""
400
+ regressions = test_scheduling.get_config_select_regressions(
388
401
  lambda: db.read(test_scheduling.PUSH_DATA_CONFIG_GROUP_DB)
389
402
  )
390
403
  logger.info(
@@ -394,7 +407,7 @@ def load_regressions(
394
407
  )
395
408
 
396
409
  if not with_patches:
397
- return regressions, known_configs, {}
410
+ return regressions, {}
398
411
 
399
412
  revs = {rev: r.push_index for r in regressions for rev in r.revs}
400
413
  files: dict[int, list[str]] = collections.defaultdict(list)
@@ -408,7 +421,7 @@ def load_regressions(
408
421
  for push_index, push_files in files.items()
409
422
  }
410
423
  logger.info("Patches found for %d pushes", len(patches))
411
- return regressions, known_configs, patches
424
+ return regressions, patches
412
425
 
413
426
 
414
427
  def split_push_index(
@@ -671,10 +684,8 @@ class TestConfigSelectModel(ConfigSelector, Model):
671
684
  self.calculate_importance = False
672
685
  self.entire_dataset_training = True
673
686
 
674
- # Inference state: the failure history up to the end of the training data, and the configs
675
- # seen recently (to name the tasks of the current task graph, see live_candidates).
687
+ # Inference state: the failure history up to the end of the training data.
676
688
  self.history = ConfigHistory()
677
- self.known_configs: set[str] = set()
678
689
 
679
690
  self._regressions: list[test_scheduling.ConfigSelectRegression] | None = None
680
691
  self._patches: dict[int, PatchInfo] = {}
@@ -735,7 +746,7 @@ class TestConfigSelectModel(ConfigSelector, Model):
735
746
 
736
747
  def _load_regressions(self) -> list[test_scheduling.ConfigSelectRegression]:
737
748
  if self._regressions is None:
738
- self._regressions, self.known_configs, self._patches = load_regressions()
749
+ self._regressions, self._patches = load_regressions()
739
750
  return self._regressions
740
751
 
741
752
  def _split_push_index(self) -> int:
@@ -17,6 +17,7 @@ import os
17
17
  import pickle
18
18
  import re
19
19
  import shelve
20
+ import shutil
20
21
  import subprocess
21
22
  import sys
22
23
  import threading
@@ -26,6 +27,7 @@ from typing import Collection, Iterable, Iterator, NamedTuple, NewType, Set, Uni
26
27
 
27
28
  import hglib
28
29
  import lmdb
30
+ import orjson
29
31
  import requests
30
32
  import rs_parsepatch
31
33
  import tenacity
@@ -321,6 +323,132 @@ def get_commits(
321
323
  )
322
324
 
323
325
 
326
+ # How many commits get_last_commit reads from the end of the commits DB before falling back to
327
+ # reading all of them.
328
+ LAST_COMMIT_RECENT_COMMITS = 256
329
+
330
+
331
+ def get_last_commit(
332
+ include_no_bug: bool = False,
333
+ include_backouts: bool = False,
334
+ include_ignored: bool = False,
335
+ ) -> CommitDict | None:
336
+ """Return the last commit that get_commits would return, or None if it would return none.
337
+
338
+ Only the end of the commits DB is read, unless none of the last commits passes the filters.
339
+ """
340
+ filters = {
341
+ "include_no_bug": include_no_bug,
342
+ "include_backouts": include_backouts,
343
+ "include_ignored": include_ignored,
344
+ }
345
+
346
+ recent_commits = db.read_last(COMMITS_DB, LAST_COMMIT_RECENT_COMMITS)
347
+ last_commit = collections.deque(filter_commits(recent_commits, **filters), maxlen=1)
348
+ # If fewer commits than requested were read, the whole DB was read.
349
+ if not last_commit and len(recent_commits) == LAST_COMMIT_RECENT_COMMITS:
350
+ logger.info("None of the last commits passes the filters, reading all commits")
351
+ last_commit = collections.deque(get_commits(**filters), maxlen=1)
352
+
353
+ return last_commit[0] if last_commit else None
354
+
355
+
356
+ # The offset of each commit in the commits DB, by node, to find them without reading the whole DB.
357
+ COMMITS_INDEX_DB = "data/commits_index.lmdb"
358
+ # The size of the part of the commits DB which is indexed.
359
+ COMMITS_INDEX_SIZE_KEY = b"$indexed_size$"
360
+ # The serialized commits start with their node (see Commit.to_dict).
361
+ COMMIT_LINE_PREFIX = b'{"node":"'
362
+ COMMITS_INDEX_BLOCK_SIZE = 16 * 1024 * 1024
363
+
364
+
365
+ def _update_commits_index(index: LMDBDict) -> None:
366
+ # The offset in the DB of the start of `pending`, the part of the DB read but not indexed yet.
367
+ pos = int(bytes(index.get(COMMITS_INDEX_SIZE_KEY, b"0")))
368
+ pending = b""
369
+
370
+ with open(COMMITS_DB, "rb") as f:
371
+ f.seek(pos)
372
+ # The DB is read in blocks, as mapping it in memory would make it count as used memory.
373
+ while block := f.read(COMMITS_INDEX_BLOCK_SIZE):
374
+ pending += block
375
+ start = 0
376
+ # Only the complete lines are indexed, in case the DB is being written to.
377
+ while (end := pending.find(b"\n", start)) != -1:
378
+ node_start = start + len(COMMIT_LINE_PREFIX)
379
+ if pending.startswith(COMMIT_LINE_PREFIX, start):
380
+ node = pending[node_start : node_start + 40]
381
+ else:
382
+ node = orjson.loads(pending[start:end])["node"].encode("ascii")
383
+ index[node] = str(pos + start).encode("ascii")
384
+ start = end + 1
385
+ pending = pending[start:]
386
+ pos += start
387
+
388
+ index[COMMITS_INDEX_SIZE_KEY] = str(pos).encode("ascii")
389
+
390
+
391
+ def delete_commits_index() -> None:
392
+ """Delete the index of the commits DB, which is wrong once the DB is rewritten."""
393
+ shutil.rmtree(COMMITS_INDEX_DB, ignore_errors=True)
394
+
395
+
396
+ def update_commits_index() -> None:
397
+ """Index the commits added to the commits DB since the last update."""
398
+ index = LMDBDict(COMMITS_INDEX_DB)
399
+ try:
400
+ _update_commits_index(index)
401
+ finally:
402
+ index.close()
403
+
404
+
405
+ def _get_commits_offsets(nodes: Iterable[str]) -> dict[str, int]:
406
+ """Return the offsets in the commits DB of the commits among `nodes` which are in it.
407
+
408
+ The index of the DB is updated first with the commits added to the DB since the last update.
409
+ """
410
+ if not os.path.exists(COMMITS_DB):
411
+ return {}
412
+
413
+ index = LMDBDict(COMMITS_INDEX_DB)
414
+ try:
415
+ _update_commits_index(index)
416
+ return {
417
+ node: int(bytes(offset))
418
+ for node in nodes
419
+ if (offset := index.get(node.encode("ascii"))) is not None
420
+ }
421
+ finally:
422
+ index.close()
423
+
424
+
425
+ def get_nodes_in_db(nodes: Iterable[str]) -> set[str]:
426
+ """Return the commits among `nodes` which are in the commits DB."""
427
+ return set(_get_commits_offsets(nodes))
428
+
429
+
430
+ def get_commits_from_db(nodes: Iterable[str]) -> dict[str, CommitDict]:
431
+ """Return the commits among `nodes` which are already in the commits DB, by node.
432
+
433
+ These commits can't be mined again (with save=False), as their experience features would be
434
+ calculated after the ones of the commits pushed after them, which are in the experiences DB.
435
+ The commits are found through an index of the DB.
436
+ """
437
+ offsets = _get_commits_offsets(nodes)
438
+ if not offsets:
439
+ return {}
440
+
441
+ commits: dict[str, CommitDict] = {}
442
+ with open(COMMITS_DB, "rb") as f:
443
+ for node, offset in offsets.items():
444
+ f.seek(offset)
445
+ commit = orjson.loads(f.readline())
446
+ assert commit["node"] == node, f"The commits index is wrong for {node}"
447
+ commits[node] = commit
448
+
449
+ return commits
450
+
451
+
324
452
  def get_revision_id(commit: CommitDict) -> int | None:
325
453
  match = PHABRICATOR_REVISION_REGEX.search(commit["desc"])
326
454
  if not match:
@@ -1045,6 +1173,22 @@ def get_revs(hg, rev_start=0, rev_end="default"):
1045
1173
  return x.splitlines()
1046
1174
 
1047
1175
 
1176
+ def get_new_revs(hg: hglib.client, base: str, head: str) -> list[bytes]:
1177
+ """Get the non-merge commits on the default branch which are ancestors of `head`, but not of `base`.
1178
+
1179
+ Unlike the commits after `base` by revision number, these don't include the commits from other
1180
+ repositories pulled in the same clone (e.g. try).
1181
+ """
1182
+ args = hglib.util.cmdbuilder(
1183
+ b"log",
1184
+ template="{node}\n",
1185
+ no_merges=True,
1186
+ branch="default",
1187
+ rev=f"::{head} - ::{base}",
1188
+ )
1189
+ return hg.rawcommand(args).splitlines()
1190
+
1191
+
1048
1192
  class Experiences:
1049
1193
  def __init__(self, save):
1050
1194
  self.save = save
@@ -1501,7 +1645,11 @@ def download_commits(
1501
1645
  # Fixing https://github.com/mozilla/bugbug/issues/3131
1502
1646
  mp_context=mp.get_context("fork"),
1503
1647
  ) as executor:
1504
- commits_iter = executor.map(_transform, commits, chunksize=64)
1648
+ # Large chunks reduce the overhead when mining many commits, but with few of them
1649
+ # (e.g. when updating the DB) they would leave most processes idle: give several
1650
+ # chunks to each process.
1651
+ chunksize = max(1, min(64, commits_num // ((cpu_count or 1) * 4)))
1652
+ commits_iter = executor.map(_transform, commits, chunksize=chunksize)
1505
1653
  commits_iter = tqdm(commits_iter, total=commits_num)
1506
1654
  commits = tuple(commits_iter)
1507
1655
  else:
@@ -1653,6 +1801,7 @@ def update_commits(repo_dir: str | None = None) -> None:
1653
1801
  refresh_backouts_and_ignored(repo_dir, commits)
1654
1802
 
1655
1803
  db.write(COMMITS_DB, commits)
1804
+ delete_commits_index()
1656
1805
 
1657
1806
 
1658
1807
  def clean(hg, repo_dir):
@@ -1702,6 +1851,10 @@ def clone(
1702
1851
  if "abort: repository" not in str(e) and "not found" not in str(e):
1703
1852
  raise
1704
1853
 
1854
+ # robustcheckout pulls twice: into the pooled store, and then into the share. mozext records
1855
+ # the pushes in the `changetracker.db` of each repository (not in the shared store), so it would
1856
+ # download the whole pushlog for both pulls, and the copy of the pooled store is never used. Its
1857
+ # database is disabled for the clone, and the pushes are retrieved once by pulling in the share.
1705
1858
  cmd = _build_hg_cmd(
1706
1859
  "robustcheckout",
1707
1860
  url,
@@ -1711,9 +1864,13 @@ def clone(
1711
1864
  networkattempts=7,
1712
1865
  branch=b"default",
1713
1866
  noupdate=not update,
1867
+ config=b"mozext.disable_local_database=true",
1714
1868
  )
1715
1869
  subprocess.run(cmd, check=True)
1716
1870
 
1871
+ with hglib.open(repo_dir) as hg:
1872
+ hg.pull(update=update)
1873
+
1717
1874
  logger.info("%s cloned", repo_dir)
1718
1875
 
1719
1876
 
@@ -8,6 +8,7 @@ import collections
8
8
  import dataclasses
9
9
  import glob
10
10
  import itertools
11
+ import json
11
12
  import logging
12
13
  import math
13
14
  import os
@@ -78,6 +79,12 @@ db.register(
78
79
  TEST_GROUP_SCHEDULING_DB = "data/test_group_scheduling_history.pickle"
79
80
  PAST_FAILURES_GROUP_DB = "past_failures_group.lmdb.tar.zst"
80
81
  TOUCHED_TOGETHER_DB = "touched_together.lmdb.tar.zst"
82
+ # The number of commits at the end of the commits DB among which the last commit analyzed for the
83
+ # touched together DB is looked for, and how many of them before it are read too (see
84
+ # _get_commits_from). The window allows the DB to be updated quickly with up to about two weeks of
85
+ # commits.
86
+ TOUCHED_TOGETHER_RECENT_COMMITS = 10000
87
+ TOUCHED_TOGETHER_RECENT_MARGIN = 2000
81
88
  db.register(
82
89
  TEST_GROUP_SCHEDULING_DB,
83
90
  "https://community-tc.services.mozilla.com/api/index/v1/task/project.bugbug.data_test_group_scheduling_history.latest/artifacts/public/test_group_scheduling_history.pickle.zst",
@@ -187,6 +194,37 @@ def normalize_group(group: str) -> str:
187
194
  return group.split(":")[0]
188
195
 
189
196
 
197
+ def get_full_graph_tasks(content: bytes, labels: set[str]) -> dict[str, dict]:
198
+ """The definitions of some tasks from a decision task's full-task-graph.json, by label.
199
+
200
+ The full task graph is hundreds of MB, and much more once parsed, so only the definitions of
201
+ the given tasks are parsed, where they are in the text. If one isn't found this way (e.g. if
202
+ the format of the file changed), the whole graph is parsed.
203
+ """
204
+ text = content.decode()
205
+ decoder = json.JSONDecoder()
206
+ tasks: dict[str, dict] = {}
207
+ for label in labels:
208
+ key = f"{json.dumps(label)}:{{"
209
+ start = text.find(key)
210
+ while start != -1:
211
+ try:
212
+ task, _ = decoder.raw_decode(text, start + len(key) - 1)
213
+ except ValueError:
214
+ task = None
215
+ if isinstance(task, dict) and task.get("label") == label:
216
+ tasks[label] = task
217
+ break
218
+ start = text.find(key, start + 1)
219
+
220
+ missing = labels - tasks.keys()
221
+ if missing:
222
+ del text
223
+ graph = orjson.loads(content)
224
+ tasks.update({label: graph[label] for label in missing if label in graph})
225
+ return tasks
226
+
227
+
190
228
  def rename_task(task: str) -> str:
191
229
  # https://bugzilla.mozilla.org/show_bug.cgi?id=1602863
192
230
  task = task.replace("test-linux64", "test-linux1804-64")
@@ -402,8 +440,7 @@ def _configs_by_group(config_groups: Iterable[Runnable]) -> dict[Group, set[str]
402
440
 
403
441
  def get_config_select_regressions(
404
442
  push_data_factory: Callable[[], Iterable[PushResult]],
405
- recent_pushes: int = 1000,
406
- ) -> tuple[list[ConfigSelectRegression], set[str]]:
443
+ ) -> list[ConfigSelectRegression]:
407
444
  """The regressions of config/group push data, with the configs they failed on and passed on.
408
445
 
409
446
  A config the regressed group ran on without failing passed, both on the culprit push and on the
@@ -412,9 +449,6 @@ def get_config_select_regressions(
412
449
  run after the culprit failed and the failure was attributed to a later push (e.g. because the config
413
450
  didn't run on the culprit): with no run in between, the attribution can't tell the pushes apart, so
414
451
  the config didn't verifiably pass. A failure after a pass doesn't matter (as in get_non_run_negatives).
415
-
416
- Also returns the configs that ran in the last `recent_pushes` pushes, used to name the configs of
417
- the tasks in the current task graph (see testconfigselect.live_candidates).
418
452
  """
419
453
  rev_index: dict[Revision, int] = {}
420
454
  culprits: list[
@@ -427,7 +461,6 @@ def get_config_select_regressions(
427
461
  ]
428
462
  ] = []
429
463
  failures_at: dict[int, dict[Group, set[str]]] = {}
430
- num_pushes = 0
431
464
  for index, push in enumerate(push_data_factory()):
432
465
  (
433
466
  revisions,
@@ -436,7 +469,6 @@ def get_config_select_regressions(
436
469
  possible_regressions,
437
470
  likely_regressions,
438
471
  ) = push
439
- num_pushes += 1
440
472
  for revision in revisions:
441
473
  rev_index[revision] = index
442
474
  if possible_regressions or likely_regressions:
@@ -470,16 +502,13 @@ def get_config_select_regressions(
470
502
 
471
503
  # The first push of the window each config ran the group on.
472
504
  later_runs: dict[tuple[int, Group], dict[str, int]] = collections.defaultdict(dict)
473
- recent: set[str] = set()
474
505
  for index, push in enumerate(push_data_factory()):
475
506
  groups_needed = needed.get(index)
476
- if groups_needed is None and index < num_pushes - recent_pushes:
507
+ if groups_needed is None:
477
508
  continue
478
509
 
479
510
  for group, configs in _configs_by_group(push[2]).items():
480
- if index >= num_pushes - recent_pushes:
481
- recent |= configs
482
- for culprit in groups_needed.get(group, ()) if groups_needed else ():
511
+ for culprit in groups_needed.get(group, ()):
483
512
  for config in configs:
484
513
  later_runs[(culprit, group)].setdefault(config, index)
485
514
 
@@ -505,7 +534,7 @@ def get_config_select_regressions(
505
534
  )
506
535
  )
507
536
 
508
- return regressions, recent
537
+ return regressions
509
538
 
510
539
 
511
540
  def get_push_data(
@@ -1056,6 +1085,45 @@ def get_cochange_pmi(source_dirs: Iterable[str], runnable_dirs: Iterable[str]) -
1056
1085
  return best
1057
1086
 
1058
1087
 
1088
+ def _get_commits_from(
1089
+ last_analyzed: bytes | memoryview | None,
1090
+ ) -> Iterable[repository.CommitDict]:
1091
+ """The commits of the commits DB from where the touched together DB needs to be updated.
1092
+
1093
+ They are filtered like repository.get_commits does. When the last analyzed commit is among the last TOUCHED_TOGETHER_RECENT_COMMITS commits, the
1094
+ commits start TOUCHED_TOGETHER_RECENT_MARGIN commits before it, so that the revisions sent to
1095
+ update_touched_together which are slightly before it (as commits can be in a different order
1096
+ in mozilla-central and autoland) are found. Otherwise, all the commits are read, which is much
1097
+ slower as the commits DB is very large.
1098
+ """
1099
+ if last_analyzed is not None:
1100
+ last_analyzed = bytes(last_analyzed)
1101
+ lines = db.read_last_lines(
1102
+ repository.COMMITS_DB, TOUCHED_TOGETHER_RECENT_COMMITS
1103
+ )
1104
+ # Only the commit with the node is deserialized (if the serialization changed, the commit
1105
+ # wouldn't be found, and all the commits would be read).
1106
+ needle = b'"node":"' + last_analyzed + b'"'
1107
+ position = next(
1108
+ (
1109
+ i
1110
+ for i, line in enumerate(lines)
1111
+ if needle in line
1112
+ and orjson.loads(line)["node"] == last_analyzed.decode()
1113
+ ),
1114
+ None,
1115
+ )
1116
+ if position is not None and position >= TOUCHED_TOGETHER_RECENT_MARGIN:
1117
+ del lines[: position - TOUCHED_TOGETHER_RECENT_MARGIN]
1118
+ return repository.filter_commits(orjson.loads(line) for line in lines)
1119
+
1120
+ logger.info(
1121
+ "The last analyzed commit is not among the last commits, reading all commits"
1122
+ )
1123
+
1124
+ return repository.get_commits()
1125
+
1126
+
1059
1127
  def update_touched_together(
1060
1128
  runnable_dirs: Collection[str] = (),
1061
1129
  ) -> Generator[None, Revision | None, None]:
@@ -1075,7 +1143,8 @@ def update_touched_together(
1075
1143
 
1076
1144
  end_revision = yield
1077
1145
 
1078
- for commit in repository.get_commits():
1146
+ commits = _get_commits_from(last_analyzed)
1147
+ for commit in commits:
1079
1148
  seen.add(commit["node"])
1080
1149
 
1081
1150
  if can_start: