views:

853

answers:

6

Our current solutions/projects have several classes combined into one file, I'm told this was done due to the slow compile times in VS.

Is this a confirmed problem and solution?

Can we break these apart now that we are using VS2008 Team system? Has anyone else separated the classes into different files and still had good performance?

A: 

I'm using C# rather than VB.NET, but I never encountered compiler performance problems. It seems that this is some kind of premature optimization. I don't care how long my build server needs to build the application. Don't sacrifice clarity for build time performance.

OregonGhost
Build performance is very important! It's not just about how long a build server takes to run, it's about having a quick feedback loop when you're developing. That said, this optimization is unlikely to be very effective.
Gabe Moothart
Build performance is one of the most important factors in software productivity. Having a build server is great but this is for testing, deployment, and quality reasons, a developer should still be able to debug his code locally while developing, and fast.
marr75
Well, my last project takes about 20 seconds to build for debug (no release packaging). Of that 20 seconds, about 15 are generating code and preparing some things, and about 5 are compiling all assemblies including the application itself (about 100.000 lines of code). It's nothing compared to the time my C++ buddies spend compiling. I would rather split the application into more assemblies, so you won't have to rebuild everything every time. I'm fine with waiting two seconds for the debugger to fire up.
OregonGhost
A: 

Sounds like you might want to try to persuade your team to look into the solution design; it might not be optimal to have one giant solution with all projects in there. If build times are indeed a problem, I would rather solve it by breaking the solution down to logical parts, if possible.

Fredrik Mörk
They have an insane amount of files and the projects are already broken apart too much. I know there is design issues, but that's another topic.
eschneider
A: 

I do not believe that grouping many classes into a single file will significantly improve build performance for normal projects. It should be safe to break them out into more files (one-per-class is standard).

The one exception I've run into is "Web Site" projects. I don't have any scientific data, but these do seem to get slower as the number of files increases. To fix that you can convert it to a "Web Application" project.

Having too many projects in a solution is also known to make VS slow, but that doesn't sound like your problem.

Gabe Moothart
+1  A: 

What is your hardware like?

The big bottleneck with VS is that it needs to read and write loads of little files.

A fast hard drive or two can improve performance loads!

Greg B
I've been told that the number of file handles is problematic for the application and the operating system (or their interfacing), not just the read and write times themselves. Faster hard drives definitely make for faster dev though.
marr75
I'm sure it's not fastest IO, (All my personal dev boxes are striped), but it should be usable with a recent pc.
eschneider
A: 

This is a confirmed problem and a confirmed solution. At Tech Ed this year they said that it will no longer be a problem in VS2010, which you could download a beta of and try out.

marr75
-1 Can you cite a source for this?
Gabe Moothart
VS2010 is not an option yet.
eschneider
-1 for not citing a source? My only source was as stated, "At Tech Ed this year a presenter said this is no longer an issue." So, if you feel like further investigation, download the beta as I suggested.
marr75
+4  A: 

I work on the VB.Net IDE team and I can tell you that putting everything in 1 file will make VS run slower, not faster. VB.Net works just fine with classes in different files.

The only time this would ever make a difference is if you had an unbelievably slow hard drive, and files that were on very different parts of the physical disks (resulting in more and longer seek instructions). In general this shouldn't be a problem and for the VB.Net IDE this would only be a problem during initial startup. We have several layers of caching that would help eliminate even these types of problems.

You may be able to discover some minimal benefits to this approach if you only consider the raw time it takes the command line compiler to operate. IMHO, the more important numbers are the respnosiveness of Visual Studio and the relative build time for Visual Studio. VS responsiveness will decrease if have extremely long files (which is what will eventually occur if you put ever class into a single file).

JaredPar
It's not all in 1 file, but there is multiple classes in each file, they reduced the number files by having several classes in each file.
eschneider
@escheiner, I still find it very hard to believe this makes a difference in the compilation process. As a general rule, longer files perform worse than shorter ones.
JaredPar
How many files have you tested? we have thousands of files and uncombined probably many more....
eschneider
@eschneider, we have solutions we run regressions test against which have many thousands of files. The size of some of our solutions are staggering. Also, if you are having performance issues when you split the classes out into separate files we **really** want to know about it. If you can get a repro **please** file a bug on connect.
JaredPar
I'm sure it works with thousands of files, but how fast is it, and is it faster when combining classes?I don't file bugs to MS Connect anymore, they just ignore everything I add, I have added many items there (all ignored or classified "By design").
eschneider
@eschneider, how fast it is, is very dependent on lots of different factors. But I do know we don't shy away from putting different classes in different files (it is in fact encouraged irrespective of solution size). We also have files in our solutions with lots of classes just so we can dogfood the other experience (mostly generated code).
JaredPar
(cont) As to the connect issue. Unfortunately a portion of connect bugs do end up being "by design" issues. Many issues that appear to be bugs on the surface do have a good reasons for being the way they are. But you can find a substantial performance difference between your solution with and without the classes in one file and can upload a sample for us which repros the problem, I guarantee you it won't be "by designed" for no reason. It will end up on either my plate or a coworkers and we will be hooking up a profiler.
JaredPar