-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Improved speed of DirectoryResource #21440
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
Conversation
@@ -87,10 +89,12 @@ public function isFresh($timestamp) | |||
continue; | |||
} | |||
|
|||
$newestMTime = max($file->getMTime(), $newestMTime); | |||
if ($file->getMTime() < $timestamp) { | |||
return true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing ;
I doubt this really works. |
@nicolas-grekas With regard to modification time behavior #!/bin/bash
TMPDIR="/tmp/mtime-test/"
TMPFILE="$TMPDIR/test-file"
TMPINNERDIR="$TMPDIR/test-dir/"
TMPINNERFILE="$TMPINNERDIR/test-file"
rm -fr $TMPDIR && mkdir $TMPDIR
CREATIONTIME="$(stat -c %Y $TMPDIR)"
sleep 2
touch $TMPFILE
TOUCHTIME="$(stat -c %Y $TMPDIR)"
if [[ "$CREATIOBTIME" == "$TOUCHTIME" ]]; then
echo ":-( Touching inner file doesn't modify time."
else
echo ":-) Touching inner file modified time!"
fi
echo "Before Time : $CREATIONTIME"
echo -e "After Time : $TOUCHTIME\n"
sleep 2
echo "IDK" > $TMPFILE
MODTIME="$(stat -c %Y $TMPDIR)"
if [[ "$TOUCHTIME" == "$MODTIME" ]]; then
echo ":-( Modifying inner file doesn't modify time."
else
echo ":-) Modifying inner file modified time!"
fi
echo "Before Time : $TOUCHTIME"
echo -e "After Time : $MODTIME\n"
sleep 2
mkdir $TMPINNERDIR
INNERMKDIRTIME="$(stat -c %Y $TMPDIR)"
if [[ "$MODTIME" == "$INNERMKDIRTIME" ]]; then
echo ":-( Creating inner dir doesn't modify time."
else
echo ":-) Creating inner dir modified time!"
fi
echo "After Time : $MODTIME"
echo -e "Before Time : $INNERMKDIRTIME\n"
sleep 2
touch $TMPINNERFILE
INNERFILETIME="$(stat -c %Y $TMPDIR)"
if [[ "$INNERMKDIRTIME" == "$INNERFILETIME" ]]; then
echo ":-( Creating inner^2 file doesn't modify time."
else
echo ":-) Creating inner^2 file modified time!"
fi
echo "Before Time : $INNERMKDIRTIME"
echo "After Time : $INNERFILETIME" Results:
|
executive summary: do you see anything we can improve in DirectoryResource? |
Just gave the class a once-over, and nothing specific jumps out to me. This PR does completely break the test suite, though (in line with what I mentioned above):
|
You could possibly change line 90 to something like if (($fileMTime = $file->getMTime()) > $timestamp) {
return false;
}
$newestMTime = max($fileMTime, $newestMTime); But with regard to this PR, you can never break early with a return of |
Closing a discussed. Thanks for the PR anyway! |
Hm, I wanted to break early when anything found is newer, but this should return false of course, right. We can never quit early with true, but in the end true should be returned. |
This PR was squashed before being merged into the 2.7 branch (closes #21458). Discussion ---------- [Config] Early return for DirectoryResource | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | sure? | BC breaks? | no | Deprecations? | no | Tests pass? | no | Fixed tickets | | Related PRs | #21440 | License | MIT | Doc PR | n/a Alternate PR that implements an early return for `DirectoryResource` to increase the speed on large file sets. We can never return early with `true` without checking all assets within the resource, as the aforementioned referenced PR did; hence this PR takes the counter approach and returns `false` early where appropriate. _Conversation about possible bug at #21458 (comment) Commits ------- d5746ec fix directory resource considers same timestamp not fresh 96107e2 return false early from directory resource
isFresh()
quits as soon as a newer resource is found.