-
Notifications
You must be signed in to change notification settings - Fork 75
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
Is there any option to improve performace in multi-core envir. #13
Comments
Not for now, but this is definitely on my list. |
Leanifying PNG takes a long time, as well as DOCX files containing PNG. |
docx is slow because it's a zip file, and it uses zopfli to optimize. |
@JayXon Exactly, can I leanify all files in DOCX(ZIP) except PNG? Another question, interruptting the process of leanifying a DOCX may damage the file. |
It still makes the result larger though. Yes, interrupting leanify may damage the file because it's using file mapping. |
The more general solution is to use a file type filter. The option could be -i png. |
If I add |
I think multi-process couple of files would be easiest way to improve performance without rebuild internal algorithms |
I considered processing multiple files at the same time if more than one file is given to leanify or a zip file has multiple files inside but the problem with that is stdout will be a mess. |
@JayXon An optimized version like @MrKrzYch00's fork is multi-threaded & would solve that for you. |
His fork is using pthread which is not standard C/C++, so it won't compile in Visual Studio. |
https://stackoverflow.com/questions/28975700/how-to-add-pthread-library-to-c-project-in-visual-studio-community-edition seems to have a solution for that, but I'm unsure if that would introduce the need for a DLL dependency, or could be done for |
Maybe leanify.exe can run as a host or dispatcher when several file path arguments passed to it, which will start several sub-processes with console processing each file, to make full use of CPU cores. |
@JayXon now it uses WIN32 threads. However I'm not sure if HANDLE, DWORD WINAPI, CreateThread, SetThreadAffinityMask is supported the same way on Visual Studio as it is in GCC's windows.h. If it is and VS can handle "#ifdef _WIN32" the same way GCC does then it may be able to compile? Also there weren't a lot of changes needed to be done to have windows exception for this, at least in GCC. Said so, my multi-threading may be kind of messy... but it works! :) Also beware of --all, it's actually not supported by my fork and may be removed as I think it is the cause of some memory leaking going on. --testrec and using all modes separately might be superior (needs verification), which is also multi-threaded starting from v18.2.13. |
At least, you can fork() on PNGs in .docx|.pptx|(.pdf). Every proccessed PNG only outputs one line to stdout, so it wont make a mess and you would waitpid() for all threads before finishing up the file. |
I'm working on multicore leanifying using https://github.com/taskflow/taskflow library. Everything is working fine now, but I need more time to cleanup code and fix console outputs. |
Everything is merged. You can use it with |
Anyone got any benchmarks? @JayXon Any plans for official binaries for such a monumental release? |
I still need to update some libraries and I'll cut a new release after that. Do note that this is only parallel on the file level, so it only works if you pass leanify multiple files or a directory. |
@TPS did you try nightly builds for parallel leanifying? |
@doterax No, I use leanify solely via various FileOptimizer toolchains, which run 1 file @ a time, so this improvement would do nothing there currently. |
@JayXon you can use external |
Optipng and it's Rust's port oxipng use deflate as a compression algorithm. Leanify, in other hands, uses zopfly as a compression algorithm with a better compression results. |
Okay, as I understand the minimal size of the produced artifact is more important than time spent for optimization, thus zopfli would be better despite taking drastically more time. |
You can use --parallel switch to distribute processing of files between CPUs. But this doesn't work for a single file. You should provide a batch of files to process. |
How can I make use of all the CPU cores?
Is there any simple way?
The text was updated successfully, but these errors were encountered: