Skip to content

Add remote.Reuse for Pusher/Puller#1672

Merged
jonjohnsonjr merged 5 commits intogoogle:mainfrom
jonjohnsonjr:reuse
Apr 25, 2023
Merged

Add remote.Reuse for Pusher/Puller#1672
jonjohnsonjr merged 5 commits intogoogle:mainfrom
jonjohnsonjr:reuse

Conversation

@jonjohnsonjr
Copy link
Copy Markdown
Collaborator

This is a big change, but it helps callers out a lot.

The Pusher/Puller interfaces allow us to deduplicate a bunch of work
(largely, ping an auth), but they only work if you actually use them.

It's a huge pain to migrate callers from remote.{Image,Index,...}
interfaces to start using Pusher/Puller because the remote functions can
be called from anywhere, which means plumbing pushers and pullers around
the entire callgraph, which is super painful.

Happily, though, most callers already plumb remote.Options around the
callgraph so that they can set their options in one place and have them
be consistent throughout their application.

This change takes advantage of that fact by introducing remote.Reuse,
which takes either a Puller or a Pusher, and calls equivalent methods on
said pusher/puller whenever you pass remote.Reuse into a remote
function.

The end result is that we can get almost all of the performance wins of
using Puller/Pusher directly with a 3 line change to most applications
rather than refactoring everything.

This package was only used to copy schema 1 images, which we don't need
anymore.
This is a big change, but it helps callers out a lot.

The Pusher/Puller interfaces allow us to deduplicate a bunch of work
(largely, ping an auth), but they only work if you actually use them.

It's a huge pain to migrate callers from remote.{Image,Index,...}
interfaces to start using Pusher/Puller because the remote functions can
be called from anywhere, which means plumbing pushers and pullers around
the entire callgraph, which is super painful.

Happily, though, most callers already plumb remote.Options around the
callgraph so that they can set their options in one place and have them
be consistent throughout their application.

This change takes advantage of that fact by introducing remote.Reuse,
which takes either a Puller or a Pusher, and calls equivalent methods on
said pusher/puller whenever you pass remote.Reuse into a remote
function.

The end result is that we can get almost all of the performance wins of
using Puller/Pusher directly with a 3 line change to most applications
rather than refactoring everything.
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 24, 2023

Codecov Report

Merging #1672 (a65ff5f) into main (07c767c) will increase coverage by 0.90%.
The diff coverage is 72.08%.

@@            Coverage Diff             @@
##             main    #1672      +/-   ##
==========================================
+ Coverage   71.89%   72.79%   +0.90%     
==========================================
  Files         120      120              
  Lines        9833     9599     -234     
==========================================
- Hits         7069     6988      -81     
+ Misses       2046     1935     -111     
+ Partials      718      676      -42     
Impacted Files Coverage Δ
pkg/v1/remote/options.go 71.42% <0.00%> (-4.85%) ⬇️
pkg/crane/options.go 85.24% <50.00%> (-1.20%) ⬇️
pkg/v1/remote/pusher.go 70.00% <55.55%> (+6.80%) ⬆️
pkg/v1/remote/puller.go 69.50% <69.01%> (-3.83%) ⬇️
pkg/v1/remote/referrers.go 65.21% <70.49%> (+25.21%) ⬆️
pkg/v1/remote/fetcher.go 72.72% <72.72%> (ø)
pkg/v1/remote/list.go 68.83% <75.00%> (ø)
pkg/crane/copy.go 70.96% <76.92%> (+10.96%) ⬆️
pkg/v1/remote/catalog.go 59.55% <100.00%> (ø)
pkg/v1/remote/delete.go 50.00% <100.00%> (-7.15%) ⬇️
... and 6 more

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

Copy link
Copy Markdown
Contributor

@imjasonh imjasonh left a comment

Choose a reason for hiding this comment

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

This is awesome. 🔥

@jonjohnsonjr jonjohnsonjr merged commit 005bb71 into google:main Apr 25, 2023
@jonjohnsonjr jonjohnsonjr deleted the reuse branch April 25, 2023 16:16
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.

3 participants