Skip to content

Introduce copy_uncompressed_file, for direct copy - #81

Closed
afbjorklund wants to merge 1 commit into
ccache:masterfrom
afbjorklund:uncompressed
Closed

afbjorklund wants to merge 1 commit into
ccache:masterfrom
afbjorklund:uncompressed

Conversation

@afbjorklund

Copy link
Copy Markdown
Contributor

For copying compressed files etc, fall back to the original copy version.
(this is mostly a refactoring, for future features and also optimizations)

@jrosdahl

jrosdahl commented May 23, 2016 •

Copy link
Copy Markdown
Member

I like the idea but not the code duplication. :) Have you checked whether copy_uncompressed_file is measurably faster than copy_file for uncompressed files? Is the potential speedup worth the extra maintenance cost, albeit small?

@afbjorklund

Copy link
Copy Markdown
Contributor Author

Yes and no. It was faster (for the actual file copy), but it didn't make much difference. Basically I just wanted a version without the gzip complexity, especially when adding more compressions to the mix.

To make it really go faster, you would have to resort to a lot of non-portable tricks. And even then you would have to have pretty large files. But some things like preallocating (ftrunc) can be very useful.

See https://github.com/itensionanders/ccache/tree/uncompressed-fast for the stuff involved ?

The new lz4f was at afbjorklund@06d1081#diff-6d7e72ea1ca2b7d0258e568a155084bd
(but should probably be split out to a separate file, much like zlib handles the gzip streams ?)

Another use case was compressed->compressed copy, like done in the "external" branch...

@jrosdahl jrosdahl added the issue: feature New feature label Jun 11, 2016
For copying compressed files etc, fall back to the original copy version.
@afbjorklund

Copy link
Copy Markdown
Contributor Author

Oops, turned out that I missed some error handling when "translating" from gzio to stdio...

@jrosdahl

Copy link
Copy Markdown
Member

Oops, turned out that I missed some error handling when "translating" from gzio to stdio...

Which means? :)

@afbjorklund

Copy link
Copy Markdown
Contributor Author

You could get silent read errors, updated the branch with those checks added though.

Think the test build failed due to a timeout, actually.

@jrosdahl

Copy link
Copy Markdown
Member

OK, but what does it mean from a pull request point of view? Should I drop it?

@afbjorklund

Copy link
Copy Markdown
Contributor Author

I think the name of the new function is awful, so it could probably need some more thought...

But what I wanted to accomplish compared to copy_file was:

  1. Add an option to not decompress the source, in case it was e.g. a manifest being copied it got "corrupted" by being unpacked
  2. Allow for more performant copies by doing "straight" binary copies, like with other buffer sizes or special opeating system features

It coukd definitely need some tests and benchmarks written, either way.

@jrosdahl

jrosdahl commented Jul 30, 2016 •

Copy link
Copy Markdown
Member

Regarding ef2c268: I tried out posix_fadvise and it gave me neither better nor worse performance. However, fallocate gave significantly worse performance (≈15%) on my system.

@afbjorklund

Copy link
Copy Markdown
Contributor Author

I think this code will show up at other places if needed, and the "fast" track really wasn't.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

issue: feature New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants