This is going to be a really technical blog, so be warned, it's about coding and performance improvements. So, I am always looking to squeeze out more speed out of the Meshcentral.com server, this is lead by the fact that I need to scale to support a large number of users and managed computers. When I have free time over looking a computer display, I use search engines to look for various performance tips and tricks. A few weeks ago, I discovered the benefits of using a pool of objects and reusing objects instead of creating new ones each time I need them. I used the technique successfully in C# to recycle all of the MemoryStreams, BinaryWriters and StringBuilders. These 3 classes allocate a bunch of memory and being able to reuse them for many operations is really a good thing. So far, most of the server software has been modified to use the pooling for all objects of these 3 types. Today, I complete the transition and now, the ASP.net web site itself pools there 3 object types. It should not show any speed increase, but memory use should be a bit better on my server.
Now for the interesting part. This morning, I was running the Microsoft SQL Server Profiler. It's a tool that looks at each operation on the database in real time. I had never used it before, but I think I will be using it a lot in the future. Database operations are an very important part of the Meshcentral server, in fact, a huge part. If I am not receiving or sending something, it's probably because I am doing a database operation. I noticed in the profiler that there was a lot of connect & disconnect operations. In my code, each time I need to perform a database operation, I start by creating a new SQLConnection object... seems like this is a great candidate for pooling!
It took me about 5 hours today, but I changed all of my database access code so that, it would get the database connection object from a pool, if none are available a new one is created. Mind you, I have 100's of database access code and so, this was a lot of repetitive work. But, once done, I ran it on my test server and so far, I only ever had to create one or two connections... all of the call would reuse the same one or two connection objects! Wow. It did also seem like it was visibly faster and the Microsoft SQL profiler showed much less connect/disconnect calls. After a few hours of testing, I updated the just server on Meshcentral.com. The chance affects pretty much everything Meshcentral does, but so far, it seems to work great, and smoother then ever.
So everyone, if you notice anything unexpected, please let me know.
For more complete information about compiler optimizations, see our Optimization Notice.