This document lists some points that can be improved to increase performances, generally CPU time.

Server Startup

 

StepCPU TimeReasonsSolutions
Registration of quality profiles~37%Bad management of SQL requests
  • Replace Hibernate by MyBatis and use batch insert mode
  • Register profiles once by using the table LOADED_TEMPLATES
Registration of rules~9%Bad management of SQL requestsReplace Hibernate by MyBatis and use batch insert mode
Initialization of Hibernate~8%For information MyBatis initialization is ~3%.Drop Hibernate
Registration of metrics~3%Bad management of SQL requestsReplace Hibernate by MyBatis and use batch insert mode
Initialization of JRuby on Rails~23%Heavily framework initialization, including ActiveRecord loading of tables metadata
  • (error) Replacing JIT compilation by AOT did not help
  • Use Java 7 invokedynamic. Upgrading to latest version of JRuby is recommended, but it requires to stop the support of Servlet 2.4 (Tomcat 5.5)

Build

 ReasonsSolutions
Unit tests : Hibernate initialization To be killed
Unit tests : Database startupDerby seems to be slow to be started

Replace Derby by H2. David estimation : performances x 2.
https://jira.codehaus.org/browse/SONAR-3507

Unit tests : sequential execution of testsSome modules execute tests in parallel, but's currently not possible on the modules that start an in-memory databaseTBD
Compilation : GWT 
  • Use -Pdev to reduce number of GWT permutations
  • Replace GWT by Ruby on Rails

Code Inspection

 ReasonsSolutions
PMD is slow Parallel execution of file analysis, if PMD is thread-safe

Integration Tests

Note that integration tests are close-source and use a SonarSource internal framework to interact with Sonar components.

 ReasonsSolutions
Download, unzip, build war and deploy to cargoRequires many filesystem I/O but not network I/O because of local cache of zip filesTo be defined. Publishing a standalone and runnable WAR is a good candidate.
Server startupSee above 
Server shutdownTimeout to guarantee that queue of notifications is empty

See https://jira.codehaus.org/browse/SONAR-3509

Initialization of Selenium RCIs the Selenium proxy long to be started ? To be verifiedTest suites could use the same Selenium RC proxy
http://jira.sonarsource.com/browse/ORCH-91
Too many server startupsEach Java file uses at least one serverGroup unit tests by reusing shared servers. BUT this is a problem only if server startup is long.
Project inspections are long 
  • Use the Sonar Runner instead of Maven to launch inspections
  • Do not build sources when possible, by storing bytecode in SCM
  • Do not execute rule engines when not needed -> should be the default behavior
Each junit test is longDue to test requirements (server, code inspection, selenium rc)Use parallel tests
Many tests to executeBecause we love testsExecute only the tests that relate to changed code

UI

 Solutions
Many HTTP requests to get imagesUse CSS sprites