- Steve McNiven
Hidden in the 10.1 startup time tips is a GEM! The roslyn section is not only just glazed over, but there’s no direct instructions on how to enable it… it’s crazy easy though, lets get to it.
Background: Why is it a problem
Asp.net (and thus sitefinity) uses a runtime compilation to compile assets together. I’m sure we’re all acutely aware of this, whenever we request a new sitefinity page after build or recycle, there’s just a painfully long wait time, that’s the compiler at work.
You can even WATCH it happen if you are developing locally or are remote into your server.
Open the windows task manager and hangout around the “c”'s in the details tab. Once the status gears page finishes bootstrapping you’ll see “csc.exe” keep popping up and disappear; this is the compilation at work… and it’s slow.
So just to clarify here, it’s RUNTIME compilation, not BUILDTIME.
Roslyn to the rescue
So Roslyn is the name for Microsofts new compiler, it’s lightyears faster than the default compiler. Telerik estimates at least 6 times faster, in a large site Microsoft profiled it from 15 minutes down to just 70 seconds… but regardless it’s just night and day.
How to use in Sitefinity
I’m not sure if you need to be on v10.1 or not, but I tried to enable on another devs 9.0 project and had issues, maybe unrelated though.
- Open your Sitefinity project in visual studio
- Right-Click your web project, Manage Nuget Packages
- Search for “Roslyn” and install this guy
- Build (This step is important, it adds a roslyn folder to your bin folder)
- …done :)
So now on a reload you can see “csc.exe” loading from the bin folder in your webroot.
*Note: You might need to add the CommandLine column to the Task Manager if it isn’t there already.
To enable on your live server
- Copy all bin folder dlls up along with the new roslyn sub-folder
- Notice the new node at the bottom of your web.config (system.codedom), put this in the live web.config as well. I’m not going to paste it in here in case it’s structure or syntax changes in a future release.
- Done, and like above you can validate it’s working with the Task Managers command line column.
This is using my site (this one), loading the homepage, from once the bootstrapping completes.
Regular compiler: 38 Seconds to see the homepage
Roslyn: 7 Seconds, and from there it’s just crazy peppy.