开发者

Precompiled XSLT, ReBase and NGEN

Advanced performance question here. Here's my scenario:

I have a database that contains thous开发者_Python百科ands of XSLT documents. One for each page of a website so these translate XML into HTML. An ASP.NET web server (farm) loads the XSLT documents from the database and uses them to render HTML for each web request.

I've implemented the optimization of using XslCompiledTransform and caching it between database refreshes (every 30 minutes). I'm looking to notch performance up further by pre-compiling the XSLT to DLLs with xsltc.exe. This is supposed to eliminate all the Dynamic Method Invocations that XslCompiledTransform creates.

So, I have a separate server writing the XSLTs to files and running through them with xsltc.exe. Takes about 20 minutes but that's OK. I then drop the DLLs onto each webserver. Now I can just have the webserver dynamically load the DLLs on an as-needed basis. Here's the code I'm using to load the assembly into XslCompiledTransform:

byte[] bytes = File.ReadAllBytes(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "XsltDlls\\" + fileName + ".dll"));
Assembly assembly = Assembly.Load(bytes);
Type type = assembly.GetType(fileName);
XslCompiledTransform compiledTransform = new XslCompiledTransform();
compiledTransform.Load(type);

Shoud I ReBase.exe the DLLs in the directory and/or NGEN.exe them? ReBase takes about 5 minutes and NGEN.exe with /queue will take about 10 minutes during which CPU is hit hard - likely causing an impact to the traffic serving function of the webserver. Given how I'm loading the assembly by reading bytes from the assembly will the native NGEN image even be referenced or will the JIT fire up anyway?

Any/all insight into this will be MUCHLY appreciated!

malcolm


Wow!

Assembly.Load(string) does permit native images to be loaded. However, I suspect that the overload that takes a byte array may not use it. I can't find a reference for that, but perhaps some experimentation using the Assembly Binding Log Viewer on a test project might prove either way.

You also have to make sure that your assemblies are strongly named for the native image to be used.

As for rebasing, this blog suggests that it's not required on Vista generation OSes or later.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