Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collapse clean and non clean build requests on clean builders #266

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

DavidSpickett
Copy link
Contributor

This is to address #250. Where build requests were piling up on slower builders because they were clean/don't clean/clean/ don't clean etc. and we could not merge those requests because of that difference.

Galina suggested that if we knew that the builder was going to clean the build first anyway, we could merge them. This commit implements that.

We do this by first setting a "clean" attribute on the builder's factory object, that we can find later via in the collapse callback.

So far only ClangBuilder passes this on but any builder can opt in by copying what it does.

In the collapse function when comparing properties we delete the "clean_obj" key from both sets of properties if we know that the builder's factory is always clean.

With some logging (not included in this commit) we can see it now collapses a clean/non-clean pair of requests:

collapseRequests
selfBuildSetProperties: {'scheduler': ('main:clang,clang-tools-extra,compiler-rt,flang,lld,llvm,mlir', 'Scheduler')}
otherBuildSetProperties: {'scheduler': ('main:clang,clang-tools-extra,compiler-rt,flang,lld,llvm,mlir', 'Scheduler'), 'clean_obj': (True, 'Change')}
Removing clean_obj from build set properties.
Build set properties were the same.

This has beeen tested by my colleague Omair Javaid on a test build master. Of course we only tested it with one of Linaro's builders, so it's possible we see other side effects in production.

This is to address llvm#250.
Where build requests were piling up on slower builders because
they were clean/don't clean/clean/ don't clean etc. and we could
not merge those requests because of that difference.

Galina suggested that if we knew that the builder was going to
clean the build first anyway, we could merge them. This commit
implements that.

We do this by first setting a "clean" attribute on the builder's
factory object, that we can find later via in the collapse callback.

So far only ClangBuilder passes this on but any builder can opt
in by copying what it does.

In the collapse function when comparing properties we delete the
"clean_obj" key from both sets of properties if we know that the
builder's factory is always clean.

With some logging (not included in this commit) we can see it now
collapses a clean/non-clean pair of requests:
```
collapseRequests
selfBuildSetProperties: {'scheduler': ('main:clang,clang-tools-extra,compiler-rt,flang,lld,llvm,mlir', 'Scheduler')}
otherBuildSetProperties: {'scheduler': ('main:clang,clang-tools-extra,compiler-rt,flang,lld,llvm,mlir', 'Scheduler'), 'clean_obj': (True, 'Change')}
Removing clean_obj from build set properties.
Build set properties were the same.
```

This has beeen tested by my colleague Omair Javaid on a test build
master. Of course we only tested it with one of Linaro's builders,
so it's possible we see other side effects in production.
@joker-eph
Copy link
Contributor

Why would we prevent from collapsing clean/non-clean builds?

@DavidSpickett
Copy link
Contributor Author

We already merge:

unclean
unclean

And

clean
clean

As the properties matched.

Now we want to merge:

clean
unclean

Assuming unclean merges into clean, and the result is also clean, we could do this for any builder even if it does not clean by default. In current production we wouldn't because the properties don't match.

unclean
clean

This we can only merge if the builder itself would clean anyway, or if we are able to edit the request after merging to add clean_obj Currently it's just a boolean collapse or not.

I will see if I can edit the collapsed request, then this can apply globally not just to builders marked clean.

@DavidSpickett
Copy link
Contributor Author

DavidSpickett commented Sep 25, 2024

I'm going to see if it's feasible to modify the request that we collapse into, to address Mehdi's question.

And to be clear, Galina has the deciding approval here.

@DavidSpickett
Copy link
Contributor Author

I'm going to see if it's feasible to modify the request that we collapse into, to address Mehdi's question.

This is the buildbot function that calls the callback I'm modifying in this PR: https://github.com/buildbot/buildbot/blob/master/master/buildbot/process/buildrequest.py#L66

If we want to collapse unclean -< clean, we'd need to change this callback to return a new request with the clean_obj added. Or make the default some sort of superset of all options of both requests.

But I'd rather not get into changing Buildbot itself (or trying to monkeypatch it)

Why would we prevent from collapsing clean/non-clean builds?

@joker-eph tell me if I've answered this or not. Might have gone on a sidetrack there.

@DavidSpickett
Copy link
Contributor Author

DavidSpickett commented Sep 26, 2024

One sentence answer based on current buildbot behaviour:
"The result of a request collapse retains the properties of the request being collapsed into, if that request is unclean we would lose the clean property of the clean request that was collapsed."

That is unless we knew that the builder would clean anyway, which is what this PR checks for.

Copy link
Contributor

@slydiman slydiman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM,
But it seems it is necessary to add similar clean=clean to LLDBBuilder.py, PollyBuilder.py, OpenMPBuilder.py and BOLTBuilder.py. Note most builders use UnifiedTreeBuilder which already contains clean property. See the full list of factories with clean=True in llvm-zorg/buildbot/osuosl/master/config/builders.py

Copy link
Contributor

@slydiman slydiman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default value in getattr() is necessary to avoid an exception if some factory does not have the clean property.

@joker-eph
Copy link
Contributor

@joker-eph tell me if I've answered this or not. Might have gone on a sidetrack there.

Yes, this is exactly what I was looking for, thanks.

Copy link
Contributor

@slydiman slydiman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

Copy link
Contributor

@gkistanova gkistanova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this, David!

The patch looks good with a small nit pick. Please see my comments inline.
In the mean time I staged the patch to see it in action.

zorg/buildbot/process/buildrequest.py Outdated Show resolved Hide resolved
zorg/buildbot/process/buildrequest.py Outdated Show resolved Hide resolved
@DavidSpickett
Copy link
Contributor Author

In the mean time I staged the patch to see it in action.

I've cleared the queue for one of our affected builders, https://lab.llvm.org/staging/#/builders/75, and will see how the queue develops.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants