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

fix: avoid copying Repository mutex state #364

Merged
merged 3 commits into from
Nov 30, 2022

Conversation

abursavich
Copy link
Contributor

The Repository struct contains mutex state (in the sync.Mutex and syncutil.Pool). When converting RepositoryOptions values to Repository values, this mutex state is copied. This change prevents the internal state from being copied by passing RepositoryOptions around by reference and explicitly copying the visible fields.

@abursavich
Copy link
Contributor Author

I considered also copying the referrersState, but I ultimately decided against it since RepositoryOptions blocks the methods on Repository that can mutate it.

@Wwwsylvia
Copy link
Member

The Repository struct contains mutex state (in the sync.Mutex and syncutil.Pool). When converting RepositoryOptions values to Repository values, this mutex state is copied.

Nice catch!

@codecov-commenter
Copy link

codecov-commenter commented Nov 21, 2022

Codecov Report

Merging #364 (ae08840) into main (f09c857) will increase coverage by 0.06%.
The diff coverage is 78.94%.

@@            Coverage Diff             @@
##             main     #364      +/-   ##
==========================================
+ Coverage   72.16%   72.22%   +0.06%     
==========================================
  Files          42       42              
  Lines        4092     4105      +13     
==========================================
+ Hits         2953     2965      +12     
- Misses        857      858       +1     
  Partials      282      282              
Impacted Files Coverage Δ
registry/remote/repository.go 68.56% <77.77%> (+0.17%) ⬆️
registry/remote/registry.go 67.41% <100.00%> (+1.45%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

registry/remote/repository.go Show resolved Hide resolved
go.mod Outdated Show resolved Hide resolved
registry/remote/registry.go Show resolved Hide resolved
registry/remote/registry.go Show resolved Hide resolved
registry/remote/repository.go Show resolved Hide resolved
registry/remote/repository.go Show resolved Hide resolved
go.mod Outdated Show resolved Hide resolved
registry/remote/repository.go Show resolved Hide resolved
@shizhMSFT
Copy link
Contributor

@abursavich Thank you for your contribution and catching this bug. Could you address the review comments accordingly so that we can merged your PR?

Signed-off-by: Andy Bursavich <abursavich@gmail.com>
@abursavich
Copy link
Contributor Author

@shizhMSFT, PTAL.

registry/remote/repository.go Outdated Show resolved Hide resolved
registry/remote/repository.go Outdated Show resolved Hide resolved
registry/remote/repository.go Outdated Show resolved Hide resolved
Copy link
Contributor

@shizhMSFT shizhMSFT left a comment

Choose a reason for hiding this comment

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

LGTM

registry/remote/repository.go Outdated Show resolved Hide resolved
Signed-off-by: Andy Bursavich <abursavich@gmail.com>
Signed-off-by: Andy Bursavich <abursavich@gmail.com>
@abursavich
Copy link
Contributor Author

PTAL

Copy link
Member

@Wwwsylvia Wwwsylvia left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@shizhMSFT shizhMSFT left a comment

Choose a reason for hiding this comment

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

LGTM

@shizhMSFT shizhMSFT merged commit 511e4d4 into oras-project:main Nov 30, 2022
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.

4 participants