Listening for message events on safari.self.tab makes SunSpider crawl

Originator:marc.hoyois
Number:rdar://9950247 Date Originated:2011-08-13
Status:Open Resolved:
Product:Safari Product Version:5.1 (7534.48.3)
Classification:Performance Reproducible:Always
 
Summary:

Listening to "message" events on safari.self.tab within a content script of a Safari extension makes the SunSpider Javascript benchmark 1.132 as slow:

http://www.webkit.org/perf/sunspider-0.9.1/sunspider-0.9.1/results.html?%7B%22v%22:%20%22sunspider-0.9.1%22,%20%223d-cube%22:%5B15,15,17,17,17,17,17,18,18,18%5D,%223d-morph%22:%5B12,12,11,12,12,12,12,12,12,12%5D,%223d-raytrace%22:%5B15,15,16,16,16,16,16,17,17,17%5D,%22access-binary-trees%22:%5B8,7,9,9,10,10,11,11,11,11%5D,%22access-fannkuch%22:%5B18,18,17,17,17,19,17,17,17,18%5D,%22access-nbody%22:%5B10,11,10,11,11,11,11,11,10,11%5D,%22access-nsieve%22:%5B5,5,5,5,5,5,5,5,5,5%5D,%22bitops-3bit-bits-in-byte%22:%5B3,3,3,3,3,3,4,4,3,3%5D,%22bitops-bits-in-byte%22:%5B7,7,8,8,8,7,7,7,7,7%5D,%22bitops-bitwise-and%22:%5B4,5,4,5,4,4,4,5,4,4%5D,%22bitops-nsieve-bits%22:%5B8,8,8,8,8,7,8,8,7,8%5D,%22controlflow-recursive%22:%5B4,4,4,4,4,3,3,4,4,3%5D,%22crypto-aes%22:%5B13,13,14,14,15,16,16,16,16,17%5D,%22crypto-md5%22:%5B5,4,4,4,5,4,5,4,4,4%5D,%22crypto-sha1%22:%5B4,3,4,4,4,3,3,3,3,3%5D,%22date-format-tofte%22:%5B26,27,28,29,29,30,30,31,32,31%5D,%22date-format-xparb%22:%5B19,19,23,22,22,22,23,23,24,24%5D,%22math-cordic%22:%5B10,10,10,9,10,10,10,9,10,9%5D,%22math-partial-sums%22:%5B15,15,15,14,15,15,15,15,15,15%5D,%22math-spectral-norm%22:%5B7,6,7,7,7,7,6,6,6,7%5D,%22regexp-dna%22:%5B17,16,17,16,17,17,17,16,17,17%5D,%22string-base64%22:%5B16,18,19,19,20,21,21,22,23,23%5D,%22string-fasta%22:%5B15,16,16,17,17,17,17,17,19,18%5D,%22string-tagcloud%22:%5B23,23,24,25,25,25,25,25,25,26%5D,%22string-unpack-code%22:%5B43,45,46,45,46,48,46,47,48,48%5D,%22string-validate-input%22:%5B23,25,27,26,27,28,28,29,29,30%5D%7D

compared to:

http://www.webkit.org/perf/sunspider-0.9.1/sunspider-0.9.1/results.html?%7B%22v%22:%20%22sunspider-0.9.1%22,%20%223d-cube%22:%5B16,15,15,15,14,14,14,14,15,15%5D,%223d-morph%22:%5B12,11,12,12,12,11,12,12,12,11%5D,%223d-raytrace%22:%5B15,15,14,15,15,15,15,15,15,14%5D,%22access-binary-trees%22:%5B6,6,6,7,6,6,6,7,6,6%5D,%22access-fannkuch%22:%5B18,17,20,19,18,17,17,18,18,17%5D,%22access-nbody%22:%5B11,10,10,11,11,10,10,11,10,10%5D,%22access-nsieve%22:%5B5,5,5,6,5,5,5,5,5,5%5D,%22bitops-3bit-bits-in-byte%22:%5B3,4,3,3,3,3,4,3,4,4%5D,%22bitops-bits-in-byte%22:%5B7,7,7,7,7,7,8,7,7,8%5D,%22bitops-bitwise-and%22:%5B4,4,4,4,5,4,5,4,4,4%5D,%22bitops-nsieve-bits%22:%5B7,8,8,8,7,8,8,8,8,8%5D,%22controlflow-recursive%22:%5B3,3,4,3,3,3,4,4,4,4%5D,%22crypto-aes%22:%5B12,12,12,13,12,12,12,12,12,12%5D,%22crypto-md5%22:%5B5,5,4,5,4,4,4,4,4,4%5D,%22crypto-sha1%22:%5B4,3,4,4,3,3,3,4,3,4%5D,%22date-format-tofte%22:%5B25,25,24,25,25,24,25,25,25,24%5D,%22date-format-xparb%22:%5B18,18,17,18,18,18,17,18,17,18%5D,%22math-cordic%22:%5B9,9,10,9,9,10,9,9,10,9%5D,%22math-partial-sums%22:%5B15,15,15,15,17,15,15,15,14,15%5D,%22math-spectral-norm%22:%5B7,7,6,7,7,6,7,6,6,6%5D,%22regexp-dna%22:%5B16,16,16,17,16,17,16,16,16,16%5D,%22string-base64%22:%5B14,14,14,14,14,15,14,14,14,14%5D,%22string-fasta%22:%5B15,15,14,14,14,14,14,14,14,14%5D,%22string-tagcloud%22:%5B22,22,22,22,22,22,22,22,22,22%5D,%22string-unpack-code%22:%5B41,40,40,41,41,40,41,42,41,41%5D,%22string-validate-input%22:%5B21,20,21,20,21,20,20,20,21,20%5D%7D

Steps to Reproduce:

Install the attached extension, which has the following injected script:

safari.self.addEventListener("message", respondToMessage, false);
function respondToMessage(event) {}

Disable all other extensions and run the SunSpider test at http://www.webkit.org/perf/sunspider/sunspider.html.

Expected Results:

No significant difference with or without the extension.

Actual Results:

1.132 times as slow with the extension!

Regression: ?

Notes:

This is the reason most extensions make the SunSpider test crawl.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!