Skip to content

chore(bigframes): optimize system test teardown#17443

Merged
ohmayr merged 4 commits into
mainfrom
optimize-bigframes-system-tests
Jun 12, 2026
Merged

chore(bigframes): optimize system test teardown#17443
ohmayr merged 4 commits into
mainfrom
optimize-bigframes-system-tests

Conversation

@ohmayr

@ohmayr ohmayr commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

brings down bigframes system tests from 23 mins to 12 mins i.e. 2x speed up.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request parallelizes table deletion using a ThreadPoolExecutor and moves the Python UDF cleanup process to a background daemon thread in anonymous_dataset.py. Additionally, it configures pytest to use the worksteal distribution algorithm in noxfile.py. Feedback on these changes highlights potential issues with silent failures during table deletion due to unhandled exceptions in the thread pool, and warns that running the UDF cleanup in a daemon thread may lead to incomplete cleanup and secondary exceptions during interpreter shutdown.

Comment thread packages/bigframes/bigframes/session/anonymous_dataset.py Outdated
)
warnings.warn(msg, category=bfe.CleanupFailedWarning)

threading.Thread(target=run_cleanup, daemon=True, name="bigframes-udf-cleanup").start()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Starting the UDF cleanup in a daemon thread (daemon=True) means that if the Python process exits shortly after close() is called (which is very common at the end of a script or test run), the thread will be abruptly terminated. This can prevent the cleanup from completing, leading to resource accumulation (the very issue b/450913424 is trying to solve).

Additionally, calling warnings.warn from a daemon thread during interpreter shutdown can raise secondary exceptions (like TypeError or AttributeError due to modules being cleaned up and set to None).

Consider whether this cleanup should be synchronous, or if there is a way to register an atexit handler to ensure the thread completes before the process exits.

@ohmayr ohmayr marked this pull request as ready for review June 12, 2026 16:44
@ohmayr ohmayr requested review from a team as code owners June 12, 2026 16:44
@ohmayr ohmayr requested review from TrevorBergeron and removed request for a team June 12, 2026 16:44

@chalmerlowe chalmerlowe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

By and large, this LGTM.
I think it is reasonable to check in on the note that gemini-code-assist provided.
There may be some merit to adding that defensive pattern in place.

I leave the decision up to you and do not need to re-review, unless there is a major change.

@ohmayr ohmayr merged commit d7f57fc into main Jun 12, 2026
32 checks passed
@ohmayr ohmayr deleted the optimize-bigframes-system-tests branch June 12, 2026 18:02
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.

2 participants