Skip to content

perf: Add inventory caching for interlink resolution#1152

Closed
CybotTM wants to merge 2 commits into
TYPO3-Documentation:mainfrom
CybotTM:perf/inventory-caching
Closed

perf: Add inventory caching for interlink resolution#1152
CybotTM wants to merge 2 commits into
TYPO3-Documentation:mainfrom
CybotTM:perf/inventory-caching

Conversation

@CybotTM

@CybotTM CybotTM commented Jan 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Introduces CachingJsonLoader that decorates JsonLoader to cache inventory files locally, significantly reducing render time for documentation with many interlinks.

Features

  • File-based caching: Stores inventory JSON files in system temp directory with configurable TTL (default 1 hour)
  • In-memory caching: Deduplicates requests within the same render process
  • Parallel prefetch: Capability for bulk inventory loading (enables future parallel fetching)
  • Hash-based filenames: Uses xxh128 for URL → filename mapping

Performance Impact

~53% render time improvement for interlink-heavy documentation (measured on TYPO3 core docs).

Technical Details

  • Decorator pattern: CachingJsonLoader wraps existing JsonLoader
  • PHP 8.1 compatible (no typed constants or #[\Override])
  • Cache location: {sys_temp_dir}/typo3-guides-inventory-cache/
  • TTL validation prevents stale cache usage

Part of Performance Initiative

This is Phase 1.1 of the performance optimization initiative tracked in #1143.

Upstream dependencies (phpdocumentor/guides):

  • #1287 - DocumentEntryNode file path method
  • #1288 - DocumentEntryNode isRoot flag
  • #1289 - ProjectNode find method
  • #1293 - O(1) document lookup optimization

Test plan

  • Run render on documentation with many interlinks
  • Verify cache files created in temp directory
  • Confirm cache hit on subsequent renders
  • Test cache expiration after TTL

Introduces CachingJsonLoader that decorates JsonLoader with:
- File-based caching with configurable TTL (default 1 hour)
- In-memory caching for current request deduplication
- Parallel prefetch capability for bulk inventory loading
- ~53% render time improvement for interlink-heavy docs

Cache is stored in system temp directory with xxh128 URL hashing.
PHP 8.1 compatible (no typed constants or #[\Override]).
Change 0755 to 0o755 for code style compliance.
@CybotTM

CybotTM commented Jan 23, 2026

Copy link
Copy Markdown
Contributor Author

Closing - moved upstream to phpDocumentor/guides PR #1295. The caching logic is not TYPO3-specific and benefits all users of phpDocumentor/guides.

@CybotTM CybotTM closed this Jan 23, 2026
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