Home All Groups Group Topic Archive Search About

ActiveX EXE SingleUse Vs MultiUse

Author
13 Aug 2010 4:34 PM
BeeJ
So what is happening?
In both cases I have set Thread Per Object.
I instantiate four of the same ActiveX EXEs (set as an array of Ax().
With SingleUse I see all four in Process Explorer.
with MultiUse I see one in Process Explorer.
The Main App runs and uses what is provided in either case but ...

Is the MultiUse some sort of reentrant thing?
Is there only one copy in memory?
How is the CPU interacting with these?

All are working at the same time (as sliced).
But maybe the timing is better with SingleUse.  i.e. I could run faster
due to lower overhead.

Sorry I do not know the terminology to research this and if I did I
probably would not get the gist of it.
Still in learning mode ... thanks for your patience.

Author
13 Aug 2010 4:53 PM
Nobody
Show quote Hide quote
"BeeJ" <nospam@live.com> wrote in message
news:i43s74$s8u$1@speranza.aioe.org...
> So what is happening?
> In both cases I have set Thread Per Object.
> I instantiate four of the same ActiveX EXEs (set as an array of Ax().
> With SingleUse I see all four in Process Explorer.
> with MultiUse I see one in Process Explorer.
> The Main App runs and uses what is provided in either case but ...
>
> Is the MultiUse some sort of reentrant thing?
> Is there only one copy in memory?
> How is the CPU interacting with these?
>
> All are working at the same time (as sliced).
> But maybe the timing is better with SingleUse.  i.e. I could run faster
> due to lower overhead.
>
> Sorry I do not know the terminology to research this and if I did I
> probably would not get the gist of it.
> Still in learning mode ... thanks for your patience.

Check "Thread Count" in Task Manager. I think you would see that the Single
Use has at least 4.
Author
13 Aug 2010 5:09 PM
Paul Clement
On Fri, 13 Aug 2010 09:34:21 -0700, BeeJ <nospam@live.com> wrote:

¤ So what is happening?
¤ In both cases I have set Thread Per Object.
¤ I instantiate four of the same ActiveX EXEs (set as an array of Ax().
¤ With SingleUse I see all four in Process Explorer.
¤ with MultiUse I see one in Process Explorer.
¤ The Main App runs and uses what is provided in either case but ...
¤
¤ Is the MultiUse some sort of reentrant thing?
¤ Is there only one copy in memory?
¤ How is the CPU interacting with these?
¤
¤ All are working at the same time (as sliced).
¤ But maybe the timing is better with SingleUse.  i.e. I could run faster
¤ due to lower overhead.
¤
¤ Sorry I do not know the terminology to research this and if I did I
¤ probably would not get the gist of it.
¤ Still in learning mode ... thanks for your patience.
¤

Some your questions would require a little more info, but you can find the differences between
Instancing values documented in the below article:

http://msdn.microsoft.com/en-us/library/aa242107%28VS.60%29.aspx


Paul
~~~~
Microsoft MVP (Visual Basic)
Author
13 Aug 2010 6:22 PM
BeeJ
Paul Clement formulated the question :
Show quoteHide quote
> On Fri, 13 Aug 2010 09:34:21 -0700, BeeJ <nospam@live.com> wrote:
>
> ¤ So what is happening?
> ¤ In both cases I have set Thread Per Object.
> ¤ I instantiate four of the same ActiveX EXEs (set as an array of Ax().
> ¤ With SingleUse I see all four in Process Explorer.
> ¤ with MultiUse I see one in Process Explorer.
> ¤ The Main App runs and uses what is provided in either case but ...
> ¤
> ¤ Is the MultiUse some sort of reentrant thing?
> ¤ Is there only one copy in memory?
> ¤ How is the CPU interacting with these?
> ¤
> ¤ All are working at the same time (as sliced).
> ¤ But maybe the timing is better with SingleUse.  i.e. I could run faster
> ¤ due to lower overhead.
> ¤
> ¤ Sorry I do not know the terminology to research this and if I did I
> ¤ probably would not get the gist of it.
> ¤ Still in learning mode ... thanks for your patience.
> ¤
>
> Some your questions would require a little more info, but you can find the
> differences between Instancing values documented in the below article:
>
> http://msdn.microsoft.com/en-us/library/aa242107%28VS.60%29.aspx
>
>
> Paul
> ~~~~
> Microsoft MVP (Visual Basic)

Well not what I was after.  I saw similar in MSDN Help (F1) from the
IDE.  I am more interested in what the CPU does.
When only one appears in Process Explorer and i have instantiated four,
what is really going on?  I left the question slightly ambiguous to get
outside the box responses that give me more fodder.
Is there more overhead?
These are small ActiveX EXE with no global data to speak of so having
four in memory does not seem like too much but ... ?
If I need more speed or more assurance that something will get done
when I request it?  Those are what matters to me.
In the past I did similar but the interface driver that my ActiveX EXE
talked to was not reentrant and it really was a pain because i could
not get anything to work.  I think National Instruments finally came
out with a reentrant driver but by then the management had thrown in
the towel.  Anyway, i am retired now so i don't give a hoot about that.
Author
13 Aug 2010 7:11 PM
Jim Mack
BeeJ wrote:

> When only one appears in Process Explorer and i have instantiated
> four, what is really going on?  I left the question slightly
> ambiguous to get outside the box responses that give me more fodder.
> Is there more overhead?

Processes don't run -- only threads run. Four processes each with a
single thread shouldn't work any faster or slower than four threads in
a single process.

There will be startup overhead for each process and for each thread,
and some small memory overhead for each process, but aside from that
it should make no difference to performance.

--
   Jim Mack
   Twisted tees at http://www.cafepress.com/2050inc
   "We sew confusion"
Author
13 Aug 2010 7:26 PM
Tom Shelton
Jim Mack brought next idea :
Show quoteHide quote
> BeeJ wrote:
>
>> When only one appears in Process Explorer and i have instantiated
>> four, what is really going on?  I left the question slightly
>> ambiguous to get outside the box responses that give me more fodder.
>> Is there more overhead?
>
> Processes don't run -- only threads run. Four processes each with a
> single thread shouldn't work any faster or slower than four threads in
> a single process.
>
> There will be startup overhead for each process and for each thread,
> and some small memory overhead for each process, but aside from that
> it should make no difference to performance.

Actually...  It can make a difference in certain scenarios...  If you
are creating short lived objects, then you incure the pretty weighty
overhead of process startup on every object instantiation.

But, if you are dealing with long lived objects in general, it's not
going to make a difference.

--
Tom Shelton
Author
13 Aug 2010 7:45 PM
Mike Williams
"Tom Shelton" <tom_shelton@comcast.invalid> wrote in message
news:i4469u$bl7$1@news.eternal-september.org...

> Actually...  It can make a difference in certain scenarios...

Hi Tom. Any idea where your friend Senn (aka Tom the bank clerk) is? We
haven't seen him since he was unfrocked. Has he told you where he has gone,
or has he left you in the dark as well?

Mike
Author
13 Aug 2010 7:57 PM
Tom Shelton
Mike Williams formulated the question :
> "Tom Shelton" <tom_shelton@comcast.invalid> wrote in message
> news:i4469u$bl7$1@news.eternal-september.org...
>
>> Actually...  It can make a difference in certain scenarios...
>
> Hi Tom. Any idea where your friend Senn (aka Tom the bank clerk) is? We
> haven't seen him since he was unfrocked. Has he told you where he has gone,
> or has he left you in the dark as well?
>
> Mike

Nice try.  I know nothing about senn...  other then what i've seen in
his posts.

--
Tom Shelton
Author
13 Aug 2010 8:44 PM
Mike Williams
"Tom Shelton" <tom_shelton@comcast.invalid> wrote in message
news:i4482p$s15$1@news.eternal-september.org...
>> Mike Williams formulated the question :
>> Hi Tom. Any idea where your friend Senn (aka Tom the bank
>> clerk) is? We haven't seen him since he was unfrocked. Has he
>> told you where he has gone, or has he left you in the dark as well?
>
> Nice try.  I know nothing about senn...  other then what i've
> seen in his posts.

No problem, Tom. In fact I wasn't really interested in Senn or his
whereabouts. I was just checking the sincerity of your recent statement that
I will get no further reply from you until I effectively toe the party line
;-)

Mike
Author
14 Aug 2010 6:17 AM
Tom Shelton
Mike Williams presented the following explanation :
Show quoteHide quote
> "Tom Shelton" <tom_shelton@comcast.invalid> wrote in message
> news:i4482p$s15$1@news.eternal-september.org...
>>> Mike Williams formulated the question :
>>> Hi Tom. Any idea where your friend Senn (aka Tom the bank
>>> clerk) is? We haven't seen him since he was unfrocked. Has he
>>> told you where he has gone, or has he left you in the dark as well?
>>
>> Nice try.  I know nothing about senn...  other then what i've
>> seen in his posts.
>
> No problem, Tom. In fact I wasn't really interested in Senn or his
> whereabouts. I was just checking the sincerity of your recent statement that
> I will get no further reply from you until I effectively toe the party line
> ;-)
>
> Mike

Go back and read what I said.  I said, I would not reply unless it was
reasonable discussion.  So far, this has been reasonable - so I
replied.

It has nothing to do with toeing the party line...

--
Tom Shelton
Author
13 Aug 2010 7:22 PM
Tom Shelton
BeeJ submitted this idea :
Show quoteHide quote
> Paul Clement formulated the question :
>> On Fri, 13 Aug 2010 09:34:21 -0700, BeeJ <nospam@live.com> wrote:
>>
>> ¤ So what is happening?
>> ¤ In both cases I have set Thread Per Object.
>> ¤ I instantiate four of the same ActiveX EXEs (set as an array of Ax().
>> ¤ With SingleUse I see all four in Process Explorer.
>> ¤ with MultiUse I see one in Process Explorer.
>> ¤ The Main App runs and uses what is provided in either case but ...
>> ¤ ¤ Is the MultiUse some sort of reentrant thing?
>> ¤ Is there only one copy in memory?
>> ¤ How is the CPU interacting with these?
>> ¤ ¤ All are working at the same time (as sliced).
>> ¤ But maybe the timing is better with SingleUse.  i.e. I could run faster ¤
>> due to lower overhead.
>> ¤ ¤ Sorry I do not know the terminology to research this and if I did I ¤
>> probably would not get the gist of it.
>> ¤ Still in learning mode ... thanks for your patience.
>> ¤
>>
>> Some your questions would require a little more info, but you can find the
>> differences between Instancing values documented in the below article:
>>
>> http://msdn.microsoft.com/en-us/library/aa242107%28VS.60%29.aspx
>>
>>
>> Paul
>> ~~~~
>> Microsoft MVP (Visual Basic)
>
> Well not what I was after.  I saw similar in MSDN Help (F1) from the IDE.  I
> am more interested in what the CPU does.
> When only one appears in Process Explorer and i have instantiated four, what
> is really going on?

A new thread is started in the ax exe process, and the object is
created on that thread.

> I left the question slightly ambiguous to get outside
> the box responses that give me more fodder.
> Is there more overhead?

Actually, less.  Windows is is very slow at starting processes (when
compared to other os's) - but, pretty quick at starting threads.

With a singleuse, it has to start the process, start the thread for the
object, initialize the thread for tls and com, and then create the
object.  With the multiuse, you only get the process start overhead on
the very first client to connect.  After that, its just start the
thread, initialize tls and com, create the object.  Not to mention,
that each process will get a much larger piece of memory then they
really need.

> These are small ActiveX EXE with no global data to speak of so having four in
> memory does not seem like too much but ... ?

There is no such thing as global data in a activex exe.  VB.CLASSIC's
threading model is single appartment threading.  Which means, that it
uses Thread Local Storage (TLS).  Everytime, a new thread is spawned,
they get their own fresh copy of the global data - meaning, global
values are global to the thread, not the process.  This is the reason
it's sort of a pain to do cross thread communication in vb.CLASSIC.

Of course, it's also makes simple threading scenarios - where each
object is independant and there isn't a lot of cross thread chatter
going on - a bit simpler, because you don't have to worry about
explicit syncronization.


> If I need more speed or more assurance that something will get done when I
> request it? 

The difference between singleuse and multiuse isn't going to make much
difference for long lasting objects.  In other words, if you create
them and then hold on to them for the life of your program, it's not as
big a deal as if you are in a loop creating short lived objects...  For
the shorter lifetimes, multiuse is going to be better (though still
sucky as that is just the nature of com reference counting...  there is
a lot of overhead in object creation)

--
Tom Shelton
Author
14 Aug 2010 12:55 AM
David Youngblood
"Tom Shelton" <tom_shelton@comcast.invalid> wrote in message
news:i4462a$96g$1@news.eternal-september.org...
> BeeJ submitted this idea :
>> These are small ActiveX EXE with no global data to speak of so having
>> four in memory does not seem like too much but ... ?
>
> There is no such thing as global data in a activex exe.

That hasn't been my experience, or are we talking about 2 different things?
I made a small test to verify, and it does show that an object created from
a muli-use class refers to the same public variable, while the single-use
objects have their own data.

David

'* Test code in standard exe
Private Sub Command1_Click()

    Dim c1 As Object, c2 As Object

    '* Create muli-use objects
    Set c1 = CreateObject("Project1.Class1")
    Set c2 = CreateObject("Project1.Class1")
    c1.foo = "Hello"
    c2.foo = "World"
    Debug.Print c1.foo & " " & c2.foo
    '*** Prints "World World", c1 and c2 access the same public variable
    Set c1 = Nothing
    Set c2 = Nothing

    '* Create single-use objects
    Set c1 = CreateObject("Project1.Class2")
    Set c2 = CreateObject("Project1.Class2")
    c1.foo = "Hello"
    c2.foo = "World"
    Debug.Print c1.foo & " " & c2.foo
    '*** Prints "Hello World", c1 and c2 each have their own data
    Set c1 = Nothing
    Set c2 = Nothing

End Sub


ActiveX Exe code follows,

'* Module1
Public g_sFoo As String

'* Class1, Instancing = MultiUse
Public Property Get Foo() As String
    Foo = g_sFoo
End Property
Public Property Let Foo(ByVal sNewValue As String)
    g_sFoo = sNewValue
End Property

'* Class2 code,  Instancing = SingleUse
Public Property Get Foo() As String
    Foo = g_sFoo
End Property
Public Property Let Foo(ByVal sNewValue As String)
    g_sFoo = sNewValue
End Property
Author
14 Aug 2010 1:42 AM
Tom Shelton
David Youngblood formulated on Friday :
Show quoteHide quote
> "Tom Shelton" <tom_shelton@comcast.invalid> wrote in message
> news:i4462a$96g$1@news.eternal-september.org...
>> BeeJ submitted this idea :
>>> These are small ActiveX EXE with no global data to speak of so having four
>>> in memory does not seem like too much but ... ?
>>
>> There is no such thing as global data in a activex exe.
>
> That hasn't been my experience, or are we talking about 2 different things? I
> made a small test to verify, and it does show that an object created from a
> muli-use class refers to the same public variable, while the single-use
> objects have their own data.
>
> David
>
> '* Test code in standard exe
> Private Sub Command1_Click()
>
>     Dim c1 As Object, c2 As Object
>
>     '* Create muli-use objects
>     Set c1 = CreateObject("Project1.Class1")
>     Set c2 = CreateObject("Project1.Class1")
>     c1.foo = "Hello"
>     c2.foo = "World"
>     Debug.Print c1.foo & " " & c2.foo
>     '*** Prints "World World", c1 and c2 access the same public variable
>     Set c1 = Nothing
>     Set c2 = Nothing
>
>     '* Create single-use objects
>     Set c1 = CreateObject("Project1.Class2")
>     Set c2 = CreateObject("Project1.Class2")
>     c1.foo = "Hello"
>     c2.foo = "World"
>     Debug.Print c1.foo & " " & c2.foo
>     '*** Prints "Hello World", c1 and c2 each have their own data
>     Set c1 = Nothing
>     Set c2 = Nothing
>
> End Sub
>
>
> ActiveX Exe code follows,
>
> '* Module1
> Public g_sFoo As String
>
> '* Class1, Instancing = MultiUse
> Public Property Get Foo() As String
>     Foo = g_sFoo
> End Property
> Public Property Let Foo(ByVal sNewValue As String)
>     g_sFoo = sNewValue
> End Property
>
> '* Class2 code,  Instancing = SingleUse
> Public Property Get Foo() As String
>     Foo = g_sFoo
> End Property
> Public Property Let Foo(ByVal sNewValue As String)
>     g_sFoo = sNewValue
> End Property

Change your thread model to Thread per object...   We are talking about
two different things :)

--
Tom Shelton
Author
14 Aug 2010 2:39 AM
David Youngblood
Show quote Hide quote
"Tom Shelton" <tom_shelton@comcast.invalid> wrote in message
news:i44s9j$igt$1@news.eternal-september.org...
> David Youngblood formulated on Friday :
>> "Tom Shelton" <tom_shelton@comcast.invalid> wrote in message
>> news:i4462a$96g$1@news.eternal-september.org...
>>> BeeJ submitted this idea :
>>>> These are small ActiveX EXE with no global data to speak of so having
>>>> four in memory does not seem like too much but ... ?
>>>
>>> There is no such thing as global data in a activex exe.
>>
>> That hasn't been my experience, or are we talking about 2 different
>> things? I made a small test to verify, and it does show that an object
>> created from a muli-use class refers to the same public variable, while
>> the single-use objects have their own data.
>>
> Change your thread model to Thread per object...   We are talking about
> two different things :)

I see, thanks for the clarification. My use of ActiveX Exe has always been
with single thread pool (using a scripting component) and I've always
expected global variables to be global. I've never had a need multiple
threads.

David
Author
14 Aug 2010 3:33 AM
Paul Clement
On Fri, 13 Aug 2010 11:22:39 -0700, BeeJ <nospam@live.com> wrote:


¤ > Some your questions would require a little more info, but you can find the
¤ > differences between Instancing values documented in the below article:
¤ >
¤ > http://msdn.microsoft.com/en-us/library/aa242107%28VS.60%29.aspx
¤ >
¤ >
¤ > Paul
¤ > ~~~~
¤ > Microsoft MVP (Visual Basic)
¤
¤ Well not what I was after.  I saw similar in MSDN Help (F1) from the
¤ IDE.  I am more interested in what the CPU does.
¤ When only one appears in Process Explorer and i have instantiated four,
¤ what is really going on?  I left the question slightly ambiguous to get
¤ outside the box responses that give me more fodder.
¤ Is there more overhead?
¤ These are small ActiveX EXE with no global data to speak of so having
¤ four in memory does not seem like too much but ... ?
¤ If I need more speed or more assurance that something will get done
¤ when I request it?  Those are what matters to me.
¤ In the past I did similar but the interface driver that my ActiveX EXE
¤ talked to was not reentrant and it really was a pain because i could
¤ not get anything to work.  I think National Instruments finally came
¤ out with a reentrant driver but by then the management had thrown in
¤ the towel.  Anyway, i am retired now so i don't give a hoot about that.
¤

Well it kind of helps to have context (such as what the component is doing, how
many clients it will support, etc.), which is why I pointed you to the
documentation. I think Jim and Tom pretty much addressed your follow-up
questions though so I won't repeat anything.

Paul
~~~~
Microsoft MVP (Visual Basic)