Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-T LZVN doesn't work #29

Open
lucianmarin opened this issue Jun 9, 2019 · 38 comments
Open

-T LZVN doesn't work #29

lucianmarin opened this issue Jun 9, 2019 · 38 comments

Comments

@lucianmarin
Copy link

afsctool -T LZVN -c /path/to/random/file
/path/to/random/file: unsupported compression type 2 bytes
Unable to compress file (already compressed).

I think LZVN support is enabled (cmake LZVN repo then cmake afsctool), but it doesn't seem to work on High Sierra.

@lucianmarin lucianmarin changed the title -T LZVN -T LZVN doesn't work Jun 9, 2019
@RJVB
Copy link
Owner

RJVB commented Jun 9, 2019 via email

@lucianmarin
Copy link
Author

lucianmarin commented Jun 9, 2019

make install LZVN

Install the project...
/usr/local/Cellar/cmake/3.13.2/bin/cmake -P cmake_install.cmake
-- Install configuration: ""
-- Up-to-date: /usr/local/lib/libFastCompression.1.0.dylib
-- Up-to-date: /usr/local/lib/libFastCompression.1.dylib
-- Up-to-date: /usr/local/lib/libFastCompression.dylib
-- Up-to-date: /usr/local/lib/libFastCompression.a
/Library/Developer/CommandLineTools/usr/bin/ranlib: file: /usr/local/lib/libFastCompression.a(liblzvn.c.o) has no symbols
-- Up-to-date: /usr/local/bin/lzvn
-- Up-to-date: /usr/local/include/lzvn.h
-- Up-to-date: /usr/local/include/FastCompression.h

cmake -Wno-dev .. afsctool (after last git pull)

-- LZVN_HEADER,LIB: /usr/local/include/FastCompression.h /usr/local/lib/libFastCompression.dylib
-- Enabling LZVN support
-- Setting afsctool version to: 1.6.9. (1.6.8.6-127-g731aeaa)

Later edit: seems to work when I do cmake .. instead of cmake -Wno-dev .. and make install instead of make install/fast for both projects.

afsctool -v afsctool
File is HFS+/APFS compressed.
Compression type: LZVN in resource fork (8)
Compression savings: 71.0%

@lucianmarin
Copy link
Author

lucianmarin commented Jun 9, 2019

Can you make LZVN the default compression format if support is enabled?

afsctool -c afsctool
afsctool -v afsctool
File is HFS+/APFS compressed.
Compression type: ZLIB in resource fork (4)
Compression savings: 73.6%

I also get lzvn compression failed on chunk #0 on some files if they were previously ZLIB compressed then decompressed then compressed with LZVN. ZLIB works on those files, but LZVN doesn't. They are too tiny for LZVN compression. lzvn infile outfile produces a 0 bytes outfile.

@RJVB
Copy link
Owner

RJVB commented Jun 9, 2019 via email

@gingerbeardman
Copy link
Contributor

gingerbeardman commented Jun 10, 2019

LZVN works for me on High Sierra, so you'll need to check that you are compiling afsctool correctly.

I use:

afsctool -c -T LZVN "$@"

I'm using afsctool 1.6.9. (1.6.8.6-125-ge269dbf) as I've not built a new version in a while.

@RJVB
Copy link
Owner

RJVB commented Jun 10, 2019

I also get lzvn compression failed on chunk #0 on some files if they were previously ZLIB compressed then decompressed then compressed with LZVN. ZLIB works on those files, but LZVN doesn't. They are too tiny for LZVN compression. lzvn infile outfile produces a 0 bytes outfile.

I didn't notice this part. I'd need to have one of those files to do some testing, but if lzvn fails itself there probably isn't much I can do about that.

I don't really get why you'd want to recompress files with LZVN though. In every test I did it compresses less well than (higher levels of) ZLIB. It may decompress faster, but do you really notice that IRL? OS X has a rather agressive file cache, and to the best of my knowledge this comes after the file system (i.e. it caches data after "HFS decompression").

@gingerbeardman
Copy link
Contributor

FWIW I use LZVN because macOS App Store uses LZVN, and I mainly compress apps so I want to keep things the same as those apps.

@RJVB
Copy link
Owner

RJVB commented Jun 10, 2019 via email

@gingerbeardman
Copy link
Contributor

gingerbeardman commented Jun 10, 2019

I read that here the other day, and I countered by saying that Apple ship their OS and apps from the Mac App Store with HFS+ compression turned on, so I don't really see the reasoning?

My reason is not to "do it like Apple" but so that my scripts and workflow do not undo what Apple have done and then redo with the same. Also, LZVN is more efficient in terms of speed and CPU usage, so I don't notice when it's working in the background (compared to ZLIB that makes my fans go crazy). But, yes, whatever works for each of us.

Also, try FSNotes for an app that gives this:

/Applications/FSNotes.app/Contents/Resources/de.lproj/InfoPlist.strings: lzvn compression failed on chunk #0

@lucianmarin
Copy link
Author

Also, try FSNotes for an app that gives this:

/Applications/FSNotes.app/Contents/Resources/de.lproj/InfoPlist.strings: lzvn compression failed on chunk #0

I can confirm this on multiple apps. LZVN utility produces 0 bytes output on the same files.

@RJVB
Copy link
Owner

RJVB commented Jun 10, 2019 via email

@gingerbeardman
Copy link
Contributor

Thanks René!

@gingerbeardman
Copy link
Contributor

gingerbeardman commented Jun 10, 2019

define for LZVN_MINIMUM_COMPRESSABLE_SIZE is missing in latest commit
make sure you pull, build and install the latest LZVN

