[MDEV-11827] Use NTFS compression for page compression in Innodb/XtraDB Created: 2017-01-17 Updated: 2022-07-08 Resolved: 2022-07-08 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Storage Engine - InnoDB |
| Fix Version/s: | N/A |
| Type: | Task | Priority: | Major |
| Reporter: | Vladislav Vaintroub | Assignee: | Unassigned |
| Resolution: | Won't Do | Votes: | 0 |
| Labels: | None | ||
| Sprint: | 10.2.4-1, 10.2.4-2 |
| Description |
|
There are currently 2 implementations of the "trim" functionality in MariaDB
There is however a much simpler possible implementation based on NTFS transparent compression DeviceIoControl(FSCTL_SET_COMPRESSION). It works similarly to the homebrew innodb compression, and similar to sparse files, in that it does not allocate space in FS if blocks can be compressed. Besides sparse file optimization (compressing runs of 0 bytes), it also features data compression, is optimized for random IO, and space savings can actually be seen in explorer, or programmatically retrieved with GetCompressedFileSize(). The downside is that file gets fragmented, but this is the problem any sparse file implementation, and "punch hole" will have to face. The purpose of this work is to enable NTFS file compression whenever PAGE_COMPRESSED option is used during CREATE TABLE, or ALTER TABLE. Handling encryption with compression. Usually, the intended use of compression on Windows would be this . User enables PAGE_COMPRESSION=1, but sets innodb_compression_algorithm=none. The DeviceIoControl(FSCTL_SET_COMPRESSION) will ensure that it is NTFS that actually compressed the data, and does the "trim". There will be no homebrew compression inside Innodb in this case. However, if data is encrypted, it won't compressing well. In this case, user would need to set innodb_compression_algorithm=zlib, so innodb compressed data. NTFS compression in this case would not be able to compress already compressed data. However, it still can handle runs of binary zeros, so it will do the "trim" functionality. My tests verified that NTFS compression on top of Innodb compression works alright, and is able to save about the same (or even slightly more) space as NTFS compression alone. This, at least in theory, should add a little overhead on NTFS side (it would be trying unsuccessfully to compress already compressed data), that needs to be measured. |
| Comments |
| Comment by Vladislav Vaintroub [ 2022-07-08 ] |
|
It seems much easier to do that (transparently compress and uncompress) using "compact.exe" windows utility, than to squeeze it into Innodb and give it an "ALTER TABLE" SQL interface. Closing for now, could be reconsidered, if there is a substantial user interest. |