<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
Perhaps I'm getting confused with the terminology, but I don't think moving <i>compilation</i> to a separate process helps here.  IIUC, compilation (as in LLVM IR -> x86 code) can happen anywhere, the problem is loading the JITed code (ie, make writeable memory
 executable.)</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
As mentioned, there are many places this can be done.</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
If Venus does not suite your needs, the easiest way to achieve this would be to:</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
- back all buffer/texture memory with shared memory, visible to the 2<span><sup>nd</sup> process</span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<span>- modify gallivm to tell LLVM either spit out .so files, or to use shared memory</span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<span class="ContentPasted1">- modify gallivm_jit_function to return a wrapper that marshals the call into the 2<span><sup>nd</sup> process</span>:</span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<span class="ContentPasted1">  - either a generic C wrapper which can introspect the LLVM IR Function arguments</span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<span class="ContentPasted1">  - or hand written C wrappers for every function prototype returned by <span style="display: inline !important; background-color: rgb(255, 255, 255);" class="ContentPasted0">gallivm_jit_function</span></span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
- there are also a few places where JIT code refers to host process memory addresses explicitly (e.g, util_format_xxx helper functions) which need to be handled separately (e.g, by passing these addresses in a structure which can be rewritten to match the 2<span><sup>nd</sup> process</span>)</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
Jose</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size: 11pt; color: rgb(0, 0, 0);"><b>From:</b> mesa-dev <mesa-dev-bounces@lists.freedesktop.org> on behalf of Dave Airlie <airlied@gmail.com><br>
<b>Sent:</b> Thursday, April 27, 2023 08:39<br>
<b>To:</b> Josh Gargus <jjosh@google.com><br>
<b>Cc:</b> mesa-dev@lists.freedesktop.org <mesa-dev@lists.freedesktop.org><br>
<b>Subject:</b> Re: Advice on modifying Lavapipe to isolate JIT compilation in separate process</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt">
<div class="PlainText">!! External Email<br>
<br>
On Thu, 27 Apr 2023 at 15:18, Josh Gargus <jjosh@google.com> wrote:<br>
><br>
> Thanks for your advice!  I hadn't looked at Venus, but that seems like a very promising place to start.<br>
><br>
> The other approach feels more approachable now too; it feels like there are less "unknown unknowns", although there are plenty of known unknowns to investigate (address independence was one that was already bugging be before I wrote to this list).<br>
<br>
I think it shouldn't be too horrible to work out, another option might<br>
be to abuse the cache somehow, but I think that still needs writable +<br>
executable which probably doesn't help, but stuff should be address<br>
independent as I do write x86 asm programs to the cache and read them<br>
back out, only relocating around the global symbols.<br>
<br>
><br>
> It seems like Venus is the more straightforward approach, so I'm inclined to just go with it.  However, it seems like there would be a performance hit compared to only doing JIT compilation in a separate process.  Do you have a rough sense of the performance
 hit of serializing everything over Venus?  The answer will depend on the workload, I know.<br>
<br>
Yeah I think you'll definitely see a large perf hit than just moving<br>
compilation out to a separate process, I'm not sure of the raw venus<br>
overhead numbers here, someone else might have more information<br>
available.<br>
<br>
Dave.<br>
<br>
!! External Email: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender.<br>
</div>
</span></font></div>
</body>
</html>