Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
iSulad-img
提交
62353c9b
I
iSulad-img
项目概览
openeuler
/
iSulad-img
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
iSulad-img
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
62353c9b
编写于
6月 29, 2020
作者:
O
openeuler-ci-bot
提交者:
Gitee
6月 29, 2020
浏览文件
操作
浏览文件
下载
差异文件
!50 use function DecompressStream to decompress to speed up
Merge pull request !50 from wangfengtu/fast_load
上级
8767d1a1
58204ac6
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
154 addition
and
1 deletion
+154
-1
iSulad-img.spec
iSulad-img.spec
+1
-1
patch/0058-use-function-DecompressStream-to-decompress-to-speed.patch
...se-function-DecompressStream-to-decompress-to-speed.patch
+152
-0
patch/series-patch.conf
patch/series-patch.conf
+1
-0
未找到文件。
iSulad-img.spec
浏览文件 @
62353c9b
%global _version 2.0.0
%global _release 202006
19.162225.gitb2154cf4
%global _release 202006
29.162148.git8767d1a1
Name: iSulad-img
Version: %{_version}
Release: %{_release}
...
...
patch/0058-use-function-DecompressStream-to-decompress-to-speed.patch
0 → 100644
浏览文件 @
62353c9b
From 0f8d19210ce69278b5c876c49a9cddb5af82c58f Mon Sep 17 00:00:00 2001
From: WangFengTu <wangfengtu@huawei.com>
Date: Mon, 29 Jun 2020 15:00:48 +0800
Subject: [PATCH] use function DecompressStream to decompress to speed up
Signed-off-by: WangFengTu <wangfengtu@huawei.com>
---
.../github.com/containers/image/copy/copy.go | 4 ++-
.../containers/image/docker/tarfile/src.go | 31 +++++++++++--------
.../containers/image/tarball/tarball_src.go | 21 +++++--------
3 files changed, 29 insertions(+), 27 deletions(-)
diff --git a/vendor/github.com/containers/image/copy/copy.go b/vendor/github.com/containers/image/copy/copy.go
index da119d5..0b5399c 100644
--- a/vendor/github.com/containers/image/copy/copy.go
+++ b/vendor/github.com/containers/image/copy/copy.go
@@ -20,6 +20,7 @@
import (
"github.com/containers/image/signature"
"github.com/containers/image/transports"
"github.com/containers/image/types"
+ "github.com/containers/storage/pkg/archive"
"github.com/klauspost/pgzip"
"github.com/opencontainers/go-digest"
"github.com/pkg/errors"
@@ -741,7 +742,8 @@
func diffIDComputationGoroutine(dest chan<- diffIDResult, layerStream io.ReadClo
// computeDiffID reads all input from layerStream, uncompresses it using decompressor if necessary, and returns its digest.
func computeDiffID(stream io.Reader, decompressor compression.DecompressorFunc) (digest.Digest, error) {
if decompressor != nil {
- s, err := decompressor(stream)
+ // decompressor is too slow, DecompressStream is faster
+ s, err := archive.DecompressStream(stream)
if err != nil {
return "", err
}
diff --git a/vendor/github.com/containers/image/docker/tarfile/src.go b/vendor/github.com/containers/image/docker/tarfile/src.go
index c8b4f4e..1743ae7 100644
--- a/vendor/github.com/containers/image/docker/tarfile/src.go
+++ b/vendor/github.com/containers/image/docker/tarfile/src.go
@@ -17,6 +17,7 @@
import (
"github.com/containers/image/manifest"
"github.com/containers/image/pkg/compression"
"github.com/containers/image/types"
+ "github.com/containers/storage/pkg/archive"
"github.com/opencontainers/go-digest"
"github.com/pkg/errors"
)
@@ -56,21 +57,34 @@
func NewSourceFromFile(path, repoTag string) (*Source, error) {
if err != nil {
return nil, errors.Wrapf(err, "error opening file %q", path)
}
- defer file.Close()
// If the file is already not compressed we can just return the file itself
// as a source. Otherwise we pass the stream to NewSourceFromStream.
- stream, isCompressed, err := compression.AutoDecompress(file)
+ _, isCompressed, err := compression.AutoDecompress(file)
if err != nil {
+ file.Close()
return nil, errors.Wrapf(err, "Error detecting compression for file %q", path)
}
- defer stream.Close()
+ file.Close()
if !isCompressed {
return &Source{
tarPath: path,
repoTag: repoTag,
}, nil
}
+
+ file, err = os.Open(path)
+ if err != nil {
+ return nil, errors.Wrapf(err, "error opening file %v", path)
+ }
+ defer file.Close()
+
+ stream, err := archive.DecompressStream(file)
+ if err != nil {
+ return nil, errors.Wrapf(err, "Error decompression file %v", path)
+ }
+ defer stream.Close()
+
return NewSourceFromStream(stream, repoTag)
}
@@ -93,20 +107,11 @@
func NewSourceFromStream(inputStream io.Reader, repoTag string) (*Source, error)
}
}()
- // In order to be compatible with docker-load, we need to support
- // auto-decompression (it's also a nice quality-of-life thing to avoid
- // giving users really confusing "invalid tar header" errors).
- uncompressedStream, _, err := compression.AutoDecompress(inputStream)
- if err != nil {
- return nil, errors.Wrap(err, "Error auto-decompressing input")
- }
- defer uncompressedStream.Close()
-
// Copy the plain archive to the temporary file.
//
// TODO: This can take quite some time, and should ideally be cancellable
// using a context.Context.
- if _, err := io.Copy(tarCopyFile, uncompressedStream); err != nil {
+ if _, err := io.Copy(tarCopyFile, inputStream); err != nil {
return nil, errors.Wrapf(err, "error copying contents to temporary file %q", tarCopyFile.Name())
}
succeeded = true
diff --git a/vendor/github.com/containers/image/tarball/tarball_src.go b/vendor/github.com/containers/image/tarball/tarball_src.go
index a3c5453..4c25d78 100644
--- a/vendor/github.com/containers/image/tarball/tarball_src.go
+++ b/vendor/github.com/containers/image/tarball/tarball_src.go
@@ -12,8 +12,8 @@
import (
"strings"
"time"
- "github.com/containers/image/pkg/compression"
"github.com/containers/image/types"
+ "github.com/containers/storage/pkg/archive"
digest "github.com/opencontainers/go-digest"
imgspecs "github.com/opencontainers/image-spec/specs-go"
imgspecv1 "github.com/opencontainers/image-spec/specs-go/v1"
@@ -71,21 +71,16 @@
func (r *tarballReference) NewImageSource(ctx context.Context, sys *types.System
blobIDdigester := digest.Canonical.Digester()
reader = io.TeeReader(reader, blobIDdigester.Hash())
- // Set up to digest the file after we maybe decompress it.
- diffIDdigester := digest.Canonical.Digester()
- uncompressed, iscompressed, err := compression.AutoDecompress(reader)
+ uncompressed, err := archive.DecompressStream(reader)
if err != nil {
- return nil, fmt.Errorf("error decompress %q: %v", filename, err)
+ return nil, fmt.Errorf("error decompression file %v: %v", filename, err)
}
defer uncompressed.Close()
- if iscompressed {
- // It is compressed, so the diffID is the digest of the uncompressed version
- reader = io.TeeReader(uncompressed, diffIDdigester.Hash())
- } else {
- // It is not compressed, so the diffID and the blobID are going to be the same
- diffIDdigester = blobIDdigester
- uncompressed = nil
- }
+
+ // It is compressed, so the diffID is the digest of the uncompressed version
+ diffIDdigester := digest.Canonical.Digester()
+ reader = io.TeeReader(uncompressed, diffIDdigester.Hash())
+
// TODO: This can take quite some time, and should ideally be cancellable using ctx.Done().
n, err := io.Copy(ioutil.Discard, reader)
if err != nil {
--
2.20.1
patch/series-patch.conf
浏览文件 @
62353c9b
...
...
@@ -55,3 +55,4 @@
0055
-
Change
-
copyright
-
from
-
MulanPSL
-
to
-
MulanPSL2
.
patch
0056
-
make
-
sure
-
created
-
time
-
is
-
larger
-
or
-
equal
-
than
-
1970
.
patch
0057
-
support
-
more
-
compressed
-
type
-
when
-
import
-
tarball
.
patch
0058
-
use
-
function
-
DecompressStream
-
to
-
decompress
-
to
-
speed
.
patch
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录