<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/1.5" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: objc_msgSend</title>
	<link>http://ridiculousfish.com/blog/archives/2005/08/01/objc_msgsend/</link>
	<description>serious code</description>
	<pubDate>Wed, 20 Aug 2008 12:42:01 +0000</pubDate>
	<generator>http://wordpress.org/?v=1.5</generator>

	<item>
		<title>by: Daniel Jalkut</title>
		<link>http://ridiculousfish.com/blog/archives/2005/08/01/objc_msgsend/#comment-69</link>
		<pubDate>Mon, 01 Aug 2005 12:12:14 +0000</pubDate>
		<guid>http://ridiculousfish.com/blog/archives/2005/08/01/objc_msgsend/#comment-69</guid>
					<description>How does this hack compare with the objc_msgSend_rtp optimization included in Tiger?  It sounds like essentially the same approach (but presumably Apple's sanctioned technique doesn't have the same drawbacks as your compiler mod).

I assume your performance comparisons are against plain 10.4 compiles. Have you profiled your code compiled on 10.4 with &quot;-fobjc-direct-dispatch&quot; option set?

Daniel
</description>
		<content:encoded><![CDATA[	<p>How does this hack compare with the objc_msgSend_rtp optimization included in Tiger?  It sounds like essentially the same approach (but presumably Apple&#8217;s sanctioned technique doesn&#8217;t have the same drawbacks as your compiler mod).</p>
	<p>I assume your performance comparisons are against plain 10.4 compiles. Have you profiled your code compiled on 10.4 with &#8220;-fobjc-direct-dispatch&#8221; option set?</p>
	<p>Daniel
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: ridiculous_fish</title>
		<link>http://ridiculousfish.com/blog/archives/2005/08/01/objc_msgsend/#comment-70</link>
		<pubDate>Mon, 01 Aug 2005 12:59:46 +0000</pubDate>
		<guid>http://ridiculousfish.com/blog/archives/2005/08/01/objc_msgsend/#comment-70</guid>
					<description>Here's the skinny on -fobjc-direct-dispatch:


The general theory of &quot;remove the stub overhead&quot; is the same.  The implementation is different, and has different tradeoffs.  The above approach relies on the dynamic linker to supply the address of objc_msgSend() at runtime, stashes that in a fast place, and calls objc_msgSend() through the function pointer.  -fobjc-direct-dispatch relies on the dynamic linker to put the objc_msgSend() implementation at a fixed address known by the *static* linker (or possibly the compiler), so the function can be jumped to directly, without the overhead of the function pointer.

 -fobjc-direct-dispatch is definitely faster, about 17% faster than the approach I outlined above.

 -fobjc-direct-dispatch requires fancy linker support to always put the objc_msgSend_rtp() function at the same address.  In this way, it's a bit like a hybrid static/dynamic linking.  The above approach does not require modifying the linker.

In principle, -fobjc-direct-dispatch is dangerous because the address is hardwired.  If the objc_msgSend_rtp() function needs to move (because it grows too big, for example), programs would have to be recompiled to pick up the new implementation.  The above approach does not have that problem.  (In pratice, objc_msgSend() is quite stable, so that is unlikely to be a concern.)

The biggest practical concern is that programs built with -fobjc-direct-dispatch will not run on pre-Tiger systems; the fancy linker support is missing.  The above approach should be able to run on pre-Tiger systems.
</description>
		<content:encoded><![CDATA[	<p>Here&#8217;s the skinny on -fobjc-direct-dispatch:</p>
	<p>The general theory of &#8220;remove the stub overhead&#8221; is the same.  The implementation is different, and has different tradeoffs.  The above approach relies on the dynamic linker to supply the address of objc_msgSend() at runtime, stashes that in a fast place, and calls objc_msgSend() through the function pointer.  -fobjc-direct-dispatch relies on the dynamic linker to put the objc_msgSend() implementation at a fixed address known by the *static* linker (or possibly the compiler), so the function can be jumped to directly, without the overhead of the function pointer.</p>
	<p> -fobjc-direct-dispatch is definitely faster, about 17% faster than the approach I outlined above.</p>
	<p> -fobjc-direct-dispatch requires fancy linker support to always put the objc_msgSend_rtp() function at the same address.  In this way, it&#8217;s a bit like a hybrid static/dynamic linking.  The above approach does not require modifying the linker.</p>
	<p>In principle, -fobjc-direct-dispatch is dangerous because the address is hardwired.  If the objc_msgSend_rtp() function needs to move (because it grows too big, for example), programs would have to be recompiled to pick up the new implementation.  The above approach does not have that problem.  (In pratice, objc_msgSend() is quite stable, so that is unlikely to be a concern.)</p>
	<p>The biggest practical concern is that programs built with -fobjc-direct-dispatch will not run on pre-Tiger systems; the fancy linker support is missing.  The above approach should be able to run on pre-Tiger systems.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Daniel Jalkut</title>
		<link>http://ridiculousfish.com/blog/archives/2005/08/01/objc_msgsend/#comment-71</link>
		<pubDate>Mon, 01 Aug 2005 13:01:28 +0000</pubDate>
		<guid>http://ridiculousfish.com/blog/archives/2005/08/01/objc_msgsend/#comment-71</guid>
					<description>Thanks for that detailed explanation!</description>
		<content:encoded><![CDATA[	<p>Thanks for that detailed explanation!
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Ross</title>
		<link>http://ridiculousfish.com/blog/archives/2005/08/01/objc_msgsend/#comment-72</link>
		<pubDate>Mon, 01 Aug 2005 13:49:30 +0000</pubDate>
		<guid>http://ridiculousfish.com/blog/archives/2005/08/01/objc_msgsend/#comment-72</guid>
					<description>Did you not use qsort because worst case it is O(n**2)?

I am guessing but I *SO* want that pen (I have a pen habit to support).</description>
		<content:encoded><![CDATA[	<p>Did you not use qsort because worst case it is O(n**2)?</p>
	<p>I am guessing but I *SO* want that pen (I have a pen habit to support).
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Mark Rowe</title>
		<link>http://ridiculousfish.com/blog/archives/2005/08/01/objc_msgsend/#comment-73</link>
		<pubDate>Mon, 01 Aug 2005 14:24:10 +0000</pubDate>
		<guid>http://ridiculousfish.com/blog/archives/2005/08/01/objc_msgsend/#comment-73</guid>
					<description>A bit of a guess: one reason not to use the standard library's qsort is that it adds an extra function call via a function pointer for each comparison.</description>
		<content:encoded><![CDATA[	<p>A bit of a guess: one reason not to use the standard library&#8217;s qsort is that it adds an extra function call via a function pointer for each comparison.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Dan V. P. Christiansen</title>
		<link>http://ridiculousfish.com/blog/archives/2005/08/01/objc_msgsend/#comment-74</link>
		<pubDate>Mon, 01 Aug 2005 15:21:38 +0000</pubDate>
		<guid>http://ridiculousfish.com/blog/archives/2005/08/01/objc_msgsend/#comment-74</guid>
					<description>I'd say the same thing as Mark Rowe, with the addition that the call to qsort is indirect, it seems, and my guess is that would mean that the call to your comparison function becomes indirect as well, defeating the purpose of your test.</description>
		<content:encoded><![CDATA[	<p>I&#8217;d say the same thing as Mark Rowe, with the addition that the call to qsort is indirect, it seems, and my guess is that would mean that the call to your comparison function becomes indirect as well, defeating the purpose of your test.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Mark Rowe</title>
		<link>http://ridiculousfish.com/blog/archives/2005/08/01/objc_msgsend/#comment-75</link>
		<pubDate>Mon, 01 Aug 2005 17:05:01 +0000</pubDate>
		<guid>http://ridiculousfish.com/blog/archives/2005/08/01/objc_msgsend/#comment-75</guid>
					<description>Dan, that's what I was getting at.  Thanks for following the train of thought through to it's conclusion. :)</description>
		<content:encoded><![CDATA[	<p>Dan, that&#8217;s what I was getting at.  Thanks for following the train of thought through to it&#8217;s conclusion. :)
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Out of Cheese</title>
		<link>http://ridiculousfish.com/blog/archives/2005/08/01/objc_msgsend/#comment-76</link>
		<pubDate>Mon, 01 Aug 2005 20:32:24 +0000</pubDate>
		<guid>http://ridiculousfish.com/blog/archives/2005/08/01/objc_msgsend/#comment-76</guid>
					<description>&lt;strong&gt;Objective-C messaging&lt;/strong&gt;

Peter has some interesting thoughts about objc_msgSend. His post is worth reading if you're curious about some complicated ways to...</description>
		<content:encoded><![CDATA[	<p><strong>Objective-C messaging</strong></p>
	<p>Peter has some interesting thoughts about objc_msgSend. His post is worth reading if you&#8217;re curious about some complicated ways to...
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Duncan mak</title>
		<link>http://ridiculousfish.com/blog/archives/2005/08/01/objc_msgsend/#comment-77</link>
		<pubDate>Tue, 02 Aug 2005 00:21:02 +0000</pubDate>
		<guid>http://ridiculousfish.com/blog/archives/2005/08/01/objc_msgsend/#comment-77</guid>
					<description>This is interesting:

http://www.cincomsmalltalk.com/userblogs/vbykov/blogView?showComments=true&amp;amp;entry=3300398515</description>
		<content:encoded><![CDATA[	<p>This is interesting:</p>
	<p><a href='http://www.cincomsmalltalk.com/userblogs/vbykov/blogView?showComments=true&amp;entry=3300398515' rel='nofollow'>http://www.cincomsmalltalk.com/userblogs/vbykov/blogView?showComments=true&amp;entry=3300398515</a>
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Erik M. Buck</title>
		<link>http://ridiculousfish.com/blog/archives/2005/08/01/objc_msgsend/#comment-78</link>
		<pubDate>Tue, 02 Aug 2005 06:54:29 +0000</pubDate>
		<guid>http://ridiculousfish.com/blog/archives/2005/08/01/objc_msgsend/#comment-78</guid>
					<description>There is a lot of related information at http://www.mulle-kybernetik.com/artikel/Optimization/

In particular, there are interesting ideas for optimizing objc_msgSend() at http://www.mulle-kybernetik.com/artikel/Optimization/opti-9.html
</description>
		<content:encoded><![CDATA[	<p>There is a lot of related information at <a href='http://www.mulle-kybernetik.com/artikel/Optimization/' rel='nofollow'>http://www.mulle-kybernetik.com/artikel/Optimization/</a></p>
	<p>In particular, there are interesting ideas for optimizing objc_msgSend() at <a href='http://www.mulle-kybernetik.com/artikel/Optimization/opti-9.html' rel='nofollow'>http://www.mulle-kybernetik.com/artikel/Optimization/opti-9.html</a>
</p>
]]></content:encoded>
				</item>
</channel>
</rss>
