Skip to content

Blazor support JIT-runtime in browser #45471

Open

Description

@ivanivanyuk1993

Is your feature request related to a problem? Please describe.

I am trying to do an app for inside use for enterprise in Blazor - https://fir-ec434.web.app/. While it runs great on desktop, it feels laggy on mobiles. My simple measures show that C# runs ~50 times slower than JS, so I had to move performance critical parts(like url state persisting, which can grow up to O(5000) for every state change which uses UrlReactiveValueProvider or its' ChildValueExtractingReactiveValueProvider-s) to JS

Describe the solution you'd like

My app doesn't care about initial loading time, it would tolerate loading of whole 200mb JIT-runtime on first load as long as performance is native and long loading happens once and then app uses cache

Hence, my app would benefit from loading performant JIT instead of using interpreter

Additional context

By the way, described feature would be better than native apps for many use cases, like games
My typical user experience with AppStore and PlayStore games

  • Click install
  • Wait for load/install, while waiting browse the web or do other stuff
  • Close/Swipe from memory AppStore/PlayStore
  • Find app in menu
  • Click app to open it

For Blazor my expected user experience is:

  • Open url
  • Wait for load, while waiting browse the web or do other stuff
  • Open url with loaded app again

If you are interested in my simple measure, which shows ~50 times performance difference

            // C# benchmark
            // var a = 0;
            // var s = DateTime.Now;
            // for (var i = 0; i < 1e7; i++)
            // {
            //     ++a;
            // }
            // var f = DateTime.Now;
            // Console.WriteLine((f - s).TotalMilliseconds);
            // Console.WriteLine(a);
            //
            // JS benchmark
            // var a = 0; var s = Date.now(); for (var i = 0; i < 1e7; i++) { ++a }; var f = Date.now(); console.log(f - s); console.log(a);

Activity

  1. javiercn commented on Dec 2, 2020

    @javiercn
    Member

    @ivanivanyuk1993 thanks for contacting us.

    We are moving this issue to the runtime repository since we don't own the underlying .NET runtime.

    /cc: @danroth27

  2. transferred this issue fromdotnet/aspnetcoreon Dec 2, 2020
  3. Dotnet-GitSync-Bot commented on Dec 2, 2020

    @Dotnet-GitSync-Bot
    Collaborator

    I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

  4. srxqds commented on Dec 2, 2020

    @srxqds
    Contributor

    the browser can support jit mode?

  5. ivanivanyuk1993 commented on Dec 2, 2020

    @ivanivanyuk1993
    Author

    @srxqds
    Well, since clr is written in C++, I think it's not a problem to download it and run it in wasm

  6. added this to the Future milestone on Jun 17, 2021
  7. removed
    untriagedNew issue has not been triaged by the area owner
    on Jun 17, 2021
  8. lewing commented on Jun 17, 2021

    @lewing
    Member

    The WebAssembly runtime is by design much more limited than a normal execution environment and anything approaching just in time compilation for a CLR would be extremely difficult.

  9. redradist commented on Jan 17, 2022

    @redradist

    Is there any work in this area ?

  10. danroth27 commented on Jan 18, 2022

    @danroth27
    Member

    Is there any work in this area ?

    Not currently due to web platform limitations. Our focus instead is on ahead-of-time (AOT) compilation.

  11. SupinePandora43 commented on Mar 27, 2022

    @SupinePandora43

    Is there any work in this area ?

    Not currently due to web platform limitations. Our focus instead is on ahead-of-time (AOT) compilation.

    Will we get NativeAOT or NativeAOT-llvm in blazor?

  12. danroth27 commented on Mar 31, 2022

    @danroth27
    Member

    Will we get NativeAOT or NativeAOT-llvm in blazor?

    There are no immediate plans to switch Blazor WebAssembly to NativeAOT. Blazor WebAssembly currently uses the Mono AOT toolchain, the same toolchain used for .NET apps on iOS. Currently the NativeAOT support for WebAssembly is experimental.

  13. Thaina commented on Apr 14, 2022

    @Thaina

    Will we get NativeAOT or NativeAOT-llvm in blazor?

    There are no immediate plans to switch Blazor WebAssembly to NativeAOT. Blazor WebAssembly currently uses the Mono AOT toolchain, the same toolchain used for .NET apps on iOS. Currently the NativeAOT support for WebAssembly is experimental.

    Thanks for the info. Are there issue and roadmap about this experimental? Do we have guideline to enable it?

    But actually I am more concern about full JIT support in browser wasm. I can't see why we need AoT in browser when browser actually could support loading and generating code at runtime anyway?

  14. danroth27 commented on Apr 19, 2022

    @danroth27
    Member

    Are there issue and roadmap about this experimental? Do we have guideline to enable it?

    No, experimental means there isn't a committed roadmap for this functionality. See https://github.com/dotnet/runtimelab/blob/feature/NativeAOT-LLVM/docs/using-nativeaot/compiling.md#webassembly or additional details.

    I am more concern about full JIT support in browser wasm. I can't see why we need AoT in browser when browser actually could support loading and generating code at runtime anyway?

    From what I understand there is still a limitation in browsers that prevents the runtime generation and loading of WebAssembly modules in a manner suitable for JIT compilation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions