Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move RemoteAssetGraph.from_external_repository to cached property on ExternalRepository #20468

Conversation

alangenfeld
Copy link
Member

@alangenfeld alangenfeld commented Mar 14, 2024

RemoteAssetGraph is a relatively heavy object. Given a large asset graph, if any code ends up creating copies on the order of number of assets, it can be very expensive.

We already do a good job of memoizing ExternalRepository via CodeLocation via WorkspaceRequestContext via WorkspaceProcessContext, so caching these RemoteAssetGraph on the ExternalRepository that they are a pure function of should avoid excess computation and memory until the WorkspaceProcessContext refreshes its snapshots on code server update.

How I Tested These Changes

existing coverage
a memray run of a script doing per asset RemoteAssetGraph showed drastic reduction in memory

@alangenfeld
Copy link
Member Author

alangenfeld commented Mar 14, 2024

@alangenfeld alangenfeld force-pushed the al/03-13-move_RemoteAssetGraph.from_external_repository_to_cached_property_on_ExternalRepository branch from b94c965 to e1b34f7 Compare March 14, 2024 02:29
@alangenfeld alangenfeld force-pushed the al/03-13-move_RemoteAssetGraph.from_external_repository_to_cached_property_on_ExternalRepository branch 2 times, most recently from 7e0f9e8 to 7a446a9 Compare March 14, 2024 03:24
@alangenfeld alangenfeld force-pushed the al/03-13-move_RemoteAssetGraph.from_external_repository_to_cached_property_on_ExternalRepository branch from 7a446a9 to 28c758d Compare March 14, 2024 14:58
@alangenfeld alangenfeld force-pushed the al/03-13-move_RemoteAssetGraph.from_external_repository_to_cached_property_on_ExternalRepository branch from 28c758d to a9d5a2d Compare March 14, 2024 15:24
@alangenfeld alangenfeld merged commit 1a07aa3 into master Mar 14, 2024
1 check failed
@alangenfeld alangenfeld deleted the al/03-13-move_RemoteAssetGraph.from_external_repository_to_cached_property_on_ExternalRepository branch March 14, 2024 15:56
alangenfeld added a commit that referenced this pull request Mar 14, 2024
…#20469)

same logic as #20468

## How I Tested These Changes

existing coverage
alangenfeld added a commit that referenced this pull request Mar 14, 2024
…ExternalRepository (#20468)

`RemoteAssetGraph` is a relatively heavy object. Given a large asset
graph, if any code ends up creating copies on the order of number of
assets, it can be very expensive.

We already do a good job of memoizing `ExternalRepository` via
`CodeLocation` via `WorkspaceRequestContext` via
`WorkspaceProcessContext`, so caching these `RemoteAssetGraph` on the
`ExternalRepository` that they are a pure function of should avoid
excess computation and memory until the `WorkspaceProcessContext`
refreshes its snapshots on code server update.

## How I Tested These Changes

existing coverage
a `memray` run of a script doing per asset `RemoteAssetGraph` showed
drastic reduction in memory
alangenfeld added a commit that referenced this pull request Mar 14, 2024
…#20469)

same logic as #20468

## How I Tested These Changes

existing coverage
PedramNavid pushed a commit that referenced this pull request Mar 28, 2024
…ExternalRepository (#20468)

`RemoteAssetGraph` is a relatively heavy object. Given a large asset
graph, if any code ends up creating copies on the order of number of
assets, it can be very expensive.

We already do a good job of memoizing `ExternalRepository` via
`CodeLocation` via `WorkspaceRequestContext` via
`WorkspaceProcessContext`, so caching these `RemoteAssetGraph` on the
`ExternalRepository` that they are a pure function of should avoid
excess computation and memory until the `WorkspaceProcessContext`
refreshes its snapshots on code server update.

## How I Tested These Changes

existing coverage
a `memray` run of a script doing per asset `RemoteAssetGraph` showed
drastic reduction in memory
PedramNavid pushed a commit that referenced this pull request Mar 28, 2024
…#20469)

same logic as #20468

## How I Tested These Changes

existing coverage
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