Label Cloud

Showing posts with label Performance. Show all posts
Showing posts with label Performance. Show all posts

Sunday, August 09, 2009

Multithreading will only take you so far

Working with Oracle Coherence, I do a lot of thinking about distributed architecture, parallel processing, and multithreading. Making use of all this technology is a great way to solve many problems. It can often seem, that as long as you can split your problem into small enough pieces, you’ll be able to process data instantaneously.

When thinking about distributed system, we often forget that making a system distributed, we still have a limited number resources to distribute the workload. The application is deployed on a specific number of machines, each with a specific number of CPU Cores. Each CPU core can process one instruction at a time (not completely true, but for simplicity’s sake). For example: In a distributed system where each workload takes 1 second to process, and we have a total of 10 workloads that need to be processed, will take at least 3 seconds to process all of them

image

Adding more threads will not work, only adding more CPU cores will. That is critically important when you consider that for many complex operations, a result of individual workload is not enough to provide a meaningful result to the end user. Results from all requested workloads have to be aggregated to create a final result.  This makes it relatively simple to figure out how much a calculation will take:

Total Time = Number of Work Loads / Number of Cores * Time Take by Work Load

Another very import point to remember, is that during performance testing, distributed systems behave differently. Requests from multiple clients will interfere a lot more with each other then they do in a straight processing system. In a prior example, a request that takes 3 seconds when ran from 1 client, can take 6 seconds with 2 clients, if the last work item for the first client, is started after all work items of the second client.

image

That will probably not happen, yet you have take the possibility into account. That is just the nature of the beast. 


Share/Save/Bookmark

Tuesday, December 09, 2008

Hard Drive Defragmentation

Recently my laptop had been spinning its hard drive a bit too much and I thought to my self "when was the last time I defragmented?" Apparently too long ago:

PreOptimization

  • 36% fragmented files
  • 5% Free Space
  • Very red looking picture
  • Very slow drive access

I have Diskeeper Lite (a free version) - and ran that overnight. The picture became slightly better, but not quite what I wanted:

Optimization-Pass1

Its very hard to defragment the harddrive with less then 20% free space available. So after removing some old files, and freeing up some space, 2nd run was much better:

Optimization-Pass2

Running it for 3rd time did not help much, so for now I am leaving it at that.

Optimization-Pass3 

Overall.... The machine definitely seems faster. Lesson: Defragment regulargly. I'll update the post in a few days to note if the performance stayed good.

Technorati Tags:


Share/Save/Bookmark

Thursday, September 13, 2007

Asynchronous ForEach (Part 2)

I wrote about creating an asynchronous ForEach method before. Apparently, there is a going to be a TPL (Task Parallel Library) available that will do the same type of functionality (and more I am sure)

Parallel.For(0, 100, delegate(int i) { a[i] = a[i]*a[i]; });

Technorati Tags: ,


Share/Save/Bookmark

Wednesday, December 13, 2006

A VERY cool example of compiler optimization

http://blogs.msdn.com/abhinaba/archive/2006/12/13/why-can-we-only-use-constants-in-a-switch-case-statement.aspx

Reading Microsoft Blogs, I saw a great example of compiler optimization. Apparently, C# compiler is able to optimize case statement that is based on string constants. Once the number of cases reaches a specific level (example was with 7 cases including default) , the compiler switched from using if statement, to pre-populating values into a dictionary and doing a value lookup.

It really is amazing how good compilers are these day and proves once again

  • Do not try to outsmart the compiler
  • Do not over-optimize too early
  • Profile early, Profile Often


Share/Save/Bookmark
Directory of Computers/Tech Blogs