-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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
Add tests for function/class declared in a file included repeatedly #7563
Conversation
So the tests need to be skipped if OPcache is not enabled. |
yes |
Even if the extension is loaded, it may not be enabled. |
08aed71
to
1fc627a
Compare
84e0695
to
2f0d35c
Compare
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.
Thanks for the PR! Frankly, I'm not sure whether it makes sense to have these tests, but they don't seem to hurt either.
651c753
to
e1795fe
Compare
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.
This is okay for me.
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.
Including files more than twice is unnecessary.
This is not true, for ex. in PHP 7.4 /w opcache I needed 82 iterations for
I belive this is because some hashmap resize was needed and these tests accounts for that. On linux, the tests are fast, on Windows, include is slower but the tests accounts for that to keep them fast. |
@nikic is the iteration count in the test with this reasoning enoughly justified? |
@cmb69 can these tests be merged? |
I think @nikic is referring to our builds using MSan (and similar) which should be able to detect the memory leaks. As such, neither including more than twice should be necessary, nor checking the memory usage manually. |
I do not think so, this is not related to memory leak of an object instance, but instead of a anonymous class DEFINITION. Correct me if I am wrong, but I do not think this is checked in MSan. Also, as the used memory increase can be observed with much higher include count only, I belive the only way to test it reliably is to test is with reasonable count which caused issues in the prePHP8.1 versions. |
The importance of more than several iterations can be seen in #8078 to detect memory leaks such op_array arena allocation. |
e1795fe
to
153c4ab
Compare
d66436c
to
2cf0a67
Compare
2cf0a67
to
9959470
Compare
9959470
to
17970f0
Compare
Why is this targeting 8.1 and not master? |
because the memory leakage was fixed in PHP 8.1 /w opcache, thus I target the lowest possible branch to assert that behaviour since this version |
Can this PR be merged? It asserts no memory leaking which is quite important feature user may rely on. |
17970f0
to
1bbf4fa
Compare
I would like to summarize this PR:
Given these facts, I would like to have this PR merged as I belive all feedback was addressed. |
@nielsdos @iluuu1994 are you ok to merge these tests? And can they target PHP-8.1? |
I don't know if all the variants are truely necessary, since it is unrelated to dynamic definitions. Other than that I guess testing that opcache doesn't leak this probably makes sense. |
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.
There's too little context to this PR. It's unclear what fix this is trying to test, and whether that's already covered by the tests added at the time.
$m = -1; | ||
$mDiff = -1; | ||
$mPrev = 0; | ||
for ($i = 0; $i < (PHP_OS_FAMILY === 'Windows' ? 1_000 /* include is slow on Windows */ : 20_000); $i++) { |
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.
If 1,000 iterations are enough for Windows, why use 20,000 on others?
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.
On some systems I needed several hundreds iterations to trigger a memory increase. So I figured 20k is good count to test this extensively and keep it still fast (<1 second), in Windows, the repeated include is quite costly, so on Windows, only 1k iterations are tested in hope it will be enough and to keep the test/CI still fast.
1bbf4fa
to
7f54b3d
Compare
This hasn't been answered yet. Do you have a link to the original commit that fixes what we're testing here? |
The explamation is in the tests titles. I do not think this is tested now, thus this PR to assert no memory increase on repeated include with opcache. Once fixed for /wo opcache, |
I hope we can agree memory leaks are not wanted. The current impl. with opcache does not leak, so we test/assert it. For non-opcache we xfail the tests now. I hope this makes sense. |
@iluuu1994 can this PR be merged please? It asserts the expected behaviour - currently with opcache only - discussed in #11975 |
I'm closing this as there is no reason this should target |
Folks, could you please tell me what I could do so that this PR gets merged? Let me know if you have any concerns |
Memory leaks are fixed in PHP 8.1 /w opcache.
Add tests to check if memory does not increase on repeated include so code can rely on it.