Alik Levin's

Clarity, Technology, and Solving Problems | PracticeThis.com 

October, 2008

  • Alik Levin's

    Seven Habits Of Highly Effective Consultants

    • 1 Comments
     Alik Levin    I was reading The Practice of Leadership blog that briefly reviewed Steven Covey's book The 7 Habits of Highly Effective People. I like Steven Covey's approach. In fact, I massively use Steven's Urgent/Important quadrants to prioritize my daily work (as outlined here - Prioritize What You Do – Steven Covey Way [The Way That Works]).

    I thought it'd be interesting to test myself as a consultant for effectiveness according to Steven Covey.

    Seven Habits

    1. Be proactive.
    2. Begin with the end in mind.
    3. Put first things first.
    4. Think win-win.
    5. Seek first to understand, then to be understood.
    6. Synergize.
    7. Sharpen the saw.

    All these habits should serve some sort of goal or objectives. Being proactive or thinking win-win won't make a trick without having clear goals. What are you goals? What are your objectives? Here are mine:

    • Make my family happy by maintaining healthy Work/Life Balance (WLB).
    • Make my managers happy by accomplishing what I am supposed to and a bit beyond.
    • Make my customers happy by solving their problems effectively, offering them first class professional service.
    • Make myself happy by doing interesting work with proper impact.

    If your goals are similar to mine then the following practices might help you hitting them.

    Habit 1 - Be proactive

    Proactively manage your time. Consultant live and breathe time. Utilization (or billable time) is consultant's main product. Spending time for non-billable time activities will hurt your WLB. Proactively allocate time for billable (actual consulting), non-billable (training, biz dev), and personal activities. Here is how I manage my time annually, monthly, weekly, and daily:

    Habit 2 - Begin with the end in mind

    What do you want to accomplish? What's your definition for success? Imagining the end results can help achieving it. See it through, deliver it, exceed it. Become a super hero.

    Habit 3 - Put first things first

    You have more to do than there are hours. How do you prioritize what's important and what is not? I found Steven Covey's technique is very practical:

    Habit 4 - Think win/win

    Establish right communication channels with your manager, customers, and the family. Speak their language. Do not get mad when failed. Practice emotional intelligent. Win the Heart, the Mind Follows.

    Habit 5 - Seek first to understand, then to be understood

    When the communication channels established you are ready to understand the other party. You are ready to understand what matters the most to your manager, to your customers, to your family. When understood you can better help the other party understand yourself. When your manager pushes you to another gig you understand that it is because of the deficit in the team's budget. You could close another deal for better price while dealing with better technology. Win/win. When your customer is calling your every hour it is because she wants to be in control of project progress. You could send progress reports proactively and save the head aches. Win/win. Fulfill their dreams and they will do the same to you.

    Habit 6 - Sinergize

    Consultant is a field warrior. A Peaceful Warrior. A loner. Nevertheless, he is part of a larger team. The team of sales, marketing, support, operations, and other specialists. Build trust within the team and the team will support you when you are all alone in the field.

    Habit 7 - Sharpen the saw

    This one is fundamental in order to survive. Better consultant is the one with deeper skills. Become a SME (subject matter expert), but do not pigeon hole your self into too narrow area of expertise. It might become obsolete tomorrow. Stay tuned with what happens in industry and adjust accordingly. I adopted Abraham Lincoln's:

    "Give me six hours to chop down a tree and I will spend the first four sharpening the axe"

    Question

    What are your practices that make you better consultant?

     

    This template is made with PracticeThis.com plugin for Windows Live Writer

  • Alik Levin's

    Improve ASP.NET 2.0 Performance With PageAsyncTask - Multithreading For The Masses

    • 0 Comments
     Alik Levin    Multithreading is tough. This is what John Robbins says about it in his excellent book Debugging Microsoft .NET 2.0 Applications:

    "Don't do it... Make sure there's no other way you can structure your program before you decide to incorporate multithreading into your application... you are easily adding a minimum of an extra month of development and testing to your schedule". I agree with it completely. But there are times multithreading is unavoidable. Especially when more and more Services popping up in the wild...


    From Asynchronous Pages in ASP.NET 2.0

    Customer Case Study

    I am working with the customer to improve their ASP.NET 2.0 application performance. The application issues multiple requests to the backend middleware that is exposed as a web service. The application cannot get a hold on the actual proxies rather it is provided with the components that wrap the web services proxies. The application needs to issue concurrent  requests. Serial request would result in serious latency which is unacceptable by end users.

    Analysis

    Since we cannot get hold on web services proxies we cannot utilize available asynchronous methods available with it: BeginMyMethod/EndMyMethod and MyMethodAsync/MyMethodCompleted. But we definitely can utilize another option available with ASP.NET 2.0 - registering asynchronous tasks using PageAsyncTask class.

    The following information is based on the following materials:

    PageAsyncTask Implementation Steps

    This is the summary of the steps to implement and register PageAsyncTask:

    • Create a class that contains lengthy operation
    • Declare AsyncTaskDelegate
    • Add OnBegin, OnEnd, OnTimeout methods to the class
    • Mark the calling page as Async="true"
    • Register the PageAsyncTasks in the ASPX page and execute it

    You can grab the Visual Studio 2008 project with the implementation from my SkyDrive here:

    Related Materials

    This template is made with PracticeThis.com plugin for Windows Live Writer

  • Alik Levin's

    ASP.NET Performance: Dynamically Loaded Assemblies Cause Application Recycles (Problem and Solution)

    • 4 Comments
     Alik Levin    In my speak - dynamically loaded assemblies are those assemblies that were compiled during run time dynamically via CodeProvider like CSharpCodeProvider directly or by using types that use this class internally. Assemblies that are loaded dynamically using reflection via Load/LoadFrom method are out of the scope of this post.

    Customer Case Study

    The customer complained on periodic restarts/recycles of the ASP.NET application. We observed relative entries in the Event Log that showed up systematically on timely basis. We also observed memory utilization growth in Task Manager. After reaching 500 MB of memory utilization the application would recycle spawning another w3wp.exe to accept new incoming requests while draining the old w3wp.exe.

    Analysis

    After short discussion with the dev team about the design of the application we thought that the memory leak might be caused by improper usage of XmlSerializer that generate dynamic assemblies. Tess published fantastic walk through specifically dedicated to this case. Using either perfmon (.NET CLR Loading\Current Assemblies) or Process Explorer (see pic below)we observed unusual number (thousands) of loaded assemblies (notice Assemblies column). Also, notice the csc.exe in red - this is CSharp compiler that is invoked on each request:

    Process Explorer ASP.NET Performance Dynamically Loaded Assemblies

    We decided to take a memory dump to deeply investigate the case. Following are the steps that we took while analyzing the dump using WinDBG to identify the root cause:

    Step 1 - Dumping memory heap to identify object allocated on heap

    This is the fragment of the long list of objects. Our attention was caught by unusually large number of reflected assemblies.

    !dumpheap –stat
    9,019       216,456 System.Reflection.Assembly
    112         4,032 System.Xml.Serialization.TempAssembly
    104         5,408 System.Xml.Serialization.TypeDesc

    After 3 minutes the number of dynamic assemblies is larger by more 350 assemblies (from subsequent dump):

    !dumpheap –stat
    9,379       225,096 System.Reflection.Assembly
    114         4,104 System.Xml.Serialization.TempAssembly
    102         5,304 System.Xml.Serialization.TypeDesc

    Step 2 - Dumping appdomains to identify loaded assemblies

    Another cross check to make sure we are dealing with tons of loaded assemblies.

    !dumpdomain -stat 
        Domain              Num Assemblies   Size Assemblies    Name
    0x793f15d8                       1                       2,142,208        System Domain
    0x793f2aa8                       56                    16,012,288      Shared Domain
    0x000ab7d8                      2                       2,498,560        DefaultDomain
    0x000d3368                  9,018                  55,447,040      /LM/W3SV......

    Total 4 Domains, Total Size 76,100,096

    Step 3 - Dumping all dynamic assemblies

    How many of the assemblies are dynamic? (dda stands for dumpdynamicassemblies)

    !dda

    Domain: 0x793f15d8
    -------------------
    Domain: .
    -------------------
    Domain: DefaultDomain
    -------------------
    Domain: /LM/W3SVC/1/ROOT/......
    -------------------
    Assembly: 0x19058818 [RegexAssembly133_0] Dynamic Module: 0x16f4c220 loaded at: 0x0 Size: 0x0((null))
    Assembly: 0x19058818 [RegexAssembly133_0] Dynamic Module: 0x190696a0 loaded at: 0x0 Size: 0x0((null))
    Assembly: 0x19103ee8 [-0g5u8-v] Dynamic Module: 0x1920d6f8 loaded at: 0x19911000 Size: 0xc000((null))
    Assembly: 0x190c9a40 [cvmmynwf] Dynamic Module: 0x190dc0d0 loaded at: 0x19a71000 Size: 0x4000((null))
    Assembly: 0x1911bad8 [0ikhy_lx] Dynamic Module: 0x1911aa98 loaded at: 0x19f21000 Size: 0xc00((null))
    .......
    Assembly: 0x43199720 [nv1lvdiy] Dynamic Module: 0x431b3190 loaded at: 0x4cf61000 Size: 0xc00((null))
    Assembly: 0x2d2bf008 [rk6dabem] Dynamic Module: 0x2d2bf258 loaded at: 0x4cf71000 Size: 0xc00((null))
    --------------------------------------

    Total 8,911 Dynamic Assemblies, Total size: 0x1d5b600(30,782,976) bytes.

    Step 4 - Saving dynamic assembly to physical DLL

    Save assemblies to the filesystem

    !savemodule 0x2d2bc4c8 C: \0x1c344438.dll

    clip_image002

    To save all the assemblies to the file system use the following command:

    !dda -save C:\MODULES

    Step 5 - Using Reflector to reverse engineer the DLL:

    Use Reflector to inspect the implementation/source code of the dynamic assemblies.

    clip_image001

    Step 6 - Using Reflector to find  ExpressionEvaluator class

    Try to locate the class in the static assemblies hopefully hitting the code that generates it:

    image

    Step 7 - Bingo! Each constructor for ExpressionEvaluator invokes compiler

    ICodeCompiler compiler = new CSharpCodeProvider().CreateCompiler();
    ...
    CompilerResults results = compiler.CompileAssemblyFromSource(options, builder.ToString());
    ...
    this._Compiled = results.CompiledAssembly.CreateInstance("NavServices._ExpressionEvaluator");

    This is actually the code that causes Process Explorer to show csc.exe under w3wp.exe (see red line in the first pic). And this is the code that caused number of loaded assemblies to grow. And this is the code that caused the application restarts.

    Acknowledgements

    During this investigation the following resources were used. Big THANK-YOU goes to:

    Related Materials

    This template is made with PracticeThis.com plugin for Windows Live Writer

Page 1 of 2 (6 items) 12