@malthe
Copy link

malthe commented Jan 19, 2021

Now we just need ARM-support for LZVN :-)

@RJVB
Copy link
Owner

RJVB commented Jan 19, 2021 via email

@malthe
Copy link

malthe commented Jan 19, 2021

In the library yeah – there's lots of assembly code in there.

@RJVB
Copy link
Owner

RJVB commented Jan 20, 2021 via email

@RJVB
Copy link
Owner

RJVB commented Jan 20, 2021 via email

@malthe
Copy link

malthe commented Jan 20, 2021

@RJVB works perfectly.

@RJVB
Copy link
Owner

RJVB commented Jan 20, 2021 via email

@malthe
Copy link

malthe commented Jan 20, 2021

It takes quite a while, but this is an 8GB run:

Number of HFS+/APFS compressed files: 140960
Total number of files: 145251
Total number of folders: 20516
Total number of items (number of files + number of folders): 165767
Folder size (uncompressed; reported size by Mac OS 10.6+ Finder): 7840604172 bytes / 8.2 GB (gigabytes, base-10)
Folder size (compressed): 3696919434 bytes / 3.45 GiB
Compression savings: 52.8% over 140960 of 145251 files
Approximate total folder size (files + file overhead + folder overhead): 3704770889 bytes / 3.45 GiB

(Both LZVN and LZFSE tested.)

@RJVB
Copy link
Owner

RJVB commented Jan 20, 2021 via email

@gingerbeardman
Copy link
Contributor

@malthe off-topic, slightly, but regarding your (old) blog post: https://maltheborch.com/#using-built-in-transparent-compression-on-macos ditto is in-built tool that can do this (HFS+ in-place compression) to a degree, and Apple do it for all system files in an install and all apps installed/updated using the Mac App Store. Just an FYI

@malthe
Copy link

malthe commented Jan 20, 2021

@gingerbeardman thanks – I was planning to update that post once this is all merged in. Will try and see if I can come up with a command-line for ditto.

@gingerbeardman
Copy link
Contributor

@malthe from man it's ditto --hfsCompression src dest

@malthe
Copy link

malthe commented Jan 21, 2021

@gingerbeardman doesn't work if src is the same as dest though:

<src> and <dest> are identical (not copied).

@gingerbeardman
Copy link
Contributor

ah yes, you have to do a dance through a temporary file

@RJVB
Copy link
Owner

RJVB commented Jan 21, 2021 via email

@gingerbeardman
Copy link
Contributor

gingerbeardman commented Jan 21, 2021

I've heard that before, but my counter is that they apply this to the system and Mac App Store so they're doing more than nothing.

I do think they should enable it by default but there are so many issues that would raise.

Apple storage is pretty reasonable price these days.

@gingerbeardman
Copy link
Contributor

Oh, and I use CleanMyMac to trim language files which still works well.

Screen shot 2021-01-21 at 11 21 27

@RJVB
Copy link
Owner

RJVB commented Jan 21, 2021 via email

@gingerbeardman
Copy link
Contributor

gingerbeardman commented Jan 21, 2021

I presume "CleanMyMac" only removes language resources that are not inside app bundles, and possibly from apps that aren't signed (or are known not to be crippled when they lose their signing)?

I'd say: you presume too much :)

Well, I just installed OmniGraffle from the Mac App Store and it stripped the localisation out of that with no effect on the running of the app.

Screen shot 2021-01-21 at 12 47 45

before
Screen shot 2021-01-21 at 12 48 06

after
Screen shot 2021-01-21 at 12 48 38

@RJVB
Copy link
Owner

RJVB commented Jan 21, 2021 via email

@Dr-Emann
Copy link
Contributor

BTW, According to libfsapfs (scroll past the table):

If the LZVN compressed data starts with 0x06 (end of stream oppcode) the data is stored uncompressed after the first compressed data byte.

Similar to how an 0xFF prefix can be used for zlib compression to store uncompressed data with only 1 byte overhead.

I think this could be used to handle cases where the last block is too small for LZVN (or if LZVN compression would ever increase the size of the block)

@RJVB
Copy link
Owner

RJVB commented Nov 12, 2022 via email

@Dr-Emann
Copy link
Contributor

It looks like it's currently handled by rejecting the whole file:

afsctool/src/afsctool.c

Lines 239 to 246 in cadc2a3

if (comptype == LZVN){
int lastChunkSize = inFileInfo->st_size % 0x10000;
if (lastChunkSize > 0 && lastChunkSize < LZVN_ENCODE_MIN_SRC_SIZE) {
if (printVerbose >= 2) {
fprintf( stderr, "\"%s\": file too small or will contain a too small compression chunk (try ZLIB compression)\n",
inFile);
}
return false;

$ truncate -s $((0x10000 + 7)) /tmp/bad_block

$ ./afsctool -c -vvvv -T LZVN /tmp/bad_block
"/tmp/bad_block": file too small or will contain a too small compression chunk (try ZLIB compression)
"/tmp/bad_block": file too small or will contain a too small compression chunk (try ZLIB compression)
/tmp/bad_block:
Unable to compress file.
File content type: public.data
File data fork size (reported size by Mac OS X Finder): 65543 bytes / 70 KB (kilobytes, base-10)
Number of extended attributes: 0
Total size of extended attribute data: 0 bytes
Approximate total file size (data fork + resource fork + EA + EA overhead + file overhead): 69632 bytes / 68 KiB

@RJVB
Copy link
Owner

RJVB commented Nov 12, 2022 via email

@RJVB
Copy link
Owner

RJVB commented Nov 12, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants