jenkinsci / jenkinsci/workflow-multibranch-plugin
WorkflowBranchProjectFactory: avoid unconditional saves during branch scanning
- Dominant language
- Java
- Stars
- 87
- Forks
- 131
- PR merge metrics
- No merged PRs in 30d
Description
### What feature do you want to see added?
Currently, `setBranch()` unconditionally calls `property.setBranch(branch); project.save();` whenever a `BranchJobProperty` already exists on the job - even when nothing has changed. For a multibranch project with many long-lived branches/tags, this means every branch-indexing scan performs a full synchronous, disk write (fsync:ed) for all branches and tags, regardless of whether anything actually changed. This time is noticeable especially on a networked drive.
Separately, branch-api-plugin's `MultiBranchProject.observeExisting()` already computes a `needSave` comparison (branch equality plus a digest comparison of the SCM config) and uses it to guard a later `project.save()` call in the same method — but `_factory.setBranch(...)` is invoked earlier, before that comparison is available to the factory, so the existing change-detection logic never reaches this call site. I am not sure if this could be reused in some way.
Looking into the code there used to be a check but it was removed with commit `18077ec [JENKINS-30206] Fixed branch property propagation.`
### Upstream changes
_No response_
### Are you interested in contributing this feature?
I don't think that I am familiar enough with the code base to do this change in a good way.
Contributor guide
Research direction
Start by locating WorkflowBranchProjectFactory.setBranch() and branch-api-plugin's MultiBranchProject.observeExisting(), then review commit 18077ec (JENKINS-30206) to understand the removed check. Trace how BranchJobProperty propagation and needSave interact; done means unchanged branch scans avoid synchronous project.save() calls while changed properties are still persisted.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- ci-cd
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100