Repository navigation
Excludes: During directory traversal, use QRegularExpression - #6063
Conversation
|
Done with a lot of help from @ckamm ! |
49ca551 to
781d704
Compare
There was a problem hiding this comment.
should be using the check for case sensitivity in utility
There was a problem hiding this comment.
My benchmark test shows that this is still significant when there are no exclude. Can they not be put in the regexp?
There was a problem hiding this comment.
I don't understand what you mean? That excluded_common still shows up in benchmarks even when there are no excludes?
There was a problem hiding this comment.
yes exactly. So this part is still slow and perhaps could be improved if merged within the same regexp.
(possibly in another capture?)
Altough i did not test the new patch which check that the file is not starting with . so maybe it is ok.
There was a problem hiding this comment.
could be written:
for (const char *word : win_reserved_words_3)
(less error prone)
There was a problem hiding this comment.
wondering if this should not be a member function of the parsed_traversal_excludes class
781d704 to
e1c625d
Compare
|
@ogoffart updated |
|
From jenkins: |
|
@ogoffart Jenkins passing, review needed:) |
b574e42 to
b61b294
Compare
| void prepare(c_strlist_t *excludes); | ||
|
|
||
| QRegularExpression regexp_exclude; | ||
| c_strlist_t *list_patterns_with_slashes = nullptr; |
There was a problem hiding this comment.
Is this not leaking? Where is it destroyed?
ogoffart
left a comment
There was a problem hiding this comment.
-1 because of the leak.
| QRegularExpression regexp_exclude; | ||
| c_strlist_t *list_patterns_with_slashes = nullptr; | ||
| /* FIXME ^^ at a later point use QRegularExpression too if those become popular */ | ||
| } parsed_traversal_excludes; |
There was a problem hiding this comment.
Maybe this should be a pointer to the ExcludedFiles object instead, and everything should be put in the ExcludeFiles class. This would avoid the leak. Curently , the ~ExcludeFiles take care about destroying the excludes pointer.
Also now i guess we could use QVector instead od c_strlist_t.
|
Also it seems that this does not optimize csync_excluded_no_ctx which is called by ExcludedFiles::isExcluded, this is important as well at startup as it is called for every directory while initiating the file system watcher... (see also #5245 ) |
|
@ogoffart Pushed a fix for the leak. Looks good? PS: I agree with optimizing the _no_ctx too. I don't agree with having the list in |
ogoffart
left a comment
There was a problem hiding this comment.
I don't agree with having the list in Excludes object, it feels weird to have the ownership there. The ownership of something inside CSYNCshould be from CSYNC
well, the question is if it should still be inside CSYNC. Also, the excludes list is already owned by the Excludes obect. The journal is already owned by the folder or the sync engine. And making it a aprt of exclude also means we keep the compled regexp there even between sync.
| /* Only for bnames (not paths) */ | ||
| static QString convertToBnameRegexpSyntax(QString exclude) | ||
| { | ||
| QString s = QRegularExpression::escape(exclude).replace("\\*", ".*").replace("?", "."); |
There was a problem hiding this comment.
? would be escaped to \?, so that's wrong.
Also the [ and ] needs de-escaping, same for {}, these were supported by fnmatch, i don't know if people have used them in expressions.
And the backslashes needs de-escaping ( \\\\ -> \\ ), maybe more. (What if somebody had a pattern to ingore files with a * (yes, you can have files with * on unix), it would look like *\** after escaping it whould be \*\\\*\* and we need to convert it to .*\*.*
There was a problem hiding this comment.
+1 on fixing "?" (and adding tests for it!)
I'm not convinced it's worth it to try to emulate fnmatch behavior completely. For example PathMatchSpec we use on windows also offers quite different matching options.
If we want to be 100% backwards compatible we'll need to introduce a new pattern-prefix character to go into the 'fast regex' codepath and can never get rid of the fnmatch based codepath.
There was a problem hiding this comment.
we would not need a pattern-prefix. We could just detect occurence of [ or { in the pattern and then put them in the slash pattern section. they should be rare anyway.
There was a problem hiding this comment.
@ogoffart True. Minor: { does not seem to have special meaning to fnmatch, only ?, *, [ and escaping. (had to check glibc's fnmatch_loop.c)
| static QString convertToBnameRegexpSyntax(QString exclude) | ||
| { | ||
| QString s = QRegularExpression::escape(exclude).replace("\\*", ".*").replace("?", "."); | ||
| //qDebug() << "Converted pattern" << exclude << "to regex" << s; |
f75fbab to
e01b292
Compare
|
@ogoffart fixup pushed |
|
thanks! will rebase and squash my 3 commits and have @ckamm 's on top |
On Mac, this halves the time spent in csync_excluded_traversal when using check_csync_excluded_performance. A similar performance increase is seen on linux.
e01b292 to
a985b2f
Compare
On my Mac, this halves the time spent in csync_excluded_traversal
when using check_csync_excluded_performance.
On Linux the changes were not so much visible, maybe the fnmatch
there is much faster.