зеркало из https://github.com/microsoft/docker.git
daemon: faster image cache miss detection
Lookup the graph parent reference to detect a builder cache miss before looping the whole graph image index to build a parent-children tree. Signed-off-by: Antonio Murdaca <runcom@redhat.com>
This commit is contained in:
Родитель
56f5e3459f
Коммит
f9e81b40f4
|
@ -1147,6 +1147,14 @@ func (daemon *Daemon) GetRemappedUIDGID() (int, int) {
|
|||
// created. nil is returned if a child cannot be found. An error is
|
||||
// returned if the parent image cannot be found.
|
||||
func (daemon *Daemon) ImageGetCached(imgID string, config *runconfig.Config) (*image.Image, error) {
|
||||
// for now just exit if imgID has no children.
|
||||
// maybe parentRefs in graph could be used to store
|
||||
// the Image obj children for faster lookup below but this can
|
||||
// be quite memory hungry.
|
||||
if !daemon.Graph().HasChildren(imgID) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// Retrieve all images
|
||||
images := daemon.Graph().Map()
|
||||
|
||||
|
|
|
@ -337,5 +337,5 @@ func (daemon *Daemon) checkImageDeleteSoftConflict(img *image.Image) *imageDelet
|
|||
// that there are no repository references to the given image and it has no
|
||||
// child images.
|
||||
func (daemon *Daemon) imageIsDangling(img *image.Image) bool {
|
||||
return !(daemon.Repositories().HasReferences(img) || daemon.Graph().HasChildren(img.ID))
|
||||
return !(daemon.repositories.HasReferences(img) || daemon.Graph().HasChildren(img.ID))
|
||||
}
|
||||
|
|
|
@ -512,8 +512,7 @@ func (graph *Graph) Release(sessionID string, layerIDs ...string) {
|
|||
func (graph *Graph) Heads() map[string]*image.Image {
|
||||
heads := make(map[string]*image.Image)
|
||||
graph.walkAll(func(image *image.Image) {
|
||||
// If it's not in the byParent lookup table, then
|
||||
// it's not a parent -> so it's a head!
|
||||
// if it has no children, then it's not a parent, so it's an head
|
||||
if !graph.HasChildren(image.ID) {
|
||||
heads[image.ID] = image
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче