JIT

By: (0xe2.0x9a.0x9b.delete@this.gmail.com), July 13, 2013 4:50 am
Room: Moderated Discussions
Linus Torvalds (torvalds.delete@this.linux-foundation.org) on July 12, 2013 11:14 am wrote:
> ⚛ (0xe2.0x9a.0x9b.delete@this.gmail.com) on July 12, 2013 10:48 am wrote:
> >
> > The primary goal of JIT is to achieve better performance via code specialization.
> > That's the only thing that can beat static compilation.
>
> Nobody sane believes the "JIT can beat static compilers" fairy tales.

That's no fairy tail. The only thing that can beat static compilation is runtime code specialization. The main problem is the high complexity of such a JIT compiler.

> JIT's have other advantages. Performance isn't one of them. They need to get close enough, the "beating static
> compilers" thing was always just a dream, backed up by benchmarks that were completely unrealistic.
>
> The real advantage of JIT is handling stuff that traditional compilers aren't good at. Particularly
> cross-architecture code, but also languages that are (mis-)designed to not have sufficient
> static information, and where you need to do a lot of decisions at runtime.

Most codes in dynamic programming languages contain large parts that are at least in theory compilable statically. So it isn't true that those programs lack static information. The truth is that static compilers either do not exist or are incapable of detecting and using the available static information.

If you take a careful look at Python/Java/Javascript/etc programs you may be able to find that there is a lot of static information in the source code. Simply imagine how you would rewrite the code into C, that's all there is to it.

> Look around you, and ask yourself where people use JIT's.

The implementation of a language can start as an interpreter, or as a compiler generating machine code. Over time, performance concerns force interpreted implementations to be converted to JIT compilers. A JIT compiler takes several years to develop. The primary reason for the 2nd stage being a JIT engine is that it is easier to integrate it into the existing infrastructure than to integrate a static compiler into the dynamic programming language. This does not imply that static compilation of source codes written in the dynamic language is impossible, nor does it imply that static compilation (of initially dynamic languages) would have worse performance than the JIT.

> It's used as a higher-performance alternative to languages
> that were designed for being interpreted (which are often very dynamic in their data types, since for interpretation
> that is very natural and makes things easier for users) and for architecture-neutral languages (ie Java VM and
> variations like Dalvik, but also things like OpenGL and DirectX shader languages etc).

Jitted C done right generates better code than statically compiled C code. If a JIT compiler is constrained to deal with trivial cases then the JIT has no performance advantage over statically compiled C code. So the JIT compiler for C would need to be at least comparable in complexity to the static C compiler. The assumption that JIT compilers have to deal with easy cases only is invalid.

In relation to OpenGL and DirectX: Static shader codes can be compiled statically when the application is first installed onto the computer and when an update is downloaded from internet. Recompilation also needs to happen when the machine changes its graphics card or drivers. None of these cases requires a JIT compiler, so all of this can be done via static compilation and caching.

> So forget the "JITs perform better" crap. It's a bedtime story for retarded gerbils.

If JIT always runs after the static compiler has completed its job then the jitted code by definition performs better. Unfortunately, without reason, the static compilation pass is completely absent in programming languages such as Python or Javascript. Maybe, Javascript and similar languages will obtain a static compilation pass in the future.

There is no equivalent for "gcc a.c; ./a.out" in the Python world, programs are started be typing "python a.py". The form in which static compilation will appear in the dynamic programming language world is via transparent caching and background compilation. At the same time "pythonc a.py" will appear as an option of how to tell Python to statically compile a.py and add the compiled code to its caches.

> The
> real story is "JITs can perform well enough, and have advantages in other areas".
>
> They have their own set of disadvantages too, so it's not an "either or" situation.
> We'll continue to see both, anybody that tells you otherwise is lying.
>
> Linus

The final stage of all static programming languages (including the C programming language) which initially have a static compile-to-machine-code compiler is to hide JIT compilation behind a command such as "gcc a.c". Running this command will perform static compilation. Running the compiled executable will start a JIT compiler. The combination static+JIT will have better performance then static compilation alone.

