Skip to content
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

call_reducer_with_tx: move work before/after tx lock aquire/release #1099

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

Centril
Copy link
Contributor

@Centril Centril commented Apr 16, 2024

Description of Changes

Most of these were noticeable in the 380 CCU flame graph.

  1. Create ctx & clone tx_slot before taking tx lock.
  2. Move an allocation before taking tx lock.
  3. Move energy_monitor.record_reducer(..) to after releasing tx lock.
  4. Move tracing & metrics work to after releasing tx lock.
  5. Move actual dropping of Arc<ModuleEvent> (last referent) to outside of blocking_broadcast_event, reducing the time the subscriptions.read() lock and tx lock is held.
  6. Move work done by record_metrics after tx/subscription locks have been released.
  7. Tweak merge_apply_inserts and merge_apply_deletes to update metrics at most once per table.

API and ABI breaking changes

None

Expected complexity level and risk

3 - We've had deadlocks and threading issues in this code path before, so review the logic with care.

Testing

A playtest would be good to run before merging, primarily for safety reasons.

@Centril Centril added enhancement New feature or request performance energy-tracking Changes related to measuring and tracking resources within SpacetimeDB test-with-bots Recommend to test under higher CCU labels Apr 16, 2024
Copy link
Contributor

@cloutiertyler cloutiertyler left a comment

Choose a reason for hiding this comment

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

See comment.

@Centril Centril force-pushed the centril/reducer-hold-tx-less branch from a82e483 to 10eb9d6 Compare April 18, 2024 21:46
@bfops bfops added release-any To be landed in any release window and removed performance labels Apr 22, 2024
1. Create ctx & clone tx_slot before taking tx lock.
2. Move an allocation before taking tx lock.
3. Move energy_monitor.record_reducer(..) to after releasing tx lock.
4. Move tracing & metrics work to after releasing tx lock.
@Centril Centril force-pushed the centril/reducer-hold-tx-less branch from 84663d0 to 9f57c85 Compare May 15, 2024 11:26
@Centril Centril force-pushed the centril/reducer-hold-tx-less branch from 9f57c85 to c4f6d61 Compare May 28, 2024 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
energy-tracking Changes related to measuring and tracking resources within SpacetimeDB enhancement New feature or request release-any To be landed in any release window test-with-bots Recommend to test under higher CCU
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants