[
https://issues.redhat.com/browse/WFLY-14372?page=com.atlassian.jira.plugi...
]
Jason Lee commented on WFLY-14372:
----------------------------------
I talked to Jeff about this this morning. He's pretty confident we're not
collecting the same metrics twice. With the caveat that I'm still learning this part
of the system, I think I agree. The root resources are different, so, if I understand the
code correctly, there's no overlap.
He and I do agree that the call to hasChildren() is likely superfluous. Looking at that
implementation, we see this:
{code:java}
@Override
public boolean hasChildren(final String childType) {
if (BatchJobExecutionResourceDefinition.EXECUTION.equals(childType)) {
return
!getChildrenNames(BatchJobExecutionResourceDefinition.EXECUTION).isEmpty();
}
return delegate.hasChildren(childType);
}
{code}
Chasing that down the code path, the system does iterate over the list of jobs:
{code:java}
final List<JobExecution> executions = new ArrayList<>();
// Casting to (Supplier<List<JobInstance>>) is done here on purpose as a
workaround for a bug in 1.8.0_45
final List<JobInstance> instances =
jobOperator.allowMissingJob((Supplier<List<JobInstance>>)() ->
jobOperator.getJobInstances(jobName, 0, Integer.MAX_VALUE)
, Collections.emptyList());
for (JobInstance instance : instances) {
executions.addAll(jobOperator.getJobExecutions(instance));
}
children.clear();
for (JobExecution execution : executions) {
final String name = Long.toString(execution.getExecutionId());
children.add(name);
}
{code}
For this particular use case, hasChildren() does seem extremely expensive. It seems to me
that if we remove the call to hasChildren(), we can eliminate at least one iteration over
the children. How much of an improvement that might represent for the user is hard to say
without a reproducer, but it seems like it would certainly be noticeable.
Multiple metrics collections
----------------------------
Key: WFLY-14372
URL:
https://issues.redhat.com/browse/WFLY-14372
Project: WildFly
Issue Type: Task
Components: MP Metrics
Reporter: Brian Stansberry
Assignee: Jason Lee
Priority: Critical
See discussion on
https://github.com/wildfly/wildfly/pull/13871
Do we have MetricsCollector collecting the container metrics multiple times?
I haven't thought hard about this, but doesn't the Stage.VERIFY collection in
MetricsSubsystemAdd end up re-collecting all the deployment=* subtree metrics already
collected in Stage.RUNTIME via DeploymentMetricProcessor/DeploymentMetricService? It walks
the whole resource tree from the root.
If the MP Metrics subsystem is installed, isn't MicroProfileMetricsSubsystemAdd and
that subsystem's DeploymentMetricProcessor/DeploymentMetricService also collecting the
same set of metrics?
I'm filing this as a Task because maybe all that's needed is to investigate and
answer those questions reporting that all is well. But if all isn't well this should
converted to a Bug.
Also, as discussed on PR #13871,
https://github.com/wildfly/wildfly/blob/22.0.0.Final/metrics/src/main/jav...
is probably not the best idiom given the code is iterating over runtime-only resources,
where the cost of hasChildren can be high.
--
This message was sent by Atlassian Jira
(v8.13.1#813001)