请教:多接口为什么会造成对象方法执行响应时间延长呢?如何避免?

28 views
Skip to first unread message

cherokee

unread,
Jan 19, 2009, 4:41:57 AM1/19/09
to ace-...@googlegroups.com
client连接server,调用server上的对象并执行方法,发现当server计算机配置了多个ip地址时,会使得执行时间长达数十秒,这是什么原因,如何避免呢?

techabc

unread,
Feb 10, 2009, 8:35:20 PM2/10/09
to ace-...@googlegroups.com
这个问题困扰已久,还请知情的朋友指点迷津啊

2009/1/19 cherokee <tec...@gmail.com>

刘国标

unread,
Feb 17, 2009, 7:46:09 AM2/17/09
to ace-...@googlegroups.com
?所谓的虚函数效率问题?

2009/2/11 techabc <tec...@gmail.com>

techabc

unread,
Feb 18, 2009, 3:04:31 AM2/18/09
to ace-...@googlegroups.com
虚函数效率能有这么大的延时?而且,CPU占用率无明显变化。

2009/2/17 刘国标 <liugu...@gmail.com>

刘国标

unread,
Feb 18, 2009, 8:16:42 AM2/18/09
to ace-...@googlegroups.com
Server端心跳或路由的原因?广播风暴?

2009/2/18 techabc <tec...@gmail.com>

techabc

unread,
Feb 18, 2009, 9:14:29 PM2/18/09
to ace-...@googlegroups.com
局域网环境,非常简单,不涉及这些问题吧?

2009/2/18 刘国标 <liugu...@gmail.com>

Lei Yang

unread,
Feb 19, 2009, 12:19:07 AM2/19/09
to ace-...@googlegroups.com

虚函数慢的原因是因为访问内存次数多,当然不会造成CPU占用率增大了,相反应该减少才对 ;-), 

2009/2/19 techabc <tec...@gmail.com>

techabc

unread,
Feb 19, 2009, 8:04:44 PM2/19/09
to ace-...@googlegroups.com
前述现象如果是虚函数造成的话,那么单IP和多IP情况下应该表现一致,但事实并非如此啊

2009/2/19 Lei Yang <ynk...@gmail.com>

techabc

unread,
Feb 25, 2009, 4:34:21 AM2/25/09
to ace-...@googlegroups.com
我在启动server应用程序时加了 -ORBPreferredInterfaces 192.168.10.*=192.168.10.* 参数,仍然不行,期盼大家指点

2009/2/20 techabc <tec...@gmail.com>

techabc

unread,
Feb 26, 2009, 3:27:42 AM2/26/09
to ace-...@googlegroups.com
继续探讨:

我写了一个很简单的示例(见附件)来观察,示例的idl如下:

#ifndef __ECHO_IDL__
#define __ECHO_IDL__

interface Echo {
  string echoString(in string mesg);
};

#endif  // __ECHO_IDL__

在client中调用这个方法10次,我记下了时间(直接调用GetTickCount获得),如下:
多接口时:

before OrbInit: 232564

before getObjRef: 232604

finish getObjRef: 232614

finish narrowObj: 232614

before turn 0:   232614

before turn 1:   253664

before turn 2:   253704

before turn 3:   253734

before turn 4:   253774

before turn 5:   253804

before turn 6:   253834

before turn 7:   253875

before turn 8:   253905

before turn 9:   253935

will destroy ORB: 253975

单接口时:

before OrbInit: 3004780

before getObjRef: 3004810

finish getObjRef: 3004830

finish narrowObj: 3004830

before turn 0:   3004830

before turn 1:   3004870

before turn 2:   3004910

before turn 3:   3004950

before turn 4:   3004990

before turn 5:   3005031

before turn 6:   3005071

before turn 7:   3005111

before turn 8:   3005151

before turn 9:   3005191

will destroy ORB: 3005231

对比可见,问题出在第一次执行那个方法上,多接口时耗费了约2秒的时间,而单接口时则基本可以忽略不计。
这多出来的2秒时间到底是怎么造成的呢?
我的实际应用程序在多IP和单IP的差别下每执行一个方法都要多耗费数十秒的时间……
期盼方家指点!

2009/2/25 techabc <tec...@gmail.com>
HelloWorld.7z

sapy

unread,
Mar 12, 2009, 9:22:04 AM3/12/09
to ace-china
我也遇到了,当server是2个ip是要消耗20s,禁用一个ip后,速度马上就快了
恳请高手给个解决方案啊,
油箱chengd...@gmail.com

On 1月19日, 下午5时41分, cherokee <tech...@gmail.com> wrote:
> client连接server,调用server上的对象并执行方法,发现当server计算机配置了多个ip地址时,会使得执行时间长达数十秒,这是什么原因-,如何避免呢?

techabc

unread,
Mar 15, 2009, 11:32:23 PM3/15/09
to ace-...@googlegroups.com
遇到这个问题的弟兄们越来越多,这个问题应该比较普遍,各位对tao比较熟悉的朋友们应该有解决办法吧,请大家都来谈谈经验吧

2009/3/12 sapy <chengd...@gmail.com>

Stone Jiang

unread,
Mar 16, 2009, 12:07:32 AM3/16/09
to ace-...@googlegroups.com
由于我无法重现你的网络环境,所以这个问题一直没法帮得上你。


官方文档中提供了一些关于连接管理的选项,其中有两个选项与多网卡有关。我转贴如下
-ORBPreferredInterfaces "targetNetwork:localNetwork,.." 

This option allows clients running on a multihomed host to pick a local network/interface to communicate with a remote target. When TAO attempts to establish a connection with a host matching targetNetwork, then it will use the local ip address matching localNetwork. Simple wildcards can be used for both parameters, and multiple preferred interfaces can be specified using comma separators. For example, for a machine with two network cards identified by the ip addresses 192.168.1.10 and 192.168.1.20, you can use -ORBPreferredInterfaces *=*10,*=*20. Or to force all communication on the loopback address to try to first use the loopback address, use -ORBPreferredInterfaces 127.0.0.1=127* . targetNetwork can use any string, and must typically match with the value read from an IOR. localNetwork must use a dotted decimal address, because it will be matched with the local ip interfaces. 

-ORBEnforcePreferredInterfaces
 boolean (0|1)

 If this option is set to 1(true), then TAO will only try to use the interfaces specified by the -ORBPreferredInterfaces option. The default is 0(false), in which case if a connection cannot be made using a preferred interface, TAO will attempt to use the default interface (INADDR_ANY). Note: If none of the preferred interfaces apply to an outgoing connection then they will not be enforced. For this option to have any effect, therefore, the connection through a legal preferred interface must fail.  


但上述方法你是否已经测试过?有人说这个选项无效。 你可以试试。 

我的确遇到过在装有虚拟机的环境下第一次建立连接很慢的问题,当禁用一块不用的网卡则速度飞快。
如果不禁用不用的网卡,我是在 /etc/host文件中(windows在system32/drivers/host)中,增加了参与通讯的机器的ip和名字对应的条目,这样也能解决上述问题。 这个方法似乎你有人也说无效,你可以试试看。



2009/3/16 techabc <tec...@gmail.com>

sapy

unread,
Mar 16, 2009, 8:30:51 AM3/16/09
to ace-china
多谢了
option 中增加选项的方法我用过,双网卡的机子调用单网卡机子的方法并执行速度不慢,但是反过来还是很慢
明天试试你说的第2个方法

On 3月16日, 下午12时07分, Stone Jiang <2005...@gmail.com> wrote:
> 由于我无法重现你的网络环境,所以这个问题一直没法帮得上你。
>
> 官方文档中提供了一些关于连接管理的选项,其中有两个选项与多网卡有关。我转贴如下

> -ORBPreferredInterfaces *"targetNetwork:localNetwork,.."*


>
> This option allows clients running on a multihomed host to pick a local
> network/interface to communicate with a remote target. When TAO attempts to
> establish a connection with a host matching targetNetwork, then it will use
> the local ip address matching localNetwork. Simple wildcards can be used for
> both parameters, and multiple preferred interfaces can be specified using
> comma separators. For example, for a machine with two network cards
> identified by the ip addresses 192.168.1.10 and 192.168.1.20, you can use
> -ORBPreferredInterfaces *=*10,*=*20. Or to force all communication on the
> loopback address to try to first use the loopback address, use

> -ORBPreferredInterfaces 127.0.0.1=127* . *targetNetwork* can use any string,
> and must typically match with the value read from an IOR. *localNetwork* must


> use a dotted decimal address, because it will be matched with the local ip
> interfaces.
>
> -ORBEnforcePreferredInterfaces

> *boolean (0|1)*


>
> If this option is set to 1(true), then TAO will only try to use the
> interfaces specified by the -ORBPreferredInterfaces option. The
> default is 0(false),
> in which case if a connection cannot be made using a preferred interface,
> TAO will attempt to use the default interface (INADDR_ANY). Note: If none of
> the preferred interfaces apply to an outgoing connection then they will not
> be enforced. For this option to have any effect, therefore, the connection
> through a legal preferred interface must fail.
>
> 但上述方法你是否已经测试过?有人说这个选项无效。 你可以试试。
> 我的确遇到过在装有虚拟机的环境下第一次建立连接很慢的问题,当禁用一块不用的网卡则速度飞快。
> 如果不禁用不用的网卡,我是在

> /etc/host文件中(windows在system32/drivers/host)中,增加了参与通讯的机器的ip和名字对应的条目,这样也能解决上述-问题。
> 这个方法似乎你有人也说无效,你可以试试看。
>
> 2009/3/16 techabc <tech...@gmail.com>
>
>
>
> > 遇到这个问题的弟兄们越来越多,这个问题应该比较普遍,各位对tao比较熟悉的朋友们应该有解决办法吧,请大家都来谈谈经验吧
>
> > 2009/3/12 sapy <chengdongx...@gmail.com>
>
> > 我也遇到了,当server是2个ip是要消耗20s,禁用一个ip后,速度马上就快了
> >> 恳请高手给个解决方案啊,
> >> 油箱chengdongx...@gmail.com


>
> >> On 1月19日, 下午5时41分, cherokee <tech...@gmail.com> wrote:
>

> >> client连接server,调用server上的对象并执行方法,发现当server计算机配置了多个ip地址时,会使得执行时间长达数十秒,这是什么原因--,如何避免呢?- 隐藏被引用文字 -
>
> - 显示引用的文字 -

evangel

unread,
Mar 20, 2009, 4:04:56 AM3/20/09
to ace-china
我进行了以下测试,问题还是存在:
Server端:192.168.10.115(IP地址1),192.168.10.117(IP地址2),192.168.11.115(IP地址
3)
Client端:192.168.10.116(IP地址4)
子网掩码:255.255.255.0

现象: C端----S端(地址1) 正常
C端----S端(地址1和地址2) 正常
C端----S端(地址1和地址3) 延迟20秒左右

使用命令:server.exe -ORBPreferredInterfaces *=*10.115,*=*11.115 -
ORBEnforcePreferredInterfaces 1 无改善
server.exe -ORBPreferredInterfaces 192.168.10.115=192.168.11.115 -
ORBEnforcePreferredInterfaces 1 无改善

总结:S端多IP与C端IP属于同一网段时无延迟,而S端多IP中存在与C端不同网段的IP时有延迟。

> > /etc/host文件中(windows在system32/drivers/host)中,增加了参与通讯的机器的ip和名字对应的条目,这样也能解决上述--问题。


> > 这个方法似乎你有人也说无效,你可以试试看。
>
> > 2009/3/16 techabc <tech...@gmail.com>
>
> > > 遇到这个问题的弟兄们越来越多,这个问题应该比较普遍,各位对tao比较熟悉的朋友们应该有解决办法吧,请大家都来谈谈经验吧
>
> > > 2009/3/12 sapy <chengdongx...@gmail.com>
>
> > > 我也遇到了,当server是2个ip是要消耗20s,禁用一个ip后,速度马上就快了
> > >> 恳请高手给个解决方案啊,
> > >> 油箱chengdongx...@gmail.com
>
> > >> On 1月19日, 下午5时41分, cherokee <tech...@gmail.com> wrote:
>

> > >> client连接server,调用server上的对象并执行方法,发现当server计算机配置了多个ip地址时,会使得执行时间长达数十秒,这是什么原因---,如何避免呢?- 隐藏被引用文字 -
>
> > - 显示引用的文字 -- 隐藏被引用文字 -
>
> - 显示引用的文字 -

dong cheng

unread,
Mar 25, 2009, 10:34:38 AM3/25/09
to ace-...@googlegroups.com
你好,能详细的说一下吗?
我的情况是这样的,
server 192.168.6.100 和 16.3.4.2 其中16.3.4.2是我使用的ip
client 是 16.3.4.41
我从client调用server上的方法的时候,如果禁用的掉192.168.6.100的话很快,否则要20s
 
你说的第一个方法我试了,不管用,如果是采用第2个方法的话,具体应该怎么设置啊.
是在client机器上的 /etc/host文件中 进行设置 16.3.4.2 hostname??
 
多谢了


 
2009/3/16 Stone Jiang <200...@gmail.com>

Stone Jiang

unread,
Mar 25, 2009, 10:02:45 PM3/25/09
to ace-...@googlegroups.com
下面的论坛在解决描述了解决多网卡首次建立连接时延迟的问题


http://www.tao-studio.net/bbs/viewthread.php?tid=28&extra=page%3D1


2009/3/25 dong cheng <chengd...@gmail.com>

evangel

