Skip to content

Conversation

Forostovec
Copy link

Refactor get_payload to avoid awaiting while holding the payloads mutex. Previously, the code held the tokio::Mutex across an async join (finishing a payload build task), which could serialize concurrent engine_getPayload calls and cause avoidable stalls. The new flow removes the entry under lock, drops the lock, finishes the task, then re-acquires the lock to reinsert the finished payload at a clamped index. This preserves eviction/order semantics as much as possible while eliminating the await-under-lock hotspot.

@Forostovec Forostovec requested a review from a team as a code owner October 2, 2025 09:40
.iter()
.position(|(id, _)| id == &payload_id)
.ok_or(ChainError::UnknownPayload)?;
let (_, item) = payloads.remove(idx);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Removing the payload would make the following requests find nothing here. We should change the underlying value type in payloads to something that can be safely shared with the payloads map.

Copy link
Author

Choose a reason for hiding this comment

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

Removing the payload would make the following requests find nothing here. We should change the underlying value type in payloads to something that can be safely shared with the payloads map.

done boss

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