Posts

Running docker-compose against WSL2

Just adding a quick note for myself here. I wanted to run against docker host on WSL2 and docker compose connects to DockerDesktopVM instance by default (the full virtual machine). What I wanted to try is to run Docker Compose experience without the virtual machine utilizing the new WSL2 capabilities. Scott Hanselman has a good write-up about this feature. Prequisities Windows 10 insider build from the fast ring (at the time of writing), build 18932 or newer Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform Install Ubuntu 18.04 from Windows Store, ensure it has the correct WSL version wsl --set-version Ubuntu-18.04 2 To make life easier, make the new version default wsl --set-default-version 2 Install Docker Desktop WSL 2 Technical Preview Run docker-compose targeting the Linux WSL2 docker host The key is to use the -H parameter, when you are hosting both the Virtual Machine and lightweight WSL2 version. docker-compose -H "npipe:/...

Optimizing Jint part 7: Rewriting the interpreter

So when you start to hit the wall trying to get things faster using the current infrastructure, you can always level the playing field by re-thinking the problem and finding a better way to approach the problem. A recent big change was to refactor how the JavaScript AST tree is being interpreted.

Optimizing Jint part 6: DictionarySlim is coming to town

The past weekend I read about an interesting  pull request which is bringing a new type of dictionary with great interest. The idea of creating a new, simpler and enhanced version , now called DictionarySlim, original spun from the famous k-nucleotide benchmark  where .NET had some trouble performing well with the built-in Dictionary . What is this new member in *Slim family?

Optimizing Jint part 5: Optimizing Javascript primitives

Javascript primitives in Jint Jint has abstraction for each primitive Javascript type. Having these fundamental types work and interact with the engine in efficient manner is crucial for good performance. In this blog post we are investigating some of them and problems I found while profiling.

Optimizing Jint part 4: Interfaces are good, virtual calls better, direct field access the best

I'm probably going to break all the rules of OO encapsulation and some SOLID principles here. Be warned. We all have had our share of the strategy pattern, abstract factory, you name it. Abstracting targets behind interfaces and abstract base classes. They all are fine and aim to produce better software and they usually do. But when it comes to performance, you should sometime bend the rules a bit.

Optimizing Jint part 3: Banishing LINQ

So you want your code go fast? Just remove all occurrences of using System.Linq; and make the code compile again without it and be done with! In all seriousness, LINQ is a powerful tool, but it also has it's pitfalls. It really makes a difference if you use LINQ in the wrong places, one being the hot paths of a Javascript interpreter. Next I'm going to show examples of better performing code - it's neither prettier nor more idiomatic than the LINQ counterpart. So be warned. You should again weigh your use case and whether anything here is really needed. Jint optimization: usage of LINQ in Jint Jint used LINQ in some places and made the code quite easy to read. Jint being an interpreter, it made things unnecessarily slow however. When scripts are run there can be millions of iterations in loops, choosing the correct way of looping and collecting data can make a big difference. Removing LINQ is quite the easy optimization for libraries that have hot paths and ...

Optimizing Jint part 2: Tools of the trade

I think making performance optimizations is a great example of true engineering task, there should be numbers and evidence, always. You cannot state that something has improved unless you can show hard numbers about either reduced time to run or reduced memory usage (ideally of course both). Otherwise it's just good old feels faster . In this post we'll examine some tools and checklists when doing performance analysis.