We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Based on the results of AppImageCommunity/appimaged#53, regular expressions seem to be really CPU intensive.
Hence, we should replace them with something more efficient. Possibly fnmatch(3) would be more efficient (to be verified),
fnmatch(3)
After having replaced regular expressions with something else, please test that
--appimage-extract
*
appimaged
The text was updated successfully, but these errors were encountered:
I've run the following two test programs in a VM (4GiB RAM, 4 CPU cores).
#include <stdio.h> #include <fnmatch.h> #include <stdlib.h> int main(int argc, char* argv[]) { if (argc != 2) { printf("Usage: %s <num rounds>\n", argv[0]); return 2; } const int rounds = atoi(argv[1]); char pattern[] = "abc*nop"; char test[] = "abcdefghijklnmop"; for (int i = 0; i < rounds; ++i) { fnmatch(pattern, test, FNM_PATHNAME); } return 0; }
#include <stdio.h> #include <regex.h> #include <stdlib.h> int main(int argc, char* argv[]) { if (argc != 2) { printf("Usage: %s <num rounds>\n", argv[0]); return 2; } const int rounds = atoi(argv[1]); char pattern[] = "abc.*nop"; char test[] = "abcdefghijklnmop"; for (int i = 0; i < rounds; ++i) { regex_t regex; regcomp(®ex, pattern, /*REG_ICASE |*/ REG_EXTENDED); regmatch_t matches[1]; regexec(®ex, test, 1, matches, 0); regfree(®ex); } return 0; }
The fnmatch based implementation is a lot shorter than the regex based one.
fnmatch
In terms of performance, these are the results for 10.000.000 iterations (both applications compiled using gcc -O0 -o <app> <app>.c):
gcc -O0 -o <app> <app>.c
$ time ./regex 10000000 real 1m54.342s ... $ time ./fnmatch 10000000 real 0.780s
With -O3, the results change to 1m44.257s and 0.738s.
-O3
1m44.257s
0.738s
Sorry, something went wrong.
No branches or pull requests
Based on the results of AppImageCommunity/appimaged#53, regular expressions seem to be really CPU intensive.
Hence, we should replace them with something more efficient. Possibly
fnmatch(3)
would be more efficient (to be verified),After having replaced regular expressions with something else, please test that
--appimage-extract
still works with*
wildcardsappimaged
consumes significantly less CPUThe text was updated successfully, but these errors were encountered: