Skip to content

Explore making indexing locations lazily fetched with comments #2705

@vinistock

Description

@vinistock

Currently, we eagerly capture all entry locations in the index. We may be able to improve both performance and memory usage if we delay that to only when entries are interacted with.

Entries already know which file they were discovered in and we already fetch their comments lazily, so we could very well build the indexer locations lazily too. Something like

class Entry
  def comments
    return @comments if @comments

    fetch_lazy_data!
    @comments
  end

  def location
    return @location if @location

    fetch_lazy_data!
    @location
  end

  private

  def fetch_lazy_data!
    parse_result = Prism.parse_file(@file_path)

    # Figure out the location for this entry
    # Figure out comments
    # Other things we fetch lazily
  end
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestpinnedThis issue or pull request is pinned and won't be marked as staleserverThis pull request should be included in the server gem's release notes

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions