|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
ActiveX EXE SingleUse Vs MultiUseSo 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.
Show quote
Hide quote
"BeeJ" <nospam@live.com> wrote in message Check "Thread Count" in Task Manager. I think you would see that the Single 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. Use has at least 4. 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) Paul Clement formulated the question :
Show quoteHide quote > On Fri, 13 Aug 2010 09:34:21 -0700, BeeJ <nospam@live.com> wrote: Well not what I was after. I saw similar in MSDN Help (F1) from the > > ¤ 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) 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. BeeJ wrote:
> When only one appears in Process Explorer and i have instantiated Processes don't run -- only threads run. Four processes each with a> 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? 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 brought next idea :
Show quoteHide quote > BeeJ wrote: Actually... It can make a difference in certain scenarios... If you > >> 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. 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 "Tom Shelton" <tom_shelton@comcast.invalid> wrote in message Hi Tom. Any idea where your friend Senn (aka Tom the bank clerk) is? We news:i4469u$bl7$1@news.eternal-september.org... > Actually... It can make a difference in certain scenarios... 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 Mike Williams formulated the question :
> "Tom Shelton" <tom_shelton@comcast.invalid> wrote in message Nice try. I know nothing about senn... other then what i've seen in > 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 his posts. -- Tom Shelton "Tom Shelton" <tom_shelton@comcast.invalid> wrote in message No problem, Tom. In fact I wasn't really interested in Senn or his 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. 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 Mike Williams presented the following explanation :
Show quoteHide quote > "Tom Shelton" <tom_shelton@comcast.invalid> wrote in message Go back and read what I said. I said, I would not reply unless it was > 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 reasonable discussion. So far, this has been reasonable - so I replied. It has nothing to do with toeing the party line... -- Tom Shelton BeeJ submitted this idea :
Show quoteHide quote > Paul Clement formulated the question : A new thread is started in the ax exe process, and the object is >> 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? created on that thread. > I left the question slightly ambiguous to get outside Actually, less. Windows is is very slow at starting processes (when > the box responses that give me more fodder. > Is there more overhead? 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 There is no such thing as global data in a activex exe. VB.CLASSIC's > memory does not seem like too much but ... ? 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 The difference between singleuse and multiuse isn't going to make much > request it? 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 "Tom Shelton" <tom_shelton@comcast.invalid> wrote in message That hasn't been my experience, or are we talking about 2 different things? 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. 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 David Youngblood formulated on Friday :
Show quoteHide quote > "Tom Shelton" <tom_shelton@comcast.invalid> wrote in message Change your thread model to Thread per object... We are talking about > 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 two different things :) -- Tom Shelton
Show quote
Hide quote
"Tom Shelton" <tom_shelton@comcast.invalid> wrote in message I see, thanks for the clarification. My use of ActiveX Exe has always been 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 :) 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 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) |
|||||||||||||||||||||||