Skip to content

perf: remove trace/traceDpp from eager queries and slim FETCH_RESOURCES - #881

Merged
phoebus-84 merged 2 commits into
mainfrom
perf/remove-trace-and-slim-fetch-resources
Aug 5, 2026
Merged

perf: remove trace/traceDpp from eager queries and slim FETCH_RESOURCES#881
phoebus-84 merged 2 commits into
mainfrom
perf/remove-trace-and-slim-fetch-resources

Conversation

@phoebus-84

Copy link
Copy Markdown
Contributor

Problem

Production GUI times out loading zenflows assets because:

1. Project detail page fires 5 expensive queries simultaneously

Each triggers a full event-chain DFS traversal in the zenflows backend:

  • GET_PROJECT_LAYOUT with trace (FetchProjectLayout)
  • GET_TRACE with trace (ProjectTime)
  • GET_PROJECT_TRACE with trace (LoshImportedDate)
  • QUERY_TRACE_DPP with traceDpp (ProjectTabs)
  • QUERY_TRACE_DPP with traceDpp (ContributionsCard)

Backend detail: trace triggers EconomicResource.Domain.trace/2 which does a depth-first search through the entire event chain. traceDpp is worse — trace_dpp/2 recursively walks the trace graph with depth 100M, each recursion wrapped in Repo.multi DB transactions.

2. FETCH_RESOURCES fetches heavy unused fields per resource

  • primaryAccountable.images.bin — base64 binary image data (HUGE payload)
  • custodian — DB preload, never used in cards
  • accountingQuantity / onhandQuantityMeasure.preload each, never used in cards
  • okhv, repo, version, licensor, primaryAccountable.note, primaryAccountable.primaryLocation — unused strings

Changes

  • Remove trace from GET_PROJECT_LAYOUT
  • Remove eager QUERY_TRACE_DPP from ProjectTabs & ContributionsCard, use project.metadata?.dpp fallback
  • Remove GET_TRACE from ProjectTime (was dead code, never imported)
  • Remove GET_PROJECT_TRACE from LoshImportedDate, simplify to optional prop
  • Fix broken e.trace?.filter(...)[0] crash in ProjectsTableRow
  • Slim FETCH_RESOURCES: removed 10 unused/heavy fields
  • Make getUserImage() safe when bin is missing
  • Matching FETCH_RESOURCES update in interfacer-client (already pushed)

What's preserved

  • ProjectDpp.tsx still fetches traceDpp lazily — only when user clicks the DPP tab
  • currentLocation kept in FETCH_RESOURCES (used by maps and some cards)

Problem: production GUI times out loading zenflows assets because:
1. Project detail page fires 5 expensive trace/traceDpp queries simultaneously,
   each triggering full event-chain DFS traversals in the backend.
2. FETCH_RESOURCES (listing pages) fetches heavy unused fields including
   base64 image binary data, unused DB preloads per resource.

Changes:
- Remove trace from GET_PROJECT_LAYOUT (FetchProjectLayout)
- Remove eager QUERY_TRACE_DPP from ProjectTabs and ContributionsCard,
  use project.metadata?.dpp fallback instead
- Remove GET_TRACE query from ProjectTime (was dead code)
- Remove GET_PROJECT_TRACE from LoshImportedDate, simplify to prop
- Fix broken e.trace?.filter(...)[0] in ProjectsTableRow
- Slim FETCH_RESOURCES: remove primaryAccountable.images.bin,
  custodian, accountingQuantity, onhandQuantity, okhv, repo, version,
  licensor, primaryAccountable.note/primaryLocation
- Make getUserImage() safe when bin is missing
…jectId prop

- ContributionsCard.tsx: the traceDpp removal left the QUERY_RESOURCE_PROPOSAlS
  useQuery call unclosed and its @apollo/client import removed, causing a
  build parsing error. Restore the query args, closing paren and import.
- LoshImportedDate.tsx: projectId prop is no longer used; remove it from the
  props type so call sites passing only addedOn typecheck.
@phoebus-84
phoebus-84 merged commit c51e45f into main Aug 5, 2026
1 check passed
@phoebus-84
phoebus-84 deleted the perf/remove-trace-and-slim-fetch-resources branch August 5, 2026 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant