aspcompat performance problem

Discussion in 'ASP .Net' started by Cosmin, May 10, 2009.

  1. Cosmin

    Cosmin Guest

    I am using aspcompat page attribute in ASP.NET so the com components I call
    can get at ASP intrinsic objects (Request, Response, Application, etc)

    I have quickly created a new test project, one asp.net page and a vb6 com
    component.

    The page does this:

    for (int i = 0; i < 1000; i++)
    Application["string" + i] = i.ToString();
    Debug.WriteLine(string.Format("{0} done adding strings to
    app",Environment.TickCount));
    var asp = new ASPTest.CompClass();
    asp.SetProcessId();


    Basically I add stuff in the application object and then call the com
    component.

    Set context = GetObjectContext
    If Not context Is Nothing Then
    Set app = context("Application")
    Set ses = context("Session")
    Set resp = context("Response")
    If Not app Is Nothing Then
    OutputDebugString "" & GetTickCount & " writing response"
    resp.Write "I see application from vb <br/>"
    OutputDebugString "" & GetTickCount & " before "
    For i = 100 To 200
    resp.Write GetTickCount & " i = " & app("string" & i) &
    "<br/>"
    Next
    OutputDebugString "" & GetTickCount & " after "
    End If
    Else
    OutputDebugString "No context"
    End If


    The problem is that the more stuff I put in the application the slower the
    vb code becomes. Not all the code though, just when I first try to invoke any
    method on intrinsic objects, in my example my first resp.Write call. If I add
    10000 items in the app resp.Write takes ten seconds to complete, 60000 =>
    timeout. If only 100 items in the App => no delay.

    It seems that when I touch any intrinsic object the first time the runtime
    does something nasty to make the objects available to COM.

    Have you ever seen this? Any suggestion is much appreciated.
     
    Cosmin, May 10, 2009
    #1
    1. Advertising

  2. Cosmin

    bruce barker Guest

    aspcompat incurs large performance problems. it causes all all calls to
    an apt com object to be done on a single thread. a special thread is
    created to access the apt com objects, and all asp.net requests that
    access the com object must use this thread.

    in general, apt model com objects (vb6) should never be used with
    asp.net. you should host the com objects in com+ (they are still a
    performance bottleneck but it may be better).


    -- bruce


    Cosmin wrote:
    > I am using aspcompat page attribute in ASP.NET so the com components I call
    > can get at ASP intrinsic objects (Request, Response, Application, etc)
    >
    > I have quickly created a new test project, one asp.net page and a vb6 com
    > component.
    >
    > The page does this:
    >
    > for (int i = 0; i < 1000; i++)
    > Application["string" + i] = i.ToString();
    > Debug.WriteLine(string.Format("{0} done adding strings to
    > app",Environment.TickCount));
    > var asp = new ASPTest.CompClass();
    > asp.SetProcessId();
    >
    >
    > Basically I add stuff in the application object and then call the com
    > component.
    >
    > Set context = GetObjectContext
    > If Not context Is Nothing Then
    > Set app = context("Application")
    > Set ses = context("Session")
    > Set resp = context("Response")
    > If Not app Is Nothing Then
    > OutputDebugString "" & GetTickCount & " writing response"
    > resp.Write "I see application from vb <br/>"
    > OutputDebugString "" & GetTickCount & " before "
    > For i = 100 To 200
    > resp.Write GetTickCount & " i = " & app("string" & i) &
    > "<br/>"
    > Next
    > OutputDebugString "" & GetTickCount & " after "
    > End If
    > Else
    > OutputDebugString "No context"
    > End If
    >
    >
    > The problem is that the more stuff I put in the application the slower the
    > vb code becomes. Not all the code though, just when I first try to invoke any
    > method on intrinsic objects, in my example my first resp.Write call. If I add
    > 10000 items in the app resp.Write takes ten seconds to complete, 60000 =>
    > timeout. If only 100 items in the App => no delay.
    >
    > It seems that when I touch any intrinsic object the first time the runtime
    > does something nasty to make the objects available to COM.
    >
    > Have you ever seen this? Any suggestion is much appreciated.
    >
     
    bruce barker, May 11, 2009
    #2
    1. Advertising

  3. Cosmin

    Cosmin Guest

    Bruce,

    I know com interop and aspcompat are slow but that is what I have to do. You
    didn't answer my question though. Why is it slow when I access the first time
    an intrinsic object from the COM component? From what you describe it should
    be slow when I access the com object from the asp.net page, which is not the
    case.


    "bruce barker" wrote:

    > aspcompat incurs large performance problems. it causes all all calls to
    > an apt com object to be done on a single thread. a special thread is
    > created to access the apt com objects, and all asp.net requests that
    > access the com object must use this thread.
    >
    > in general, apt model com objects (vb6) should never be used with
    > asp.net. you should host the com objects in com+ (they are still a
    > performance bottleneck but it may be better).
    >
    >
    > -- bruce
     
    Cosmin, May 11, 2009
    #3
  4. Cosmin

    bruce barker Guest

    ..net objects (even strings) are not com objects. GetObjectContext has
    to build and compile a com wrapper for any objects contained by the
    intrinsic objects. the more strings you stuff in application, the more
    more com wrapper objects needed (one per string).


    -- bruce (sqlwork.com)

    Cosmin wrote:
    > Bruce,
    >
    > I know com interop and aspcompat are slow but that is what I have to do. You
    > didn't answer my question though. Why is it slow when I access the first time
    > an intrinsic object from the COM component? From what you describe it should
    > be slow when I access the com object from the asp.net page, which is not the
    > case.
    >
    >
    > "bruce barker" wrote:
    >
    >> aspcompat incurs large performance problems. it causes all all calls to
    >> an apt com object to be done on a single thread. a special thread is
    >> created to access the apt com objects, and all asp.net requests that
    >> access the com object must use this thread.
    >>
    >> in general, apt model com objects (vb6) should never be used with
    >> asp.net. you should host the com objects in com+ (they are still a
    >> performance bottleneck but it may be better).
    >>
    >>
    >> -- bruce

    >
     
    bruce barker, May 11, 2009
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tormod Hystad
    Replies:
    0
    Views:
    437
    Tormod Hystad
    Jul 4, 2003
  2. =?Utf-8?B?U3RldmU=?=

    ASPCompat mode

    =?Utf-8?B?U3RldmU=?=, May 19, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    743
    =?Utf-8?B?U3RldmU=?=
    May 20, 2004
  3. Angelo Brusati
    Replies:
    3
    Views:
    1,433
    Angelo Brusati
    Mar 31, 2005
  4. =?Utf-8?B?Ui4gVG9kZA==?=

    AspCompat causes CCW count to grow

    =?Utf-8?B?Ui4gVG9kZA==?=, Jun 18, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    423
    =?Utf-8?B?Ui4gVG9kZA==?=
    Jun 20, 2005
  5. =?Utf-8?B?Ui4gVG9kZA==?=

    AspCompat causes CCW count to grow

    =?Utf-8?B?Ui4gVG9kZA==?=, Jun 22, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    351
    =?Utf-8?B?Ui4gVG9kZA==?=
    Jun 22, 2005
Loading...

Share This Page