Skip to content

✨ feat(database): per-namespace governor limits / overall limit view (certified managed packages) #862

Description

@lukecotter

Background

Governor limits in Apex are per certified-managed-package namespace for most counters, and global for a few. Per the governor limits doc (Per-Transaction Certified Managed Package Limits):

  • Per-namespace: SOQL queries, SOSL queries, DML statements, DML rows, query rows, callouts, email invocations.
  • Global (whole transaction): CPU time, heap, execution time, unique namespaces.

The debug log reports usage per namespace via LIMIT_USAGE_FOR_NS blocks (parser stores these in governorLimits.byNamespace).

Problem

The current rollup (ApexLogParser.addGovernorLimits) sums used across namespaces but pairs it with a single namespace's limit. On multi-namespace transactions this renders misleading values in the Database tab, e.g. SOQL 119 / 100 (four namespaces each ≤ 100). Shipped as-is in #162 / #861 — this ticket is the follow-up to handle it properly.

Goal

Show governor usage correctly for multi-namespace logs — ideally an at-a-glance overall figure (e.g. 150 / 450) and/or a per-namespace breakdown, without ever overstating headroom.

Research so far

  • Detecting pools: a namespace with its own LIMIT_USAGE_FOR_NS block has its own reported pool; a namespace that appears (e.g. ENTERING_MANAGED_PKG) but has no block is folded into default (already counted there — no double-count). No external "is certified" flag needed.
  • Can't hardcode: the same package varies by org — SCMC and dlrs each had their own pool in one org's log and folded into default in another. java__util is a Salesforce-internal namespace (always folds).
  • ⚠️ The catch (verified in a namespaced scratch org): in a namespaced org the org's own code is attributed to its namespace, not default (we saw insert/SELECT/update/delete land under pse while (default) stayed 0). And a dev/namespaced org reports per-namespace blocks that back one underlying pool — so summing limits (sum(limit)) can overstate available headroom (pse 100 + default 100 = 200 when there's really 100). We cannot reliably distinguish "separate certified pool (subscriber org)" from "one shared pool (dev/namespaced org)" from the log alone — this is the open research question.
  • Global limits (CPU/heap/exec) must be treated as whole-transaction, never summed.

Options

  1. Per-namespace + tightest-% headline (safe, no research needed): show the namespace closest to its limit as the headline gauge, full per-namespace breakdown on hover. Never overstates; correct in both subscriber and dev-org cases.
  2. Combined used / sum(limit) (e.g. 150 / 450): nicer at-a-glance, but only valid once we can confirm the pools are genuinely separate — needs the research above.
  3. Both, gated on which case a log is.

Suggested next step

Adopt option 1 for the UI now (correctness), and research option 2 (certified-vs-shared pool detection) before showing a combined ceiling. Fix the parser rollup so global limits aren't summed and namespaced limits expose byNamespace instead of a misleading single total.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions