<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>گنجه &#187; Firefox</title>
	<atom:link href="http://blog.ebrahim.ir/tag/firefox/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.ebrahim.ir</link>
	<description># tail -f /var/log/experience</description>
	<lastBuildDate>Wed, 25 Aug 2010 22:16:39 +0000</lastBuildDate>
	<language>fa</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>بهینه‌سازی هدایت‌شده با سابقه</title>
		<link>http://blog.ebrahim.ir/1387/12/profile-guided-optimization/</link>
		<comments>http://blog.ebrahim.ir/1387/12/profile-guided-optimization/#comments</comments>
		<pubDate>Tue, 03 Mar 2009 03:57:45 +0000</pubDate>
		<dc:creator>ابراهیم</dc:creator>
				<category><![CDATA[رایانه]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[C++‎]]></category>
		<category><![CDATA[CMake]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[GCC]]></category>
		<category><![CDATA[PGO]]></category>
		<category><![CDATA[ابزار]]></category>
		<category><![CDATA[برنامه‌نویسی]]></category>
		<category><![CDATA[بهینه‌سازی]]></category>
		<category><![CDATA[سابقه‌گیری]]></category>
		<category><![CDATA[لینوکس]]></category>
		<category><![CDATA[هم‌گردان]]></category>
		<category><![CDATA[ویندوز]]></category>
		<category><![CDATA[کارآیی]]></category>

		<guid isPermaLink="false">http://blog.ebrahim.ir/?p=200</guid>
		<description><![CDATA[یکی از روش‌های نسبتاً متفاوت هم‌گردان0ها برای بهینه‌سازی1، روش «بهینه‌سازی هدایت‌شده با سابقه»2 است که گاهی اون رو کوتاهانه3 PGO هم می‌گویند. مؤثر بودن این روش رو می‌شه به چشم دید. مثلاً اگر از مرورگر Firefox هم در لینوکس4 و هم در ویندوز5 استفاده کرده باشید، حتماً تفاوت فاحش کارآیی6 رو حس کرده‌اید. دلیل این [...]]]></description>
			<content:encoded><![CDATA[<p><!--startnum=0--></p>
<p>یکی از روش‌های نسبتاً متفاوت هم‌گردان<sup><a href="http://blog.ebrahim.ir/1387/12/profile-guided-optimization/#footnote_0_200" id="identifier_0_200" class="footnote-link footnote-identifier-link" title="Compiler">0</a></sup>ها برای بهینه‌سازی<sup><a href="http://blog.ebrahim.ir/1387/12/profile-guided-optimization/#footnote_1_200" id="identifier_1_200" class="footnote-link footnote-identifier-link" title="Optimization">1</a></sup>، روش «بهینه‌سازی هدایت‌شده با سابقه»<sup><a href="http://blog.ebrahim.ir/1387/12/profile-guided-optimization/#footnote_2_200" id="identifier_2_200" class="footnote-link footnote-identifier-link" title="Profile-Guided Optimization">2</a></sup> است که گاهی اون رو کوتاهانه<sup><a href="http://blog.ebrahim.ir/1387/12/profile-guided-optimization/#footnote_3_200" id="identifier_3_200" class="footnote-link footnote-identifier-link" title="به یاد استاد روحانی رانکوهی!">3</a></sup> PGO هم می‌گویند.</p>
<p>مؤثر بودن این روش رو می‌شه به چشم دید. مثلاً اگر از مرورگر Firefox هم در لینوکس<sup><a href="http://blog.ebrahim.ir/1387/12/profile-guided-optimization/#footnote_4_200" id="identifier_4_200" class="footnote-link footnote-identifier-link" title="Linux">4</a></sup> و هم در ویندوز<sup><a href="http://blog.ebrahim.ir/1387/12/profile-guided-optimization/#footnote_5_200" id="identifier_5_200" class="footnote-link footnote-identifier-link" title="Windows">5</a></sup> استفاده کرده باشید، حتماً تفاوت فاحش کارآیی<sup><a href="http://blog.ebrahim.ir/1387/12/profile-guided-optimization/#footnote_6_200" id="identifier_6_200" class="footnote-link footnote-identifier-link" title="Performance">6</a></sup> رو حس کرده‌اید. دلیل این تفاوت فاحش، استفاده از PGO در ساخت<sup><a href="http://blog.ebrahim.ir/1387/12/profile-guided-optimization/#footnote_7_200" id="identifier_7_200" class="footnote-link footnote-identifier-link" title="Build">7</a></sup> پروندهٔ<sup><a href="http://blog.ebrahim.ir/1387/12/profile-guided-optimization/#footnote_8_200" id="identifier_8_200" class="footnote-link footnote-identifier-link" title="File">8</a></sup> اجرایی<sup><a href="http://blog.ebrahim.ir/1387/12/profile-guided-optimization/#footnote_9_200" id="identifier_9_200" class="footnote-link footnote-identifier-link" title="Executable">9</a></sup> ویندوز و عدم استفاده ازش در ساخت اجرایی لینوکس بیان شده.</p>
<p>خوب، حالا که به اندازهٔ کافی انگیزوندمتون (!)، ببینیم این روش اصلاً چی هست و چه‌جوری می‌تونیم ازش استفاده کنیم.</p>
<p>اساس این روش، استفاده از اطلاعات کسب‌شده در زمان اجرا<sup><a href="http://blog.ebrahim.ir/1387/12/profile-guided-optimization/#footnote_10_200" id="identifier_10_200" class="footnote-link footnote-identifier-link" title="Run-time">10</a></sup>ی برنامه، برای بهینه‌سازی در زمان هم‌گردانی<sup><a href="http://blog.ebrahim.ir/1387/12/profile-guided-optimization/#footnote_11_200" id="identifier_11_200" class="footnote-link footnote-identifier-link" title="Compile-time">11</a></sup> هست. پس هم‌گردانی با این روش، سه مرحله خواهد داشت:</p>
<p>۱. هم‌گردانی برای تولید اجرایی مخصوص جمع‌آوری اطلاعات مورد نیاز برای بهینه‌سازی<br />
۲. اجرای برنامهٔ تولیدشده در مرحلهٔ ۱ و استفاده از موارد کاربرد<sup><a href="http://blog.ebrahim.ir/1387/12/profile-guided-optimization/#footnote_12_200" id="identifier_12_200" class="footnote-link footnote-identifier-link" title="Use case">12</a></sup> مورد نظر برای بهینه‌سازی<br />
۳. هم‌گردانی با بهینه‌سازی به کمک اطلاعات جمع‌آوری‌شده در مرحلهٔ ۲</p>
<p>هم‌گردان‌ها برای مراحل ۱ و ۳ گزینه‌های مخصوصی دارند که این‌جا فقط GCC رو می‌بینیم.</p>
<p>درGCC برای مرحلهٔ ۱ از گزینهٔ ‎-fprofile-generate و برای مرحلهٔ ۳ از گزینهٔ ‎-fprofile-use استفاده می‌کنیم. دقت کنید که گزینهٔ ‎-fprofile-generate رو هم باید برای هم‌گردانی<sup><a href="http://blog.ebrahim.ir/1387/12/profile-guided-optimization/#footnote_13_200" id="identifier_13_200" class="footnote-link footnote-identifier-link" title="Compiling">13</a></sup> بدید، و هم برای پیوند<sup><a href="http://blog.ebrahim.ir/1387/12/profile-guided-optimization/#footnote_14_200" id="identifier_14_200" class="footnote-link footnote-identifier-link" title="Linking">14</a></sup>.</p>
<p>من که معمولاً از CMake به عنوان سامانهٔ ساخت<sup><a href="http://blog.ebrahim.ir/1387/12/profile-guided-optimization/#footnote_15_200" id="identifier_15_200" class="footnote-link footnote-identifier-link" title="Build System">15</a></sup> استفاده می‌کنم، برای به کارگیری این روش، این چند خط رو به CMakeLists.txt اضافه می‌کنم:</p>

<div class="wp_syntax" dir="ltr"><div class="code"><pre class="none" style="font-family:monospace;"># profile::generate
#set(CMAKE_C_FLAGS &quot;${CMAKE_C_FLAGS} --profile-generate&quot;)
#set(CMAKE_CXX_FLAGS &quot;${CMAKE_CXX_FLAGS} --profile-generate&quot;)
#set(CMAKE_EXE_LINKER_FLAGS &quot;${CMAKE_EXE_LINKER_FLAGS} --profile-generate&quot;)
# profile::use
#set(CMAKE_C_FLAGS &quot;${CMAKE_C_FLAGS} --profile-use&quot;)
#set(CMAKE_CXX_FLAGS &quot;${CMAKE_CXX_FLAGS} --profile-use&quot;)
#set(CMAKE_EXE_LINKER_FLAGS &quot;${CMAKE_EXE_LINKER_FLAGS} --profile-use&quot;)</pre></div></div>

<p>برای مرحلهٔ ۱، سه تا set اول و برای مرحلهٔ ۳، سه تا set دوم رو فعال می‌کنم. راستی دقت کردید که به جای ‎-fprofile-folan می‌شه از  ‎-profile-folan- استفاده کرد؟!</p>
<ol start="0" class="footnotes"><li id="footnote_0_200" class="footnote">Compiler</li><li id="footnote_1_200" class="footnote">Optimization</li><li id="footnote_2_200" class="footnote">Profile-Guided Optimization</li><li id="footnote_3_200" class="footnote"><span dir="rtl">به یاد استاد روحانی رانکوهی!</span></li><li id="footnote_4_200" class="footnote">Linux</li><li id="footnote_5_200" class="footnote">Windows</li><li id="footnote_6_200" class="footnote">Performance</li><li id="footnote_7_200" class="footnote">Build</li><li id="footnote_8_200" class="footnote">File</li><li id="footnote_9_200" class="footnote">Executable</li><li id="footnote_10_200" class="footnote">Run-time</li><li id="footnote_11_200" class="footnote">Compile-time</li><li id="footnote_12_200" class="footnote">Use case</li><li id="footnote_13_200" class="footnote">Compiling</li><li id="footnote_14_200" class="footnote">Linking</li><li id="footnote_15_200" class="footnote">Build System</li></ol>]]></content:encoded>
			<wfw:commentRss>http://blog.ebrahim.ir/1387/12/profile-guided-optimization/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>میمون چرب؛ دوست روباه آتشین</title>
		<link>http://blog.ebrahim.ir/1387/09/grease-monkey-a-friend-of-fire-fox/</link>
		<comments>http://blog.ebrahim.ir/1387/09/grease-monkey-a-friend-of-fire-fox/#comments</comments>
		<pubDate>Sat, 13 Dec 2008 22:50:36 +0000</pubDate>
		<dc:creator>ابراهیم</dc:creator>
				<category><![CDATA[رایانه]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Greasemonkey]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[ابزار]]></category>
		<category><![CDATA[برنامه‌نویسی]]></category>
		<category><![CDATA[تار]]></category>
		<category><![CDATA[دست‌نوشته]]></category>
		<category><![CDATA[فارسی]]></category>
		<category><![CDATA[مرورگر]]></category>
		<category><![CDATA[نرم‌افزار آزاد]]></category>

		<guid isPermaLink="false">http://blog.ebrahim.ir/?p=123</guid>
		<description><![CDATA[از وقتی با Greasemonkey آشنا شده‌ام توقعم از تار1 خیلی بالا رفته. با این افزونهٔ Firefox می‌شه در طرف مخدوم2، به هر صفحه‌ای کدهای JavaScript دل‌خواه رو اضافه کرد. علاوه بر کلی دست‌نوشتهٔ3 آماده که توی http://userscripts.org براش وجود داره، خودمون هم می‌تونیم به راحتی براش دست‌نوشته بنویسیم. حالا اگر قدرت JavaScript رو بیاری تو [...]]]></description>
			<content:encoded><![CDATA[<p>از وقتی با <a href="https://addons.mozilla.org/firefox/748/">Greasemonkey</a> آشنا شده‌ام توقعم از تار<sup><a href="http://blog.ebrahim.ir/1387/09/grease-monkey-a-friend-of-fire-fox/#footnote_0_123" id="identifier_0_123" class="footnote-link footnote-identifier-link" title="Web">1</a></sup> خیلی بالا رفته.</p>
<p>با این افزونهٔ Firefox می‌شه در طرف مخدوم<sup><a href="http://blog.ebrahim.ir/1387/09/grease-monkey-a-friend-of-fire-fox/#footnote_1_123" id="identifier_1_123" class="footnote-link footnote-identifier-link" title="Client Side">2</a></sup>، به هر صفحه‌ای کدهای JavaScript دل‌خواه رو اضافه کرد. علاوه بر کلی دست‌نوشتهٔ<sup><a href="http://blog.ebrahim.ir/1387/09/grease-monkey-a-friend-of-fire-fox/#footnote_2_123" id="identifier_2_123" class="footnote-link footnote-identifier-link" title="Script">3</a></sup> آماده که توی <a href="http://userscripts.org/">http://userscripts.org</a> براش وجود داره، خودمون هم می‌تونیم به راحتی براش دست‌نوشته بنویسیم. حالا اگر قدرت JavaScript رو بیاری تو ذهنت می‌بینی که چه کارها می‌شه به کمک این میمون چرب (!) کرد.</p>
<p>برای شروع ماجراجویی، کمی از <a href="http://diveintogreasemonkey.org/">http://diveintogreasemonkey.org</a> رو خوندم. نقطهٔ شروع بسیار خوبی بود.</p>
<p>یک دست‌نوشته به نام <a href="http://userscripts.org/scripts/show/38610">فارسنده یا Persianizer</a> که به شیوهٔ بِکَن-بچسبون<sup><a href="http://blog.ebrahim.ir/1387/09/grease-monkey-a-friend-of-fire-fox/#footnote_3_123" id="identifier_3_123" class="footnote-link footnote-identifier-link" title="Copy-Paste">4</a></sup> ساخته‌ام، همهٔ رقم‌های انگلیسی و «ي» و «ك»های عربی توی صفحهٔ بارگذاری شده رو به معادل فارسیشون تبدیل می‌کنه. بس که اون صفحه‌های فارسی پر از «ي» حالم رو بد می‌کنه! فقط موقع استفاده حواست باشه پایگاه‌هایی که قراره فارسنده روشون کار بکنه رو خوب انتخاب کنی؛ پیش‌فرض‌هاش خوب نیستند.</p>
<p>البته یکی از شرایط من (و خیلی‌های دیگر) برای استفاده از یک فن‌آوری، انحصاری نبودنش هست که خوش‌بختانه افزونه‌هایی سازگار با Greasemonkey برای مرورگرهای مهم دیگه (از جمله Konqueror) هم وجود داره.</p>
<p>نکتهٔ پایانی این که اگر کاربر Greasemonkey باشی، افزونهٔ <a href="https://addons.mozilla.org/firefox/addon/8352">Greasefire</a> هم احتمالاً برات جالب هست.</p>
<p>این هم فهرست دست‌نوشته‌های محبوب من:<br />
<a href="http://userscripts.org/users/73214/favorites">http://userscripts.org/users/73214/favorites</a></p>
<ol class="footnotes"><li id="footnote_0_123" class="footnote">Web</li><li id="footnote_1_123" class="footnote">Client Side</li><li id="footnote_2_123" class="footnote">Script</li><li id="footnote_3_123" class="footnote">Copy-Paste</li></ol>]]></content:encoded>
			<wfw:commentRss>http://blog.ebrahim.ir/1387/09/grease-monkey-a-friend-of-fire-fox/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (user agent is rejected)

Served from: blog.ebrahim.ir @ 2012-02-07 00:19:22 -->
