zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.55k stars 6.46k forks source link

Track PR merge times #56304

Open keith-zephyr opened 1 year ago

keith-zephyr commented 1 year ago

Proposal With the recent publication of Zephyr's Contributor and Reviewer Expectations, it would be valuable to measure and track PR merge times. This data could inform whether policy changes are helping or hindering the velocity of the project.

LFX insights provides some of this data, but I don't know the methodology used, and the numbers don't look correct. The times seem far too low and the most recent data might be incomplete.

Time To Merge-small

Time in Review-small

GitHub's Insights view only shows the total number of commits per week, without any data for merge and review times.

Tracking the median time for PRs to get the first review and to merge would be a good place to start. This tracking could later be enhanced to distinguish between bug fixes and new features. The expectation is that bug fixes will merge fairly quickly, while new features go through additional review.

nordicjm commented 1 year ago

I imagine you'd probably need to have a bot scrape through the PRs to get this information. @kartben

kartben commented 1 year ago

It looks indeed like the LFX data might not be accurate. I have it on my agenda for next week to discuss with the LFX team how to fix the discrepancies we're seeing there.

In the mean time, I've pulled the entire PR history and played with the data a bit:

image

Note that this probably needs to be looked at together with number of outstanding PRs

image
kartben commented 1 year ago

Just realized I looked at all closed PRs, not those that were closed by merging.

kartben commented 1 year ago

Closed+Merged PRs only:

image

This doesn't look too far off from the LFX data now. My guess is they might be showing things in a counter-intuitive way i.e. is the "The average time in days required for pull request/changeset to be merged over the last 90 days" only looking at PRs created in that period, or does it also include PRs closed during the period but that might be much older?

nordicjm commented 1 year ago

The list of PRs used for this would need to be set somehow, because things like hotfixes should be excluded as they will completely skew the results

nordicjm commented 1 year ago

And maybe remove doc only changes too, since those also aren't relevant and have very short merge times, especially around release times

kartben commented 1 year ago

The list of PRs used for this would need to be set somehow, because things like hotfixes should be excluded as they will completely skew the results

Could you clarify what you mean by hotfixes? And what would be the criteria to flag them?

And maybe remove doc only changes too, since those also aren't relevant and have very short merge times, especially around release times

Mmmh ya, maybe, but in the other hand I would argue that looking at median/high-percentile/low-percentile might be enough to automagically not put too much emphasis on some of the outliers, while still allowing us to identify long-term trends. At the end of the day, it's not really the actual "number of days to close that matters", IMO, but rather to know if it's getting better or worse. So while those fixes with short merge times might skew the absolute numbers (which again, I don't think matter all that much -- do we know what would be a "good" average time to merge? a median one?), they probably don't matter as much when looking at the big picture?

nordicjm commented 1 year ago

Could you clarify what you mean by hotfixes? And what would be the criteria to flag them?

Anything with the hotfix label: https://github.com/zephyrproject-rtos/zephyr/pulls?q=is%3Apr+label%3AHotfix+is%3Aclosed

Mmmh ya, maybe, but in the other hand I would argue that looking at median/high-percentile/low-percentile might be enough to automagically not put too much emphasis on some of the outliers, while still allowing us to identify long-term trends.

From my view, it's more important to see merge times for features or additions, nor minor changes. Anyone can review documentation, not everyone can review code or code for specific area/driver/system. Maybe even grouping things e.g. average time for a board to get merged, a driver, etc.

keith-zephyr commented 1 year ago

Could you clarify what you mean by hotfixes? And what would be the criteria to flag them?

Anything with the hotfix label: https://github.com/zephyrproject-rtos/zephyr/pulls?q=is%3Apr+label%3AHotfix+is%3Aclosed

It could be useful to break out PRs with the "Trivial" label as well: https://github.com/zephyrproject-rtos/zephyr/pulls?q=is%3Apr+is%3Amerged+label%3Atrivial+

Mmmh ya, maybe, but in the other hand I would argue that looking at median/high-percentile/low-percentile might be enough to automagically not put too much emphasis on some of the outliers, while still allowing us to identify long-term trends.

From my view, it's more important to see merge times for features or additions, nor minor changes. Anyone can review documentation, not everyone can review code or code for specific area/driver/system. Maybe even grouping things e.g. average time for a board to get merged, a driver, etc.

+1: tracking PR velocity for new features is the main reason I opened this issue.

keith-zephyr commented 1 year ago

@kartben - Your chart in https://github.com/zephyrproject-rtos/zephyr/issues/56304#issuecomment-1490240503 looks like a great start on this effort. I'm curious how much the "days to close" increases once trivial and hotfixes are excluded.

This issue has been added to the next Process Working Group agenda. @kartben and @nordicjm, do you think you'll be able to attend that meeting?

nordicjm commented 1 year ago

This issue has been added to the next Process Working Group agenda. @kartben and @nordicjm, do you think you'll be able to attend that meeting?

That's this Wednesday at 9:00 (UTC-7)?

keith-zephyr commented 1 year ago

This issue has been added to the next Process Working Group agenda. @kartben and @nordicjm, do you think you'll be able to attend that meeting?

That's this Wednesday at 9:00 (UTC-7)?

The meeting is at 10:00 (UTC-7). Here's a link to the invite (requires a login): https://lists.zephyrproject.org/g/tsc/viewevent?repeatid=17893&eventid=1726025&calstart=2023-04-05

kartben commented 1 year ago

@kartben - Your chart in #56304 (comment) looks like a great start on this effort. I'm curious how much the "days to close" increases once trivial and hotfixes are excluded.

This issue has been added to the next Process Working Group agenda. @kartben and @nordicjm, do you think you'll be able to attend that meeting?

yes I plan on attending.

keith-zephyr commented 1 year ago

@kartben I just saw your post on the tsc channel. Did you use https://github.com/kartben/zephyr-repo-metrics to generate this data?

kartben commented 1 year ago

Hey @keith-zephyr -- I actually put the scripts for the PR "dump" here: https://github.com/kartben/gh-pr-stats As it's probably never gonna be Zephyr or "open source RTOS" specific, I thought it could live in a different repo. I've committed the CSV file if you want to play with it directly.

Edit: there's also Excel and PowerBI files that can be used as a starting point

mbolivar-nordic commented 1 year ago

Process WG:


kartben commented 1 year ago

I updated and ran some of my scripts to extract more info re: first-time contributors, and thought I would share an update -- both in terms of charts and words (since I feel like my dataviz fu could be improved :))

