Re: Erlang JIT and loaded code
Vitor Rocha <[email protected]> Mon, 25 Apr 2022 21:06:33 -0300
| Newsgroups | gmane.comp.lang.erlang.general |
|---|---|
| Message-ID | <CAOJ54GpFcXvDR702+dyckML2taUHgnd0zryY6qSiSdEcj2H0oA@mail.gmail.com> |
--000000000000d8637205dd837779 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thanks for the answer, Lukas. Giving a bit more context: I'm doing a benchmarking research on Erlang JIT, similar to what ErLLVM did. I managed to get the code size (I suppose) from internal structures: - erl_module_instance->code_length (for emulator and asm) - erl_module_instance->hipe_code->text_segment_size (for HiPE and ErLLVM= ) Does that make sense or are those values unrelated? Em seg., 25 de abr. de 2022 =C3=A0s 06:13, Lukas Larsson <[email protected]> escreveu: > Hello! > > On Tue, Apr 19, 2022 at 7:17 AM Vitor Rocha <[email protected]> wrote: > >> (1) how do I know if my code is actually being executed as interpreted o= r >> native? >> > > All code loaded from .beam files are run natively if the VM supports JIT > compilation. > > >> (2) If I compile a module inside Erlang's shell, using the `c:c/1` >> function, is the module going to be compiled to native too? Will its >> execution be switched to native? >> > > There is no difference in how it is compiled, it will always be translate= d > into native code when loaded. > > >> (3) Where is stored the generated beamasm native code? I would like to >> get its size in bytes? >> > > It is stored in memory of the VM. You can get a file dump of the native > code by passing `+JDdump true` when starting `erl`. There is no way to ge= t > the loaded memory size of a single module, but you can get a relatively > close value by checking what `erlang:memory(code)` returns before and aft= er > the module is loaded. > > >> >> -- >> Atenciosamente, >> Vitor Rocha da Silva >> > --=20 Atenciosamente, Vitor Rocha da Silva --000000000000d8637205dd837779 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div>Thanks for the answer, Lukas.<br></div><div><br></div= ><div>Giving a bit more context: I'm doing a benchmarking research on E= rlang JIT, similar to what ErLLVM did.<br></div><div><br></div><div>I manag= ed to get the code size (I suppose) from internal structures:<br><ul><li>er= l_module_instance->code_length (for emulator and asm)</li><li>erl_module= _instance->hipe_code->text_segment_size (for HiPE and ErLLVM)</li></u= l><div>Does that make sense or are those values unrelated?<br></div></div><= /div><br><div class=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">E= m seg., 25 de abr. de 2022 =C3=A0s 06:13, Lukas Larsson <<a href=3D"mail= to:[email protected]">[email protected]</a>> escreveu:<br></div><blockquot= e class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px s= olid rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr"><div>Hello!</div><= br><div class=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">On Tue,= Apr 19, 2022 at 7:17 AM Vitor Rocha <<a href=3D"mailto:vitor.vrs@gmail.= com" target=3D"_blank">[email protected]</a>> wrote:<br></div><blockqu= ote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px= solid rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr"><div>(1) how do = I know if my code is actually being executed as interpreted or native?</div= ></div></blockquote><div><br></div><div>All code loaded from .beam files ar= e run natively if the VM supports JIT compilation.</div><div>=C2=A0</div><b= lockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-le= ft:1px solid rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr"><div>(2) I= f I compile a module inside Erlang's shell, using the `c:c/1` function,= is the module going to be compiled to native too? Will its execution be sw= itched to native?<br></div></div></blockquote><div><br></div><div>There is = no=C2=A0difference in how it is compiled, it will always be translated into= native code when loaded.</div><div>=C2=A0</div><blockquote class=3D"gmail_= quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,= 204);padding-left:1ex"><div dir=3D"ltr"><div></div><div>(3) Where is stored= the generated beamasm native code? I would like to get its size in bytes?<= br></div></div></blockquote><div><br></div><div>It is stored in memory of t= he VM. You can get a file dump of the native code by passing `+JDdump true`= when starting `erl`. There is no way to get the loaded memory size of a si= ngle module, but you can get a relatively close value by checking what `erl= ang:memory(code)` returns before and after the module is loaded.</div><div>= =C2=A0</div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0= .8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir=3D"l= tr"><div><br></div><div>-- <br><div dir=3D"ltr"><span style=3D"font-family:= "trebuchet ms",sans-serif">Atenciosamente,<br>Vitor Rocha da Silv= a</span><br></div></div></div> </blockquote></div></div> </blockquote></div><br clear=3D"all"><br>-- <br><div dir=3D"ltr" class=3D"g= mail_signature"><span style=3D"font-family:trebuchet ms,sans-serif">Atencio= samente,<br>Vitor Rocha da Silva</span><br></div> --000000000000d8637205dd837779--