Summary
Calculating the source code difference size between the Linux kernel and Android using Git resulted in an unexpectedly small difference of ~15 MiB. This postmortem analyzes the root cause, real-world impact, and solutions to this issue.
Root Cause
The primary issue lies in the incorrect assumption that the calculated difference represents the entire Android kernel compared to the vanilla Linux kernel. The actual cause includes:
- Partial comparison: The script only compares specific commits, not the full history or all files.
- Repository structure: Android’s kernel repository may exclude non-essential files or include only Android-specific changes.
- Script limitations: The
git-file-size-diff.shscript calculates file size changes between two commits, not the total difference in source code.
Why This Happens in Real Systems
- Repository organization: Android’s kernel repository is structured differently from the vanilla Linux kernel, often containing only necessary files.
- Git limitations: Git compares commits, not entire repositories, unless explicitly configured to do so.
- Script assumptions: The script assumes a direct comparison between two commits, ignoring potential missing files or directories.
Real-World Impact
- Misinterpretation: Developers may underestimate the actual differences between Android and Linux kernels.
- Inefficient analysis: Incorrect results lead to wasted time and effort in troubleshooting or decision-making.
- Documentation gaps: Lack of clarity in repository documentation can exacerbate confusion.
Example or Code (if necessary and relevant)
# Incorrect usage of git-file-size-diff.sh
git file-size-diff.sh 5fa4793a2 dda2fd289
How Senior Engineers Fix It
- Full repository comparison: Use tools like
difformeldto compare entire repositories, not just commits. - Repository analysis: Understand the structure and contents of both repositories before comparison.
- Custom scripts: Develop scripts that account for repository differences and missing files.
- Documentation review: Consult official documentation for Android and Linux kernel repositories to identify included files.
Why Juniors Miss It
- Assumption of completeness: Juniors may assume Git repositories are identical in structure and content.
- Lack of repository knowledge: Limited understanding of how Android and Linux kernel repositories are organized.
- Overreliance on scripts: Trusting scripts without verifying their assumptions or limitations.
- Insufficient testing: Failing to validate results against known differences or expected outcomes.