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

Update logo #313

Merged
merged 20 commits into from
Aug 11, 2022
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
add latency printing
eloyekunle committed Dec 5, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 21fc10435123e8282e084c020e5c26f7d83a7b4b
6 changes: 4 additions & 2 deletions src/server/command_handler.py
Original file line number Diff line number Diff line change
@@ -34,11 +34,13 @@ def execute_query(query, mm: MetricsManager) -> Iterator[Batch]:
mm_start(mm, "parsing")
stmt = Parser().parse(query)[0]

mm_end_start(mm, "parsing", "planning")
mm_end_start(mm, "parsing", "planning.convertor")
l_plan = StatementToPlanConvertor().visit(stmt)

mm_end_start(mm, "planning.convertor", "planning.build")
p_plan = PlanGenerator().build(l_plan)

mm_end_start(mm, "planning", "execution")
mm_end_start(mm, "planning.build", "execution")
output = PlanExecutor(p_plan).execute_plan()

mm_end(mm, "execution")
17 changes: 12 additions & 5 deletions src/utils/metrics.py
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@


class MetricsManager(object):
_last = "" # track last started timer contex
_timers = {}
_current = "" # helps with nesting

@@ -19,7 +20,7 @@ def start(self, context):
raise Exception(
f"context: '{self._current}' already exists in MetricsManager")

self._timers[self._current] = {"start": time.time(), "children": {}}
self._timers[self._current] = {"start": time.time_ns()}

def end(self, context):
if not self._current.endswith(context):
@@ -31,12 +32,18 @@ def end(self, context):
raise Exception(
f"context: '{self._current}' does not exist in MetricsManager")

self._timers[self._current]["end"] = time.time()
self._current = ".".join(self._current.split(".")[:-1])
self._timers[self._current]["end"] = time.time_ns()

self._current = self._current[:-len(context)]
if self._current.endswith("."):
self._current = self._current[:-1]

def print(self):
# todo generate meaningful string output from timers
return self._timers, self._current
latency = {}
for k, v in self._timers.items():
latency[k] = v['end'] - v['start']

return {"latency (ns)": latency}


def mm_start(mm: MetricsManager, context: str):