Skip to content

Commit

Permalink
[JENKINS-17363] Ludicrously slow load time [with lazyloading]
Browse files Browse the repository at this point in the history
[JENKINS-19437] Implement load on demand functionality in Cppcheck

- All details from Cppcheck report is stored to build.xml which is wrong. The file quickly grows with many findings and causes performance and memory issues.
- Storing of the details to external file cppcheck_details.xml and their lazy loading implemented to fix the issue. File build.xml now contains only small statitistics neccessary for trend graph and build summary.
- There is no need to store CppcheckReport during the build at all, its content is fully dupplicated in CppcheckSourceContainer. CppcheckStatistics has nearly identical interface so it can be used instead of CppcheckReport most of time.
- Incorrect uses of @SuppressWarnings("unused") removed to solve compiler warnings.
- Cppcheck tool version is stored to build.xml together with CppcheckStatistics now. This fixes a bug in the details page, the information was expected in CppcheckReport but its field is transient so the information was never stored/loaded and displayed.
- Content of tabview/main.jelly moved dirrectly to CppcheckResult/index.jelly, include removed. This was probably only a historical location.
- New developer added to pom.xml.
- Several TODOs unrelated to this commit added to the code, they will be fixed in future.
  • Loading branch information
mixalturek committed Feb 12, 2014
1 parent 9568ebc commit e912256
Show file tree
Hide file tree
Showing 10 changed files with 316 additions and 105 deletions.
5 changes: 5 additions & 0 deletions pom.xml
Expand Up @@ -26,6 +26,11 @@
<name>Gregory Boissinot</name>
<timezone>+1</timezone>
</developer>
<developer>
<id>mixalturek</id>
<name>Michal Turek</name>
<email>mixalturek@users.sf.net</email>
</developer>
</developers>

<scm>
Expand Down
Expand Up @@ -74,33 +74,34 @@ private DataSetBuilder<String, ChartUtil.NumberOnlyBuildLabel> getDataSetBuilder

for (CppcheckBuildAction a = this; a != null; a = a.getPreviousResult()) {
ChartUtil.NumberOnlyBuildLabel label = new ChartUtil.NumberOnlyBuildLabel(a.owner);
CppcheckReport report = a.getResult().getReport();
CppcheckStatistics statistics = a.getResult().getStatistics();
CppcheckConfigGraph configGraph = cppcheckConfig.getConfigGraph();

// error
if (configGraph.isDisplayErrorSeverity())
dsb.add(report.getErrorSeverityList().size(), "Severity 'error'", label);
dsb.add(statistics.getNumberErrorSeverity(), "Severity 'error'", label);

//warning
if (configGraph.isDisplayWarningSeverity())
dsb.add(report.getWarningSeverityList().size(), "Severity 'warning'", label);
dsb.add(statistics.getNumberWarningSeverity(), "Severity 'warning'", label);

//style
if (configGraph.isDisplayStyleSeverity())
dsb.add(report.getStyleSeverityList().size(), "Severity 'style'", label);
dsb.add(statistics.getNumberStyleSeverity(), "Severity 'style'", label);

//performance
if (configGraph.isDisplayPerformanceSeverity())
dsb.add(report.getPerformanceSeverityList().size(), "Severity 'performance'", label);
dsb.add(statistics.getNumberPerformanceSeverity(), "Severity 'performance'", label);

//information
if (configGraph.isDisplayInformationSeverity())
dsb.add(report.getPerformanceSeverityList().size(), "Severity 'information'", label);
dsb.add(statistics.getNumberInformationSeverity(), "Severity 'information'", label);

// TODO: getNumberNoCategorySeverity()

// all errors
if (configGraph.isDisplayAllErrors())
dsb.add(report.getAllErrors().size(), "All errors", label);

dsb.add(statistics.getNumberTotal(), "All errors", label);
}
return dsb;
}
Expand Down
@@ -1,9 +1,11 @@
package org.jenkinsci.plugins.cppcheck;

import com.thalesgroup.hudson.plugins.cppcheck.model.CppcheckWorkspaceFile;

import hudson.Extension;
import hudson.FilePath;
import hudson.Launcher;
import hudson.XmlFile;
import hudson.matrix.MatrixProject;
import hudson.maven.MavenModuleSet;
import hudson.model.*;
Expand All @@ -12,6 +14,7 @@
import hudson.tasks.BuildStepMonitor;
import hudson.tasks.Publisher;
import hudson.tasks.Recorder;

import org.jenkinsci.plugins.cppcheck.config.CppcheckConfig;
import org.jenkinsci.plugins.cppcheck.config.CppcheckConfigGraph;
import org.jenkinsci.plugins.cppcheck.config.CppcheckConfigSeverityEvaluation;
Expand All @@ -28,11 +31,16 @@
* @author Gregory Boissinot
*/
public class CppcheckPublisher extends Recorder {
/**
* XML file with source container data. Lazy loading instead of data in build.xml.
*
* @since 1.15
*/
public static final String XML_FILE_DETAILS = "cppcheck_details.xml";

private CppcheckConfig cppcheckConfig;

@DataBoundConstructor
@SuppressWarnings("unused")
public CppcheckPublisher(String pattern,
boolean ignoreBlankFiles, String threshold,
boolean allowNoReport,
Expand Down Expand Up @@ -80,7 +88,6 @@ public CppcheckPublisher(CppcheckConfig cppcheckConfig) {
this.cppcheckConfig = cppcheckConfig;
}

@SuppressWarnings("unused")
public CppcheckConfig getCppcheckConfig() {
return cppcheckConfig;
}
Expand Down Expand Up @@ -126,7 +133,7 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListen

CppcheckSourceContainer cppcheckSourceContainer = new CppcheckSourceContainer(listener, build.getWorkspace(), build.getModuleRoot(), cppcheckReport.getAllErrors());

CppcheckResult result = new CppcheckResult(cppcheckReport, cppcheckSourceContainer, build);
CppcheckResult result = new CppcheckResult(cppcheckReport.getStatistics(), build);

Result buildResult = new CppcheckBuildResultEvaluator().evaluateBuildResult(
listener, result.getNumberErrorsAccordingConfiguration(cppcheckConfig, false),
Expand All @@ -140,6 +147,9 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListen
CppcheckBuildAction buildAction = new CppcheckBuildAction(build, result, cppcheckConfig);
build.addAction(buildAction);

XmlFile xmlSourceContainer = new XmlFile(new File(build.getRootDir(),
XML_FILE_DETAILS));
xmlSourceContainer.write(cppcheckSourceContainer);

if (build.getWorkspace().isRemote()) {
copyFilesFromSlaveToMaster(build.getRootDir(), launcher.getChannel(), cppcheckSourceContainer.getInternalMap().values());
Expand Down Expand Up @@ -222,11 +232,8 @@ public String getPluginRoot() {
return "/plugin/cppcheck/";
}

@SuppressWarnings("unused")
public CppcheckConfig getConfig() {
return new CppcheckConfig();
}

}

}
21 changes: 12 additions & 9 deletions src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckReport.java
Expand Up @@ -97,49 +97,40 @@ public void setNoCategorySeverityList(List<CppcheckFile> noCategorySeverityList)
}

@Exported
@SuppressWarnings("unused")
public int getNumberTotal() {
return (allErrors == null) ? 0 : allErrors.size();
}

@Exported
@SuppressWarnings("unused")
public int getNumberErrorSeverity() {
return (errorSeverityList == null) ? 0 : errorSeverityList.size();
}

@Exported
@SuppressWarnings("unused")
public int getNumberWarningSeverity() {
return (warningSeverityList == null) ? 0 : warningSeverityList.size();
}

@Exported
@SuppressWarnings("unused")
public int getNumberStyleSeverity() {
return (styleSeverityList == null) ? 0 : styleSeverityList.size();
}

@Exported
@SuppressWarnings("unused")
public int getNumberPerformanceSeverity() {
return (performanceSeverityList == null) ? 0 : performanceSeverityList.size();
}

@Exported
@SuppressWarnings("unused")
public int getNumberInformationSeverity() {
return (informationSeverityList == null) ? 0 : informationSeverityList.size();
}

@Exported
@SuppressWarnings("unused")
public int getNumberNoCategorySeverity() {
return (noCategorySeverityList == null) ? 0 : noCategorySeverityList.size();
}


@SuppressWarnings("unused")
private Object readResolve() {
this.allErrors = new ArrayList<CppcheckFile>();
this.allErrors.addAll(errorSeverityList);
Expand All @@ -150,4 +141,16 @@ private Object readResolve() {
this.allErrors.addAll(noCategorySeverityList);
return this;
}

/**
* Get statistics for this report.
*
* @return the statistics
*/
public CppcheckStatistics getStatistics() {
return new CppcheckStatistics(getNumberErrorSeverity(),
getNumberWarningSeverity(), getNumberStyleSeverity(),
getNumberPerformanceSeverity(), getNumberInformationSeverity(),
getNumberNoCategorySeverity(), versions);
}
}

0 comments on commit e912256

Please sign in to comment.