8000 Avoid excessive filesystem read/writes during test execution by kyri-petrou · Pull Request #9795 · zio/zio · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Avoid excessive filesystem read/writes during test execution #9795

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

Merged

Conversation

kyri-petrou
Copy link
Contributor

/fixes #9783

Currently we're appending the result of each test to a file. When test execution finishes, we load up the entire file, and then write each line by opening / closing a new java.io.FileWriter. This is very inefficient especially for large test suites.

With this PR we store all the writes in a queue which we then drain and write its contents to the FS once we close ResultFileOps.

Previously, running coreTestsJVM/test locally required 10 seconds (!!!) for the test reports to be written to the file, whereas now it's done in a matter of milliseconds.

@@ -7,66 +7,42 @@ import java.nio.file.Path

object ResultFileOpsJsonSpec extends ZIOBaseSpec {
def spec = suite("ResultFileOpsJsonSpec")(
test("simple write")(
test("writes lines within the result array sequentially")(
Copy link
Collaborator

Choose a reason for hiding this comment

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

The previous testing didn't have this, but given the special casing for commas, should we have that in the test?

Otherwise LGTM

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The previous testing didn't have this
I know but I wanted to have a more "deterministic" test that wrote things sequentially and a non-deterministic one that tested parallel writes

but given the special casing for commas, should we have that in the test

Good point, I'll add this

}
.ignore
)
private[test] class Json private (resultPath: String) extends ResultFileOps {
Copy link
Member

Choose a reason for hiding this comment

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

🟢 Could be final?

guizmaii
guizmaii previously approved these changes Apr 15, 2025
Copy link
Member
@guizmaii guizmaii left a comment

Choose a reason for hiding this comment

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

LGTM

@hearnadam hearnadam merged commit 4fbf341 into zio:series/2.x Apr 17, 2025
18 checks passed
@kyri-petrou kyri-petrou deleted the avoid-excessive-io-during-test-execution branch April 17, 2025 07:48
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.

Inefficient output of results in zio-test
3 participants
0