Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@p-x9
Copy link
Owner

@p-x9 p-x9 commented Oct 5, 2025

  • Initializing DyldCache or FullDyldCache every time to access the cache is inefficient.
    • Each time, the file is mapped into memory using mmap and then discarded immediately.
  • However, up until now, we have avoided retaining it from the perspective of biosynthesis during parallel execution.
    • Previously, Foundation.FileHandle was used for reading files, resulting in a structure that repeatedly performed seek and read operations.
    • Improve performance of file I/O using mmap #195
    • Currently, since it only reads values that have been loaded into memory, there is no issue.
  • This PR minimizes the number of times files need to be expanded into memory.

@p-x9 p-x9 requested a review from Copilot October 5, 2025 15:33
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds retention of dyld cache objects to avoid repeatedly re-mapping the same files and propagates parent FullDyldCache / main-cache references through created DyldCache and MachOFile instances.

  • Passes DyldCache references into MachOFile initializers to retain and reuse mapped caches.
  • Introduces internal linkage (_fullCache / _mainCache) plus helper APIs (cache(for:), subcache init) to navigate between main, sub, and full caches.
  • Updates ObjC optimization helpers and subcache resolution to propagate cache references.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
ObjCHeaderInfoRO.swift Adds cache parameter when constructing MachOFile to retain associated DyldCache.
DyldSubCacheEntry.swift Uses new subcache initializer and propagates _fullCache.
MachOFile.swift Adds cache/fullCache retention fields, new convenience init, and makes cache/fullCache properties public with lazy caching logic.
FullDyldCache.swift Ensures created DyldCache instances point back to FullDyldCache; adds cache(for:) lookup.
DyldCache.swift Adds retention of parent/full caches, new subcache init variant, and passes self when creating MachOFile instances.

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

public var cache: DyldCache? {
if let _cache { return _cache }
if let fullCache {
return fullCache.cache(for: url)
Copy link

Copilot AI Oct 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The result of fullCache.cache(for:) is not stored back into _cache, causing a new DyldCache instance to be produced on every access despite the stated goal of retaining caches. Assign the looked-up cache to _cache before returning to ensure reuse.

Suggested change
return fullCache.cache(for: url)
_cache = fullCache.cache(for: url)
return _cache

Copilot uses AI. Check for mistakes.
if let _fullCache { return _fullCache }
if let _cache,
let _fullCache = _cache._fullCache {
return _cache._fullCache
Copy link

Copilot AI Oct 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This early return does not persist the discovered FullDyldCache into self._fullCache, so subsequent calls will recompute (or re-traverse) instead of using a cached reference. Set self._fullCache = _fullCache before returning to retain it.

Suggested change
return _cache._fullCache
self._fullCache = _fullCache
return _fullCache

Copilot uses AI. Check for mistakes.
p-x9 added 4 commits October 6, 2025 00:40
…ence

- Ensure _fullCache is set in _cache when initializing
- Return _fullCache directly if available
@p-x9 p-x9 merged commit 3b653ed into main Oct 12, 2025
2 checks passed
@p-x9 p-x9 deleted the feature/retain-cache-file branch October 12, 2025 14:37
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