Skip to content

Add fetch span #875

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
merged 3 commits into from
May 26, 2025
Merged

Add fetch span #875

merged 3 commits into from
May 26, 2025

Conversation

MichaReiser
Copy link
Contributor

@MichaReiser MichaReiser commented May 22, 2025

I often find it hard to understand the query stack when debugging salsa.

This PR adds a fetch span, including the ingredient. This gives a better sense for how salsa recurses and (when enter and exit logging is enabled), when a query completes.

This is a separate PR to see how it affects perf:

Example from a recent debugging sesison of mine (the thread id part is custom)

2025-05-21T13:37:38.146709Z DEBUG t2{thread_id=ThreadId(4)}:fetch{query=query_c(Id(0))}:fetch{query=query_b(Id(800))}: salsa::runtime: Block ThreadId(4) on ThreadId(3) because it depends on query_a(Id(400)) (currently running on that thread).

Copy link

netlify bot commented May 22, 2025

Deploy Preview for salsa-rs canceled.

Name Link
🔨 Latest commit 9553013
🔍 Latest deploy log https://app.netlify.com/projects/salsa-rs/deploys/6830a12b7a8cd8000837b18e

Copy link

codspeed-hq bot commented May 22, 2025

CodSpeed Performance Report

Merging #875 will not alter performance

Comparing MichaReiser:fetch-span (9553013) with master (0414d89)

Summary

✅ 12 untouched benchmarks

@MichaReiser
Copy link
Contributor Author

Hmm, perf is definetely regressing :(

@@ -15,14 +15,17 @@ where
let (zalsa, zalsa_local) = db.zalsas();
zalsa.unwind_if_revision_cancelled(zalsa_local);

let database_key_index = self.database_key_index(id);
let _span = tracing::debug_span!("fetch", query = ?database_key_index).entered();
Copy link
Member

Choose a reason for hiding this comment

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

I assume its just the allocation and deallocation of the span causing the perf regression but could you try using a query = ?{database_key_index} to force a move? (or inline the local into the method call). Rust's formatting infra captures the address of things which may inhibit optimizations.

@@ -15,14 +15,18 @@ where
let (zalsa, zalsa_local) = db.zalsas();
zalsa.unwind_if_revision_cancelled(zalsa_local);

let database_key_index = self.database_key_index(id);
#[cfg(debug_assertions)]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This sort of defeats the purpose of tracing but I hopefully will never have to debug release-mode only salsa bugs

@MichaReiser MichaReiser marked this pull request as ready for review May 22, 2025 09:59
@MichaReiser MichaReiser added this pull request to the merge queue May 26, 2025
Merged via the queue into salsa-rs:master with commit 393cf7c May 26, 2025
12 checks passed
@MichaReiser MichaReiser deleted the fetch-span branch May 26, 2025 17:01
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.

3 participants