Skip to content

Prefetch research: folder children — orderObjects wakes every child #4355

Description

@jensens

Part of the research plan for #4350 (see anchor comment there for the full decomposition).

Folder children are wake-free prefetch candidates: children obtained from plone.folder's _tree (or OFS attribute storage) are ghosts whose _p_oid is readable without activation — collect ghosts, prefetch, then iterate.

Findings (Plone 6.2 coredev scan, 2026-07-06)

# Call site Pattern
C1 plone.folder 5.0.0 ordered.py:93-105 objectValues/objectItems LazyMap_getOb per child on access
C2 plone.folder default.py:130,136 and partial.py:149 orderObjects wakes every child to read the sort key
C3 OFS/ObjectManager.py:436-449 list comprehension, _getOb per child

C2 is the cleanest bounded win: reordering a large folder by attribute currently loads all children sequentially; a ghost-collection prefetch before the sort batches this into one round-trip on capable storages.

Tasks

  • orderObjects: collect child ghosts from _tree, prefetch(), then sort (uses the plone.base helper sub-issue).
  • Evaluate automatic prefetch in objectValues/objectItems-heavy paths — the full id list is materialized anyway; question is whether an opt-in (prefetch=True) or automatic-with-threshold is appropriate, since not every caller iterates the whole LazyMap.
  • Check which core UI paths hit C1/C3 with large folders (folder_contents, content rules, copy/move) and measure with the harness sub-issue.
  • Upstream consideration: plone.folder changes are Plone-owned; OFS.ObjectManager would need Zope buy-in — likely out of scope for v1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions