Skip to content

Use unique IDs for unresolved references#282

Merged
Morriar merged 1 commit intomainfrom
at-ref-ids
Nov 3, 2025
Merged

Use unique IDs for unresolved references#282
Morriar merged 1 commit intomainfrom
at-ref-ids

Conversation

@Morriar
Copy link
Contributor

@Morriar Morriar commented Oct 29, 2025

Iterating from Ruby on unresolved references without the ID handle trick is painful, I think we need to create unique IDs for the references.

Take this simple script:

graph = Saturn::Graph.new
graph.index_all([path])

refs = graph.unresolved_references
  .grep(Saturn::UnresolvedConstantReference)
  .select { |ref| ref.name.include?("Shopify") }

puts "Selected: #{refs.size}"

Here's a comparison of performances between an array of references and an array of reference ids:

# array of references

Maximum Resident Set Size: 7427211264 bytes (7083.14 MB)
Peak Memory Footprint:     9216089600 bytes (8789.14 MB)
Execution Time:            1301.68 seconds

# array of ID handles

Maximum Resident Set Size: 2281750528 bytes (2176.04 MB)    x3.2 smaller
Peak Memory Footprint:     1567594496 bytes (1494.97 MB)    x5.8 smaller
Execution Time:            125.06 seconds                   x10.4 faster

@Morriar Morriar self-assigned this Oct 29, 2025
@Morriar Morriar requested a review from a team as a code owner October 29, 2025 23:01
@Morriar Morriar added the enhancement New feature or request label Oct 29, 2025
@Morriar Morriar force-pushed the at-index-method-references branch from e89252d to 6b7556c Compare October 31, 2025 16:06
Base automatically changed from at-index-method-references to main October 31, 2025 16:24
Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
@Morriar Morriar merged commit 52bd050 into main Nov 3, 2025
12 checks passed
@Morriar Morriar deleted the at-ref-ids branch November 3, 2025 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants