speed problem using smart pointers on FPC.Root

The EggHeadCafe.com web spider found the following conversation that may be helpful to you.

Next Thread:   Upgrade ISA 2000 (on SBS 2003) to ISA 2004 I get an Error

8/10/2004 2:30:04 PM    speed problem using smart pointers on FPC.Root
Hi,  
  
I've a little speed problem while browsing destinations sets. It tooks  
  
about 8" to browse a full 1024 destinations set. It's not a network  
  
problem, because I got also large execution time when running on the ISA  
  
server (4" : +-1000 entries/second).  
  
It's a problem, because I plane to use destinations sets that contains  
  
more than 450 000 entries so it could take more than an hour to export  
  
the entiere content.  
  
Is there any way to speed up the thing ?  
  
When using ISA mmc, it takes not such time to retrieve the destination  
  
sets content even from a distant machine.  
  
Maybe the smart pointers are not the right way.  
  
I connect to the ISA using CoInitializeEx(), using "localhost" as target  
  
when running on the ISA.  
  
nb: Because of the bug on the long result for fpcDestinationSet->Count  
  
discuted a few days ago, I can't know the count for a Set, so, I'm using  
  
an infinite loop incrementing the variable "l" until falling in  
  
exception catched by the try/catch couple when reaching the end.  
  
Thanks for help.  
  
-------------------------------------  
  
FpcDestinationAddressType  Dtype ;  
  
long l = 1;  
  
CString Buff;  
  
try {  
  
while (fpcDestination = fpcDestinationSet->Item  
  
(_variant_t(l),(BSTR) NULL ,(BSTR) NULL)){  
  
fpcDestination->get_Type( &Dtype );  
  
Dtype=fpcDestination->Type;  
  
switch ( Dtype ){  
  
case  0 :  
  
Buff=(char*) fpcDestination->DomainName;  
  
break;  
  
case  1 :  
  
Buff= (char*) fpcDestination->IP_From;  
  
break;  
  
case 2:  
  
break;  
  
default :  
  
break;  
  
}  
  
Buff.TrimRight();  
  
Buff.TrimLeft();  
  
//here : storing Buff in a file but commented while testing speed  
  
l++;  
  
}  
  
}catch ( _com_error& pCE ){  
  
}



8/11/2004 7:15:25 AM    RE: speed problem using smart pointers on FPC.Root
Hi Alni,  
  
I have been looking into this issue and will update you with my  
  
result. Please wait for my message. Thanks.  
  
Best regards,  
  
WenJun Zhang  
  
Microsoft Online Support  
  
This posting is provided "AS IS" with no warranties, and confers no  
  
rights.  
  
Get Secure! - www.microsoft.com/security

8/11/2004 2:18:32 PM    Re: speed problem using smart pointers on FPC.Root
Bonjour,  
  
"WenJun Zhang[msft]" <[email protected]> a écrit :  
  
Yes, of course, I know. Thanks again for that.  
  
But at this point, I just wonder if I should consider as "normal", that  
  
it takes more than 4" to browse 1000 destinations using my code. May be  
  
there is an other way.  
  
Because I'm planning to use destinations sets of about half a million  
  
destinations. So it could take more than 4*500=2000". More than 1/h hour  
  
to retrieve the set to a file !!!  
  
Such a file that contains 500 000 entries weigh 8Mo, so the "write to  
  
file" time should be negligible.  
  
On the other side, using ISA management MMC, it takes about 5" to fill  
  
the list box that contains the 500 000 entries set (even on a distant  
  
machine). That's why, I wonder....  
  
Regards,

8/12/2004 10:24:44 AM    Re: speed problem using smart pointers on FPC.Root
Hi Alni,  
  
I also met the C2556 and C2371 errors on GetType(). I wonder how you  
  
finally worked around it?  
  
error C2556: 'GetType' : overloaded functions only differ by return  
  
type  
  
error C2371: 'GetType' : redefinition; different basic types  
  
At least the low performance shouldn't be caused by FPC. I tested  
  
going through 1024 items destination set in vbs. It definitely  
  
needn't 1 sec to finish. So I do think the problem is in the VC code.  
  
Dim objFPC  
  
Dim fpcDestinationSets  
  
Dim fpcDestinationSet  
  
Dim objFPCArray  
  
Dim fpcDestination  
  
Dim temp  
  
Set objFPC = CreateObject("FPC.Root")  
  
Set objFPCArray = objFPC.Arrays(1)  
  
Set fpcDestinationSets = objFPCArray.PolicyElements.DestinationSets  
  
set fpcDestinationSet= fpcDestinationSets("test")  
  
for each fpcDestination in fpcDestinationSet  
  
'Wscript.echo fpcDestination.type  
  
Select Case fpcDestination.type  
  
Case 0  
  
'Wscript.echo fpcDestination.domainname  
  
temp = fpcDestination.domainname  
  
Case 1  
  
'Wscript.echo fpcDestination.Ip_From  
  
temp = fpcDestination.Ip_From  
  
Case 2  
  
End Select  
  
'Wscript.echo  
  
next  
  
Wscript.echo temp  
  
Best regards,  
  
WenJun Zhang  
  
Microsoft Online Support  
  
This posting is provided "AS IS" with no warranties, and confers no  
  
rights.  
  
Get Secure! - www.microsoft.com/security

8/12/2004 5:33:37 PM    Re: speed problem using smart pointers on FPC.Root
Hi,  
  
"WenJun Zhang[msft]" <[email protected]> a écrit :  
  
There is an enum "type" for the return value  
  
http://msdn.microsoft.com/library/en-us/isa/isaenum_9ecl.asp  
  
So :  
  
FpcDestinationAddressType  Dtype ;  
  
long l=1;  
  
try {  
  
while (fpcDestination = fpcDestinationSet->Item  
  
(_variant_t(l),(BSTR) NULL ,(BSTR) NULL)){  
  
Dtype=fpcDestination->Type;  
  
// or   fpcDestination->get_Type( &Dtype );  
  
switch ( Dtype ){  
  
case  0 :  
  
Buff=(char*) fpcDestination->DomainName;  
  
break;  
  
case  1 :  
  
Buff= (char*) fpcDestination->IP_From;  
  
break;  
  
default :  
  
break;  
  
}  
  
...../....  
  
l++  
  
}  
  
}catch ( _com_error& pCE ){  
  
Display.Format("Failed: %x, source %s/n", pCE.Error, (char*)  
  
pCE.Source());  
  
//  MessageBox(Display);  
  
}  
  
Using CoCreateInstanceEx() ?  
  
In order to use my prog from a distant machine, I have to use this  
  
method.  
  
Of course when I use hr = fpcRoot.CreateInstance("FPC.Root")  
  
and run the exe on the ISA itself, I've no speed problem at all  
  
Looking at the task manager of the ISA while running the 2 methods, I  
  
can observe that  
  
- CoCreateInstanceEx()uses a dllhost.dll on the ISA that grows up to 300  
  
Mo when using my huge destination set (470000 entries). The process is  
  
slow as I said previously, even if I run from the ISA specifying  
  
localhost as target.  
  
- fpcRoot.CreateInstance("FPC.Root") runs on the ISA itself and is very  
  
fast (also less than less than 1" to complete the export 1000 items  
  
destination set. In that case, there is no dllhost that appears, but my  
  
prg itself grows up to 300Mo when playing with the huge set.  
  
But for now, I've removed the huge set, I run my test ISA server in a  
  
vmware and my computer is only 512Mo RAM, so this huge set was causing  
  
lots of swap on the VM and on my computer :)  
  
What's happen if you use :  
  
Set objFPC = CreateObject("FPC.Root", "YourISAServer")  
  
from your ISA and eventually from a distant machine ?  
  
I suppose that vbs translate : CreateObject("FPC.Root")  
  
by fpcRoot.CreateInstance("FPC.Root") (whih is fast for me)  
  
but I wonder how it will translate :  
  
CreateObject("FPC.Root", "YourISAServer") and if it cause speeds  
  
problems  
  
If I've a little time I will try to use your script using this method.  
  
Regards,

8/13/2004 10:30:36 AM    Re: speed problem using smart pointers on FPC.Root
Hi Alni,  
  
I'm not testing on a distant machine. Locally test the following two  
  
lines and their performance appears to be no difference.  
  
Set objFPC = CreateObject("FPC.Root")  
  
Set objFPC = CreateObject("FPC.Root", "YourISAServer")  
  
Have you got a work around of the huge set yet? :-)  
  
Best regards,  
  
WenJun Zhang  
  
Microsoft Online Support  
  
This posting is provided "AS IS" with no warranties, and confers no  
  
rights.  
  
Get Secure! - www.microsoft.com/security

8/13/2004 3:07:47 PM    Re: speed problem using smart pointers on FPC.Root
Bonjour,  
  
"WenJun Zhang[msft]" <[email protected]> a écrit :  
  
While not fixed, I'm using endless loops between try/catch couples  
  
-----------------------------------------  
  
l=1;  
  
FpcDestinationAddressType Dtype ;  
  
try {  
  
while (fpcDestination = fpcDestinationSet->Item  
  
(_variant_t(l),(BSTR) NULL ,(BSTR) NULL)){  
  
fpcDestination->get_Type( &Dtype );  
  
Dtype=fpcDestination->Type;  
  
switch ( Dtype ){  
  
case 0 :  
  
Buff=(char*) fpcDestination->DomainName;  
  
break;  
  
case 1 :  
  
Buff= (char*) fpcDestination->IP_From;  
  
break;  
  
case 2:  
  
break;  
  
default :  
  
break;  
  
}  
  
Buff.TrimRight();  
  
Buff.TrimLeft();  
  
Buff+="/n";  
  
File.WriteString(Buff);  
  
l++;  
  
}  
  
}catch ( _com_error& pCE ){  
  
TRACE("Failed: %x, source %s/n", pCE.Error, (char*) pCE.Source());  
  
}  
  
When the program reach the end of the set, it falls in the catch....  
  
I've just put a TRACE in order to prevent compilation warning if pCE is  
  
not used.  
  
Regards

8/16/2004 9:54:12 AM    Re: speed problem using smart pointers on FPC.Root
Hi Alni,  
  
I'm still not able to get rid of the C2556 and C2371 error. Reduced  
  
the code as below and the error still occurs. Could you provide the  
  
your modified code with the error worked around? Probabaly I'd file  
  
another ISA SE bug about the FpcDestinationAddressType GetType  
  
redefinition.  
  
I haven't found where can cause the endless loop. Will you still get  
  
into the loop with the following reduced code?  
  
int main (int argc, WCHAR **argv)  
  
{  
  
DWORD dwRet = 0;  
  
HRESULT hr = CoInitializeEx (NULL, COINIT_APARTMENTTHREADED );  
  
FPCLib::IFPCPtr fpcRoot;  
  
FPCLib::IFPCArraysPtr fpcArrays;  
  
FPCLib::IFPCArrayPtr fpcArray;  
  
FPCLib::IFPCDestinationSetPtr fpcDestinationSet;  
  
FPCLib::IFPCDestinationPtr fpcDestination;  
  
hr = fpcRoot.CreateInstance("FPC.Root");  
  
if (FAILED (hr))  
  
{  
  
printf ("Failed: %x/n", hr);  
  
return dwRet;  
  
}  
  
try  
  
{  
  
fpcArrays = fpcRoot->Arrays;  
  
long v1 = 1;  
  
if ( fpcArrays->Item (_variant_t(v1)) == NULL )  
  
return dwRet;  
  
fpcArray = fpcArrays->Item (_variant_t(v1)) ;  
  
fpcDestinationSet=fpcArray->PolicyElements->DestinationSets->Item(_var  
  
iant_t(v1)) ;  
  
FPCLib::FpcDestinationAddressType Dtype ;  
  
CString Buff;  
  
long l = 1;  
  
try {  
  
while (fpcDestination = fpcDestinationSet->Item  
  
(_variant_t(l),(BSTR) NULL ,(BSTR) NULL)){  
  
fpcDestination->get_Type( &Dtype );  
  
Dtype=fpcDestination->Type;  
  
switch ( Dtype ){  
  
case  0 :  
  
Buff=(char*) fpcDestination->DomainName;  
  
printf ("Destination domain name: %s/n", Buff);  
  
break;  
  
case  1 :  
  
Buff= (char*) fpcDestination->IP_From;  
  
printf ("Destination IP from: %s/n", Buff);  
  
break;  
  
case 2:  
  
break;  
  
default :  
  
break;  
  
}  
  
l++;  
  
}  
  
}  
  
catch ( _com_error& pCE ){  
  
printf ("Failed: %x, source %s/n", pCE.Error, (char*)  
  
pCE.Source());  
  
}  
  
}  
  
catch (_com_error& pCE)  
  
{  
  
printf ("Failed: %x, source %s/n", pCE.Error, (char*)  
  
pCE.Source());  
  
}  
  
dwRet = 1; // Ok.  
  
CoUninitialize();  
  
return dwRet;  
  
}  
  
Best regards,  
  
WenJun Zhang  
  
Microsoft Online Support  
  
This posting is provided "AS IS" with no warranties, and confers no  
  
rights.  
  
Get Secure! - www.microsoft.com/security

8/16/2004 1:32:52 PM    Re: speed problem using smart pointers on FPC.Root
Bonjour,  
  
"WenJun Zhang[msft]" <[email protected]> a écrit :  
  
I use "using namespace FPCLib;" directive, then I declare :  
  
IFPCPtr fpcRoot;  
  
IFPCArraysPtr fpcArrays;  
  
IFPCArrayPtr fpcArray;  
  
IFPCDestinationSetPtr fpcDestinationSet;  
  
IFPCDestinationPtr fpcDestination;  
  
FpcDestinationAddressType Dtype;  
  
That works this way.  
  
This is part of my OnExport() function.  
  
When the counter "l" reach the end of the set+1, this line fails :  
  
while(fpcDestination = fpcDestinationSet->Item())  
  
So the program jumps to the catch line...  
  
---------------------------------------------------  
  
l=1;  
  
FpcDestinationAddressType  Dtype ;  
  
try {  
  
while (fpcDestination = fpcDestinationSet->Item  
  
(_variant_t(l),(BSTR) NULL ,(BSTR) NULL)){  
  
if (l%100==0)  
  
{  
  
m_Status.Format("Export in progress... Count : %8ld",l);  
  
UpdateData(FALSE);  
  
UpdateWindow();  
  
}  
  
fpcDestination->get_Type( &Dtype );  
  
Dtype=fpcDestination->Type;  
  
switch ( Dtype ){  
  
case  0 :  
  
Buff=(char*) fpcDestination->DomainName;  
  
break;  
  
case  1 :  
  
Buff= (char*) fpcDestination->IP_From;  
  
break;  
  
case 2:  
  
break;  
  
default :  
  
break;  
  
}  
  
Buff.TrimRight();  
  
Buff.TrimLeft();  
  
Buff+="/n";  
  
File.WriteString(Buff);  
  
l++;  
  
}  
  
}catch ( _com_error& pCE ){  
  
TRACE("Failed: %x, source %s/n", pCE.Error, (char*) pCE.Source());  
  
}  
  
m_Status="Export completed.";

8/19/2004 1:16:14 PM    Re: speed problem using smart pointers on FPC.Root
Hi Alni,  
  
I'm still researching this issue and will update you as soon as I get  
  
more information on it. Please wait for my message. Thanks.  
  
Best regards,  
  
WenJun Zhang  
  
Microsoft Online Support  
  
This posting is provided "AS IS" with no warranties, and confers no  
  
rights.  
  
Get Secure! - www.microsoft.com/security

8/20/2004 11:15:22 AM    Re: speed problem using smart pointers on FPC.Root
Hi Alni,  
  
I finally reproduced the problem you met. When the l exceeds the  
  
count of the set, the exception is thrown out.  
  
fpcDestination = fpcDestinationSet->Item(_variant_t(l)  
  
Since currently you cannot use fpcDestinationSet->Count to determine  
  
if l has exceeded, I think there isn't a way to prevent it from  
  
jumping into the Catch.  
  
I'll keep monitoring the previous bug. Current status is it has been  
  
assigned to 1 of our test engineers.  
  
Please also consider if it's necessary for you to open a case and  
  
submit QFE request.  
  
Thanks.  
  
Best regards,  
  
WenJun Zhang  
  
Microsoft Online Support  
  
This posting is provided "AS IS" with no warranties, and confers no  
  
rights.  
  
Get Secure! - www.microsoft.com/security

8/20/2004 7:35:36 PM    Re: speed problem using smart pointers on FPC.Root
Bonjour,  
  
"WenJun Zhang[msft]" <[email protected]> a écrit :  
  
?????  
  
That's what I want : "Jump into the catch" :)  
  
I have no problem with this.  
  
You ask me : > Have you got a work around of the huge set yet? :-)  
  
I've understood, that you want me to show you what workaround I've found  
  
while the fpcDestinationSet->Count bug is not fixed.  
  
Then, I put an endless loop between a try/catch couple, and when it  
  
falls into the catch, I know I'm at the end of the set. It works fine  
  
this way, waiting the bug to be fixed.

8/23/2004 10:02:58 AM    Re: speed problem using smart pointers on FPC.Root
"It works fine this way, waiting the bug to be fixed."  
  
Sure, it has been taken ownership by one of our product test  
  
engineer. I'll keep monitoring and when the bug is closed, I'll send  
  
a mail to inform you. :-)  
  
Thanks.  
  
Best regards,  
  
WenJun Zhang  
  
Microsoft Online Support  
  
This posting is provided "AS IS" with no warranties, and confers no  
  
rights.  
  
Get Secure! - www.microsoft.com/security

你可能感兴趣的:(exception,Google,Microsoft,null,performance,Pointers)