1 | <!doctype html> |
---|
2 | <html> |
---|
3 | <body> |
---|
4 | <p style="font-family:Arial; font-size:20px">-Ford January Lot Blowout - Select your 2014-</p> |
---|
5 | <p style="font-family:Arial; font-size:16px"><strong>Below Kelly Blue Book -<em> (2014's still available)</em></strong><br> |
---|
6 | <a href="http://www.pannerautomobiles.com/debauching/laid/misbehaved/maledictive/arid/noncollectible.php">www.Ford/2014/all-makes-and-models.html</a> |
---|
7 | </p> |
---|
8 | |
---|
9 | <ul> |
---|
10 | <li>Dealers need to make room for 2015 models.</li> |
---|
11 | <li>That means you can get in to a 2014 for a lot less then you would expect</li> |
---|
12 | </ul> |
---|
13 | <p style=" font-family:Arial;">Remanning cars can be seen below:<br> |
---|
14 | </p> |
---|
15 | |
---|
16 | <div><!--[if mso]> |
---|
17 | <v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="http://www.pannerautomobiles.com/debauching/laid/misbehaved/maledictive/arid/noncollectible.php" style="height:40px;v-text-anchor:middle;width:200px;" arcsize="10%" strokecolor="#1e3650" fillcolor="#556270"> |
---|
18 | <w:anchorlock/> |
---|
19 | <center style="color:#ffffff;font-family:sans-serif;font-size:13px;font-weight:bold;">Choose Mode/Make Here</center> |
---|
20 | </v:roundrect> |
---|
21 | <![endif]--><a href="http://www.pannerautomobiles.com/debauching/laid/misbehaved/maledictive/arid/noncollectible.php" |
---|
22 | style="background-color:#556270;border:1px solid #1e3650;border-radius:4px;color:#ffffff;display:inline-block;font-family:sans-serif;font-size:13px;font-weight:bold;line-height:40px;text-align:center;text-decoration:none;width:200px;-webkit-text-size-adjust:none;mso-hide:all;">Choose Mode/Make Here</a></div> |
---|
23 | <div style="color:#FFFFFF"> |
---|
24 | <p style="font-size:12px; font-family:'Gill Sans', 'Gill Sans MT', 'Myriad Pro', 'DejaVu Sans Condensed', Helvetica, Arial, sans-serif; text-overflow:clip">IIf and can't know there is some anti-theft control aftermarket or OE for this to kill the stereo/entertainment items I can't know. Would think it wouldn't come back on ever if really controlled like that.<br> |
---|
25 | <br> |
---|
26 | <br> |
---|
27 | It's that it forget presets that makes me think just plain loss of power. Most fuses that fail plain blow, look dark or obvious that the hoop in the pic is burned out as it's supposed to.<br> |
---|
28 | <br> |
---|
29 | <br> |
---|
30 | Many vehicles come with spare fuses and a puller in the box that contain them. Check and ONLY use exact AMP rated fuse always.<br> |
---|
31 | <br> |
---|
32 | <br> |
---|
33 | If you find it blown it never should come back as they don't heal if really blown.<br> |
---|
34 | <br> |
---|
35 | <br> |
---|
36 | Start with this and not think whole unit is messed up quite yet and doubt you are going to fix anything inside it without intense details of what to test where for what. There are places that do that worth it for most if only a one time fix if needed,</p> |
---|
37 | </div> |
---|
38 | <p> </p> |
---|
39 | <p style="font-size:10px;">MMC Family Communication Group : 1 8 7 7 Atrium Dr : Melbourn : FL 32935</p> |
---|
40 | <p style="font-size:10px">If you would like to stop further promos from us please head to<br> |
---|
41 | <a href="http://www.pannerautomobiles.com/annul/cameramen/locales.html">http://www.pannerautomobiles.com/annul/cameramen/locales.html</a></p> |
---|
42 | <p style="font-size:10px"> </p> |
---|
43 | <p style="font-size:10px"> </p> |
---|
44 | <p style="font-size:10px"> </p> |
---|
45 | <p style="font-size:10px"> </p> |
---|
46 | <p style="font-size:10px"> </p> |
---|
47 | <p style="font-size:10px"> </p> |
---|
48 | <p style="font-size:10px"> </p> |
---|
49 | <p style="font-size:10px"> </p> |
---|
50 | <p style="font-size:10px"> </p> |
---|
51 | <p class="MS:Microsoft Outlook" style="font-size:1px;"><a href="http://www.fueleconomy.gov/feg/Find.do?action=bt1">http://www.fueleconomy.gov/feg/Find.do?action=bt1</a></p> |
---|
52 | |
---|
53 | <div><div data-questionid="27463669" id="question"> |
---|
54 | <table> |
---|
55 | <tbody> |
---|
56 | <tr> |
---|
57 | <td><div> |
---|
58 | <div itemprop="text"> |
---|
59 | <p>I have the following Haskell code, implementing a simple version of the "cat" unix command-line utility. Testing performance with "time" on a 400MB file, it's about 3x slower. (the exact script I am using to test it is below the code).</p> |
---|
60 | <p>My questions are:</p> |
---|
61 | <ol> |
---|
62 | <li>Is this a valid test of performance?</li> |
---|
63 | <li>How can I make this program run faster?</li> |
---|
64 | <li>How can I identify performance bottlenecks in Haskell programs in general?</li> |
---|
65 | </ol> |
---|
66 | <p>Regarding questions 2 and 3: I have used GHC -prof, then running with +RTS -p, but I'm finding the output a bit uninformative here.</p> |
---|
67 | <p>Source (Main.hs)</p> |
---|
68 | <pre>module Main where import System.IO import System.Environment import Data.ByteString as BS import Control.Monad -- Copied from cat source code bufsize = 1024*128 go handle buf = do hPut stdout buf eof <- hIsEOF handle unless eof $ do buf <- hGetSome handle bufsize go handle buf main = do file <- fmap Prelude.head getArgs handle <- openFile file ReadMode buf <- hGetSome handle bufsize hSetBuffering stdin $ BlockBuffering (Just bufsize) hSetBuffering stdout $ BlockBuffering (Just bufsize) go handle buf</pre> |
---|
69 | <p>Timing script (run.sh):</p> |
---|
70 | <pre>#!/usr/bin/env bash # Generate 10M lines of silly test data yes aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | head -n 10000000 > huge # Compile with optimisation ghc -O2 Main.hs # Run haskell echo "timing Haskell" time ./Main huge > /dev/null echo "" echo "" # Run cat echo "timing 'cat'" time cat huge > /dev/null</pre> |
---|
71 | <p>My results:</p> |
---|
72 | <pre>timing Haskell real 0m0.980s user 0m0.296s sys 0m0.684s timing 'cat' real 0m0.304s user 0m0.001s sys 0m0.302s</pre> |
---|
73 | <p>The profiling report when compiling with -prof and running with +RTS -p is below:</p> |
---|
74 | <pre> Sat Dec 13 21:26 2014 Time and Allocation Profiling Report (Final) Main +RTS -p -RTS huge total time = 0.92 secs (922 ticks @ 1000 us, 1 processor) total alloc = 7,258,596,176 bytes (excludes profiling overheads) COST CENTRE MODULE %time %alloc MAIN MAIN 100.0 100.0 individual inherited COST CENTRE MODULE no. entries %time %alloc %time %alloc MAIN MAIN 46 0 100.0 100.0 100.0 100.0 CAF GHC.Conc.Signal 84 0 0.0 0.0 0.0 0.0 CAF GHC.IO.FD 82 0 0.0 0.0 0.0 0.0 CAF GHC.IO.Handle.FD 81 0 0.0 0.0 0.0 0.0 CAF System.Posix.Internals 76 0 0.0 0.0 0.0 0.0 CAF GHC.IO.Encoding 70 0 0.0 0.0 0.0 0.0 CAF |
---|
75 | GHC.IO.Encoding.Iconv 69 0 0.0 0.0 0.0 0.0</pre> |
---|
76 | </div> |
---|
77 | <div>performanceunixhaskell</div> |
---|
78 | <table> |
---|
79 | <tbody> |
---|
80 | <tr> |
---|
81 | <td><div>share|improve this question</div></td> |
---|
82 | <td align="right"><div> |
---|
83 | <div>edited<span title="2014-12-13 21:19:07Z">Dec 13 '14 at 21:19</span></div> |
---|
84 | <div></div> |
---|
85 | <div><br> |
---|
86 | </div> |
---|
87 | </div></td> |
---|
88 | <td><div> |
---|
89 | <div>asked<span title="2014-12-13 21:10:53Z">Dec 13 '14 at 21:10</span></div> |
---|
90 | <div> |
---|
91 | <div></div> |
---|
92 | </div> |
---|
93 | <div>statusfailed<br> |
---|
94 | <span title="reputation score " dir="ltr">96</span><span title="4 bronze badges"> 4</span></div> |
---|
95 | </div></td> |
---|
96 | </tr> |
---|
97 | </tbody> |
---|
98 | </table> |
---|
99 | </div></td> |
---|
100 | </tr> |
---|
101 | <tr> |
---|
102 | <td></td> |
---|
103 | <td><div id="comments-27463669"> |
---|
104 | <table> |
---|
105 | <tbody data-remaining-comments-count="13" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true"> |
---|
106 | <tr id="comment-43363550"> |
---|
107 | <td><table> |
---|
108 | <tbody> |
---|
109 | <tr> |
---|
110 | <td><span title="number of 'useful comment' votes received">2</span></td> |
---|
111 | <td></td> |
---|
112 | </tr> |
---|
113 | </tbody> |
---|
114 | </table></td> |
---|
115 | <td><div>It's good to see that you have also added -O2 optimization. You can also post the link to the profiled report here.Sibi<span dir="ltr"><span title="2014-12-13 21:13:19Z">Dec 13 '14 at 21:13</span></span></div></td> |
---|
116 | </tr> |
---|
117 | <tr id="comment-43363720"> |
---|
118 | <td><table> |
---|
119 | <tbody> |
---|
120 | <tr> |
---|
121 | <td><span title="number of 'useful comment' votes received">4</span></td> |
---|
122 | <td></td> |
---|
123 | </tr> |
---|
124 | </tbody> |
---|
125 | </table></td> |
---|
126 | <td><div>Instead ofhGetSomeusehGetNonBlocking, it is increasing the performance substantiallySibi<span dir="ltr"><span title="2014-12-13 21:25:21Z">Dec 13 '14 at 21:25</span></span></div></td> |
---|
127 | </tr> |
---|
128 | <tr id="comment-43364283"> |
---|
129 | <td><table> |
---|
130 | <tbody> |
---|
131 | <tr> |
---|
132 | <td><span title="number of 'useful comment' votes received">5</span></td> |
---|
133 | <td></td> |
---|
134 | </tr> |
---|
135 | </tbody> |
---|
136 | </table></td> |
---|
137 | <td><div>Notice caching impacts the timing significantly. If I runcatfirst in the shell script "benchmark" instead of second it performs about 60% slower on my system.Thomas M. DuBuisson<span dir="ltr"><span title="2014-12-13 21:59:29Z">Dec 13 '14 at 21:59</span></span></div></td> |
---|
138 | </tr> |
---|
139 | <tr id="comment-43364850"> |
---|
140 | <td><table> |
---|
141 | <tbody> |
---|
142 | <tr> |
---|
143 | <td><span title="number of 'useful comment' votes received">3</span></td> |
---|
144 | <td></td> |
---|
145 | </tr> |
---|
146 | </tbody> |
---|
147 | </table></td> |
---|
148 | <td><div>-profwon’t be terribly useful if you don’t have any cost centers; try compiling it (and the wholebytestringpackage, too, if you can (probably in a Cabal sandbox)) with-fprof-autoand maybe-fprof-cafsin addition to-prof.icktoofay<span dir="ltr"><span title="2014-12-13 22:36:08Z">Dec 13 '14 at 22:36</span></span></div></td> |
---|
149 | </tr> |
---|
150 | <tr id="comment-43365599"> |
---|
151 | <td><table> |
---|
152 | <tbody> |
---|
153 | <tr> |
---|
154 | <td><span title="number of 'useful comment' votes received">4</span></td> |
---|
155 | <td></td> |
---|
156 | </tr> |
---|
157 | </tbody> |
---|
158 | </table></td> |
---|
159 | <td><div>@statusfailed Apipes solutionruns pretty close. I have also attached benchmark with the code.Sibi<span dir="ltr"><span title="2014-12-13 23:19:14Z">Dec 13 '14 at 23:19</span></span></div></td> |
---|
160 | </tr> |
---|
161 | </tbody> |
---|
162 | </table> |
---|
163 | </div> |
---|
164 | <div id="comments-link-27463669" data-rep="50" data-anon="true">show<strong>13</strong>more comments</div></td> |
---|
165 | </tr> |
---|
166 | </tbody> |
---|
167 | </table> |
---|
168 | </div> |
---|
169 | <div id="answers"> |
---|
170 | <div id="answers-header"> |
---|
171 | <div> |
---|
172 | <h2>3 Answers</h2> |
---|
173 | <div> |
---|
174 | <div id="tabs">activeoldestvotes</div> |
---|
175 | </div> |
---|
176 | </div> |
---|
177 | </div> |
---|
178 | |
---|
179 | <div id="answer-27464224" data-answerid="27464224" itemscope="" itemtype="http://schema.org/Answer"> |
---|
180 | <table> |
---|
181 | <tbody> |
---|
182 | <tr> |
---|
183 | <td><div>up vote<span itemprop="upvoteCount">14</span>down vote</div></td> |
---|
184 | <td><div itemprop="text"> |
---|
185 | <p>This is only a partial answer trying to address the second question:</p> |
---|
186 | <p>I tried something like this usingGHC.IO.BufferAPI:</p> |
---|
187 | <pre>module Main where import System.IO import System.Environment import GHC.IO.Buffer import Data.ByteString as BS import Control.Monad -- Copied from cat source code bufsize = 1024*128 go handle bufPtr = do read <- hGetBuf handle bufPtr bufsize when (read > 0) $ do hPutBuf stdout bufPtr read go handle bufPtr main = do file <- fmap Prelude.head getArgs handle <- openFile file ReadMode buf <- newByteBuffer bufsize WriteBuffer withBuffer buf $ go handle</pre> |
---|
188 | <p>and it seems to come closer to the performance of 'cat', but still definitely slower...</p> |
---|
189 | <pre>time ./Cat huge > /dev/null ./Cat huge > /dev/null 0.00s user 0.06s system 76% cpu 0.081 total time cat huge > /dev/null cat huge > /dev/null 0.00s user 0.05s system 75% cpu 0.063 total</pre> |
---|
190 | <p>I think using the buffer API, we can explicitly avoid allocating all the buffer bytestrings when usinghGetSomelike in the original code, but I am just guessing here and don't know either what exactly is happening in both compiled codes...</p> |
---|
191 | <p>UPDATE: Adding the original code's performance on my laptop:</p> |
---|
192 | <pre>time ./Cat2 huge > /dev/null ./Cat2 huge > /dev/null 0.12s user 0.10s system 99% cpu 0.219 total</pre> |
---|
193 | <p>UPDATE 2: Adding some basic profiling results:</p> |
---|
194 | <p>Original Code:</p> |
---|
195 | <pre>Cat2 +RTS -p -RTS huge total time = 0.21 secs (211 ticks @ 1000 us, 1 processor) total alloc = 6,954,068,112 bytes (excludes profiling overheads) COST CENTRE MODULE %time %alloc MAIN MAIN 100.0 100.0 individual inherited COST CENTRE MODULE no. entries %time %alloc %time %alloc MAIN MAIN 46 0 100.0 100.0 100.0 100.0 CAF GHC.IO.Handle.FD 86 0 0.0 0.0 0.0 0.0 CAF GHC.Conc.Signal 82 0 0.0 0.0 0.0 0.0 CAF GHC.IO.Encoding 80 0 0.0 0.0 0.0 0.0 CAF GHC.IO.FD 79 0 0.0 0.0 0.0 0.0 CAF System.Posix.Internals 75 0 0.0 0.0 0.0 0.0 CAF GHC.IO.Encoding.Iconv 72 0 0.0 0.0 0.0 0.0< |
---|
196 | /pre> |
---|
197 | <p>Buffer-API Code:</p> |
---|
198 | <pre>Cat +RTS -p -RTS huge total time = 0.06 secs (61 ticks @ 1000 us, 1 processor) total alloc = 3,487,712 bytes (excludes profiling overheads) COST CENTRE MODULE %time %alloc MAIN MAIN 100.0 98.9 individual inherited COST CENTRE MODULE no. entries %time %alloc %time %alloc MAIN MAIN 44 0 100.0 98.9 100.0 100.0 CAF GHC.IO.Handle.FD 85 0 0.0 1.0 0.0 1.0 CAF GHC.Conc.Signal 82 0 0.0 0.0 0.0 0.0 CAF GHC.IO.Encoding 80 0 0.0 0.1 0.0 0.1 CAF GHC.IO.FD 79 0 0.0 0.0 0.0 0.0 CAF GHC.IO.Encoding.Iconv 71 0 0.0 0.0 0.0 0.0</pre> |
---|
199 | <p>Notice especially the big difference in allocation costs...</p> |
---|
200 | </div> |
---|
201 | <table> |
---|
202 | <tbody> |
---|
203 | <tr> |
---|
204 | <td><div>share|improve this answer</div></td> |
---|
205 | <td align="right"><div> |
---|
206 | <div>edited<span title="2014-12-13 23:11:10Z">Dec 13 '14 at 23:11</span></div> |
---|
207 | <div></div> |
---|
208 | <div><br> |
---|
209 | </div> |
---|
210 | </div></td> |
---|
211 | <td align="right"><div> |
---|
212 | <div>answered<span title="2014-12-13 22:20:44Z">Dec 13 '14 at 22:20</span></div> |
---|
213 | <div> |
---|
214 | <div></div> |
---|
215 | </div> |
---|
216 | <div>bmk<br> |
---|
217 | <span title="reputation score " dir="ltr">633</span><span title="3 silver badges"> 3</span><span title="9 bronze badges"> 9</span></div> |
---|
218 | </div></td> |
---|
219 | </tr> |
---|
220 | </tbody> |
---|
221 | </table></td> |
---|
222 | </tr> |
---|
223 | <tr> |
---|
224 | <td></td> |
---|
225 | <td><div id="comments-27464224"> |
---|
226 | <table> |
---|
227 | <tbody data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true"> |
---|
228 | <tr id="comment-43364834"> |
---|
229 | <td><table> |
---|
230 | <tbody> |
---|
231 | <tr> |
---|
232 | <td><span title="number of 'useful comment' votes received">6</span></td> |
---|
233 | <td></td> |
---|
234 | </tr> |
---|
235 | </tbody> |
---|
236 | </table></td> |
---|
237 | <td><div>Note that there is also a fixed overhead of approximately 10 ms for every Haskell program, so if you subtract that from your Haskell timing it is even closer tocat.Gabriel Gonzalez<span dir="ltr"><span title="2014-12-13 22:35:27Z">Dec 13 '14 at 22:35</span></span></div></td> |
---|
238 | </tr> |
---|
239 | <tr id="comment-43365213"> |
---|
240 | <td><table> |
---|
241 | <tbody> |
---|
242 | <tr> |
---|
243 | <td><span title="number of 'useful comment' votes received">1</span></td> |
---|
244 | <td></td> |
---|
245 | </tr> |
---|
246 | </tbody> |
---|
247 | </table></td> |
---|
248 | <td><div>I know I didn't specify this in the question, but I'm hoping to go for a more idiomatic / "high level" Haskell solution. Upvoted for a good answer though.statusfailed<span dir="ltr"><span title="2014-12-13 22:58:12Z">Dec 13 '14 at 22:58</span></span></div></td> |
---|
249 | </tr> |
---|
250 | </tbody> |
---|
251 | </table> |
---|
252 | </div> |
---|
253 | <div id="comments-link-27464224" data-rep="50" data-anon="true">add a comment</div></td> |
---|
254 | </tr> |
---|
255 | </tbody> |
---|
256 | </table> |
---|
257 | </div> |
---|
258 | <div id="adzerk407721687"></div> |
---|
259 | |
---|
260 | <div id="answer-27473461" data-answerid="27473461" itemscope="" itemtype="http://schema.org/Answer"> |
---|
261 | <table> |
---|
262 | <tbody> |
---|
263 | <tr> |
---|
264 | <td><div>up vote<span itemprop="upvoteCount">12</span>down vote</div></td> |
---|
265 | <td><div itemprop="text"> |
---|
266 | <p>The original question made me think it was about finding a performance issue in the exact code provided. Since the comment "I'm hoping to go for a more idiomatic / "high level" Haskell solution" contradicts that assumption, I'll give the reasonably performing idiomatic Haskell solution.</p> |
---|
267 | <p>The way I would expect any random programmer familiar with Haskell to solve this problem is with Lazy bytestrings. This allows the programmer to simply specify the task of reading input and putting output while letting the compiler worry about mucking with the buffering and looping constructs.</p> |
---|
268 | <p>module Main where</p> |
---|
269 | <pre>import System.IO import System.Environment import Data.ByteString.Lazy as BS import Control.Monad main :: IO () main = do file <- fmap Prelude.head getArgs handle <- openFile file ReadMode buf <- BS.hGetContents handle hPut stdout buf</pre> |
---|
270 | <p>The result is both more readable and better performing than the code in the original question:</p> |
---|
271 | <pre>timing 'cat' real 0m0.075s user 0m0.000s sys 0m0.074s timing strict bytestring with GHC -O2 real 0m0.254s user 0m0.126s sys 0m0.127s timing strict bytestring with GHC -O2 -fllvm real 0m0.267s user 0m0.132s sys 0m0.134s timing lazy bytestring with GHC -O2 real 0m0.091s user 0m0.023s sys 0m0.067s timing lazy bytestring with GHC -O2 -fllvm real 0m0.091s user 0m0.021s sys 0m0.069s</pre> |
---|
272 | <p>That is, the lazy bytestring solution is 21% slower thancat. Puttingcatlast for preferential caching behavior results in 59ms runtime placing the Haskell solution at 51% slower.</p> |
---|
273 | <p>EDIT: Dons suggested using memory mapped IO would more accurately model cat's behavior. I'm not sure how accurate that statement is but mmap almost always results in better performance and this situation is certainly no exception:</p> |
---|
274 | <pre>timing memory mapped lazy bytestring with GHC -O2 real 0m0.008s user 0m0.004s sys 0m0.003s</pre> |
---|
275 | <p>Which was produced by:</p> |
---|
276 | <pre>module Main where import System.IO (stdout) import System.Environment import System.IO.Posix.MMap.Lazy import Data.ByteString.Lazy (hPut) import Control.Monad main :: IO () main = do file <- fmap Prelude.head getArgs buf <- unsafeMMapFile file hPut stdout buf</pre> |
---|
277 | </div> |
---|
278 | <table> |
---|
279 | <tbody> |
---|
280 | <tr> |
---|
281 | <td><div></div></td> |
---|
282 | </tr> |
---|
283 | </tbody> |
---|
284 | </table></td> |
---|
285 | </tr> |
---|
286 | </tbody> |
---|
287 | </table> |
---|
288 | </div> |
---|
289 | </div> |
---|
290 | |
---|
291 | </div> |
---|
292 | </body> |
---|
293 | </html> |
---|
294 | |
---|