Skip to content

perf(apps): cache generation leases in the app manager #657

Backlog

Description

@RentnerKev

Problem

Every app UI request pays several database round trips for lease checks.

  • lease::check (core/src/app_ipc/lease.rs:15-30) has no cache. Each call goes to lease_expires_at (core/src/app_ipc/gateway.rs:161-191) and runs one Postgres transaction in the web process (web/src/server/AppRuntime/management.server.ts:89-98).
  • A static UI asset costs 3 transactions: authorizeAppUi (web/src/server/AppRuntime/ui/assets.server.ts:117) plus two check_live calls (core/src/app_manager/ui.rs:270, :286). Assets are no-store, so every frame open repeats this per file.
  • A /__app-ui/call costs 6 (7 when the app answers 409): session, metadata check_live, policy check_live, pre-authorize, broker require_lease (gateway.rs:351), post-authorize.
  • check_live (ui.rs:495-513) has a 3 s timeout and runs outside the per-installation operation limit. The web UI socket has 16 slots shared by all apps (ui.rs:47, :197-201). A stalled broker therefore makes each of its requests wait about 3 s while holding a shared slot, which slows the UI of other apps.

Proposal

  • Keep the last confirmed lease expiry per generation in the app manager (monotonic clock), and invalidate it synchronously on close, stop and retire. Only call the platform when the cached lease is about to expire.
  • Check liveness once per asset request instead of twice, and run it under the per-installation limit.
  • Give a stalled broker its own budget so it cannot hold the shared web UI socket slots.

Acceptance

  • Test: opening a frame with N assets causes at most one lease round trip while the lease is valid.
  • Test: a stalled app's broker does not delay asset requests of another app beyond a small bound.
  • Revocation still takes effect immediately on stop and retire.

Found in the app platform audit of 2026-11-30.

Activity

  1. added
    enhancement
    rust
    area: runtime
    on Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: runtimeenhancementrust

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions