Conversation
daemon/daemon.go
Outdated
There was a problem hiding this comment.
It might be good to be more specific in this message to specify what's being migrated and why.
And I'd suggest putting migration log messages at a different log level than "debug", so people can more readily see what's going on.
There was a problem hiding this comment.
The migration logs are at info level. Only the timing stats are on debug level.
There was a problem hiding this comment.
Timing stats could be useful to have at the info level if we're trying to track down performance issues with migration. The log line should only ever be displayed once, so I don't think it would be overly verbose to have it at the info level.
207ab1f to
8ccbb4b
Compare
|
Did some light testing and it's working for me. LGTM |
There was a problem hiding this comment.
Why move this up here? It was originally done inside the transaction after data files has been written to decrease the amount of time this lock needs to be held.
There was a problem hiding this comment.
So you would change getWithoutLock to get. And take the lock again before Commit?
There was a problem hiding this comment.
I would just keep this whole block where it was. The case where the image already exists does mean that we have unnecessarily written out the metadata files but the transaction will clean that up. I would argue it is better to be optimistic here by writing out the files then potentially throwing them away at the end to reduce the time the layer lock is held. Acquiring the lock twice to avoid this just does not seem necessary.
There was a problem hiding this comment.
This function is actually never called in parallel so these locks don't block in migration. Still, it should be correct of course. Copying/writing files when I already know that I won't be using them does not sound like a good idea, especially when this PR is trying to optimize things. I'm fine for the second lock for clarity.
There was a problem hiding this comment.
If when this is run there will not be contention for the adding layers then I am fine with leaving it like this. Two locks mean two existence checks and that is not ideal.
|
Tested migrating with cancellation and restart. LGTM |
layer/layer.go
Outdated
There was a problem hiding this comment.
i would prefer if we put the variable name here too
8ccbb4b to
29dc425
Compare
|
I decided to revert the "direct filesystem access for tar-split in overlay" ba9442574ed8bf8445681ae5a14b2fd486d2c85a , looking at the overlay implementation more closely it didn't really provide much benefits as the graphdriver can itself recognize the case where it doesn't need to mount. It adds a lock(in |
There was a problem hiding this comment.
should we close this data file? I don't see a call to Close anywhere
29dc425 to
ee5d960
Compare
There was a problem hiding this comment.
Could this just be a utility function rather than adding a bool arg here?
so:
w, err := fm.TarSplitWriter()
w = WithCompression(w)There was a problem hiding this comment.
Slight problem with this is that the compressed version is the default that should be always used. Uncompressed (bool=truefalse) is the hack needed for migration.
There was a problem hiding this comment.
Right, so the default would be to use only fm.TarSplitWriter() and for the migration use the helper fn.
Below we'd move the close wrapper to the helper, since that's only needed because of the compression, and return f directly (as an io.WriteCloser).
There was a problem hiding this comment.
Functional args!
type TarSplitOption func(fm *fileMetadataTransaction)
func (fm *fileMetadataTransaction) TarSplitWriter(options ...TarSplitOption) (io.WriteCloser, error) {
for _, opt := range options {
opt(fm)
}
...
}
func CompressInput(fm *fileMetadataTransaction) {
fm.compressInput = true
}There was a problem hiding this comment.
Sorry, I mixed it up. bool=false is the exception for the migration.
There was a problem hiding this comment.
And the issue with bool arguments 😈
There was a problem hiding this comment.
@cpuguy83 I can rewrite it the way @aaronlehmann suggested if you find that cleaner.
There was a problem hiding this comment.
I'm ok with it as is. No need to make such a change for a single option.
df11dae to
46e82f7
Compare
Signed-off-by: Tonis Tiigi <[email protected]>
Signed-off-by: Tonis Tiigi <[email protected]>
46e82f7 to
a8f88ef
Compare
|
Changes LGTM, tested pretty well. |
|
ping @tianon - I think you had a nice big image cache to test this on? |
|
I don't have it handy (it's already long-since migrated now), but the script at https://gist.github.com/tianon/87de734e308da031fb46 should be enough to get a group of images of a sufficient size to be reasonably close to what I was testing with (I had a few more images than what this script will pull down, but probably not enough to be "statistically significant"). ie, |
|
@tianon cool! Perhaps we should include that script somewhere in the repository, and keep it for benchmarking? |
|
LGTM |
This PR contains efforts to speed up migration to content addressability. In my testcase the improvement is ~55%.
Layers checksum calculation is separated from migration process so it can be ran on parallel(and in a separate tool). Also changes it so that cancelled migration doesn't start from the beginning again.
Other optimizations include:
io.PipeMost of the improvement is for the tar-split migration. If you have lots of self-built images the improvement is mostly only from parallel processing.
Current state of the external migration tool can be seen in https://github.com/tonistiigi/docker-v1.10-migrator . Please note that I have only manually tested this tool atm.
@aaronlehmann @LK4D4