Skip to content

Fix remote cache writes to not block the Pants run (Cherry-pick of #11947)#11950

Merged
Eric-Arellano merged 1 commit into
pantsbuild:2.4.xfrom
Eric-Arellano:cp-remote-hang
Apr 21, 2021
Merged

Fix remote cache writes to not block the Pants run (Cherry-pick of #11947)#11950
Eric-Arellano merged 1 commit into
pantsbuild:2.4.xfrom
Eric-Arellano:cp-remote-hang

Conversation

@Eric-Arellano
Copy link
Copy Markdown
Contributor

No description provided.

Closes pantsbuild#11908. As described there, `ensure_remote_has_recursive()` was blocking due to its call to `executor.block_on()`. This was introduced in pantsbuild#9793, which reasoned that only the spawned thread would get blocked, which would be safe - but it turns out that this blocking stops Pants from doing anything else.

This was not introduced due to the upgrade from Tokio 0.2 to 1.x, and it's plausible this never worked as intended with remote caching, given that remote caching was not available in May 2020.

Fundamentally, the issue makes sense. Reading from LMDB Store must be synchronous to be safe, which we correctly expressed, e.g. via using `Executor.spawn_blocking()`. We tried to minimize memory consumption by allowing for a callback to access a reference/slice of the bytes, rather than cloning it. However, we desire for the remote code to be async, e.g. so that it can finish in the background a la pantsbuild#11479. If it's async, it fundamentally would not be able to use a reference because that reference may no longer be valid - we need to clone the data to fully own it. 

While cloning the bytes will result in more memory consumption, it is imperative that remote caching fails gracefully. The increase in memory consumption is less offensive than pantsbuild#11908, i.e. that slowness in remote cache writes can slow down and even hang Pants.
# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
@Eric-Arellano Eric-Arellano requested review from benjyw and tdyas April 21, 2021 00:17
@Eric-Arellano
Copy link
Copy Markdown
Contributor Author

This was a clean cherry-pick.

Copy link
Copy Markdown
Contributor

@benjyw benjyw left a comment

Choose a reason for hiding this comment

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

Rubber-stamping, but I cannot verify the rust code. I assume this was a clean cherrypick.

@Eric-Arellano Eric-Arellano merged commit 4c81520 into pantsbuild:2.4.x Apr 21, 2021
@Eric-Arellano Eric-Arellano deleted the cp-remote-hang branch April 21, 2021 03:03
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