-Atom
< Previous Post in ThreadNext Post in Thread >
TopicPosted ByDate
ARM at Computexanon2013/06/03 07:54 AM
  ARM at ComputexExophase2013/06/03 08:31 AM
    ARM at ComputexWilco2013/06/03 09:52 AM
      ARM at ComputexExophase2013/06/03 11:02 AM
        ARM at Computexnone2013/06/03 12:28 PM
          ARM at ComputexAlberto2013/06/04 09:41 AM
            ARM at Computexanon2013/06/04 12:36 PM
              ARM at ComputexWilco2013/06/04 02:56 PM
                ARM at ComputexDavid Kanter2013/06/04 03:51 PM
                  ARM at ComputexNobodyatAll2013/06/04 04:53 PM
                  ARM at Computexanon2013/06/04 05:53 PM
        ARM at ComputexWilco2013/06/03 12:47 PM
    ARM at Computexanon2013/06/04 03:03 AM
      ARM at ComputexDavid Kanter2013/06/04 07:16 AM
      ARM at ComputexExophase2013/06/04 09:36 AM
        ARM at ComputexWilco2013/06/04 03:09 PM
          ARM at ComputexNobodyatAll2013/06/04 03:23 PM
          ARM at ComputexDavid Kanter2013/06/04 04:00 PM
            ARM at Computexnone2013/06/05 04:26 AM
              ARM at Computexanon2013/06/05 06:19 AM
              ARM at Computexaaron spink2013/06/05 02:04 PM
                Saltwell Outperforming A15...With Less Power!!!Jason2013/06/07 12:56 PM
                  Saltwell Outperforming A15...With Less Power!!!John2013/06/08 05:28 AM
                    Saltwell Outperforming A15...With Less Power!!!Kevin G2013/06/08 01:18 PM
                      Saltwell Outperforming A15...With Less Power!!!David Kanter2013/06/08 07:43 PM
                      Saltwell Outperforming A15...With Less Power!!!tarlinian2013/06/09 01:00 PM
                        Saltwell Outperforming A15...With Less Power!!!none2013/06/09 02:11 PM
                          Saltwell Outperforming A15...With Less Power!!!none2013/07/10 10:46 AM
                            Saltwell Outperforming A15...With Less Power!!!Wilco2013/07/10 06:59 PM
                              Saltwell Outperforming A15...With Less Power!!!Klimax2013/07/10 09:03 PM
                                Saltwell Outperforming A15...With Less Power!!!anon2013/07/10 09:29 PM
                                  Saltwell Outperforming A15...With Less Power!!!Klimax2013/07/10 10:30 PM
                                    Saltwell Outperforming A15...With Less Power!!!Wilco2013/07/11 12:04 AM
                                      Saltwell Outperforming A15...With Less Power!!!Klimax2013/07/11 02:10 AM
                                        Saltwell Outperforming A15...With Less Power!!!anon2013/07/11 03:10 AM
                                        Saltwell Outperforming A15...With Less Power!!!Wilco2013/07/11 03:43 AM
                                        Saltwell Outperforming A15...With Less Power!!!Steve2013/07/14 07:10 PM
                                          Saltwell Outperforming A15...With Less Power!!!Klimax2013/07/14 09:55 PM
                                          Saltwell Outperforming A15...With Less Power!!!bakaneko2013/07/15 01:03 AM
                                            Saltwell Outperforming A15...With Less Power!!!anon2013/07/16 12:07 AM
                                              Saltwell Outperforming A15...With Less Power!!!bakaneko2013/07/16 05:25 AM
                                                Saltwell Outperforming A15...With Less Power!!!none2013/07/16 05:34 AM
                                                Saltwell Outperforming A15...With Less Power!!!Exophase2013/07/16 09:34 AM
                                                  Saltwell Outperforming A15...With Less Power!!!bakaneko2013/07/18 01:24 PM
                                                    Saltwell Outperforming A15...With Less Power!!!none2013/07/18 02:26 PM
                                    Saltwell Outperforming A15...With Less Power!!!anon2013/07/11 01:50 AM
                                      Saltwell Outperforming A15...With Less Power!!!Klimax2013/07/11 10:25 PM
                                        Saltwell Outperforming A15...With Less Power!!!anon2013/07/11 10:45 PM
                                          Saltwell Outperforming A15...With Less Power!!!Klimax2013/07/11 11:10 PM
                                            Saltwell Outperforming A15...With Less Power!!!anon2013/07/12 12:52 AM
                                    Saltwell Outperforming A15...With Less Power!!!Gabriele Svelto2013/07/11 03:20 AM
                                      Saltwell Outperforming A15...With Less Power!!!Klimax2013/07/11 10:51 PM
                                Saltwell Outperforming A15...With Less Power!!!bakaneko2013/07/10 11:02 PM
                                  Saltwell Outperforming A15...With Less Power!!!Klimax2013/07/10 11:28 PM
                                    Saltwell Outperforming A15...With Less Power!!!none2013/07/11 12:49 AM
                                      Saltwell Outperforming A15...With Less Power!!!Klimax2013/07/11 02:00 AM
                                        Saltwell Outperforming A15...With Less Power!!!Klimax2013/07/11 02:02 AM
                                        Saltwell Outperforming A15...With Less Power!!!none2013/07/11 03:44 AM
                                          Saltwell Outperforming A15...With Less Power!!!Michael S2013/07/11 04:33 AM
                                            Saltwell Outperforming A15...With Less Power!!!none2013/07/11 04:58 AM
                                              Saltwell Outperforming A15...With Less Power!!!none2013/07/11 04:59 AM
                                              Saltwell Outperforming A15...With Less Power!!!Wilco2013/07/11 06:40 AM
                                                Saltwell Outperforming A15...With Less Power!!!Michael S2013/07/11 07:34 AM
                                                  Saltwell Outperforming A15...With Less Power!!!none2013/07/11 07:50 AM
                                              Saltwell Outperforming A15...With Less Power!!!Michael S2013/07/11 08:02 AM
                                          Saltwell Outperforming A15...With Less Power!!!Klimax2013/07/11 09:11 PM
                                      Saltwell Outperforming A15...With Less Power!!!Michael S2013/07/11 03:12 AM
                                        Saltwell Outperforming A15...With Less Power!!!none2013/07/11 03:51 AM
                                          Saltwell Outperforming A15...With Less Power!!!Wilco2013/07/11 04:03 AM
                                            Saltwell Outperforming A15...With Less Power!!!none2013/07/11 04:12 AM
                                              Saltwell Outperforming A15...With Less Power!!!Wilco2013/07/11 06:26 AM
                                                Saltwell Outperforming A15...With Less Power!!!none2013/07/11 07:29 AM
                                                Saltwell Outperforming A15...With Less Power!!!Wilco2013/07/12 03:08 AM
                                                  Saltwell Outperforming A15...With Less Power!!!Michael S2013/07/12 03:25 AM
                                              Saltwell Outperforming A15...With Less Power!!!Klimax2013/07/11 10:55 PM
                                                Saltwell Outperforming A15...With Less Power!!!Megol2013/07/13 06:20 AM
                                    Java/Dalvik benchmarksbakaneko2013/07/11 01:26 AM
                                  Saltwell Outperforming A15...With Less Power!!!Linus Torvalds2013/07/11 09:57 AM
                                    Saltwell Outperforming A15...With Less Power!!!Linus Torvalds2013/07/11 10:20 AM
                                      Saltwell Outperforming A15...With Less Power!!!Ian Ameline2013/07/11 02:20 PM
                                      Saltwell Outperforming A15...With Less Power!!!Sylvain Collange2013/07/12 01:29 AM
                                        Saltwell Outperforming A15...With Less Power!!!Wilco2013/07/12 02:51 AM
                                          Saltwell Outperforming A15...With Less Power!!!Sylvain Collange2013/07/12 05:00 AM
                                      Saltwell Outperforming A15...With Less Power!!!bakaneko2013/07/12 02:28 AM
                                        Saltwell Outperforming A15...With Less Power!!!Linus Torvalds2013/07/12 08:11 AM
                                          Saltwell Outperforming A15...With Less Power!!!bakaneko2013/07/12 09:12 AM
                                          Saltwell Outperforming A15...With Less Power!!!2013/07/12 09:48 AM
                                            Saltwell Outperforming A15...With Less Power!!!Linus Torvalds2013/07/12 10:14 AM
                                              JIT2013/07/13 04:50 AM
                                                How'd you get this flower symbol as your user name ?anon2013/07/13 08:20 AM
                                                  How'd you get this flower symbol as your user name ?Doug S Ꭳ❂〄☢⚓♜☎♬⚄☠2013/07/13 09:12 AM
                                                JITx2013/07/15 05:43 AM
                                    Not reallyAnon2013/07/11 10:21 AM
                                    consistency, pleaseMichael S2013/07/11 10:22 AM
                                      consistency, pleaseLinus Torvalds2013/07/11 10:52 AM
                                        consistency, pleaseMichael S2013/07/11 01:43 PM
                                          consistency, pleaseLinus Torvalds2013/07/11 02:12 PM
                                            consistency, pleaseMark Roulo2013/07/11 02:54 PM
                                              the discussion was about absence of AVX in Silvermont (NT)Michael S2013/07/11 02:59 PM
                                                the discussion was about absence of AVX in SilvermontMark Roulo2013/07/11 03:19 PM
                                                  the discussion was about absence of AVX in SilvermontLinus Torvalds2013/07/12 08:16 AM
                                                    Thank youMark Roulo2013/07/12 08:58 AM
                                                    the discussion was about absence of AVX in Silvermontanon2013/07/12 09:10 AM
                                                      Not really (again)Anon2013/07/12 09:26 AM
                                                        Not really (again)anon2013/07/12 04:40 PM
                                                    the discussion was about absence of AVX in SilvermontLinus Torvalds2013/07/12 09:31 AM
                                                      you are wrong at about 100% of you saidMichael S2013/07/13 10:22 AM
                                                        you are wrong at about 100% of you saidLinus Torvalds2013/07/13 11:08 AM
                                                          you are wrong at about 100% of you saidMichael S2013/07/13 12:13 PM
                                                            you are wrong at about 100% of you saidLinus Torvalds2013/07/13 01:11 PM
                                                            you are wrong at about 100% of you saidvvid2013/07/13 02:20 PM
                                                              you are wrong at about 100% of you saidMichael S2013/07/14 12:38 AM
                                    Saltwell Outperforming A15...With Less Power!!!anon2013/07/11 05:41 PM
                                    Saltwell Outperforming A15...With Less Power!!!bakaneko2013/07/12 02:22 AM
                  Round 2: Baytrail benchmark (yes Antutu!) crushes Snapdragon 800.sammy2013/07/12 10:28 AM
                    Round 2: AnTuTu scores drop dramatically for AtomWilco2013/07/12 10:59 AM
                      Round 2: AnTuTu scores drop dramatically for AtomSteve2013/07/14 07:16 PM
                        Round 2: AnTuTu scores drop dramatically for AtomKlimax2013/07/14 09:59 PM
                        Round 2: AnTuTu scores drop dramatically for AtomDavid Kanter2013/07/15 12:57 PM
                          Intel is cheating AnTuTuWilco2013/07/15 02:43 PM
                            Intel is cheating AnTuTubakaneko2013/07/15 06:47 PM
                              Intel is cheating AnTuTuLinus Torvalds2013/07/15 07:45 PM
                                Intel is cheating AnTuTubakaneko2013/07/16 01:42 AM
                                  Intel is cheating AnTuTuWilco2013/07/16 02:47 AM
                                    Intel is cheating AnTuTubakaneko2013/07/16 04:50 AM
                                      Intel is cheating AnTuTuWilco2013/07/17 02:33 PM
                                        Intel is cheating AnTuTuKlimax2013/07/17 10:29 PM
                                          Intel is cheating AnTuTunone2013/07/17 10:35 PM
                                            Intel is cheating AnTuTuKlimax2013/07/18 12:41 AM
                                              Intel is cheating AnTuTuanon2013/07/18 01:10 AM
                                                Intel is cheating AnTuTuMichael S2013/07/18 02:39 AM
                                                Intel is cheating AnTuTuWilco2013/07/18 03:07 AM
                                                  Intel is cheating AnTuTunone2013/07/18 03:15 AM
                                                    Intel is cheating AnTuTuWilco2013/07/18 04:18 AM
                                                    Intel is cheating AnTuTuMichael S2013/07/18 05:44 AM
                                                      Intel is cheating AnTuTunone2013/07/18 06:47 AM
                                                        strict aliasingMichael S2013/07/18 07:10 AM
                                                          strict aliasing rules have existed since C89 (NT)Ricardo B2013/07/18 04:28 PM
                                                  Intel is cheating AnTuTuKlimax2013/07/18 10:30 AM
                                                Intel is cheating AnTuTuKlimax2013/07/18 10:39 AM
                                                  Intel is cheating AnTuTuanon2013/07/18 11:05 AM
                                                    Intel is cheating AnTuTuKlimax2013/07/19 11:05 PM
                                                      Intel is cheating AnTuTunone2013/07/20 01:50 AM
                                                  Intel is cheating AnTuTunone2013/07/18 11:38 AM
                                                    Intel is cheating AnTuTuKlimax2013/07/19 10:57 PM
                                  Intel is cheating AnTuTuLinus Torvalds2013/07/16 11:32 AM
                                Intel is cheating AnTuTu2013/07/16 02:16 AM
                                  Intel is cheating AnTuTubakaneko2013/07/16 03:55 AM
                                    Intel is cheating AnTuTuWilco2013/07/17 02:46 PM
                                      Intel is cheating AnTuTubakaneko2013/07/18 01:05 PM
                                      Intel is cheating AnTuTuDavid Kanter2013/07/19 01:31 AM
                          Round 2: AnTuTu scores drop dramatically for Atomanon2013/07/15 03:43 PM
                            Round 2: AnTuTu scores drop dramatically for Atomnone2013/07/15 11:15 PM
                          Round 2: AnTuTu scores drop dramatically for AtomGroo2013/07/16 06:35 AM
        ARM at Computexanon2013/06/04 09:43 PM
Reply to this Topic
Name:
Email:
Topic:
Body: No Text
How do you spell avocado?