Skip to content

Commit

Permalink
multithreaded diff
Browse files Browse the repository at this point in the history
Signed-off-by: Naoki MATSUMOTO <[email protected]>
  • Loading branch information
naoki9911 committed Mar 30, 2024
1 parent f70411f commit ca453c9
Show file tree
Hide file tree
Showing 4 changed files with 247 additions and 108 deletions.
42 changes: 38 additions & 4 deletions cmd/ctr-cli/diff/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,31 @@ func DimgCommand() *cli.Command {
Value: false,
Required: false,
},
&cli.IntFlag{
Name: "threadNum",
Usage: "The number of threads to process",
Value: 1,
Required: false,
},
&cli.StringFlag{
Name: "threadSchedMode",
Usage: "Multithread scheduling mode",
Value: "none",
Required: false,
},
},
}

return &cmd
}

func dimgAction(c *cli.Context) error {
logger.Logger.SetLevel(logrus.WarnLevel)
oldDimg := c.String("oldDimg")
newDimg := c.String("newDimg")
outDimg := c.String("outDimg")
mode := c.String("mode")
threadNum := c.Int("threadNum")
threadSchedMode := c.String("threadSchedMode")
enableBench := c.Bool("benchmark")
logger.WithFields(logrus.Fields{
"oldDimg": oldDimg,
Expand All @@ -87,7 +100,11 @@ func dimgAction(c *cli.Context) error {

start := time.Now()

err = image.GenerateDiffFromDimg(oldDimg, newDimg, outDimg, mode == ModeDiffBinary)
dc := image.DiffMultihreadConfig{
ThreadNum: threadNum,
ScheduleMode: threadSchedMode,
}
err = image.GenerateDiffFromDimg(oldDimg, newDimg, outDimg, mode == ModeDiffBinary, dc)
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -147,19 +164,32 @@ func CdimgCommand() *cli.Command {
Value: false,
Required: false,
},
&cli.IntFlag{
Name: "threadNum",
Usage: "The number of threads to process",
Value: 1,
Required: false,
},
&cli.StringFlag{
Name: "threadSchedMode",
Usage: "Multithread scheduling mode",
Value: "none",
Required: false,
},
},
}

return &cmd
}

func cdimgAction(c *cli.Context) error {
logger.Logger.SetLevel(logrus.WarnLevel)
oldCdimg := c.String("oldCdimg")
newCdimg := c.String("newCdimg")
outCdimg := c.String("outCdimg")
mode := c.String("mode")
enableBench := c.Bool("benchmark")
threadNum := c.Int("threadNum")
threadSchedMode := c.String("threadSchedMode")
logger.WithFields(logrus.Fields{
"oldCdimg": oldCdimg,
"newCdimg": newCdimg,
Expand All @@ -183,7 +213,11 @@ func cdimgAction(c *cli.Context) error {

start := time.Now()

err = image.GenerateDiffFromCdimg(oldCdimg, newCdimg, outCdimg, mode == ModeDiffBinary)
dc := image.DiffMultihreadConfig{
ThreadNum: threadNum,
ScheduleMode: threadSchedMode,
}
err = image.GenerateDiffFromCdimg(oldCdimg, newCdimg, outCdimg, mode == ModeDiffBinary, dc)
if err != nil {
panic(err)
}
Expand Down
Loading

0 comments on commit ca453c9

Please sign in to comment.