<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jul 29, 2015 at 7:27 PM, Sean Silva <span dir="ltr"><<a href="mailto:chisophugis@gmail.com" target="_blank">chisophugis@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On Wed, Jul 29, 2015 at 6:55 PM, Bob Wilson <span dir="ltr"><<a href="mailto:bob.wilson@apple.com" target="_blank">bob.wilson@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><span><blockquote type="cite"><div>On Jul 29, 2015, at 4:56 PM, Alexey Samsonov <<a href="mailto:vonosmas@gmail.com" target="_blank">vonosmas@gmail.com</a>> wrote:</div><br><div><div dir="ltr" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">Do relaxed atomics actually introduce that much of slowdown?</div></div></blockquote><div><br></div></span>I would definitely want to see some data showing that they do not slow things down before we decide to do this unconditionally. We’ve discussed this issue several times in the past. My recollection is those discussions ended with an acknowledgement there is a tradeoff between speed and accuracy and that we don’t all agree on where we want to be on that spectrum. Adding options to let people choose would be one solution. Good data, on a variety of platforms, showing that it doesn’t make much difference would be another way to resolve it.</div></div></blockquote><div><br></div></span><div>+1</div><div><br></div><div>In my testing, the overhead of the existing instrumentation is about a 2x slowdown, which is starting to get close to the range it would be very difficult to play an instrumented game. I wouldn't want to make this much slower. I'm glad to test this for you; I'll try to get around to this this week.</div><div><br></div></div></div></div></blockquote><div><br></div><div>Sean and I tested Alexey's patch on one of our large titles and got somewhere in the area of 2.5 to 3x worse performance than without AtomicRMW. For the game we tested, it was basically unplayable.</div><div><br></div><div>Jake Van Adrighem</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div></div><div>Also, in the past David Li suggested that his findings were that not using atomic operations "<span style="font-size:13px">only contribute</span></div><div><span style="font-size:13px">to very small count variations" </span><a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__groups.google.com_d_msg_llvm-2Ddev_ScLa2xIdo9s_Ow1FPDVVRIoJ&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=SLAHuMS097rE0HJBsM_g5H8e-AltKY6DSKt4fmyXXdg&s=j6dXaeF32Dce88n0W1vgcjiII4AQnur8LuEPiKzgwCc&e=" target="_blank">https://groups.google.com/d/msg/llvm-dev/ScLa2xIdo9s/Ow1FPDVVRIoJ</a></div><div>CC'ing David in case he has more input to the discussion.</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>-- Sean Silva</div></font></span><div><div class="h5"><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><br><blockquote type="cite"><div><div><div><div dir="ltr" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div><br></div><div>You're intentionally introducing a data race, this doesn't look good to me at all. However, I'm not confident about</div><div>what's allowed in LLVM IR - it's not C++ where any source-level data race is UB, but not an x86 assembly either.</div></div><div class="gmail_extra" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br><div class="gmail_quote">On Wed, Jul 29, 2015 at 4:43 PM, Justin Bogner<span> </span><span dir="ltr"><<a href="mailto:mail@justinbogner.com" target="_blank">mail@justinbogner.com</a>></span><span> </span>wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span>Alexey Samsonov <<a href="mailto:vonosmas@gmail.com" target="_blank">vonosmas@gmail.com</a>> writes:<br>> samsonov created this revision.<br>> samsonov added reviewers: dnovillo, bogner.<br>> samsonov added a subscriber: llvm-commits.<br>><br>> Since we introduced counters for functions in COMDAT sections (e.g.<br>> inline functions from STL headers), these headers can easily be<br>> incremented concurrently by multiple threads. Replace load-add-store<br>> with a single "atomicrmw add" with monotonic memory ordering.<br><br></span>This significantly changes the performance characteristics of this code,<br>pessimizing single-threaded users and potentially making the<br>multithreaded performance issues even worse.<br><br>It's fine to add an option to lower these to atomics, since this does<br>guarantee accuracy, but I think we need a switch to choose which kind of<br>lowering we're interested in in that case.<br><div><div><br>><span> </span><a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__reviews.llvm.org_D11579&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=lDx1rX-3B32oZTA_vCe21kRN0Y14ujW2ePnnU3JiUX4&s=tiiUXsu0al8aXyrPKSc28tcPx4YG5wxgSglC63-ASTQ&e=" rel="noreferrer" target="_blank">http://reviews.llvm.org/D11579</a><br>><br>> Files:<br>>   lib/Transforms/Instrumentation/InstrProfiling.cpp<br>><br>> Index: lib/Transforms/Instrumentation/InstrProfiling.cpp<br>> ===================================================================<br>> --- lib/Transforms/Instrumentation/InstrProfiling.cpp<br>> +++ lib/Transforms/Instrumentation/InstrProfiling.cpp<br>> @@ -147,9 +147,9 @@<br>>    IRBuilder<> Builder(Inc->getParent(), *Inc);<br>>    uint64_t Index = Inc->getIndex()->getZExtValue();<br>>    Value *Addr = Builder.CreateConstInBoundsGEP2_64(Counters, 0, Index);<br>> -  Value *Count = Builder.CreateLoad(Addr, "pgocount");<br>> -  Count = Builder.CreateAdd(Count, Builder.getInt64(1));<br>> -  Inc->replaceAllUsesWith(Builder.CreateStore(Count, Addr));<br>> +  Builder.CreateAtomicRMW(AtomicRMWInst::Add, Addr, Builder.getInt64(1),<br>> +                          llvm::Monotonic);<br>> +  assert(Inc->use_empty() && "InstrProfIncrementInst has uses!");<br>>    Inc->eraseFromParent();<br>>  }<br><br></div></div></blockquote></div><br><br clear="all"><div><br></div>--<span> </span><br><div><div dir="ltr">Alexey Samsonov<br><a href="mailto:vonosmas@gmail.com" target="_blank">vonosmas@gmail.com</a></div></div></div></div></div><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">_______________________________________________</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">llvm-commits mailing list</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><a href="mailto:llvm-commits@cs.uiuc.edu" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank">llvm-commits@cs.uiuc.edu</a><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a></div></blockquote></div><br></div><br>_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
<br></blockquote></div></div></div><br></div></div>
<br>_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
<br></blockquote></div><br></div></div>