8000
Skip to content

hohn/codeql-for-firefox

Repository files navigation

Overview

This repo hosts a large-scale CodeQL demo database for **Firefox**. Purpose: to demonstrate realistic CodeQL performance and scaling. Smaller demo repos understate costs and mislead about practical usage.

This is work in progress.

Download Artifacts

Base URL: https://github.com/hohn/codeql-for-firefox/releases

FilenameSizeDescriptionURL
firefox-db-bm-none.tar.zst1.66 GBFull CodeQL DB (build-mode=none)link
firefox-db-cpp-scan-bm-none.formatted.sarif.zst72.1 MBSARIF results, C++ scan (bm=none)link
firefox-db-cpp-scan.formatted.sarif.zst986 KBSARIF results, C++ scan (with bm)link
firefox-db.tar.zst756 MBFull CodeQL DB (trace build mode)link

The **bm** abbreviation is for build mode. In particular:

  • bm=none → extraction only, no actual build
  • plain → traced build

Building a CodeQL DB for Firefox (Linux, build-mode=trace-command)

cd ~/large-local-only/firefox/firefox
./mach clobber
export PATH=/home/hohn/large-local-only/codeql:$PATH
source /home/hohn/.cargo/env

codeql database init \
  --language=cpp \
  --source-root=. \
  firefox-db

./mach configure

# Run under tracing (OOM at -j20, succeeded with -j10)
codeql database trace-command firefox-db -- ./mach build -j10

codeql database finalize firefox-db

**Timings**

  • Plain Firefox build: ~10 minutes
  • Build with CodeQL trace: ~57 minutes
  • Finalize: ~50 minutes

Build Stats (firefox-db)

PhaseDirectorySizeNotes
During finalizetrap/16.5GTRAP facts
db-cpp/7.0GRelational store
log/2.8GBuild + extractor logs
src/561MSource snapshot
After finalizedb-cpp/2.5GRelational store
log/2.9GLogs
diagnostic/32KScratch
Final DB sizefirefox-db/5.5GUsable DB
Distribution filetar.zst757MCompressed archive

Note: numbers differ between “interim DB size” (~27 GB) and “final size” (5.5 GB).

Building a DB with build-mode=none

cd ~/large-local-only/firefox/firefox
./mach clobber
rm -rf obj-x86_64-pc-linux-gnu/ firefox-db*
export PATH=/home/hohn/large-local-only/codeql:$PATH
source /home/hohn/.cargo/env

./mach configure

codeql database create \
       --language=cpp \
       --source-root=. \
       --threads 20 \
       --ram=50000 \
       --build-mode=none \
       firefox-db-bm-none

tar --use-compress-program="zstd -19 -T0" -cvf \
    firefox-db-bm-none.tar.zst firefox-db-bm-none

**Results**

  • Extraction time: ~17 minutes (init → finalize)
  • TRAP import: 11m14s
  • Final DB size: ~2–3 GB relational store + 137 MB source archive
  • Compressed archive: 1.66 GB

Query Suite Selection

Available suites (CodeQL 1.4.6 cpp-queries):

SuiteQueries
cpp-code-scanning.qls60
cpp-lgtm.qls108
cpp-lgtm-full.qls178
cpp-security-and-quality.qls181
cpp-security-experimental.qls134
cpp-security-extended.qls97

Benchmarks (firefox-db, trace build)

  • DB: firefox-db
  • Suite: cpp-code-scanning (60 queries)
  • Host: Mac Studio (28c / 256 GB RAM, CodeQL 2.22.4)
WalltimeCPU%User CPU (s)Sys CPU (s)Max RSS (GB)Maj PFMin PFInvol CSVol CS
22:161065137754641241247768.2 M48.3 M230647

Notes:

  • ~22 minutes for “short” suite (60 queries)
  • ~10.6 cores saturated
  • Peak RAM: 124 GB, no swap
  • Very high context switch activity

Benchmarks (firefox-db-bm-none)

  • Wall time: 23m41s
  • CPU time: 13 555 s (≈953% CPU utilization, ~9.5 cores avg)
  • Max RAM: 126 GB
  • Page faults: 294 k major, 10 M minor
  • Context switches: 25.9 M invol, 248 k vol
  • SARIF output: 2.9 GB (!), vs 33 MB for build-traced DB

Run Summary

DBSARIF sizeLog size
firefox-db33 MB32 KB
firefox-db-bm-none2.9 GB32 KB

SARIF Output Notes

Using minimize-sarif.py:

  • firefox-db-cpp-scan-bm-none: 4.06 GB → 805 KB, 104 results
  • firefox-db-cpp-scan: 53 MB → 2.1 MB, 732 results

About

instructions and artifacts for analyzing firefox with codeql

Resources

License

Stars

Watchers

Forks

Packages

No packages published
0