unread,
Mar 31, 2009, 2:38:52 AM3/31/09
to ace-china
根据高手提示我做了以下测试:S端实现通知服务EC的创建,创建supplier端和consumer_ proxy。以下程序是C端
代码,用于接收通知服务的EC,创建他的consumer端和supplier_proxy。
我使用::GetTickCount()函数输出每行代码执行完成的时间,测试他们所使用的时间,得出结论,主要的耗时有4行,我分别在下面的
代码里做了注释。
第一个耗时的地方(resolve),通过在S端启动时增加命令"-ORBEndpoint"可以解决(例如:
eg_svr -ORBInitRef NameService=iioploc://hostlocal:2809/NameService -
ORBEndpoint iiop:// hostlocal:2810)。剩下的3个耗时比较长地方不知道如何解决,请教下~。
代码如下:
CORBA::ORB_var orb =CORBA::ORB_init (argc, argv,"");
CORBA::Object_var naming_context_object = orb-
>resolve_initial_references("NameService");
CosNaming::NamingContext_var naming_context_var =
CosNaming::NamingContext::_narrow(naming_context_object.in());

CosNaming::Name name(1);
name.length(1);
name[0].id = CORBA::string_dup("EmsSessionFactory");

/***** resolve ****/
CORBA::Object_var factory_object = naming_context_var->resolve(name);
/***** 耗时80s ,-ORBEndpoint 已解决***/

emsSessionFactory::EmsSessionFactory_I_var emsSessionF_var=
emsSessionFactory::EmsSessionFactory_I::_narrow(factory_object.in
());
emsSessionF_var->getEmsSession("user","pass",nmsSession_var.in
(),emsSession_var);
if (!CORBA::is_nil(emsSession_var))
{
emsSession_var->getEventChannel(eventChannel);
}

// notify
CosNotifyChannelAdmin::EventChannel_var ec = eventChannel;

CosNotifyChannelAdmin::AdminID adminid;
CosNotifyChannelAdmin::InterFilterGroupOperator ifgop
=CosNotifyChannelAdmin::AND_OP;

/***** new_for_consumers ****/
CosNotifyChannelAdmin::ConsumerAdmin_var consumer_admin = ec-
>new_for_consumers(ifgop, adminid);
/***** 耗时 40s *****/
CORBA::Object_var poa_object = orb->resolve_initial_references
("RootPOA");
PortableServer::POA_var poa = PortableServer::POA::_narrow
(poa_object.in());

StructuredEventConsumer_i servant(orb.in());
PortableServer::ObjectId_var oid = poa->activate_object(&servant);
CORBA::Object_var consumer_obj = poa->id_to_reference(oid.in());
CosNotifyComm::StructuredPushConsumer_var consumer =
CosNotifyComm::StructuredPushConsumer::_narrow(consumer_obj.in());

CosNotifyChannelAdmin::ProxyID consumeradmin_proxy_id;

/***** obtain_notification_push_supplier ****/
CosNotifyChannelAdmin::ProxySupplier_var proxy_supplier =
consumer_admin->obtain_notification_push_supplier(
CosNotifyChannelAdmin::STRUCTURED_EVENT,
consumeradmin_proxy_id);
/***** 耗时40s *****/

// The proxy that we are connected to.
CosNotifyChannelAdmin::StructuredProxyPushSupplier_var supplier_proxy;

/***** _narrow ****/
supplier_proxy = CosNotifyChannelAdmin::Structure ProxyPushSupplier::
_narrow(proxy_supplier.in());
/***** 耗时40s *****/

supplier_proxy->connect_structured_push_consumer(consumer.in());

// end notify
PortableServer::POAManager_var poa_manager = poa->the_POAManager();
poa_manager->activate();
orb->destroy();


On 3月26日, 上午10时02分, Stone Jiang <2005...@gmail.com> wrote:
> 下面的论坛在解决描述了解决多网卡首次建立连接时延迟的问题
>
> http://www.tao-studio.net/bbs/viewthread.php?tid=28&extra=page%3D1
>

> 2009/3/25 dong cheng <chengdongx...@gmail.com>


>
>
>
> > 你好,能详细的说一下吗?
> > 我的情况是这样的,
> > server 192.168.6.100 和 16.3.4.2 其中16.3.4.2是我使用的ip
> > client 是 16.3.4.41
> > 我从client调用server上的方法的时候,如果禁用的掉192.168.6.100的话很快,否则要20s
>
> > 你说的第一个方法我试了,不管用,如果是采用第2个方法的话,具体应该怎么设置啊.
> > 是在client机器上的 /etc/host文件中 进行设置 16.3.4.2 hostname??
>
> > 多谢了
>

> > 2009/3/16 Stone Jiang <2005...@gmail.com>


>
> > 由于我无法重现你的网络环境,所以这个问题一直没法帮得上你。
>
> >> 官方文档中提供了一些关于连接管理的选项,其中有两个选项与多网卡有关。我转贴如下

> >> -ORBPreferredInterfaces *"targetNetwork:localNetwork,.."*


>
> >> This option allows clients running on a multihomed host to pick a local
> >> network/interface to communicate with a remote target. When TAO attempts to
> >> establish a connection with a host matching targetNetwork, then it will use
> >> the local ip address matching localNetwork. Simple wildcards can be used for
> >> both parameters, and multiple preferred interfaces can be specified using
> >> comma separators. For example, for a machine with two network cards
> >> identified by the ip addresses 192.168.1.10 and 192.168.1.20, you can use
> >> -ORBPreferredInterfaces *=*10,*=*20. Or to force all communication on the
> >> loopback address to try to first use the loopback address, use

> >> -ORBPreferredInterfaces 127.0.0.1=127* . *targetNetwork* can use any
> >> string, and must typically match with the value read from an IOR. *
> >> localNetwork* must use a dotted decimal address, because it will be


> >> matched with the local ip interfaces.
>
> >> -ORBEnforcePreferredInterfaces

> >> *boolean (0|1)*


>
> >> If this option is set to 1(true), then TAO will only try to use the
> >> interfaces specified by the -ORBPreferredInterfaces option. The default
> >> is 0(false), in which case if a connection cannot be made using a
> >> preferred interface, TAO will attempt to use the default interface (
> >> INADDR_ANY). Note: If none of the preferred interfaces apply to an
> >> outgoing connection then they will not be enforced. For this option to have
> >> any effect, therefore, the connection through a legal preferred interface
> >> must fail.
>
> >> 但上述方法你是否已经测试过?有人说这个选项无效。 你可以试试。
> >> 我的确遇到过在装有虚拟机的环境下第一次建立连接很慢的问题,当禁用一块不用的网卡则速度飞快。
> >> 如果不禁用不用的网卡,我是在

> >> /etc/host文件中(windows在system32/drivers/host)中,增加了参与通讯的机器的ip和名字对应的条目,这样也能解决上述-问题。


> >> 这个方法似乎你有人也说无效,你可以试试看。
>
> >> 2009/3/16 techabc <tech...@gmail.com>
>

> >> 遇到这个问题的弟兄们越来越多,这个问题应该比较普遍,各位对tao比较熟悉的朋友们应该有解决办法吧,请大家都来谈谈经验吧
>
> >>> 2009/3/12 sapy <chengdongx...@gmail.com>
>
> >>> 我也遇到了,当server是2个ip是要消耗20s,禁用一个ip后,速度马上就快了
> >>>> 恳请高手给个解决方案啊,
> >>>> 油箱chengdongx...@gmail.com


>
> >>>> On 1月19日, 下午5时41分, cherokee <tech...@gmail.com> wrote:
>

> >>>> client连接server,调用server上的对象并执行方法,发现当server计算机配置了多个ip地址时,会使得执行时间长达数十秒,这是什么原因--,如何避免呢?- 隐藏被引用文字 -
>
> - 显示引用的文字 -

evangel

unread,
Apr 1, 2009, 10:44:16 PM4/1/09
to ace-china
原来"-ORBEndpoint"是在启动通知服务时配置,延迟基本解决。。。。谢谢大家~~~

> > >> /etc/host文件中(windows在system32/drivers/host)中,增加了参与通讯的机器的ip和名字对应的条目,这样也能解决上述--问题。


> > >> 这个方法似乎你有人也说无效,你可以试试看。
>
> > >> 2009/3/16 techabc <tech...@gmail.com>
>
> > >> 遇到这个问题的弟兄们越来越多,这个问题应该比较普遍,各位对tao比较熟悉的朋友们应该有解决办法吧,请大家都来谈谈经验吧
>
> > >>> 2009/3/12 sapy <chengdongx...@gmail.com>
>
> > >>> 我也遇到了,当server是2个ip是要消耗20s,禁用一个ip后,速度马上就快了
> > >>>> 恳请高手给个解决方案啊,
> > >>>> 油箱chengdongx...@gmail.com
>
> > >>>> On 1月19日, 下午5时41分, cherokee <tech...@gmail.com> wrote:
>

> > >>>> client连接server,调用server上的对象并执行方法,发现当server计算机配置了多个ip地址时,会使得执行时间长达数十秒,这是什么原因---,如何避免呢?- 隐藏被引用文字 -
>
> > - 显示引用的文字 -- 隐藏被引用文字 -
>
> - 显示引用的文字 -

Reply all
Reply to author
Forward
0 new messages