Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix concurrency issues in Performance Stats code #4910

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
import org.exist.xmldb.ShutdownListener;
import org.exist.xmldb.XmldbURI;
import org.exist.xquery.PerformanceStats;
import org.exist.xquery.PerformanceStatsService;
import org.exist.xquery.XQuery;

import java.io.IOException;
Expand Down Expand Up @@ -184,6 +185,7 @@ private enum Event {
.build()
);


public String getStatus() {
return status.getCurrentState().name();
}
Expand Down Expand Up @@ -473,7 +475,7 @@ private void _initialize() throws EXistException, DatabaseConfigurationException
this.cacheManager = servicesManager.register(new DefaultCacheManager(this));
this.xQueryPool = servicesManager.register(new XQueryPool());
this.processMonitor = servicesManager.register(new ProcessMonitor());
this.xqueryStats = servicesManager.register(new PerformanceStats(this));
this.xqueryStats = servicesManager.register(new PerformanceStatsService());
final XMLReaderObjectFactory xmlReaderObjectFactory = servicesManager.register(new XMLReaderObjectFactory());
this.xmlReaderPool = servicesManager.register(new XMLReaderPool(xmlReaderObjectFactory, maxBrokers, 0));
final int bufferSize = Optional.of(conf.getInteger(PROPERTY_COLLECTION_CACHE_SIZE))
Expand Down
29 changes: 14 additions & 15 deletions exist-core/src/main/java/org/exist/xquery/GeneralComparison.java
Original file line number Diff line number Diff line change
Expand Up @@ -227,14 +227,14 @@ public void visitCastExpr( CastExpression expression )
axis = firstStep.getAxis();

if( ( axis == Constants.SELF_AXIS ) && ( steps.size() > 1 ) ) {
if (steps.get(1) != null) {
axis = steps.get( 1 ).getAxis();
} else {
contextQName = null;
contextStep = null;
axis = Constants.UNKNOWN_AXIS;
optimizeChild = false;
}
if (steps.get(1) != null) {
axis = steps.get( 1 ).getAxis();
} else {
contextQName = null;
contextStep = null;
axis = Constants.UNKNOWN_AXIS;
optimizeChild = false;
}
}
optimizeChild = ( steps.size() == 1 ) && ( ( axis == Constants.CHILD_AXIS ) || ( axis == Constants.ATTRIBUTE_AXIS ) );
}
Expand Down Expand Up @@ -327,8 +327,7 @@ public NodeSet preSelect( Sequence contextSequence, boolean useContext ) throws

// if the right hand sequence has more than one item, we need to merge them
// into preselectResult
if (rightSeq.getItemCount() > 1)
{preselectResult = new NewArrayNodeSet();}
if (rightSeq.getItemCount() > 1) {preselectResult = new NewArrayNodeSet();}
dizzzz marked this conversation as resolved.
Show resolved Hide resolved

// Iterate through each item in the right-hand sequence
for( final SequenceIterator itRightSeq = Atomize.atomize(rightSeq).iterate(); itRightSeq.hasNext(); ) {
Expand Down Expand Up @@ -399,13 +398,13 @@ else if( key.getType() != indexType ) {
if( preselectResult == null ) {
preselectResult = temp;
} else {
preselectResult.addAll(temp);
preselectResult.addAll(temp);
}
}
}

if( context.getProfiler().traceFunctions() ) {
context.getProfiler().traceIndexUsage( context, PerformanceStats.RANGE_IDX_TYPE, this, PerformanceStats.OPTIMIZED_INDEX, System.currentTimeMillis() - start );
context.getProfiler().traceIndexUsage( context, PerformanceStats.RANGE_IDX_TYPE, this, PerformanceStats.IndexOptimizationLevel.OPTIMIZED, System.currentTimeMillis() - start );
}

return( ( preselectResult == null ) ? NodeSet.EMPTY_SET : preselectResult );
Expand Down Expand Up @@ -583,7 +582,7 @@ protected Sequence genericCompare( Sequence ls, Sequence contextSequence, Item c
}

if( context.getProfiler().traceFunctions() ) {
context.getProfiler().traceIndexUsage( context, PerformanceStats.RANGE_IDX_TYPE, this, PerformanceStats.NO_INDEX, System.currentTimeMillis() - start );
context.getProfiler().traceIndexUsage( context, PerformanceStats.RANGE_IDX_TYPE, this, PerformanceStats.IndexOptimizationLevel.NONE, System.currentTimeMillis() - start );
}
return( result );
}
Expand Down Expand Up @@ -652,7 +651,7 @@ protected Sequence nodeSetCompare( NodeSet nodes, Sequence contextSequence ) thr
}

if( context.getProfiler().traceFunctions() ) {
context.getProfiler().traceIndexUsage( context, PerformanceStats.RANGE_IDX_TYPE, this, PerformanceStats.NO_INDEX, System.currentTimeMillis() - start );
context.getProfiler().traceIndexUsage( context, PerformanceStats.RANGE_IDX_TYPE, this, PerformanceStats.IndexOptimizationLevel.NONE, System.currentTimeMillis() - start );
}
return( result );
}
Expand Down Expand Up @@ -905,7 +904,7 @@ else if( key.getType() != indexType ) {
}

if( context.getProfiler().traceFunctions() ) {
context.getProfiler().traceIndexUsage( context, PerformanceStats.RANGE_IDX_TYPE, this, PerformanceStats.BASIC_INDEX, System.currentTimeMillis() - start );
context.getProfiler().traceIndexUsage( context, PerformanceStats.RANGE_IDX_TYPE, this, PerformanceStats.IndexOptimizationLevel.BASIC, System.currentTimeMillis() - start );
}
return( result );
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1270,7 +1270,7 @@ private abstract class AbstractFilterBase implements StreamFilter {
this.contextId = contextId;
this.limit = limit;
if (limit > -1 && context.getProfiler().traceFunctions()) {
context.getProfiler().traceOptimization(context, PerformanceStats.OptimizationType.PositionalPredicate,
context.getProfiler().traceOptimization(context, PerformanceStats.OptimizationType.POSITIONAL_PREDICATE,
LocationStep.this);
}
}
Expand Down
Loading
Loading