What you're looking at is (still) the age of a merged PR at the time it is being merged. The repetition of the word "merge" is intentional, as it's important to keep in mind that these charts don't give any insight into "rotting" PRs -i.e. still opened- or PRs that were closed without being merged, and there would probably be some work to be done to extract insights related to these categories of PRs.

Ways to read the data:

All PRs:

image

PRs for first-time contributors:

image

/cc @carlescufi

kartben commented 1 year ago

I thought folks would be interested in seeing the recent trend in PR merge time -- looking at 12 full months,fro Aug' 22 to Jul' 23

All PRs:

image

PRs for first-time contribtuors:

image

In words:

Let me know if you have comments/questions - I am looking forward to seeing the evolution of the trends after the summer break is over.

yperess commented 1 year ago

Hey @keith-zephyr -- I actually put the scripts for the PR "dump" here: https://github.com/kartben/gh-pr-stats As it's probably never gonna be Zephyr or "open source RTOS" specific, I thought it could live in a different repo. I've committed the CSV file if you want to play with it directly.

Edit: there's also Excel and PowerBI files that can be used as a starting point

How hard would it be to add 3 more columns to this data? I would love to see:

This would also allow us to start looking at other factors for PR lifespans such as churn. I know I dread getting a comment like "you missed a period in the documentation" after I already got 1+ approvals and throwing the approval away for a typo.

kartben commented 1 year ago

Hey @keith-zephyr -- I actually put the scripts for the PR "dump" here: https://github.com/kartben/gh-pr-stats As it's probably never gonna be Zephyr or "open source RTOS" specific, I thought it could live in a different repo. I've committed the CSV file if you want to play with it directly.

Edit: there's also Excel and PowerBI files that can be used as a starting point

How hard would it be to add 3 more columns to this data? I would love to see:

  • Number of force pushes
  • Number of comments
  • Absolute value of the line diff (lines removed + added)

This would also allow us to start looking at other factors for PR lifespans such as churn. I know I dread getting a comment like "you missed a period in the documentation" after I already got 1+ approvals and throwing the approval away for a typo.

The last 2 are pretty easy but not sure there is even a way to get #1, but I'll look into it.

Edit: number of force pushes is probably available through https://docs.github.com/en/rest/issues/timeline?apiVersion=2022-11-28

FWIW if we do think about trying to make something useful out of the number of force pushes we need to find a way to exclude the ones made while a PR might have been in draft state.

keith-zephyr commented 8 months ago

@kartben - can you provide some updated charts on this issue? It would be helpful to revisit this data, determine if there are any conclusions we can determine from the data and if there are action items to fix problems.

keith-zephyr commented 3 months ago

@keith-zephyr - suggests running this once a quarter @kartben - it would good to integrate this with the PR stats work Anas has done @nashif - slow PR merge times may not be an issue overall @kartben - knowing what the PR times for worst 10%, and first time contributors is still useful to track. @dleach02 - What's the velocity of the project? Internally has created a doc to help his team be more effective at getting PRs submitted. @nashif - last month merged 1000+ PRs, with good distribution @nashif 20-30% of PRs in the queue are stale @keith-zephyr ask is to track this data to monitor health of the project @nashif - Need to be mindful not to go to deep with the analysis. @dleach02 - The dashboards created by @nashif and @fabiobaltieri are really helpful. @keith-zephyr growth of the project improves the signal we can get by monitoring these merge times. @nashif - agrees - but we should also make sure the project continues to scale (slow CI, etc)