17 Jul 2011Speed up Visual Studio 2010 (RAMDisk)
Visual Studio can at times be painfully slow. From startup, to compile, to running the web-application. Without having to resort to hardware solutions which can cost $$$ I investigated how to get Visual Studio running as fast as possible. This included tweaking VS options and using a RAMDisk.
tl:dr Using a RAMDisk may halve compile times (your milage may vary). SSDs are (in practice) close to the speed of a RAMDisk.
Solution Compile Times 7200rpm HDD RAMDisk 23 seconds 12 seconds
Tweaking VS Options
First up I recommend reading this article from Daniel Fisher. This will give some great tweaks to VS options and anti-virus exclusions to give your system a small speed boost (note: I prefer to leave ‘Track active item in Solution Explorer’ on).
Next up I tried setting up a RAMDisk to simulate having an SSD. A RAMDisk will take some of your system RAM and make it appear as a very fast drive on your system. The size of the RAMDisk will reduce the amount of free RAM. If you have 6GB RAM and the RAMDisk is 2GB, this will leave 4GB of available RAM for the OS and other processes.
To give you an idea of how fast your system RAM compared to a 7200RPM HDD I used a simple benchmarking tool (CrystalDiskMark).
HDD speeds in MB/s 7200rpm HDD RAMDisk Read 105 4995 Write 85 3554
Setting up RAMDisk
Download RAMDisk>, install it and create a RAMDisk size ~1024MB. Configure it so it should automatically Load/Save the RAMDisk image. And I recommend turning on the AutoSave for approx ~15 minutes (900 seconds).
After you create the RAMDisk open the Windows Disk Management app and partition/format the new drive (NTFS, quick format) to drive R:.
I tried two different approaches to using the RAMDisk so I’ve separated these into “Phases”. Phase 2 is slightly more complicated.
RAMDisk - Phase 1
With the RAMDisk running create a folder on the drive R:"tempvs”.
Let’s now tell Visual Studio to use this RAMDisk for it’s temporary folder. Create a batch file vs2010.bat with the contents:
Also tweak your web.config so ASP.NET dynamic compilation system can run as fast as it possibly can with the tempDirectory attribute:
If there was a speed boost at this point it was negligable.
RAMDisk - Phase 2
Now I wanted to see the compile time performance if I moved all the project source on to the RAMDisk too. By using a symlink from our current source location to our RAMDisk means there is no configuration changes or mucking around with the Solution or Project files.
If 1024MB RAMDisk isn’t big enough for your projects source code, resize it. (The existing RAMDisk will be lost and you have to create a new one).
Please backup your HDD or commit to source control before attempting this.
Copy solution folder on to the RAMDisk. Example c:\source\client\project => r:\source\client\project.
Rename (or remove) the existing solution folder. Example c:\source\client\project => c:\source\client\project_before_ramdisk
Now create the symlink to the solution folder on the RAMDisk (I’m using Windows 7, unsure if the command line differs for Vista)
You will now have a symlink from c:\source\client\project => r:\source\client\project. When you start Visual Studio and open your project from c:\source\client\project (like normal) the project should just load. With luck it will feel snappier and your compile times will be faster.
RAMDisk - Observations
Running a RAMDisk didn’t appear to have the speed benefits that I would have originally expected. I think because the .NET compiler has been optimised into oblivion the speed benefits of the RAMDisk is minimal.
That said, halving the time your waiting on the compiler is a big win.
Also if you’re running a SSD or RAID 0 solution on your PC already, I doubt there will be much benefit to you. Also if you’re already using fast disks you’re getting all-round speed benefits rather than just using a RAMDisk for source compilation.
So what speed difference did I observe?
Solution Compile Times 7200rpm HDD RAMDisk 23 seconds 12 seconds
Overall VS2010 feels snappier, and if you’re compiling many times a day and/or frequently running your Unit Tests the difference of even a few seconds will add up over days/weeks/months.
Turning off the RAMDisk and returning to my previous set up feels sluggish compared, so I will keep with this solution for the time being.
I want to be very clear that you’re using a RAMDisk. This means if your computer loses power you will lose your changes! That is until the RAMDisk is written to its image or you’ve committed to SCM you are running a risk.
Cheap Hardware Solutions
I also installed a 2nd HDD and moved the System Page file on to it as well as the SQL Server database MDF/LDF files.
I honestly can’t think of much more, I’m clutching at straws on this one.
Slightly more expensive Hardware Solutions
Upgrade to an SSD, 10,000RPM HDD or RAID 0 the HDDs. Not only will your compile times decrease, but you’re also going to see speed benefits for IIS, Visual Studio start up times, etc.
Get as much RAM as your boss will allow (whether that be management or wife).
Throw as much processing power as you can afford at the problem. I’m running an i7 2.8GHz and wishing for more.
Moving VS2010 on to RAMDisk
I created a 2GB RAMDisk and symlinked VS2010 onto it! I was hoping for a massive speed boost! Sadly this was not the case.
VS2010 Start Up Times 7200rpm HDD RAMDisk 1:15 0:43
As this computer has 6GB RAM, with a 2GB RAMDisk I’m now down to 4GB of available RAM. At this point I believe the amount of available RAM for VS is now to low and the system is starting to page. Perhaps if I had 8GB+ RAM this would be a viable solution.
Intel Core i7 at 2.8GHz 6GB RAM 7200RPM HDDRead more...
07 Mar 2011How to use iOS Home Sharing
Without a doubt the new iOS Home Sharing feature introduced in iOS 4.3 is a big deal, in fact it’s a huge deal. Strangely, it’s not talked about anywhere near as much as Hotspot tethering. I guess you could call this the sleeper-hit of 4.3.
Ever since I purchased my first iOS device back in 2007 - 4 years ago - I’ve wanted a way to easily (read: built into the OS) stream music from my iMac. Then with later iOS devices - think iPad to stream movies - this desire only became stronger. This feature always seemed a natural fit for the iOS/iTunes ecosystem, surely with Bonjour it would be a piece of cake to implement, right?
Time passed and Apple released the Remote app; it didn’t allow you to stream content from iTunes, it simply allowed gave you the ability to tell an AppleTV to stream from iTunes. Boring.
3 years later here it is. iOS 4.3 give us Home Sharing and the ability to stream content from iTunes direct to your iPhone/iPod/iPad using Home Sharing. Sadly the feature has to be turned on from settings and is not automatically configured from iTunes 10.2 (but let’s talk enhancements later).
How to setup iOS Home Sharing
- If you haven’t already you need to setup iTunes for Home Sharing; from the iTunes menu Advanced > Turn on Home Sharing.
On your iOS device. Settings > iPod > scroll to Home Sharing and type in your Home Sharing username/password you configured in step 1.
- Now open the iPod app. If you’re on an iPhone/iPod tap the More icon and then tap Shared.
If you’re using an iPad tap the Library header.
(If your iTunes library is large it might take a while).
Enhancements and Issues
I’d like iTunes to automatically recognise that I’ve not configured Home Sharing on the device and it asks me if I would like to pre-populate the Home Sharing credentials. This would reduce the complexity of setting up Home Sharing, and would also be following that great Apple motto, “It just works”.
I’ve had some issues moving between my iTunes library and the on device library. After leaving a iTunes share the iPod app does not recognise my Podcast collection and I have to restart the iPod app on the iPhone.
Interestingly on the iPhone you cannot add the Shared item on to the TabBar for quick and easy access.Read more...
09 Feb 2011IronRuby in Visual Studio - Console Tips
These are more a collection of IronRuby 1-liners for prosperity (ie my poor memory). I like to use IronRuby to be able to execute small snippets of code without having to run up a whole VS solution/project.
Using IronRuby Interactive in Visual Studio 2010
Install IronRuby from CodePlex, download from here After installation open Visual Studio and using the menu: View > Quick Access; in the search box type ‘Iron’. Click IronRuby Interactive.
Ever needed your Cocoa/Objective-C application to Launch at Login? And also have your app appear in your users System Preferences > Accounts > Login Items list? Want this integration to be super-mega-piss-easy?
Well now you can.
We’re going to wrap LSSharedFileList to get our App to start at login - a Cocoa solution - as opposed to other solutions that use Carbon or having to edit XML system pref files.
Take a look at Github - Launch at Login for the source. Don’t forget to look at the readme for assistance for implementation.
Basically copy the LaunchAtLoginController.h/.m files into your project then either you can implement with Code or with Interface Builder.
Will app launch at login?
LaunchAtLoginController *launchController = [[LaunchAtLoginController alloc] init]; BOOL launch = [launchController launchAtLogin]; [launchController release];
Set launch at login state.
LaunchAtLoginController *launchController = [[LaunchAtLoginController alloc] init]; [launchController setLaunchAtLogin:YES]; [launchController release];
- Open Interface Builder
- Place a NSObject (the blue box) into the nib window
- From the Inspector - Identity Tab (Cmd+6) set the Class to LaunchAtLoginController
- Place a Checkbox on your Window/View
- From the Inspector - Bindings Tab (Cmd+4) unroll the > Value item
- Bind to Launch at Login Controller
- Model Key Path: launchAtLogin
So what are you waiting for? Grab the code from Github - Launch at LoginRead more...
24 Feb 2010Barebones CAEmitterLayer aka Particle Effects
CAEmitterLayer: use to create particle effects. Each particle is an instance of CAEmitterCell. (10.6) - cocoadevcentral
How could you not be intrigued? Particle Effects! Well I’ve always been interested in Particle Generators, and there’s one right here in Snow Leopard. How exciting. /claps.
I recently took a look at the Fire and Fireworks sample code that Apple and was duly impressed by what Core Animation provides for so little cost both code-wise and CPU resources. So I decided to write the simplest - barebones - CAEmitterLayer code where I was only dependant on the NSView it draws on.
There’s no fancy-pants stuff going on here, just a raw, simple, single particle effect. But it gives you a great perspective on how it works and the minimal code required to have a great particle animation.
If you’re starting afresh you’re going to need to tell your project that we want to use Core Animation so:
- Right click the Frameworks > Linked Frameworks on the left,
- Add > Existing Frameworks...
- Scroll to QuartzCore.framework > Add,
- And make sure your ParticleController header file contains
Looking at CAEmitterLayer briefly (and ignoring setting up Interface Builder & the Nib) in our header file we simply need a CAEmitterLayer:
IBOutlet NSView *view; CALayer *rootLayer; CAEmitterLayer *emitter;
Where as the implementation file is going to need a whole lot of data for the Emitter plus we need to create a CAEmitterCell for the particle itself.
//Create the emitter layer emitter = [CAEmitterLayer layer]; emitter.emitterPosition = CGPointMake(CGRectGetMidX(rootLayer.bounds), CGRectGetMidY(rootLayer.bounds)); emitter.emitterMode = kCAEmitterLayerOutline; emitter.emitterShape = kCAEmitterLayerCircle; emitter.renderMode = kCAEmitterLayerAdditive; emitter.emitterSize = CGSizeMake(50 * multiplier, 0); //Create the emitter cell CAEmitterCell* particle = [CAEmitterCell emitterCell]; particle.emissionLongitude = M_PI; particle.birthRate = multiplier * 1000.0; particle.lifetime = multiplier; particle.lifetimeRange = multiplier * 0.35; particle.velocity = 180; particle.velocityRange = 130; particle.emissionRange = 1.1; particle.scaleSpeed = 0.3; CGColorRef color = CGColorCreateGenericRGB(0.3, 0.4, 0.9, 0.10); particle.color = color; CGColorRelease(color); particle.contents = (id) [self CGImageNamed:@"spark.png"];
For the complete implementation file or the complete project please feel free to grab the source code from the bitbucket project.Read more...