Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
SimonHeimberg wants to merge1 commit intosymfony:masterfromSimonHeimberg:patch-1

Conversation

@SimonHeimberg
Copy link
Contributor

QA
Branch?master
Bug fix?no
New feature?no
BC breaks?no
Deprecations?no
Tests pass??
Fixed tickets
LicenseMIT
Doc PR

isFresh() quits as soon as a newer resource is found.

chalasr reacted with thumbs up emojirobfrawley reacted with confused emoji

$newestMTime =max($file->getMTime(),$newestMTime);
if ($file->getMTime() <$timestamp) {
returntrue
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

missing;

@nicolas-grekas
Copy link
Member

I doubt this really works.
To my knowledge, the mtime of directories is not changed when a nested file is changed.

@nicolas-grekasnicolas-grekas added this to the3.x milestoneJan 29, 2017
@robfrawley
Copy link
Contributor

@nicolas-grekas With regard to modification time behavior

#!/bin/bashTMPDIR="/tmp/mtime-test/"TMPFILE="$TMPDIR/test-file"TMPINNERDIR="$TMPDIR/test-dir/"TMPINNERFILE="$TMPINNERDIR/test-file"rm -fr$TMPDIR&& mkdir$TMPDIRCREATIONTIME="$(stat -c %Y$TMPDIR)"sleep 2touch$TMPFILETOUCHTIME="$(stat -c %Y$TMPDIR)"if [["$CREATIOBTIME"=="$TOUCHTIME" ]];thenecho":-( Touching inner file doesn't modify time."elseecho":-) Touching inner file modified time!"fiecho"Before Time :$CREATIONTIME"echo -e"After Time  :$TOUCHTIME\n"sleep 2echo"IDK">$TMPFILEMODTIME="$(stat -c %Y$TMPDIR)"if [["$TOUCHTIME"=="$MODTIME" ]];thenecho":-( Modifying inner file doesn't modify time."elseecho":-) Modifying inner file modified time!"fiecho"Before Time :$TOUCHTIME"echo -e"After Time  :$MODTIME\n"sleep 2mkdir$TMPINNERDIRINNERMKDIRTIME="$(stat -c %Y$TMPDIR)"if [["$MODTIME"=="$INNERMKDIRTIME" ]];thenecho":-( Creating inner dir doesn't modify time."elseecho":-) Creating inner dir modified time!"fiecho"After Time  :$MODTIME"echo -e"Before Time :$INNERMKDIRTIME\n"sleep 2touch$TMPINNERFILEINNERFILETIME="$(stat -c %Y$TMPDIR)"if [["$INNERMKDIRTIME"=="$INNERFILETIME" ]];thenecho":-( Creating inner^2 file doesn't modify time."elseecho":-) Creating inner^2 file modified time!"fiecho"Before Time :$INNERMKDIRTIME"echo"After Time  :$INNERFILETIME"

Results:

:-) Touching inner file modified time!Before Time : 1485721881After Time  : 1485721883:-( Modifying inner file doesn't modify time.Before Time : 1485721883After Time  : 1485721883:-) Creating inner dir modified time!After Time  : 1485721883Before Time : 1485721887:-( Creating inner^2 file doesn't modify time.Before Time : 1485721887After Time  : 1485721887

@nicolas-grekas
Copy link
Member

executive summary: do you see anything we can improve in DirectoryResource?

@robfrawley
Copy link
Contributor

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):

# vendor/bin/phpunit src/Symfony/Component/Config/Tests/Resource/DirectoryResourceTest.phpClock-mocked namespaces for SymfonyTestsListener need to be nested in a "time-sensitive" key. This will be enforced in Symfony 4.0.PHPUnit 5.7.4-9-g94cec03 by Sebastian Bergmann and contributors.Testing Symfony\Component\Config\Tests\Resource\DirectoryResourceTest.....FF...FF.F...                                                 17 / 17 (100%)Time: 185 ms, Memory: 4.00MBThere were 5 failures:1) Symfony\Component\Config\Tests\Resource\DirectoryResourceTest::testIsFreshUpdateFile->isFresh() returns false if an existing file is modifiedFailed asserting that true is false./home/rmf/repositories/symfony/symfony/src/Symfony/Component/Config/Tests/Resource/DirectoryResourceTest.php:932) Symfony\Component\Config\Tests\Resource\DirectoryResourceTest::testIsFreshNewFile->isFresh() returns false if a new file is addedFailed asserting that true is false./home/rmf/repositories/symfony/symfony/src/Symfony/Component/Config/Tests/Resource/DirectoryResourceTest.php:1003) Symfony\Component\Config\Tests\Resource\DirectoryResourceTest::testIsFreshCreateFileInSubdirectory->isFresh() returns false if a new file in a subdirectory is addedFailed asserting that true is false./home/rmf/repositories/symfony/symfony/src/Symfony/Component/Config/Tests/Resource/DirectoryResourceTest.php:1334) Symfony\Component\Config\Tests\Resource\DirectoryResourceTest::testIsFreshModifySubdirectory->isFresh() returns false if a subdirectory is modified (e.g. a file gets deleted)Failed asserting that true is false./home/rmf/repositories/symfony/symfony/src/Symfony/Component/Config/Tests/Resource/DirectoryResourceTest.php:1445) Symfony\Component\Config\Tests\Resource\DirectoryResourceTest::testFilterRegexListMatch->isFresh() returns false if an new file matching the filter regex is created Failed asserting that true is false./home/rmf/repositories/symfony/symfony/src/Symfony/Component/Config/Tests/Resource/DirectoryResourceTest.php:160FAILURES!Tests: 17, Assertions: 20, Failures: 5.

@robfrawley
Copy link
Contributor

You could possibly change line 90 to something like

if (($fileMTime =$file->getMTime()) >$timestamp) {returnfalse;            }$newestMTime =max($fileMTime,$newestMTime);

But with regard to this PR, you cannever break early with a return oftrue without checking every other file for freshness, right?

@nicolas-grekas
Copy link
Member

Closing a discussed. Thanks for the PR anyway!

@SimonHeimberg
Copy link
ContributorAuthor

Hm, I wanted to break early when anything found is newer, but this should returnfalse of course, right. We can never quit early with true, but in the end true should be returned.
Replacing trying with thinking is not easy. And I have forgotten to check the test run results when they were ready.
Thanks.

fabpot added a commit that referenced this pull requestFeb 12, 2017
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/aAlternate 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 fresh96107e2 return false early from directory resource
@nicolas-grekasnicolas-grekas modified the milestones:3.x,3.3Mar 24, 2017
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@fabpotfabpotfabpot left review comments

Assignees

No one assigned

Projects

None yet

Milestone

3.3

Development

Successfully merging this pull request may close these issues.

5 participants

@SimonHeimberg@nicolas-grekas@robfrawley@fabpot@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp