Appearance
Multi-Threaded Execution Guide
Optimize BrowserStack Code Quality performance by configuring multi-threaded execution for faster code analysis.
Overview
Multi-threaded execution significantly reduces analysis time by utilizing multiple CPU cores for parallel processing. Different components support different threading configurations.
Configuration Options
Analyzer Threading
Default: 4 threads
Environment Variable: EMB_ANALYSER_THREADS
bash
# Docker Compose - add to environment section
- EMB_ANALYSER_THREADS=8
# Docker run command
docker run -e EMB_ANALYSER_THREADS=8 [other options]Recommendations:
- Small projects (<1M LOC): 4-6 threads
- Medium projects (1-5M LOC): 6-8 threads
- Large projects (>5M LOC): 8-12 threads
Java Parser Threading
Default: 2 threads
Environment Variable: EMB_PARSER_THREADS
bash
# Docker Compose configuration
- EMB_PARSER_THREADS=4
# For Java-heavy codebases, increase to match CPU cores
- EMB_PARSER_THREADS=8C++ Multi-Threading Setup
Default: Single thread
Configuration: Via scan settings
Method 1: Web Interface
- Go to Projects → Repository List
- Click repository context menu (⋯) → Scan Configuration
- Add
--jobs=4under Additional Options - Save configuration
Method 2: Repository Configuration File
- Download repository configuration file
- Edit the JSON to include:
json
{
"settings": {
"additionalOptions": [
"--jobs=4"
],
"includePaths": []
}
}- Upload the modified configuration
Performance Guidelines
Thread Count Recommendations
| CPU Cores | EMB_ANALYSER_THREADS | EMB_PARSER_THREADS | C++ --jobs |
|---|---|---|---|
| 4 cores | 4 | 2 | 2 |
| 8 cores | 6-8 | 4 | 4 |
| 16 cores | 8-12 | 6-8 | 8 |
Memory Considerations
Higher thread counts require more memory:
- Each analyzer thread: ~1-2 GB RAM
- Each parser thread: ~512 MB - 1 GB RAM
- Monitor memory usage and adjust threads accordingly
Configuration by Analysis Mode
Thread environment variables work in both analysis modes — set them wherever analysis runs.
Server Mode — Docker Compose
yaml
app:
image: "browserstack/code-quality:1.9.36.0"
environment:
- EMB_ANALYSER_THREADS=8
- EMB_PARSER_THREADS=4
- EMB_CHECKER_THREADS=4
- ANALYSER_XMX=-Xmx12gServer Mode — Docker Run
bash
docker run -d \
-e EMB_ANALYSER_THREADS=8 \
-e EMB_PARSER_THREADS=4 \
[other options] \
browserstack/code-quality:1.9.36.0CLI / Remote Analysis Mode
When running the embold-scanner CLI on your machine or a CI/CD agent, export the variables in the shell before the scan:
bash
# Set thread counts for local CLI analysis
export EMB_ANALYSER_THREADS=6
export EMB_PARSER_THREADS=4
./browserstack-codequality-scanner/bin/embold-scanner analyse \
-u https://demo.embold.io \
-t $EMBOLD_TOKEN \
-r {YOUR_REPO_UID} \
-c ./repository-configuration.jsonIn a CI/CD pipeline, declare them as pipeline environment variables:
yaml
# GitHub Actions / GitLab CI
env:
EMB_ANALYSER_THREADS: "6"
EMB_PARSER_THREADS: "4"groovy
// Jenkinsfile
environment {
EMB_ANALYSER_THREADS = '6'
EMB_PARSER_THREADS = '4'
}Match thread count to the number of CPU cores available on the agent/machine running the CLI — do not exceed available cores.
Docker Run Example (legacy)
bash
docker run -d \
-e EMB_ANALYSER_THREADS=8 \
-e EMB_PARSER_THREADS=4 \
-e EMB_CHECKER_THREADS=4 \
-e ANALYSER_XMX=-Xmx12g \
[other options] \
browserstack/code-quality:1.9.36.0Monitoring Performance
Check Thread Usage
bash
# Monitor container CPU usage
docker stats BrowserStackCodeQuality
# Check analysis logs for threading info
docker logs BrowserStackCodeQuality | grep -i threadPerformance Metrics
- Reduced scan time: 30-70% improvement typical
- CPU utilization: Should reach 70-90% during analysis
- Memory usage: Monitor for memory pressure
Best Practices
- Start Conservative: Begin with 4-6 threads and monitor performance
- Match Hardware: Don't exceed available CPU cores
- Monitor Memory: Ensure sufficient RAM for selected thread counts
- Test Incrementally: Increase threads gradually while monitoring
- Language-Specific: C++ benefits most from threading, followed by Java
Troubleshooting
High CPU, Low Performance:
- Reduce thread count if context switching overhead is high
- Check for I/O bottlenecks (use SSD storage)
Out of Memory Errors:
- Reduce thread counts or increase container memory
- See Memory Settings Guide
Inconsistent Performance:
- Ensure consistent thread settings across scans
- Monitor system load during analysis
Related Topics
- Memory Settings Guide - Memory optimization for both Server and CLI modes
- BrowserStack Code Quality CLI - Running remote analysis from the CLI
- CI/CD Integration - Setting thread variables in your pipeline
- Docker Deployment - Full container setup guide
