salsa-rs / salsa

A generic framework for on-demand, incrementalized computation. Inspired by adapton, glimmer, and rustc's query system.
https://salsa-rs.netlify.app/
Apache License 2.0
2.13k stars 152 forks source link

Reduce tracing output of memo #560

Closed MichaReiser closed 3 months ago

MichaReiser commented 3 months ago

This PR reduces the verbosity of Salsa's tracing output.

Salsa used to include the Memo value in the tracing output. If the value is large (imagine a file's source text or AST), this can lead to very verbose traces.

This PR introduces a new tracing_debug function on Memo that omits value and only includes whether the Memo's value is Some or None.

I considered chagning Memo's Debug implementation but I can see cases where it might be useful to debug print a Memo including its value when debugging a Salsa issue.

The output of Memo.revisions can still be long if a query has many dependencies but seeing the outputs is useful when debugging Salsa

Test plan

I used a field-level tracing filter in Ruff and the Salsa output looks very manageable now.

RED_KNOT_LOG=[{name=bar.baz}] cargo run --bin red_knot -- --current-directory=../test -vvv
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.12s
     Running `target/debug/red_knot --current-directory=../test -vvv`
22┐red_knot_module_resolver::resolver::resolve_module{name=child.a}
22┘
22┐red_knot_module_resolver::resolver::resolve_module{name=typing}
22┘
22┐red_knot_module_resolver::resolver::resolve_module{name=builtins}
22┘
22┐red_knot_module_resolver::resolver::resolve_module{name=b}
22┘
22┐red_knot_module_resolver::resolver::resolve_module{name=bar.baz}
22├─   0.059225s   0ms DEBUG salsa::function::maybe_changed_after module_resolution_settings(0): shallow_verify_memo(memo = Memo {
22│     value: "Some(<value>)",
22│     verified_at: AtomicCell {
22│         value: R1,
22│     },
22│     revisions: QueryRevisions {
22│         changed_at: R1,
22│         durability: Durability(
22│             2,
22│         ),
22│         origin: Derived(
22│             QueryEdges {
22│                 input_outputs: [
22│                     (
22│                         Input,
22│                         search_paths(0),
22│                     ),
22│                     (
22│                         Input,
22│                         target_version(0),
22│                     ),
22│                 ],
22│             },
22│         ),
22│     },
22│ })
22├─   0.059288s   0ms DEBUG salsa::zalsa_local report_tracked_read(input=module_resolution_settings(0), durability=Durability(2), changed_at=R1)
22├─   0.059327s   0ms DEBUG salsa::zalsa_local report_tracked_read(input=status(10), durability=Durability(0), changed_at=R1)
22├─   0.059361s   0ms TRACE ruff_db::files Adding file /home/micha/astral/test/bar/baz
22├─   0.059399s   0ms DEBUG salsa::zalsa_local report_tracked_read(input=status(29), durability=Durability(0), changed_at=R1)
22├─   0.059434s   0ms TRACE ruff_db::files Adding file /home/micha/astral/test/bar/baz.pyi
22├─   0.059466s   0ms DEBUG salsa::zalsa_local report_tracked_read(input=status(30), durability=Durability(0), changed_at=R1)
22├─   0.059502s   0ms DEBUG salsa::zalsa_local report_tracked_read(input=status(9), durability=Durability(0), changed_at=R1)
22├─   0.059531s   0ms DEBUG salsa::zalsa_local report_tracked_read(input=path(9), durability=Durability(0), changed_at=R1)
22├─   0.059552s   0ms DEBUG red_knot_module_resolver::resolver Resolved module 'bar.baz' to '/home/micha/astral/test/bar/baz.py'.
22┘
22┐red_knot_module_resolver::resolver::resolve_module{name=a}
22┘
22┐red_knot_module_resolver::resolver::resolve_module{name=a_alias}
22┘
22┐red_knot_module_resolver::resolver::resolve_module{name=random}
22┘
22┐red_knot_module_resolver::resolver::resolve_module{name=x}
22┘
22┐red_knot_module_resolver::resolver::resolve_module{name=_typeshed}
22┘
netlify[bot] commented 3 months ago

Deploy Preview for salsa-rs canceled.

Name Link
Latest commit e994e7fae0e79e60820e6607522342442c7d14c3
Latest deploy log https://app.netlify.com/sites/salsa-rs/deploys/66b47428e753ef0008120ed1
codspeed-hq[bot] commented 3 months ago

CodSpeed Performance Report

Merging #560 will not alter performance

Comparing MichaReiser:reduce-tracing-verbosity (e994e7f) with master (05c7fbe)

Summary

✅ 1 untouched benchmarks