Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Hash cache#1896

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
techalchemy merged 3 commits intopypa:masterfromjtratner:hash-cache
Apr 11, 2018
Merged

Hash cache#1896

techalchemy merged 3 commits intopypa:masterfromjtratner:hash-cache
Apr 11, 2018

Conversation

@jtratner
Copy link
Collaborator

Re-use pip's safe file cache to store hash values for packages.

Set up is:

  1. only hash if the remote provides a checksum/hash in URL (e.g.https://pypi.python.org/mypkg/whatever-path.whl#md5=....)
  2. Store hash in a path including the checksum/hash in the URL (again, only if valid)
  3. always return a hash

I will remove print statements before merging.

Gotta think about how to test this too...

@jtratner
Copy link
CollaboratorAuthor

Reduces warm lock time from 13.5 minutes (where hash component took 12-13 minutes) to 1.3 minutes! (of which the hash component takes 30s)

@jtratnerjtratnerforce-pushed thehash-cache branch 2 times, most recently fromed4e4f0 to8950e07CompareApril 4, 2018 04:19
@techalchemy
Copy link
Member

@ncoghlan would you mind giving this a once over for security concerns? This is a sizeable performance gain

@techalchemy
Copy link
Member

@jtratner@vphilippon I see that pip-tools has brought in some local repository hashing upstream, is this going to be impacted by that at all if we bring it over?

seehttps://github.com/jazzband/pip-tools/blob/master/piptools/repositories/local.py#L67-L78 --

defget_hashes(self,ireq):key=key_from_req(ireq.req)existing_pin=self.existing_pins.get(key)ifexisting_pinandireq_satisfied_by_existing_pin(ireq,existing_pin):hashes=existing_pin.options.get('hashes', {})hexdigests=hashes.get(FAVORITE_HASH)ifhexdigests:return {':'.join([FAVORITE_HASH,hexdigest])forhexdigestinhexdigests                }returnself.repository.get_hashes(ireq)

@jtratner
Copy link
CollaboratorAuthor

jtratner commentedApr 6, 2018 via email

I see that pip-tools has brought in some local repository hashing
upstream, is this going to be impacted by that at all if we bring it over?Good point. Aside from making the diff more complicated, I think it’s fine.It’s slightly obscured, but the hash key is based on the full URL includingthe fragment (and is only cached if the fragment provided some kind ofchecksum) so it’s effectively like caching on a web ETag. Ie the serverwould have to be lying to us about the hash, but we are already trustingthe server to give us the right stuff.
On Thu, Apr 5, 2018 at 7:00 PM Dan Ryan ***@***.***> wrote:@jtratner <https://github.com/jtratner>@vphilippon <https://github.com/vphilippon> I see that pip-tools has brought in some local repository hashing upstream, is this going to be impacted by that at all if we bring it over? seehttps://github.com/jazzband/pip-tools/blob/master/piptools/repositories/local.py#L67-L78 -- def get_hashes(self, ireq): key = key_from_req(ireq.req) existing_pin = self.existing_pins.get(key) if existing_pin and ireq_satisfied_by_existing_pin(ireq, existing_pin): hashes = existing_pin.options.get('hashes', {}) hexdigests = hashes.get(FAVORITE_HASH) if hexdigests: return { ':'.join([FAVORITE_HASH, hexdigest]) for hexdigest in hexdigests } return self.repository.get_hashes(ireq) — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#1896 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/ABhjq7K_gEWddCR_Z08-7IOzmWvbONyRks5tlswfgaJpZM4TFUBe> .

@techalchemy
Copy link
Member

Ok let’s get the test fixes finalized (possibly contingent upon integration test failures getting sorted) and then merged and then we can get this and everything else current and tested properly

@ncoghlan
Copy link
Member

+1 from me

  • on the server side, as@jratner notes,pipenv is already trusting that to provide correct artifacts, trusting it for hashes makes sense too. The PEP 503 URL scheme + artifact hashes means that collisions really shouldn't happen (if you wanted to be particularly paranoid, you may decide to reject the use of md5 hashes for caching purposes)
  • locally, you can mess with a build by messing with the lookup cache, but that's already possible by messing directly with pip's caches. Build machines really need to be trusted and secured environments if you're concerned about that kind of attack vector.

@jtratner
Copy link
CollaboratorAuthor

jtratner commentedApr 7, 2018 via email

Once you merge in the fix tests branch I’ll clean this up :)
On Fri, Apr 6, 2018 at 8:45 AM Nick Coghlan ***@***.***> wrote: +1 from me - on the server side, as@jratner <https://github.com/jratner> notes, pipenv is already trusting that to provide correct artifacts, trusting it for hashes makes sense too. The PEP 503 URL scheme + artifact hashes means that collisions really shouldn't happen (if you wanted to be particularly paranoid, you may decide to reject the use of md5 hashes for caching purposes) - locally, you can mess with a build by messing with the lookup cache, but that's already possible by messing directly with pip's caches. Build machines really need to be trusted and secured environments if you're concerned about that kind of attack vector. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#1896 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/ABhjq6fMySAn5k54emnxRw8fwAl01sbiks5tl42NgaJpZM4TFUBe> .
gsemet reacted with thumbs up emoji

@techalchemy
Copy link
Member

plz rebase :D

@techalchemy
Copy link
Member

I merged in master since it was doable automatically although I see now you want to clean this up first so I'll just leave it

@techalchemytechalchemy merged commit6fe401f intopypa:masterApr 11, 2018
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@jtratner@techalchemy@ncoghlan

[8]ページ先頭

©2009-2025 Movatter.jp