Skip to content

Make the CI Queue reporters work in parallel#355

Merged
ChrisBr merged 2 commits intomainfrom
make_parallel_friendly
Aug 21, 2025
Merged

Make the CI Queue reporters work in parallel#355
ChrisBr merged 2 commits intomainfrom
make_parallel_friendly

Conversation

@gmcgibbon
Copy link
Member

Make Minitest::Queue::OrderReporter parallel-friendly. This is essentially done by appending and truncating to the log file instead of writing to it. The object also doesn't depend on the start hook anymore to initialize the log file, because that isn't called in forked workers.

@gmcgibbon
Copy link
Member Author

gmcgibbon commented Aug 20, 2025

This passes locally. I assume CI is broken?

Just the python test suite.

@gmcgibbon gmcgibbon force-pushed the make_parallel_friendly branch 4 times, most recently from 21e1802 to ba76cc2 Compare August 20, 2025 21:55
@shioyama shioyama requested a review from ChrisBr August 21, 2025 01:37
Copy link
Contributor

@davidstosik davidstosik left a comment

Choose a reason for hiding this comment

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

Thank you for working on this!

Can we make sure calling file.truncate in #start does not risk truncating the first few logs?

def start
@file = File.open(@path, 'w+')
super
file.truncate(0)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is #start called only once before forking?

If not, is there a risk that you truncate the few first logs in the case the first tests ran very quickly?

Also, is it okay not to call super?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes it is called once before forking, so the truncate will behave like opening the file in write mode and rewriting sections of it in a non-forked setup.

Copy link
Member Author

@gmcgibbon gmcgibbon Aug 21, 2025

Choose a reason for hiding this comment

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

Looks like we call https://github.com/minitest/minitest/blob/7c907429e8e7ec7c3b6ee0c7045e67249f4ad505/lib/minitest.rb#L864

Probably not needed, but I see most of the time it is called. I'll add it back just in case.

Comment on lines +26 to +27
unless truffleruby?
def test_forking
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you mean to run this test only when not running the test suite with Truffle Ruby?
Does that mean the feature implemented in this PR is not compatible with Truffle Ruby?
Do we need a fallback? Will ci-queue not work with Truffle Ruby anymore?

Copy link
Member Author

Choose a reason for hiding this comment

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

Fork isn't implemented in truffle ruby. CI queue doesn't fork explicitly anywhere, we're just making sure the logging behaves well when distributed across multiple processes in forks or other threads.

Make Minitest::Queue::OrderReporter parallel-friendly. This is
essentially done by appending and truncating to the log file instead of
writing to it. The object also doesn't depend on the start hook anymore
to initialize the log file, because that isn't called in forked workers.
@gmcgibbon gmcgibbon force-pushed the make_parallel_friendly branch from ba76cc2 to 52229d6 Compare August 21, 2025 02:48
@ChrisBr ChrisBr merged commit c1df0d5 into main Aug 21, 2025
13 of 23 checks passed
@gmcgibbon gmcgibbon deleted the make_parallel_friendly branch August 21, 2025 16:40
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.

4 participants