<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 20 Apr 2015, at 16:20, Eliot Miranda &lt;<a href="mailto:eliot.miranda@gmail.com" class="">eliot.miranda@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="content-type" content="text/html; charset=utf-8" class=""><div dir="auto" class=""><div class="">Hi Nicolai,<br class=""></div><div class=""><br class="">On Apr 19, 2015, at 3:36 AM, Nicolai Hess &lt;<a href="mailto:nicolaihess@web.de" class="">nicolaihess@web.de</a>&gt; wrote:<br class=""><br class=""></div><blockquote type="cite" class=""><div class=""><span class=""></span></div></blockquote><blockquote type="cite" class=""><div dir="ltr" class=""><br class=""><div class="gmail_extra"><br class=""><div class="gmail_quote">2015-04-18 18:35 GMT+02:00 Eliot Miranda <span dir="ltr" class="">&lt;<a href="mailto:eliot.miranda@gmail.com" target="_blank" class="">eliot.miranda@gmail.com</a>&gt;</span>:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">&nbsp;<br class=""><div dir="auto" class=""><div class="">Hi Nicolai,</div><div class=""><br class=""></div><div class="">&nbsp; &nbsp; I'm rather excited that you're interested in this.&nbsp; Perhaps we (you, Esteban, Clément and I) could meet in a google hangout to discuss soon?</div><div class=""><br class=""></div><div class="">As Esteban said I was able to demonstrate threaded calls on Mac.&nbsp; CoInterpreterMT is the subclass of&nbsp;<span class="">CoInterpreter that adds support for threading. But the code is out-of-date.&nbsp; So some work is needed to get back to where I was.&nbsp; But to have someone focused on this is the key.&nbsp; I don't think we have someone with the cycles yet and if you're that person (and can talk to&nbsp;</span><span class="">Esteban, Clément and I, and maybe Ronie and Doug McPherson and Thierry) then I'm sure we can get it working soon.&nbsp; Spur has the necessary pinning support for example.</span><br class=""></div></div></blockquote><div class=""><br class=""></div><div class="">Well, I am not sure I can be a help :)<br class=""></div><div class="">And I spend my main time for fixing issues in the core image. <br class="">But I would like to help if I can.<br class=""></div></div></div></div></blockquote><div class=""><br class=""></div>Good, thanks!<div class=""><br class=""><blockquote type="cite" class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class="">About the CoInterpreterMT, is it possible to get this working with the NB additions?&nbsp;</div></div></div></div></blockquote><br class="">Of course, but NB has several issues<div class="">- it isn't cross-platform</div><div class="">- it isn't secure (it makes the entire heap executable)</div><div class="">- it is yet another JIT while we have a cross-platform one which can more easily integrate FFI marshaling code with Smalltalk code</div></div></div></div></blockquote><div><br class=""></div><div>I will also add that in the future we are going to adopt FFI, so no reason to re-implement something with NB (talking about reimplement multithread FFI, here… in case is possible).&nbsp;</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="auto" class=""><div class=""><div class=""><br class=""><blockquote type="cite" class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class="">It would be great but it sounds too simple, but would it work if we use a MT VM with NB additions and<br class=""></div><div class="">change the NB callback entry/leave code to make calls to ownVM and disownVM <br class="">(for callbacks defined in the main vm thread, but called by some native code in another thread) ?<br class=""></div></div></div></div></blockquote><div class=""><br class=""></div>Hmmm are NB callbacks different from Alien callbacks? &nbsp;IIRC, NB uses the Alien callback machinery. &nbsp;Igor, did you reimplement callback entry fir NB or reuse my code? &nbsp;If not, what was the motivation to not use the existing infrastructure?</div></div></div></div></blockquote><div><br class=""></div><div>No, is a different implementation (and like 10x slower, because it needs to do weird stuff with the heap)</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="auto" class=""><div class=""><div class=""><div class=""><br class=""></div><div class=""><br class=""><blockquote type="cite" class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class="">I am not sure if we need spurs pinning support here, because the current NB implementation works without it.</div></div></div></div></blockquote><div class=""><br class=""></div><div class="">What would happen if one made an FFI call that included a ByteArray passed by reference which is used by the called code as a buffer and that code called back and in the callback the GC ran and moved the buffer then?</div><div class=""><br class=""></div><div class="">What would happen if one&nbsp;<span style="-webkit-tap-highlight-color: rgba(26, 26, 26, 0.292969); -webkit-composition-fill-color: rgba(175, 192, 227, 0.230469); -webkit-composition-frame-color: rgba(77, 128, 180, 0.230469); " class="">made an FFI call that included a ByteArray passed by reference which is used by the called code as a buffer</span><span style="-webkit-tap-highlight-color: rgba(26, 26, 26, 0.292969); -webkit-composition-fill-color: rgba(175, 192, 227, 0.230469); -webkit-composition-frame-color: rgba(77, 128, 180, 0.230469); " class="">&nbsp;and a thread switch occurred and the system ran the GC which moved the buffer while the first thread was using the buffer?</span></div></div></div></div></div></div></blockquote><div><br class=""></div><div>yes… there is not so simple. In practice, NB uses a separate memory segment, but it has to copy from/to ByteArrays when asking for it. This is a major drawback &nbsp;(in all previous FFI implementations, including NB) that will be fixed with pin objects…&nbsp;</div><div><br class=""></div><div>cheers,&nbsp;</div><div>Esteban</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="auto" class=""><div class=""><div class=""><div class=""><div class=""><br style="-webkit-tap-highlight-color: rgba(26, 26, 26, 0.296875); -webkit-composition-fill-color: rgba(175, 192, 227, 0.230469); -webkit-composition-frame-color: rgba(77, 128, 180, 0.230469); " class=""><span style="-webkit-tap-highlight-color: rgba(26, 26, 26, 0.296875); -webkit-composition-fill-color: rgba(175, 192, 227, 0.230469); -webkit-composition-frame-color: rgba(77, 128, 180, 0.230469); " class="">Eliot (phone)</span></div><br class=""><blockquote type="cite" class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto" class=""><div class=""><br class="">Eliot (phone)</div><div class=""><br class="">On Apr 18, 2015, at 9:24 AM, Nicolai Hess &lt;<a href="mailto:nicolaihess@web.de" target="_blank" class="">nicolaihess@web.de</a>&gt; wrote:<br class=""><br class=""></div><blockquote type="cite" class=""><div class=""><span class=""></span></div></blockquote><blockquote type="cite" class=""><div class=""><div dir="ltr" class="">Thank you Esteban,<br class=""><div class=""><div class="gmail_extra"><br class=""><div class="gmail_quote">2015-04-18 9:36 GMT+02:00 Esteban Lorenzano <span dir="ltr" class="">&lt;<a href="mailto:estebanlm@gmail.com" target="_blank" class="">estebanlm@gmail.com</a>&gt;</span>:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">&nbsp;<br class=""><div style="word-wrap:break-word" class="">Hi,&nbsp;<div class=""><br class=""></div><div class="">So… “multithread” is a complicated issue. Pharo as most Smalltalks is designed thinking is as monolithic so if you are trying to make the image to work in different processes… it will not be easy at all :)</div><div class="">Time ago Eliot did a prototype (more than a prototype in fact, but still far from “production ready”) to have Threaded FFI and I’m quite sure this is the way to go, at least as a 1st milestone.&nbsp;</div><div class=""><br class=""></div><div class="">I already have a process building this experimental VM:</div><div class=""><br class=""></div><div class=""><a href="https://ci.inria.fr/pharo/view/VM/job/CogMTVM/" target="_blank" class="">https://ci.inria.fr/pharo/view/VM/job/CogMTVM/</a></div></div></blockquote><div class=""><br class=""></div><div class="">But this one does not include NativeBoost support. Do we have a build with MT and NB?<br class=""></div><div class="">&nbsp;</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" class=""><div class=""><br class=""></div><div class="">(No idea why windows build failed last two times… this can be a random fail).</div><div class=""><br class=""></div><div class="">I do not remember exactly the changes needed in the image to take advantage of it… it was just an instVar in Process, I think, but then FFI package was adapted to take advantage of this… no idea where it is now (if is already incorporated in latest FFI, which we have).</div><div class=""><br class=""></div><div class="">Then, after this… I imagine the callback mechanism can be adapted to work in multithread environments but probably we will need something like isolates from Dart to provide some degree of multithread processing without killing the image (but I’m just thinking in loud here, this can be a really bad idea, and probably there are other ways to do this better… I will let Eliot to explain better).&nbsp;</div><div class=""><br class=""></div><div class=""><b class="">TL;DR: </b>Start for the CogMTVM, is the way to go.</div><div class=""><br class=""></div><div class="">cheers,&nbsp;</div><div class="">Esteban</div><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On 17 Apr 2015, at 09:06, Nicolai Hess &lt;<a href="mailto:nicolaihess@web.de" target="_blank" class="">nicolaihess@web.de</a>&gt; wrote:</div><br class=""><div class=""><div dir="ltr" class=""><div class=""><div class=""><div class=""><div class=""><div class=""><div class=""><div class=""><div class=""><div class=""><div class=""><div class=""><div class=""><div class=""><div class="">Hi, <br class=""><br class=""></div>I've tried to build a pharovm with multithread support. I changed the config in the <br class=""></div>pharo generator.image to use the cogmt config and was able to build a vm.<br class=""></div>But this vm crashes on startup. (windows7)<br class=""><br class="">Is this the right way and did anyone got this to work (windows or linux)?<br class=""><br class=""></div>And can this work to make NB callbacks working for multithreaded libraries.<br class=""></div><br class="">(I made some simple bindings for the gstreamer lib with NB, this works<br class=""></div>for simple calls (create element/change state). But I guess this won't work<br class=""></div>for any gstreamer function that requests a callback that may b e called from<br class=""></div>a different thread)<br class=""><br class=""></div>Would this be the right way to do:<br class=""></div>- build a vm with MT support<br class=""></div>- guard the NB callback entry/leave code with the ownVM()/disownVM() call.<br class=""><br class=""></div>Or is there more to do.<br class=""><br class=""></div><div class="">Thanks in advance<br class=""></div><br class=""><br class=""></div>nicolai<br class=""><div class=""><div class=""><div class=""><br class=""><br class=""></div></div></div></div>
</div></blockquote></div><br class=""></div></div><br class=""></blockquote></div><br class=""></div></div></div>
</div></blockquote></div><br class=""></blockquote></div><br class=""></div></div>
</blockquote></div></div></div></div></div></blockquote></div><br class=""></body></html>