Skip to content

Commit e6f1016

Browse files
author
Alex Wang
authored
docs(insight): shorten scheduler overview
1 parent 7ceb422 commit e6f1016

1 file changed

Lines changed: 15 additions & 30 deletions

File tree

  • packages/aws-durable-execution-sdk-python-insight/src/aws_durable_execution_sdk_python_insight

packages/aws-durable-execution-sdk-python-insight/src/aws_durable_execution_sdk_python_insight/_export_scheduler.py

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,21 @@
11
# SPDX-FileCopyrightText: 2026-present Amazon.com, Inc. or its affiliates.
22
#
33
# SPDX-License-Identifier: Apache-2.0
4-
"""Asynchronous, coalescing export scheduler for the Workflow Insight plugin.
5-
6-
The plugin builds one canonical ``WorkflowInsight`` record on the SDK checkpoint
7-
thread and hands it to :class:`_ExportScheduler`. The scheduler keeps all
8-
exporter-specific work -- per-exporter copy, ``render``, truncation, ``export``
9-
and ``flush`` -- off the checkpoint thread by running it in a lazily-created
10-
daemon worker, one per exporter ("lane"). Scheduling a record only enqueues it
11-
and returns immediately, so ``on_operation_change`` never blocks on a slow
12-
exporter.
13-
14-
Design (``workflow-insight-async-export-design.md``):
15-
16-
* One lazy daemon worker per exporter lane; never more than one live worker per
17-
lane, and a blocked worker is retained -- never replaced -- so threads cannot
18-
grow without bound.
19-
* Per lane, at most one in-flight record and one latest *pending* record per
20-
execution ARN. Records are cumulative snapshots, so a newer pending record for
21-
an ARN replaces the older one (coalescing); an in-flight record is never
22-
cancelled. Updating a pending ARN moves it to the back of the queue for
23-
fairness across ARNs. Pending ARNs are capped; the oldest is evicted when the
24-
cap is exceeded (only reachable behind a blocked/slow exporter).
25-
* Invocation end enqueues one flush barrier per touched lane after the latest
26-
record and waits for all barriers under a single shared timeout deadline. On
27-
timeout the workflow response is returned, degradation is logged, and each
28-
stale barrier is cancelled and its still-queued ``_FLUSH`` marker pulled from
29-
the lane so barriers cannot accumulate behind a blocked worker; any blocked
30-
worker stays daemonized (a synchronous Python ``export()`` cannot be safely
31-
killed) and completes an already-popped barrier itself.
32-
* Idle workers exit after the drain/flush request, so a normal invocation leaves
33-
no lingering thread.
4+
"""Asynchronous export scheduler for the Workflow Insight plugin.
5+
6+
Exporter work runs outside the SDK checkpoint thread. Each exporter has one
7+
lazy daemon worker that serializes copying, rendering, truncation, export, and
8+
flush calls.
9+
10+
Each exporter lane:
11+
12+
* Keeps the latest pending snapshot per execution ARN and processes ARNs
13+
round-robin.
14+
* Drops the oldest pending execution when the lane-wide limit is reached,
15+
keeping memory bounded.
16+
* Uses a lane-wide flush barrier at invocation end. All barriers share one
17+
timeout; timed-out barriers are removed without replacing a blocked worker.
18+
* Stops its worker after an invocation has drained and the lane becomes idle.
3419
"""
3520

3621
from __future__ import annotations

0 commit comments

Comments
 (0)