This repository has been archived by the owner on May 6, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 5
feat(snapshot) Compress table files after taking the snapshot #29
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fpacifici
commented
Mar 14, 2021
Comment on lines
+104
to
+112
if table.zip: | ||
logger.debug("Zipping file file for %s", table.table) | ||
with self.__storage.get_table_file( | ||
table.table, dump_format, FileMode.READ | ||
) as uncompressed_file: | ||
with self.__storage.get_table_file( | ||
table.table, dump_format, FileMode.WRITE, zip=True | ||
) as compressed_file: | ||
shutil.copyfileobj(uncompressed_file, compressed_file) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried both writing directly on the gzip file and writing in an uncompressed file and compress it afterwards.
The second won easily in terms of time taken.
evanh
approved these changes
Mar 15, 2021
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Built on top of #28.
In certain cases, it is convenient to zip the table files after writing the snapshot and before using to ingest it somewhere else.
The main use case is when we need to ingest some tables contained in the snapshot via HTTP without the need of any pre-processing (we can do this with clickhouse for some tables like groupedmessages).
When that happens, ingeting a gzip file is a lot cheaper than a decompressed one. The difference in the ingestion time is more than enough to justify the time spent to gzip the file.
This allows the snapshot configuration to define whether a table has to be compressed or not.
The same snapshot can contain compressed and uncompressed table files.
In this current version compression happens for each table before closing the transaction. The transaction is not locking anything though, so this should not be a problem. We could optimize it by closing the transaction first if needed.