Factory.ai

Open-Source Wikis

/

Swift

/

By the numbers

apple/swift

By the numbers

Data collected on 2026-04-30 from apple/swift main at commit 8123d28cd2.

Size

The compiler and runtime are predominantly C++ and Swift. The standard library and the test suite are overwhelmingly Swift, while the toolchain core is C++ with sizable Python tooling.

xychart-beta horizontal
    title "Lines of code by language"
    x-axis ["C++", "C/C++ headers", "Swift (stdlib + tests)", "SIL test fixtures", "Python (build/test)"]
    y-axis "Lines (thousands)" 0 --> 1300
    bar [1186, 543, 72, 338, 46]
Metric Count
Tracked files 30,923
.cpp files 1,373 (~1.19M lines)
.h files 2,565 (~543K lines)
.swift files 22,031 (~72K lines, dwarfed by tests in raw count)
.sil test fixtures 1,303 (~338K lines)
.py files 263 (~46K lines)
.gyb templates 282
Markdown / RST docs 336 + 58
Tests under test/ ~16,489 files
Tests under validation-test/ ~5,600 files
Benchmarks 263 files in benchmark/

The single largest source files are interesting -- they hint at where the compiler's complexity is concentrated:

File Lines
stdlib/public/stubs/Unicode/Common/ScalarPropsData.h (generated) 26,335
stdlib/public/stubs/Unicode/Apple/ScalarPropsData.h (generated) 26,305
lib/Sema/CSSimplify.cpp 16,668
lib/AST/Decl.cpp 13,602
include/swift/SIL/SILInstruction.h 12,423
lib/ClangImporter/ImportDecl.cpp 11,222
lib/Parse/ParseDecl.cpp 10,976
include/swift/AST/Decl.h 10,399
lib/Sema/CSApply.cpp 9,895
lib/Sema/CSDiagnostics.cpp 9,800

Sema (lib/Sema/) dominates because the constraint-based type checker handles overload resolution, generics, conversions, and diagnostics in one place. AST also shows up because Decl.cpp and Decl.h host the bulk of declaration-node logic.

Activity

The repo has been continuously active since 2010-07-17 and has crossed 199,000 commits. It averages well over 10,000 commits per year:

Year Commits
2014 10,286
2016 14,989
2018 18,998
2020 15,696
2022 15,865
2024 17,774
2025 15,339

In the last 90 days, 2,780 commits landed.

Hotspots (last 12 months)

The 12 directories with the most file-modifying commits in the past year:

Directory Commits
include/swift/ 3,233
lib/Sema/ 2,322
stdlib/public/ 2,013
test/Interop/ 1,690
lib/AST/ 1,410
test/SILOptimizer/ 1,103
test/Concurrency/ 1,081
SwiftCompilerSources/Sources/ 959
lib/SILOptimizer/ 925
lib/ClangImporter/ 775
lib/IRGen/ 731
lib/SILGen/ 599

Sema, AST, and the SIL optimizer dominate -- Swift's type system and SIL pipeline are still evolving features (concurrency model, ownership, regex, embedded). Heavy test/Interop/ activity reflects the ongoing C++ interop and typed-throws work. The growing SwiftCompilerSources/Sources/ count tracks the ongoing port of optimizer passes from C++ to Swift.

Bot-attributed commits

Searching the Co-authored-by: trailer for the substring [bot] returns 0 commits in the entire history. The Swift project does not currently use commit-co-authoring bots; CI (@swift_ci) operates by commenting on PRs rather than pushing co-authored commits. AI-assisted work (via Copilot or similar inline tools) is invisible to git history; this number is therefore a firm 0 lower bound but not an upper bound.

Complexity

The compiler is a "fat" codebase: a few directories contribute the bulk of the lines. C++ implementation lives in lib/ (1,413 files), declarations in include/swift/ (991 files), the standard library in stdlib/ (1,091 files), and the test suite in test/ (16,489 files).

Three numbers worth remembering:

  • The test/ directory has more files (16,489) than the rest of the repository's source-bearing directories combined.
  • lib/SILOptimizer/ (288 files) is now the single largest lib/ subdirectory, narrowly ahead of lib/IRGen/ (172) and lib/AST/ (172).
  • The SwiftCompilerSources/ directory has 185 source files spread across AST, Basic, SIL, and Optimizer -- a relatively new component but already substantial.

TODO inventory

Across lib/, include/, and stdlib/ there are roughly 1,041 files containing a TODO, FIXME, HACK, or XXX comment. That's a long tail of bookmarked-but-not-yet-fixed work consistent with a 15+ year-old compiler. See Lore for selected long-running TODOs.

Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.

By the numbers – Swift wiki | Factory