Skip to content

Reduce per-container memory: cache by GUID instead of Container - #1287

Merged
labkey-jeckels merged 2 commits into
developfrom
fb_containerAndJsonObjectMemory
Oct 6, 2026
Merged

labkey-jeckels merged 2 commits into
developfrom
fb_containerAndJsonObjectMemory

Conversation

@labkey-jeckels

Copy link
Copy Markdown
Contributor

Rationale

Companion to LabKey/platform#8134, which rejects Container objects as cache keys to reduce per-container memory.

Related Pull Requests

Changes

  • Container-scoped caches use the container's GUID as their key instead of the Container object

@labkey-jeckels labkey-jeckels changed the title Reduce per-container memory: cache by GUID instead of Container, share JSON keys Reduce per-container memory: cache by GUID instead of Container Oct 6, 2026
@labkey-jeckels
labkey-jeckels merged commit bc7d5a1 into develop Oct 6, 2026
10 checks passed
@labkey-jeckels
labkey-jeckels deleted the fb_containerAndJsonObjectMemory branch October 6, 2026 01:53
labkey-jeckels added a commit to LabKey/platform that referenced this pull request Oct 10, 2026
…e JSON keys (#8134)

## Tasks
- [x] Claude Code Review
- [x] Manual Testing - N/A
- [x] Test Automation
- [x] Check TeamCity Suites
  - [x] [Daily Postgres](https://teamcity.labkey.org/build/4203956)
- [x] [Nightly SM/FM
postgres](https://teamcity.labkey.org/build/4203972)

---

## Rationale
Lower the server's memory footprint on servers with many containers and
concurrent bulk JSON API requests. A heap dump from a production server
with about 74,000 workbooks and 41 concurrent bulk list inserts showed
two main costs:

| Source | In the dump | Estimated after this PR |
|---|---|---|
| Bulk JSON payloads: the parse trees of 41 concurrent `insertRows`
requests | 1.88 GB, about 108 B per cell | about half of that, ~0.95 GB
saved, because each distinct key is stored once per request instead of
once per row |
| Caches holding one entry per container | 0.39 GB across all caches |
~175–230 MB saved |
| `Container` objects | 194,496 for 74,338 containers; stale copies are
kept alive as keys in Container-keyed caches | one per container |

Savings are estimates from object layouts and the dump's entry counts,
not measurements of the patched code.

BVT-EHR currently runs develop's specimen module rather than this
branch's, so expect container-delete failures there until [GH Issue
1643](LabKey/internal-issues#1643) is
resolved.

## Related Pull Requests
- LabKey/limsModules#2516
- LabKey/premiumModules#776
- LabKey/customModules#282
- LabKey/targetedms#1287

## Changes
- Container-scoped caches use the container's GUID as their key instead
of the `Container` object, and the cache layer now rejects `Container`
keys
- Container cache invalidation removes only the affected entries instead
of clearing whole caches, and reuses cached `Container` objects
- The folder-type and reports usage metrics and the required-modules
calculation query the database directly instead of filling a cache entry
for every container
- The pipeline-root and file-root tables are each cached as a single
map, and the WebDAV folder cache is capped at a fixed size
- The search crawler indexes only a workbook's own lists, not its
parent's
- Bulk JSON request parsing stores one copy of each repeated object key
- Optimize some metrics (folder type counts, etc) to do a single SQL
query to get results instead of iterating all containers

---------

Co-authored-by: Adam Rauch <adam@labkey.com>
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.

2 participants