Key Moments
Mondrian Code Review On The Web
Key Moments
Google's Mondrian system revolutionizes code review by moving it online, improving collaboration and efficiency, but its reliance on Perforce can still cause performance bottlenecks.
Key Insights
Code review is presented as a vital, almost mandatory, part of the software development process, akin to pair programming in principle.
The traditional code review process, especially in open source, relies heavily on email for sending patches (context diffs or unified diffs) and subsequent critique.
Mondrian's web-based system addresses limitations of command-line and email-based reviews, such as issues with remote access (VPNs), out-of-sync comments due to code changes, and workflow management.
Key features of Mondrian include snapshotting every version of code under review, side-by-side diffs with inline comments, and a centralized repository for all review-related messages.
Mondrian integrates with email, automatically sending notifications and allowing replies to be logged back into the system, making it accessible to users who prefer email-based workflows.
Despite its improvements, Mondrian's performance is often bottlenecked by Google's internal Perforce system, which is not inherently scalable or distributed.
The fundamental importance of code review
Guido van Rossum begins by emphasizing that code review is a critical, often voluntary, component of the software development lifecycle, comparable in its principled application to pair programming. The core idea is that two pairs of eyes are better than one, catching more bugs and improving code quality. This process, ideally conducted in a non-threatening environment, fosters dialogue between developers. Beyond bug detection, code review is crucial for enforcing coding standards and style guides, ensuring code uniformity that facilitates readability and maintenance over long periods. It's also a powerful tool for mentorship, allowing senior developers to guide junior developers, imparting knowledge of codebase conventions and invariants, and building trust. Van Rossum posits code review as a strong alternative to pair programming, especially in environments with frequent interruptions.
Traditional code review workflows and their limitations
In open-source settings, code review often involves developers emailing patches (context or unified diffs) to a reviewer. The reviewer critiques the code line-by-line, and the author iteratively refines the changes, resending patches until the reviewer approves. The reviewer typically has the final say on committing the code to the repository. While effective for knowledge transfer and identifying good junior developers, this email-centric approach has significant drawbacks. It struggles with remote access, especially over VPNs, making diff tools difficult to use. Comments made on specific lines can quickly become outdated as the author incorporates changes from multiple reviewers or makes other modifications, leading to confusing email trails that are hard to follow months later. Furthermore, managing review requests within overflowing inboxes can lead to lost messages and the need for constant pinging between author and reviewer, highlighting a lack of workflow management.
Introducing Mondrian: A web-based solution
Neil Noritz's initial suggestion for a web-based code review system sparked the development of Mondrian, designed to overcome the limitations of existing command-line and email-based methods. The primary goal was to create a more accessible and efficient review process, particularly for developers working remotely or at odd hours. Key features planned from the outset included snapshotting every version of code under review to maintain a complete history, providing side-by-side diff views for clearer comparison, and incorporating inline comments directly on code lines. The system was also envisioned as a central repository for all review-related discussions, ensuring that all communication for a specific change list was easily retrievable. Crucially, Mondrian was designed for gradual adoption, with strong email integration to accommodate users who preferred or relied on email communication.
Core features and user interface of Mondrian
Mondrian's user interface is centered around a personal dashboard that displays different categories of code changes: those awaiting the user's review and those submitted by the user awaiting review. Changes that have been submitted but not yet reviewed are marked yellow, turning red if neglected for four weeks. Hovering over usernames can reveal profile pictures, and hovering over change lists provides summary details. The system supports reviewing changes submitted by others or one's own pending changes that are not yet ready for review. A notable feature is the ability to view someone else's dashboard, which can be helpful in customer support scenarios. Mondrian allows for reviewing changes assigned to groups, not just individuals, facilitating team-based review processes. The interface also allows navigation between multiple files within a change list and provides keyboard shortcuts for efficiency.
Advanced review functionalities: Diffs and comments
A significant aspect of Mondrian is its advanced diffing capabilities. Users can view inline diffs or full side-by-side diffs of entire files. The system offers inline comments, allowing reviewers to click on any line of code and submit a review directly associated with that line. These comments are initially saved as drafts and can be published later. The system stores a history of all snapshots taken during the review process, identifiable by MD5 checksums, though sometimes different versions share the same checksum if no changes occurred. Reviewers can compare any two snapshots and utilize options to ignore whitespace differences. When comments are published, they are compiled into an email with hyperlinks, directing the author back to the specific location within Mondrian for response. The system also highlights subtle changes within a line, differentiating between changed text and unchanged surrounding text.
Technical architecture and backend integration
Mondrian is built using Python and Django templates, but notably, it doesn't rely on a traditional relational database. Instead, it utilizes Google's internal Bigtable service for data storage and employs a Python-based multi-threaded web server, leveraging the WSGI standard. The system interacts heavily with Google's Perforce (P4) version control system through a wrapper script that adds custom functionality, including code review support. Perforce is used for managing code changes and metadata, with Mondrian storing snapshots of code and associated metadata. The system also integrates with NFS for accessing workspaces and, when necessary, uses SSH to access local workspaces on user machines, though this is less automated. For users where neither NFS nor SSH is feasible, an option to upload context or unified diffs via email remains available.
Email integration and workflow management
Recognizing that a complete switch to a web interface would be impractical, Mondrian was designed with robust email integration. When a comment is added or updated in Mondrian, an email notification is sent to all involved parties. Replies to these emails are automatically parsed and logged back into Mondrian, preserving the conversation history. This dual approach allows users to interact with the system either through the web interface or via email, catering to different user preferences and workflow needs. The mail server scans incoming emails for change list numbers, associating comments with the correct change list and snapshot in the database. A critical function of the email processing is maintaining reviewers' to-do lists, as Perforce itself does not track what a developer needs to review.
Performance considerations and future development
While Mondrian itself is generally efficient, its performance is often dictated by the underlying Perforce system, which is a known bottleneck due to its limitations in scalability and distribution. Large files or extensive diffing operations can lead to significant delays. Generating the dashboard HTML, which crams a lot of information into a small space with interactive elements, can also be computationally intensive. Despite these challenges, the system handles a large volume of daily logins and weekly users, with most performance issues being attributed to waiting for Perforce. The core web and mail servers, running on a single machine, typically operate below 50% CPU load, demonstrating the efficiency of the application logic itself. All data, including code snapshots and review comments, is stored permanently for auditing and historical purposes, making Mondrian akin to a revision control system for pending changes.
Mentioned in This Episode
●Software & Apps
●Companies
●Concepts
●People Referenced
Common Questions
Code review is a process where one developer writes code and another reviews it to identify potential improvements or bugs. It's crucial for catching errors early, ensuring code quality and uniformity, and facilitating knowledge transfer between developers.
Topics
Mentioned in this video
The version control system used at Google, which Mondrian integrates with and wraps around.
The programming language used for the wrapper around Perforce and for the backend servers (web and mail) of Mondrian.
Secure Shell, used to remotely log into users' machines for snapshots when NFS is not available, though it's more expensive and slower.
The web-based code review tool developed by Guido van Rossum as a starter project at Google.
Network File System, used at Google to access user workspaces for snapshots, but not usable if workspaces are on local disks.
Google's internal backend for data storage, used by Mondrian to store user profile data and other information.
The web framework used to build Mondrian, specifically its templating engine, though not its relational database features.
A web server mentioned as a potential alternative that WSGI could work with.
A source control system commonly used in the Python world and mentioned in relation to open-source code review.
A text editor mentioned as an example of an application with extensive user configurability that can make reproducing problems difficult.
A web server mentioned as an example of something WSGI can work with, and which Mondrian does not use.
More from GoogleTalksArchive
View all 88 summaries
58 minEverything is Miscellaneous
54 minStatistical Aspects of Data Mining (Stats 202) Day 7
45 minKey Phrase Indexing With Controlled Vocabularies
63 minMysteries of the Human Genome
Ask anything from this episode.
Save it, chat with it, and connect it to Claude or ChatGPT. Get cited answers from the actual content — and build your own knowledge base of every podcast and video you care about.
Get Started Free