mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Pre-compute the node topics for all pool entries.
A zeek script profile showed a small percentage of time spent in Cluster::node_topic, but this never changes and can be cached.
This commit is contained in:
parent
9e19b51f41
commit
10438408a5
1 changed files with 5 additions and 3 deletions
|
@ -18,6 +18,8 @@ export {
|
||||||
site_id: count;
|
site_id: count;
|
||||||
## Whether the node is currently alive and can receive work.
|
## Whether the node is currently alive and can receive work.
|
||||||
alive: bool &default=F;
|
alive: bool &default=F;
|
||||||
|
## The pre-computed result from Cluster::node_topic
|
||||||
|
topic: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
## A pool specification.
|
## A pool specification.
|
||||||
|
@ -172,7 +174,7 @@ function hrw_topic(pool: Pool, key: any): string
|
||||||
|
|
||||||
local site = HashHRW::get_site(pool$hrw_pool, key);
|
local site = HashHRW::get_site(pool$hrw_pool, key);
|
||||||
local pn: PoolNode = site$user_data;
|
local pn: PoolNode = site$user_data;
|
||||||
return Cluster::node_topic(pn$name);
|
return pn$topic;
|
||||||
}
|
}
|
||||||
|
|
||||||
function rr_topic(pool: Pool, key: string): string
|
function rr_topic(pool: Pool, key: string): string
|
||||||
|
@ -198,7 +200,7 @@ function rr_topic(pool: Pool, key: string): string
|
||||||
|
|
||||||
if ( pn$alive )
|
if ( pn$alive )
|
||||||
{
|
{
|
||||||
rval = Cluster::node_topic(pn$name);
|
rval = pn$topic;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,7 +278,7 @@ function init_pool_node(pool: Pool, name: string): bool
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
local pn = PoolNode($name=name, $alias=alias, $site_id=site_id,
|
local pn = PoolNode($name=name, $alias=alias, $site_id=site_id,
|
||||||
$alive=Cluster::node == name);
|
$alive=Cluster::node == name, $topic=Cluster::node_topic(name));
|
||||||
pool$nodes[name] = pn;
|
pool$nodes[name] = pn;
|
||||||
pool$node_list += pn;
|
pool$node_list += pn;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue