[wp-trac] [WordPress Trac] #14889: Memory Comparison Broken / WordPress Memory Limit
WordPress Trac
wp-trac at lists.automattic.com
Wed Jun 8 16:10:54 UTC 2011
#14889: Memory Comparison Broken / WordPress Memory Limit
-----------------------------------------------+---------------------------
Reporter: hakre | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Future
Component: General | Release
Severity: normal | Version: 3.0
Keywords: has-patch 3.2-early needs-testing | Resolution:
-----------------------------------------------+---------------------------
Comment (by hakre):
I updated the benchmark script. I added some side-case values (the
benchmark script does only compares output, so it can not completely check
if the algos properly handle values in full), updated the map() function
to use a static map and to increase it's success rate to 1. Added as well
an str() function for testing.
These results are on a 32bit windows system, 1000000 iterations:
{{{
wp_function => 32M (32M) (no errors) Success
wp_function 2147483648 => 2147483648 (2147483648) (no errors) Success
wp_function 4294967296 => 4294967296 (4294967296) (no errors) Success
wp_function -1 => -1 (32M) (no errors) Fail
wp_function 100 => 32M (100) (no errors) Fail
wp_function 1m => 32M (32M) (no errors) Success
wp_function 7.5G => 7.5G (32M) (no errors) Fail
wp_function 234k => 32M (234k) (no errors) Fail
wp_function 94556M => 94556M (94556M) (no errors) Success
wp_function 128 M => 128 M (128 M) (no errors) Success
wp_function 52428800 => 52428800 (52428800) (no errors) Success
patch_function_original => 32M (32M) (1 errors!) Success
#0: 8 Uninitialized string offset: -1 [...]chrisbliss18-patch-
benchmark.2.php(25)
: runtime-created function
patch_function_original 2147483648 => 2147483648 (32M) (no errors) Fail
patch_function_original 4294967296 => 4294967296 (32M) (no errors) Fail
patch_function_original -1 => -1 (32M) (no errors) Fail
patch_function_original 100 => 32M (32M) (no errors) Success
patch_function_original 1m => 32M (32M) (no errors) Success
patch_function_original 7.5G => 7.5G (32M) (no errors) Fail
patch_function_original 234k => 32M (32M) (no errors) Success
patch_function_original 94556M => 94556M (94556M) (no errors) Success
patch_function_original 128 M => 128 M (128 M) (no errors) Success
patch_function_original 52428800 => 52428800 (32M) (no errors) Fail
patch_function_new => 32M (32M) (no errors) Success
patch_function_new 2147483648 => 2147483648 (2147483648) (no errors)
Success
patch_function_new 4294967296 => 4294967296 (4294967296) (no errors)
Success
patch_function_new -1 => -1 (-1) (no errors) Success
patch_function_new 100 => 32M (32M) (no errors) Success
patch_function_new 1m => 32M (32M) (no errors) Success
patch_function_new 7.5G => 7.5G (7.5G) (no errors) Success
patch_function_new 234k => 32M (32M) (no errors) Success
patch_function_new 94556M => 94556M (94556M) (no errors) Success
patch_function_new 128 M => 128 M (128 M) (no errors) Success
patch_function_new 52428800 => 52428800 (52428800) (no errors) Success
patch_function_new_complete => 32M (32M) (no errors) Success
patch_function_new_complete 2147483648 => 2147483648 (2147483648) (no
errors) Success
patch_function_new_complete 4294967296 => 4294967296 (4294967296) (no
errors) Success
patch_function_new_complete -1 => -1 (-1) (no errors) Success
patch_function_new_complete 100 => 32M (32M) (no errors) Success
patch_function_new_complete 1m => 32M (32M) (no errors) Success
patch_function_new_complete 7.5G => 7.5G (32M) (no errors) Fail
patch_function_new_complete 234k => 32M (32M) (no errors) Success
patch_function_new_complete 94556M => 94556M (94556M) (no errors)
Success
patch_function_new_complete 128 M => 128 M (128 M) (no errors) Success
patch_function_new_complete 52428800 => 52428800 (52428800) (no errors)
Success
wp_convert_hr_to_bytes => 32M () (no errors) Fail
wp_convert_hr_to_bytes 2147483648 => 2147483648 (2147483648) (no errors)
Success
wp_convert_hr_to_bytes 4294967296 => 4294967296 (4294967296) (no errors)
Success
wp_convert_hr_to_bytes -1 => -1 (-1) (no errors) Success
wp_convert_hr_to_bytes 100 => 32M (100) (no errors) Fail
wp_convert_hr_to_bytes 1m => 32M (1m) (no errors) Fail
wp_convert_hr_to_bytes 7.5G => 7.5G (7.5G) (no errors) Success
wp_convert_hr_to_bytes 234k => 32M (234k) (no errors) Fail
wp_convert_hr_to_bytes 94556M => 94556M (94556M) (no errors) Success
wp_convert_hr_to_bytes 128 M => 128 M (128 M) (no errors) Success
wp_convert_hr_to_bytes 52428800 => 52428800 (52428800) (no errors)
Success
map => 32M (32M) (no errors) Success
map 2147483648 => 2147483648 (2147483648) (no errors) Success
map 4294967296 => 4294967296 (4294967296) (no errors) Success
map -1 => -1 (-1) (no errors) Success
map 100 => 32M (32M) (no errors) Success
map 1m => 32M (32M) (no errors) Success
map 7.5G => 7.5G (7.5G) (no errors) Success
map 234k => 32M (32M) (no errors) Success
map 94556M => 94556M (94556M) (no errors) Success
map 128 M => 128 M (128 M) (no errors) Success
map 52428800 => 52428800 (52428800) (no errors) Success
aaron => 32M (32M) (no errors) Success
aaron 2147483648 => 2147483648 (32M) (no errors) Fail
aaron 4294967296 => 4294967296 (32M) (no errors) Fail
aaron -1 => -1 (-1) (no errors) Success
aaron 100 => 32M (32M) (no errors) Success
aaron 1m => 32M (32M) (no errors) Success
aaron 7.5G => 7.5G (32M) (no errors) Fail
aaron 234k => 32M (32M) (no errors) Success
aaron 94556M => 94556M (94556M) (no errors) Success
aaron 128 M => 128 M (128 M) (no errors) Success
aaron 52428800 => 52428800 (52428800) (no errors) Success
str => 32M (32M) (no errors) Success
str 2147483648 => 2147483648 (2147483648) (no errors) Success
str 4294967296 => 4294967296 (4294967296) (no errors) Success
str -1 => -1 (-1) (no errors) Success
str 100 => 32M (32M) (no errors) Success
str 1m => 32M (32M) (no errors) Success
str 7.5G => 7.5G (7.5G) (no errors) Success
str 234k => 32M (32M) (no errors) Success
str 94556M => 94556M (94556M) (no errors) Success
str 128 M => 128 M (128 M) (no errors) Success
str 52428800 => 52428800 (52428800) (no errors) Success
Running 1000000 iterations now... - done.
Results:
wp_function
==========================
Trials: 124892
Total Time: 154.32998085022
Average Time: 0.0012357074980801
Runs per Sec: 809.25300004547
Success Rate: 0.63636363636364
Speed Difference: 0
patch_function_original
==========================
Trials: 125286
Total Time: 390.26043176651
Average Time: 0.0031149564338115
Runs per Sec: 321.03177724909
Success Rate: 0.45454545454545
Speed Difference: 1.5287402332102
patch_function_new
==========================
Trials: 124484
Total Time: 194.98491120338
Average Time: 0.0015663451624577
Runs per Sec: 638.42888781355
Success Rate: 1
Speed Difference: 0.26342859714744
patch_function_new_complete
==========================
Trials: 124900
Total Time: 195.32537388802
Average Time: 0.0015638540743636
Runs per Sec: 639.44585137007
Success Rate: 0.90909090909091
Speed Difference: 0.26563466678314
wp_convert_hr_to_bytes
==========================
Trials: 124857
Total Time: 284.27002906799
Average Time: 0.0022767648515341
Runs per Sec: 439.21971095355
Success Rate: 0.63636363636364
Speed Difference: 0.84196244632391
map
==========================
Trials: 125201
Total Time: 194.24108624458
Average Time: 0.0015514339841102
Runs per Sec: 644.56497037064
Success Rate: 1
Speed Difference: 0.25860889228709
aaron
==========================
Trials: 125004
Total Time: 319.43641614914
Average Time: 0.0025554095560873
Runs per Sec: 391.32670440942
Success Rate: 0.72727272727273
Speed Difference: 1.0698273555749
str
==========================
Trials: 125376
Total Time: 253.95498728752
Average Time: 0.0020255470527655
Runs per Sec: 493.69378935666
Success Rate: 1
Speed Difference: 0.64553242272472
}}}
What I see fis that not all functions have the admired scuccess rate. I
tweaked map() to be conform, to be fair other functions might need some
love as well.
Using pow() looks expensive to me as well.
But what looks even more expensive to me (not shown in stats, but I tested
for it) is the @ operator. If it is removed from the code speed will go
significally up. I wonder if it is really needed for ini_get() /
ini_set(). Perhaps warnings will scare a certain type of users away,
because it will do warnings if those are disabled in `disable_functions`.
If so, return will be `NULL`.Probably it's worth to cut short on NULL.
Functions with error/notices get a sligh penalty as the error callback
gets called now. So if a function is giving notice or warning, it will not
only fail but take longer.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/14889#comment:30>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list