Skip to content

perf: instrument and speed up deployment fingerprints - #2602

Merged
betodealmeida merged 5 commits into
mainfrom
fingerprint-optimizations
Oct 7, 2026
Merged

betodealmeida merged 5 commits into
mainfrom
fingerprint-optimizations

Conversation

@betodealmeida

Copy link
Copy Markdown
Member

Summary

USG checks in https://github.netflix.net/corp/semantic-shared/pull/255 are taking more than 7 minutes, so I had to bump the timeout to 15 minutes in https://github.netflix.net/corp/semantic-shared/pull/322.

This PR does some low hanging fruit optimizations (avoid deep copying, avoid reparsing SQL). This improved perf on a synthetic tests from about 4.0 to 2.1 seconds. The PR also add logging to instrument the checks better, so we can find the bottleneck in #255.

Test Plan

  • PR has an associated issue: #
  • make check passes
  • make test shows 100% unit test coverage

Deployment Plan

A shared.main dry-run for semantic-shared PR #255 spent 340 seconds building fingerprints for 6,663 downstream impacts. Log time spent loading targets and external ancestors, converting specs, finding ancestor closures, and building current and proposed fingerprint graphs.

Avoid deep-copying external target specs between graph snapshots. Clear their current values from the shared cache before calculating proposed values so changed ancestors still produce fresh hashes. Reuse parsed query ASTs when rendered specs are fingerprinted instead of parsing the same SQL on each pass.

Add a repeatable 6,000-metric benchmark and regression tests. The synthetic run fell from about 4.0 to 2.1 seconds, with SQL parses falling from 18,000 to 6,000. Database access is mocked, so the production speedup is not yet measured. Tests: 30 deployment fingerprint tests and 44 model fingerprint tests passed.
The benchmark uses mocked database access and a synthetic graph. Keep its measurements in the PR description while retaining the production timing logs and regression tests in the source tree.
Describe why a downstream target must be rehashed against proposed ancestors when the shared cache is keyed by spec identity.
@netlify

netlify Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for thriving-cassata-78ae72 canceled.

Name Link
🔨 Latest commit d5012b5
🔍 Latest deploy log https://app.netlify.com/projects/thriving-cassata-78ae72/deploys/6ac4233184618c0008ef9975

@betodealmeida
betodealmeida marked this pull request as ready for review October 5, 2026 23:00
@greptile-apps

greptile-apps Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 4/5

[Medium risk] Adds performance instrumentation to deployment fingerprint logic.

The PR is not safe to merge until metric fingerprints remain stable regardless of prior dependency extraction.

Findings

  1. P1 Metric fingerprints depend on call history ▶

Summary

This PR adds deployment fingerprint timing logs, shares loaded target specs between current and proposed snapshots with targeted cache eviction, and reuses parsed SQL ASTs when building version-1 fingerprints.

  • AST reuse changes metric fingerprints when dependency extraction has rewritten the cached metric alias.

Reviews (1) · Last reviewed commit: "style: format fingerprint timing log"

Comment on lines +75 to +76
if rendered.rendered_query is not None:
rendered._query_ast = spec.query_ast

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Metric fingerprints depend on call history

When extract_node_graph processes a metric, it caches an AST with the projection alias rewritten to the metric name. This change then reuses that AST for the version-1 fingerprint. The deployment path therefore hashes the rewritten query, while fingerprinting the same spec without prior dependency extraction hashes the original query. An unchanged metric can receive different fingerprints depending on which path processed it first.

@philipfweiss philipfweiss left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you!

@betodealmeida
betodealmeida merged commit 904745e into main Oct 7, 2026
28 checks passed
@betodealmeida
betodealmeida deleted the fingerprint-optimizations branch October 7, 2026 17:13
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