mirror of
https://github.com/element-hq/synapse.git
synced 2026-08-14 18:01:13 +00:00
The first slice of moving the logcontext machinery into the Rust extension: ContextResourceUsage becomes a native class in the new synapse.synapse_rust.logcontext module (rust/src/logging/context.rs), re-exported from synapse.logging.context so callers are unchanged. The public attribute surface, operators and repr are a compatibility contract with the Python callers (Measure, request/background-process metrics, the task scheduler, ...). Keeping the tracker native lets the upcoming switch machinery do its rusage accounting without allocating a Python object per operation. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JFbRtswu7rsHrttJFauUUb
32 lines
1.2 KiB
Python
32 lines
1.2 KiB
Python
# This file is licensed under the Affero General Public License (AGPL) version 3.
|
|
#
|
|
# Copyright (C) 2026 Element Creations Ltd
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU Affero General Public License as
|
|
# published by the Free Software Foundation, either version 3 of the
|
|
# License, or (at your option) any later version.
|
|
#
|
|
# See the GNU Affero General Public License for more details:
|
|
# <https://www.gnu.org/licenses/agpl-3.0.html>.
|
|
|
|
from typing import Optional
|
|
|
|
class ContextResourceUsage:
|
|
"""Tracks the resources used by a log context."""
|
|
|
|
ru_stime: float
|
|
ru_utime: float
|
|
db_txn_count: int
|
|
db_txn_duration_sec: float
|
|
db_sched_duration_sec: float
|
|
evt_db_fetch_count: int
|
|
|
|
def __init__(self, copy_from: "Optional[ContextResourceUsage]" = None) -> None: ...
|
|
def copy(self) -> "ContextResourceUsage": ...
|
|
def reset(self) -> None: ...
|
|
def __iadd__(self, other: "ContextResourceUsage") -> "ContextResourceUsage": ...
|
|
def __isub__(self, other: "ContextResourceUsage") -> "ContextResourceUsage": ...
|
|
def __add__(self, other: "ContextResourceUsage") -> "ContextResourceUsage": ...
|
|
def __sub__(self, other: "ContextResourceUsage") -> "ContextResourceUsage": ...
|