<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>NOTHING is faster in 5.10</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<meta name="generator" content="pod2s5 0.07" />
<meta name="generator" content="S5" />
<meta name="version" content="S5 1.1" />
<meta name="presdate" content="Sun Aug 26 22:19:58 2007" />
<meta name="author" content="Ãvar Arnfjörð Bjarmason" />
<meta name="company" content=" " />
<!-- configuration parameters -->
<meta name="defaultView" content="slideshow" />
<meta name="controlVis" content="hidden" />
<!-- style sheet links -->
<link rel="stylesheet" href="ui/yatil/slides.css" type="text/css" media="projection" id="slideProj" />
<link rel="stylesheet" href="ui/default/outline.css" type="text/css" media="screen" id="outlineStyle" />
<link rel="stylesheet" href="ui/default/print.css" type="text/css" media="print" id="slidePrint" />
<link rel="stylesheet" href="ui/default/opera.css" type="text/css" media="projection" id="operaFix" />
<!-- embedded styles -->
<style type="text/css" media="all">
.imgcon {width: 525px; margin: 0 auto; padding: 0; text-align: center;}
#anim {width: 270px; height: 320px; position: relative; margin-top: 0.5em;}
#anim img {position: absolute; top: 42px; left: 24px;}
img#me01 {top: 0; left: 0;}
img#me02 {left: 23px;}
img#me04 {top: 44px;}
img#me05 {top: 43px;left: 36px;}
</style>
<!-- S5 JS -->
<script src="ui/default/slides.js" type="text/javascript"></script>
<!--
tom AT cpan.org:
this will not work, it's not contained
in the downloadable S5
<script src="/mint/?js" type="text/javascript"></script></head>
-->
<body>
<div class="layout">
<div id="controls"></div>
<div id="currentSlide"></div>
<div id="header"></div>
<div id="footer">
<h1>t • Sun Aug 26 22:19:58 2007</h1>
<h2>NOTHING is faster in 5.10</h2></div>
</div><div class="slide">
<h1>NOTHING is faster in 5.10
</h1><p>Ævar Arnfjörð Bjarmason <avar@cpan.org>
</p></div>
<div class="slide">
<h1>split optimizations
</h1><p>Handled by custom C code in <code>pp_split</code>. Will never reach the regex
engine (see <b>perlreapi.pod</b>)
</p> <b>my</b> <font color="#0000ff">@line</font> = <font color="#007f00">split</font> <font color="#ffa500">/</font><font color="#ff00ff">^</font><font color="#ffa500">/</font>, <font color="#0000ff">$text</font>;<BR>
<BR>
<b>my</b> <font color="#0000ff">@word</font> = <font color="#007f00">split</font> <font color="#ffa500">/</font><font color="#007f00">\s</font><font color="#ff00ff">+</font><font color="#ffa500">/</font>, <font color="#0000ff">$text</font>;<BR>
<BR>
<b>my</b> <font color="#0000ff">@char</font> = <font color="#007f00">split</font> <font color="#ffa500">//</font>, <font color="#0000ff">$text</font>; <font color="#7f7f7f"><i># NEW!</i></font><font color="#7f7f7f"><i><BR>
</i></font><BR>
<font color="#7f7f7f"><i># Hands in the air if you know what this does</i></font><font color="#7f7f7f"><i><BR>
</i></font> <b>my</b> <font color="#0000ff">@what</font> = <font color="#007f00">split</font> <font color="#ffa500">'</font><font color="#ff0000"> </font><font color="#ffa500">'</font>, <font color="#0000ff">$text</font>;<BR>
<BR>
</div>
<div class="slide">
<h1>The benchmark
</h1><b>use</b> Benchmark <font color="#ffa500">'</font><font color="#ff0000">:all</font><font color="#ffa500">'</font>;<BR>
<BR>
<b>my</b> <font color="#0000ff">$str</font> = (<font color="#ffa500">"</font><font color="#ff0000">hlagh</font><font color="#ffa500">"</font> x <font color="#00007f">666</font>);<BR>
<BR>
cmpthese(<font color="#00007f">-1</font>, {<BR>
old => <b>sub </b>{ <font color="#007f00">split</font> <font color="#ffa500">/</font><font color="#b03060"> </font><font color="#ffa500">/x</font>, <font color="#0000ff">$str</font> },<BR>
new => <b>sub </b>{ <font color="#007f00">split</font> <font color="#ffa500">//</font>, <font color="#0000ff">$str</font> },<BR>
<font color="#007f00">pack</font> => <b>sub </b>{ <font color="#007f00">unpack</font> <font color="#ffa500">"</font><font color="#ff0000">(a)*</font><font color="#ffa500">"</font>, <font color="#0000ff">$str</font> },<BR>
});<BR>
<BR>
</div>
<div class="slide">
<h1>Benchmark results
</h1><p>The new <code>split //</code> is around 3x faster than it was in 5.8.8
</p> old => <b>sub </b>{ <font color="#007f00">split</font> <font color="#ffa500">/</font><font color="#b03060"> </font><font color="#ffa500">/x</font>, <font color="#0000ff">$str</font> },<BR>
new => <b>sub </b>{ <font color="#007f00">split</font> <font color="#ffa500">//</font>, <font color="#0000ff">$str</font> },<BR>
<font color="#007f00">pack</font> => <b>sub </b>{ <font color="#007f00">unpack</font> <font color="#ffa500">"</font><font color="#ff0000">(a)*</font><font color="#ffa500">"</font>, <font color="#0000ff">$str</font> },<BR>
<BR>
<pre> Rate old pack new
old 182/s -- -61% -72%
pack 473/s 160% -- -28%
new 661/s 262% 40% -- </pre></div>
<div class="slide">
<h1>The benchmark lies...
</h1><p>...unless you compiled with <code>-DSTUPID_PATTERN_CHECKS</code>
</p><p>./Configure -A ccflags=-DSTUPID_PATTERN_CHECKS
</p><pre>$ perl5.9.5 -Mre=Debug,DUMP -e '//; /(?#I CAN HAS OPTIMIZE?!)/'
Compiling REx ""
Final program:
1: NOTHING (2)
2: END (0)
minlen 0
Compiling REx "(?#I CAN HAS OPTIMIZE?!)"
Final program:
1: NOTHING (2)
2: END (0)
minlen 0 </pre></div>
<div class="slide">
<h1>split is rarely the bottleneck
</h1> old => <b>sub </b>{ () = <font color="#007f00">map</font> { <font color="#007f00">chr</font> } <font color="#007f00">split</font> <font color="#ffa500">/</font><font color="#ff00ff">(?:)</font><font color="#ffa500">/x</font>, <font color="#0000ff">$str</font> },<BR>
new => <b>sub </b>{ () = <font color="#007f00">map</font> { <font color="#007f00">chr</font> } <font color="#007f00">split</font> <font color="#ffa500">//</font>, <font color="#0000ff">$str</font> },<BR>
<font color="#007f00">pack</font> => <b>sub </b>{ () = <font color="#007f00">unpack</font> <font color="#ffa500">"</font><font color="#ff0000">(C)*</font><font color="#ffa500">"</font>, <font color="#0000ff">$str</font> },<BR>
<BR>
<pre> Rate old new pack
old 80.7/s -- -31% -89%
new 117/s 45% -- -84%
pack 725/s 798% 518% -- </pre></div></body></html>