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

add compliation and cache tracking #4912

Merged
merged 4 commits into from
Mar 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changes/unreleased/Under the Hood-20220321-142854.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
kind: Under the Hood
body: Add Graph Compilation and Adapter Cache tracking
time: 2022-03-21T14:28:54.160087-04:00
custom:
Author: ChenyuLInx
Issue: "4625"
PR: "4912"
12 changes: 12 additions & 0 deletions core/dbt/task/runnable.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@

from dbt.graph import GraphQueue, NodeSelector, SelectionSpec, parse_difference, Graph
from dbt.parser.manifest import ManifestLoader
import dbt.tracking

import dbt.exceptions
from dbt import flags
Expand Down Expand Up @@ -88,7 +89,12 @@ def compile_manifest(self):

def _runtime_initialize(self):
self.load_manifest()

start_compile_manifest = time.perf_counter()
self.compile_manifest()
compile_time = time.perf_counter() - start_compile_manifest
if dbt.tracking.active_user is not None:
dbt.tracking.track_runnable_timing({"graph_compilation_elapsed": compile_time})


class GraphRunnableTask(ManifestTask):
Expand Down Expand Up @@ -391,7 +397,13 @@ def _mark_dependent_errors(self, node_id, result, cause):
self._skipped_children[dep_node_id] = cause

def populate_adapter_cache(self, adapter):
start_populate_cache = time.perf_counter()
adapter.set_relations_cache(self.manifest)
cache_populate_time = time.perf_counter() - start_populate_cache
if dbt.tracking.active_user is not None:
dbt.tracking.track_runnable_timing(
{"adapter_cache_construction_elapsed": cache_populate_time}
)

def before_hooks(self, adapter):
pass
Expand Down
13 changes: 13 additions & 0 deletions core/dbt/tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
RESOURCE_COUNTS = "iglu:com.dbt/resource_counts/jsonschema/1-0-0"
EXPERIMENTAL_PARSER = "iglu:com.dbt/experimental_parser/jsonschema/1-0-0"
PARTIAL_PARSER = "iglu:com.dbt/partial_parser/jsonschema/1-0-1"
RUNNABLE_TIMING = "iglu:com.dbt/runnable/jsonschema/1-0-0"
DBT_INVOCATION_ENV = "DBT_INVOCATION_ENV"


Expand Down Expand Up @@ -412,6 +413,18 @@ def track_partial_parser(options):
)


def track_runnable_timing(options):
context = [SelfDescribingJson(RUNNABLE_TIMING, options)]
assert active_user is not None, "Cannot track runnable info when active user is None"
track(
active_user,
category="dbt",
action="runnable_timing",
label=get_invocation_id(),
context=context,
)


def flush():
fire_event(FlushEvents())
try:
Expand Down