CLR 4.5: David Broman - Inside Re-JIT

Download this episode

Download Video

Description

Re-JIT is a new capability in CLR 4.5 that allows modification and recompilation of method-level IL code during runtime without requiring a process restart: so, the JIT runs again without shutting down executing applications. This is a great feature for instrumentation and profiling tools developers.

Here, we learn all about Re-JIT from one of the developers who wrote it: David Broman. Again, Re-JIT enables recompiling a method at runtime without restarting the process. Very cool.

Embed

Format

Available formats for this video:

Actual format may change based on video formats available and browser capability.

    The Discussion

    • User profile image
      felix9

      "rock & roll" again  Smiley

    • User profile image
      ganshani
      That's really great for those who love & use reflection!
    • User profile image
      MrEd

      Charles - dude, your un-managed crusade is growing tiresome.  Easy on the pot shots.

      K?

       

    • User profile image
      Charles

      @MrEd: You mean native. Pot shots? This Re-JIT technology is great, as made clear here. I feel compelled to remind folks that none of the managed world can be realized without native code, which makes it all possible... I'll continue to harp on this when appropriate. I'll also continue to bring you useful and hopefully insightful content related to .NET and managed code, which continues to evolve. We're all one big happy family.

      Native was ignored for 10 years. I'm very sensitive to this fact and I'll continue to amp native any chance I get. I certainly don't mean to offend in doing so. My related commentary here seemed rather benign to me (and to the interviewee, most importantly...).

      C

    • User profile image
      Jedrek

      In unmanaged code I can dynamically load dll using LoadLibrary then I can call GetProcAddress and get procedure from dll, then I can call the procedure, then I can call FreeLibrary and all the memory taken by the dll will be return to the OS (more or less). After that I can load different dll and call another (updated) procedure. Which looks to me as a very similar procedure to Re-JIT. All this can be done at runtime.

      If I understand correctly the content of this presentation in .net using Re-JIT now I can do the same thing. The only difference is that I cannot free the memory and the application is growing over a time until ... the system will tell me that there are no more resources and ... (?).

      As far as I know in .net I can dynamically load an assembly and using reflection. It is possible to call different procedures from diffrent assemblies which again looks very similar to Re-JIT (of course it is not possible to unload that assembly ... well ... we need to live with that). All these procedures can be done at runtime. There is also dynamic compilation which allow me to create assembly at run time.

      What is a difference between Re-JIT and reflection?

    • User profile image
      aL_

      cool stuff.. i wonder if this could be used to enable edit and continue and quickwatch for lambdas.. that would be a killer debugging feature Smiley

    • User profile image
      kallatt

      I'm very sensitive to this fact and I'll continue to amp native any chance I get.

      Incredible that an admittedly biased (against the majority of Visual Studio customers) person like this gets to publish highest number of videos at this channel.

    • User profile image
      deiruch

      @Charles: Please stop your native code spiel. While I (have to) develop in C++ some time I don't want to hear about that stuff in a CLR/JIT talk. You should also know that managed code is quite fast and can be used for low-level stuff. Reat the Singularity paper and you'll realize that.

      I guess the (btw mostly Microsoft-only) C++ revival stems from the fact that Microsoft messed up Longhorn and relied on managed code there. I just hear you, Herb Sutter and Bjarne Stroustrup talking about C++. Some random data for you: http://www.tiobe.com/content/paperinfo/tpci/images/tpci_trends.png

      Anyway, my point is this: It's great that you seem to like C++ and all that, but don't try to talk about native code in a video about managed code. And please don't assume that many people still care about C++.

    • User profile image
      Matt

      @deiruch

      I strongly disagree with you, native code is what powers up the CLR so it perfectly makes sense to mention C/C++ when dealing with the implementation details. I do not understand why Charles should focus only on native or managed stuff when both of them are relevant to the topic discussed...

      "And please don't assume that many people still care about C++." According to your link, C and C++ are still incredibly popular.

    • User profile image
      Charles

      @kallatt: I'm not biased. I think .NET is great. I don't hate any language or runtime. As I said, having been pimping .NET for most of my tenure on C9 (with my C++ interviews substantially less in volume - though they have always been here...) I am sensitive to pushing it too hard again, so I have rebalanced what I do to showcase more native stuff (like C++), of which I am a big fan.

      My point here was that in the context of the conversation (Re-JIT) David and I only talked, briefly, about the code he writes to implement Re-JIT (he's a C++ developer). I thought it was therefore logical and appropriate in context to spend a small amount of time on the subject (he also stated "we write C++ so you don't have to" which I felt compelled to address... Smiley ).

      Most of this interview (98%?) is about Re-JIT. Can we stop this now?

      C

    • User profile image
      Charles

      @deiruch: No offense, but... whatever... I'm not going to go down this rabbit hole with you. Many people care about many things - very few only care about one thing and one thing only... As I said, David is a native dev and I wanted to chat with him for a VERY small amount of time during this interview about the tool he uses to implement Re-JIT.

      Excuse me for being a curious conversationalist and not some marketing droid pimping one thing in context. You need to open your mind.

      end();

      C

    • User profile image
      Charles

      @Matt: Exactly. Thanks, Matt.
      C

    • User profile image
      Jedrek

      If I understand the content of the presentation correctly,
      then now it is possible to do arbitrarily changes in the code of the .net application at runtime.
      This mechanism looks much more flexible than reflection and reloading libraries (which I described in my previous post).
      It looks like really interesting tool for managing dynamic applications.

      I have only one big request. Maybe in the future you will find some way of removing old unusable code. After some time the amount of unused code may be significant. That may be a big problem in long running applications.

    • User profile image
      lhalstrom

      @Charles: Can't reach your profile now, but I've looked at it before and never seen you uploading dozens of videos about .NET per month, and praising it mindlessly in every single one, like you're doing with C++ now.


      @Matt:
      >According to your link, C and C++ are still incredibly popular.

      It is, but I think the graph is more about its trends: http://www.tiobe.com/index.php/paperinfo/tpci/C__.html

    • User profile image
      Charles

      @lhalstrom: There's nothing mindless about how I discuss C++ here. Watch and listen versus reacting to your fears... Enough of this. Move along.

      C

    • User profile image
      CKurt

      Another great video Charles! Good explanations and good technical stuff. Also like the fact he clearly stated the no-go stuff about re-JIT it really helps make it less of a "trying to sell the feature" video.

      However i do concur with the overwelming oppinion that the C++ renaisanse has taken over the technical content on C9 like a tsunami. It seems most good technical content is produced by you (always has been) at it all focusses on C++. The "Checking In" show is also very good, but it has less whiteboard action and is more about talking and discussing instead of explaining a (new)technology.

      I do hope to learn more about  WinRT , .NET 4.5 , await/async , Silverlight 5, Windows XAML in true old school C9 style. Right now we have to look trough a huge list of sessions from events, and those do not include the back and forth question style we love in C9 video's.

      Hoping to provide some constructive feedback Wink

    • User profile image
      Charles

      @CKurt: Thanks for the feedback - constructive, too Smiley

      Indeed I have embarked on a series of .NET/CLR 4.5 conversations - of which this and the background server GC pieces are part of - that will show up here in the near future. Stay tuned for Portable Libraries, Performance and Memory diagnostics, improved setup (less reboots required when installing .NET 4.5, which is an in-place install), BCL improvements, NGen improvements, size-on-disk improvements. It's all .NET material. (of course, there will be more C++ stuff, too Smiley )

      C

    • User profile image
      CKurt

      Aha! That is great to hear Charles! Looking forward to the Portable Libraries one! This to me seems the next big thing to make "three screens and a cloud" a more easy dev reality!

      If you could get some insights in the more closed WinRT team it would be great too. Altough it might be a bit early to answer the question "Will desktop apps be able to use WinRT or do they still need to use PInvoke?" and other compat questions surrounding ARM.

      Again thx! I'll say hi if I run into you on campus Wink

       

    • User profile image
      David_Broman

      A few questions came my way, which I'll answer here:

      "Can ReJIT be used to turn on enter/leave/tailcall hooks?"
      No.  A reasonable thing to consider for the future, but it will not be available in .NET 4.5.

      "Is ReJIT in the 4.5 Developer Preview?"
      Yes!  Go for it!

      "Where can I get a copy of that web site demo you showed?"
      Nowhere, yet.  Cleaning up and releasing the demo, with some of its sample code, is something we will consider for later.  But that would take some time, as it's currently heavily tied in with other ReJIT testing code, and split among several different components.

    • User profile image
      David_Broman

      @Jedrek: "What is a difference between Re-JIT and reflection?"

      Reflection is used typically by application code to inspect or emit new application code.  While Reflection can be used to create new, dynamic code, it cannot be used to dynamically modify statically-generated code (at least, not in any way I'm familiar with that is comparable with what ReJIT can do).

      ReJIT (and Profiling API-based IL rewriting in general) is used by a separate diagnostics tool (that the application designer had no knowledge of, and that has no knowledge of the application code), to slip in its own instrumented copy of functions that get called whenever the application designer thought she was calling her own code.

    • User profile image
      Charles

      Great chat with members of the BCL team today. Stay tuned.
      C

    • User profile image
      LeeNguyen

      They still need to use PInvoke? Scared

    • User profile image
      Richard.Hein

      @lhalstrom et al ...

      You must be new here.  Charles has posted countless managed code related videos over the many years C9 has been around!  That and functional programming, and now native.  There hasn't been that much to talk about that hasn't been covered by C9 before in the managed world, until the announcements at //BUILD for the .NET 4.5 features/changes. 

      So yes, there's a lot of native content this past year, but that's true for mainly the videos Charles has been doing.  There's still a lot of .NET/Silverlight/Azure and other things to follow on C9.  The problem isn't what Charles is doing, it's that there isn't enough Charles to go around.  Let Charles follow his interests, that's how he'll do the best job.  Someone else could pick up other areas.  That being said, I'll bet there's a ton of managed content in the pipeline anyways, and still from Charles (like this!).

      As for this ... it's great and I am surprised I missed it with all the //BUILD information, but I guess it got drowned out in the sea of Metro/WinRT/C++ announcements.

      Keep up the good work C9, and Charles ... stay on target, man. Wink

    • User profile image
      Charles

      @Richard.Hein: Thank you. In the pipleline is C++ And Beyond: C++11 Panel with Herb, Scott and Andrei, CRT Lecture with Mahmoud Saleh, MEF 2.0 conversation, BCL team interview, improved install time for .NET, GoingNative Live at BUILD part 1 (Ale, Boris and Tony), Checking In with Erik Meijer: Stephan T. Lavavej Smiley

      C

    • User profile image
      David_Broman

      Quick correction to my previous comment:

      >>

      Can ReJIT be used to turn on enter/leave/tailcall hooks?"
      No.  A reasonable thing to consider for the future, but it will not be available in .NET 4.5.

      <<

      While there is no explicit way via the ReJIT API to specify whether the codegen flags should allow or disallow generating calls to the ELT hooks, there is a slightly tricky way you can achieve this, even in the 4.5 developer preview.  I plan to write about how to do this in my blog eventually. (http://blogs.msdn.com/b/davbr/)

    Comments closed

    Comments have been closed since this content was published more than 30 days ago, but if you'd like to send us feedback you can Contact Us.