Count-based exploration works well with tabular reinforcement learning on small discrete MDPs, but it has long been assumed to fail in high-dimensional state spaces, where most states occur only once. This work shows that a simple generalization of the classic approach, which maps states to hash codes and counts those codes, reaches near state-of-the-art performance on high-dimensional and continuous deep RL benchmarks. The method offers a simple baseline for tasks that require substantial exploration.
### Why Count-Based Exploration Was Limited
- Count-based methods come with theoretical guarantees and perform near-optimally in small tabular settings.
- Raw state counts are useless in high-dimensional or continuous spaces, because nearly every state is novel.
- Recent deep RL exploration methods handle this with complex heuristics, often based on optimism under uncertainty or intrinsic motivation.
### Hashing States to Make Counts Useful
- Each state is mapped to a hash code, and occurrences of each code are tracked in a hash table.
- The resulting counts feed a reward bonus derived from classic count-based exploration theory.
- Surprisingly simple hash functions perform well on many challenging tasks.
- A learned, domain-dependent hash code can improve results further.
### What Makes a Good Hash Function
- Granularity matters: the hash must group states at an appropriate level, so that counts are neither too sparse nor too coarse.
- The hash should encode information relevant to solving the MDP, not just superficial state features.
### Results
- The method achieves near state-of-the-art performance on both continuous control tasks and Atari 2600 games.
For practitioners facing hard exploration problems in deep RL, this suggests starting with a simple hashed count bonus as a baseline before adopting more complex heuristics. Its effectiveness depends heavily on choosing a hash that has the right granularity and captures task-relevant features.
Redux Doghouse presents a way to make React/Redux components genuinely reusable by giving each component instance its own scope. The approach addresses collisions in Redux action types, state, and selectors when the same component appears multiple times. Its conclusion is that scoped Redux logic can preserve the benefits of a centralized store while allowing components to behave like isolated, reusable units.
## The Reuse Problem in React and Redux
- Redux state is global by default, while reusable components often need instance-specific state.
- Reusing a connected component can cause:
- Action types from one instance affecting another
- Selectors reading the wrong state
- Reducers sharing or overwriting unrelated data
- Boilerplate for manually generating unique identifiers
- Components therefore become tightly coupled to the shape and location of the application’s Redux store.
## Scoping Redux State
- Redux Doghouse introduces scopes that associate actions, reducers, and selectors with a particular component instance.
- Each instance receives an isolated section of state, even when multiple copies of the same component are rendered.
- Actions are scoped so dispatching an event in one component does not unintentionally update another instance.
- Selectors resolve data within the current scope rather than relying on hard-coded global paths.
## Reusable React Components
- Components can package their Redux behavior alongside their React UI.
- The parent application supplies or creates a scope when mounting the component.
- The same component can then be embedded in different parts of an application without duplicating Redux wiring.
- This approach keeps implementation details—state shape, action handling, and selectors—inside the reusable component.
## Benefits and Trade-offs
- Scoping reduces naming conflicts and makes component behavior easier to reason about.
- It supports modular development by separating local component state from application-wide state.
- Shared global data can still remain in ordinary Redux state where appropriate.
- Developers must manage scope identity and lifecycle carefully, particularly when components are dynamically mounted or removed.
Redux Doghouse is best viewed as an architectural pattern for combining Redux’s centralized data flow with component-level isolation. Teams building reusable or multiply-instantiated React components can use scoped state and behavior to avoid collisions without abandoning Redux.
Redux-Doghouse is a Redux library for creating scoped actions and reducers, allowing reusable React/Redux components to coexist without responding to one another’s actions. It preserves Redux’s ability to coordinate state across an application while ensuring that component-local actions affect only the instance that dispatched them. Datadog developed it to support reusable Query Editors within larger editors such as dashboards and Expression Editors.
## The Problem with Reusable Redux Components
- Redux reducers respond to actions based on their `TYPE`.
- If multiple instances of the same component share a Redux store, an action such as `MY_ACTION` can update every instance.
- This is useful for application-wide events, but incorrect when an action should affect only one component instance.
- Refactoring each component to use unique action types would undermine its reusability and independence.
## Scoped Actions and Reducers
- Redux-Doghouse adds a unique scope to each component instance’s actions.
- Reducers are wrapped so that a scoped action is routed only to the matching component instance.
- A component can therefore continue using generic action types such as `MY_ACTION` while remaining isolated from sibling instances.
- Higher-level components can still observe and respond to those actions, preserving Redux’s cross-component coordination.
- The parent can extend a child component’s behavior without requiring the child to know about its parent.
## Datadog’s Query Editor Use Case
- Datadog’s dashboards contain Query Editor components for editing individual metrics.
- Query Editors were rebuilt as miniature React/Redux applications so they could be reused in:
- Dashboard graph editors
- Monitor editors
- Notebook editors
- Other application contexts
- The Expression Editor needed to render an arbitrary number of Query Editors and combine their queries with expressions such as `a + b / c`.
## Coordinating Child Editors
The Expression Editor needed to:
- Validate that expressions reference existing query labels, rejecting inputs such as `a + d` when query `d` does not exist.
- Enforce compatible `group by` values across queries:
- Queries may share a value such as `host`.
- Some queries may have no grouping.
- Non-empty groupings such as `host` and `device` cannot be mixed.
- Ensure that a `SET_GROUP` action from Query Editor A affects only A, not Query Editor B.
- Allow the Expression Editor itself to observe `SET_GROUP` and enforce rules across all queries.
- Keep Query Editors independent so they remain usable outside an Expression Editor.
## How Doghouse Solves It
- The parent assigns each Query Editor a scope, such as `A`, `B`, or `C`.
- Actions dispatched by each editor receive metadata identifying that scope.
- The parent wraps each editor’s reducers and routes actions only to the reducer with the matching scope.
- The Expression Editor can still listen to the same actions at a higher level and apply cross-editor validation or coordination.
Redux-Doghouse is most useful when reusable Redux components need isolated local behavior while still participating in a shared application state. It lets teams organize actions and reducers by component, rather than forcing all Redux logic to be structured around entire views.
Generative models such as variational autoencoders, GANs, and generative moment matching networks share a decoder network, but their performance is hard to measure because their log-likelihoods are intractable and inspecting samples can be misleading. The post proposes Annealed Importance Sampling (AIS) as a way to estimate log-likelihoods for decoder-based models, and it validates the estimates with bidirectional Monte Carlo. The authors use this technique to assess how well these models perform, how reliable existing estimators are, how much they overfit, and how well they cover the modes of the data distribution.
## Decoder-Based Generative Models
- A decoder is a parametric deep neural network that defines a generative distribution over data.
- The approach covers several families: variational autoencoders, generative adversarial networks, and generative moment matching networks.
- The post treats the decoder as the shared component across these otherwise different models, which is what makes a single evaluation method applicable to all of them.
## The Evaluation Problem
- Log-likelihood is the standard quantitative metric for generative models, but it cannot be computed exactly for decoder-based models.
- Visual inspection of samples is the common fallback, but the post argues it can mislead, since good-looking samples do not show whether the model covers the whole data distribution or merely memorizes parts of it.
## Annealed Importance Sampling for Log-Likelihood Estimation
- AIS is used to estimate the log-likelihood of decoder-based models in place of an intractable exact computation.
- Its accuracy is checked with bidirectional Monte Carlo, which bounds the estimate from both directions to show how close it is to the true value.
- The evaluation code is released publicly so others can reproduce the method.
## What the Analysis Reveals
- The approach measures overall performance of decoder-based models across the families above.
- It tests how effective existing log-likelihood estimators are, not just the models themselves.
- It quantifies the degree of overfitting to the training data.
- It indicates how much of the data distribution these models fail to capture, specifically which important modes they miss.
## Practical Takeaway
If you are comparing decoder-based generative models, relying on sample quality alone is insufficient. Estimating log-likelihood with AIS, and checking the estimate with bidirectional Monte Carlo, gives a more rigorous basis for comparison, including on overfitting and mode coverage.
Generative adversarial networks (GANs), inverse reinforcement learning (IRL), and energy-based models (EBMs) are usually studied separately, but this post argues they are closely linked. The authors show that a sample-based algorithm for maximum entropy IRL is mathematically equivalent to a GAN in which the generator's density can be evaluated and fed to the discriminator. They then argue that GAN training can be understood as training an energy-based model, and they hope making these links explicit will help researchers transfer techniques for stabilizing and scaling these methods.
## Learning Cost Functions in Generative Modeling and Control
- In a GAN, the generator is trained against a cost function that a discriminator learns at the same time.
- Learning cost functions has a longer history in control and reinforcement learning, mainly for imitation learning from demonstrations.
- In those fields, recovering the cost that explains observed behavior is called inverse reinforcement learning or inverse optimal control.
## Equivalence Between Maximum Entropy IRL and GANs
- The authors show that certain IRL methods are not just analogous to GANs but mathematically equivalent to them.
- The specific match is a sample-based algorithm for maximum entropy IRL and a GAN whose discriminator also receives the generator's density as an additional input.
## Connection to Energy-Based Models
- Maximum entropy IRL is a special case of an energy-based model.
- Because of this, GAN training can be interpreted as a way to train energy-based models.
- The paper relates this view to other recent work that connects GANs and EBMs.
## Implications for Stability and Scalability
- Stability and scalability are named as major open challenges in all three areas.
- The authors suggest that ideas can move between the communities once the formal connections are clear, especially methods aimed at more stable and scalable training.
Deep reinforcement learning can learn sophisticated behaviors, but it needs a huge number of trials, while animals learn new tasks in just a few. The paper proposes RL², which closes this gap by learning a fast reinforcement learning algorithm from data rather than designing one by hand. Experiments show it approaches human-designed algorithms with optimality guarantees on small problems and scales to high-dimensional vision-based tasks.
### The Gap Between Deep RL and Animal Learning
- Deep RL learns complex behaviors automatically but requires vast numbers of trials.
- Animals adapt to new tasks in a handful of trials by drawing on prior knowledge about the world.
- The paper aims to transfer this capacity for rapid learning to artificial agents.
### Learning the Algorithm Instead of Designing It
- Rather than hand-designing a "fast" RL algorithm, RL² represents the algorithm itself as a recurrent neural network (RNN).
- The RNN's weights encode the learning algorithm and are trained slowly with a general-purpose RL algorithm.
- The RNN receives the same inputs a typical RL algorithm would: observations, actions, rewards, and termination flags.
- Its hidden state persists across episodes within a given Markov Decision Process (MDP), so its activations hold the state of the fast learner on a new, previously unseen MDP.
### Small-Scale Experiments
- RL² is trained on randomly generated multi-armed bandit problems and finite MDPs.
- On new MDPs, its performance is close to human-designed algorithms that come with optimality guarantees.
### Large-Scale Experiments
- A vision-based navigation task tests whether the approach extends to high-dimensional inputs.
- The results indicate that RL² scales beyond toy problems.
Variational Lossy Autoencoder proposes a way to learn global representations that capture overall structure while discarding irrelevant detail such as texture. The method combines a Variational Autoencoder (VAE) with neural autoregressive models. The architecture is designed so the latent code cannot encode fine-grained information, which makes the VAE a lossy autoencoder. The approach also improves generative performance, reaching state-of-the-art density estimation results on MNIST, OMNIGLOT, and Caltech-101 Silhouettes.
### Learning Global Representations
- Representation learning aims to expose useful aspects of data in a form that supports downstream tasks like classification.
- For 2D images, a good representation describes global structure and ignores detailed texture.
### Controlling the Latent Code with Architecture
- The VAE architecture is designed to control what the global latent code can learn.
- By restricting the latent code, the model is forced to discard irrelevant information such as texture, so the VAE only "autoencodes" the data in a lossy way.
### Autoregressive Priors and Decoders
- Autoregressive models such as RNN, MADE, and PixelRNN/CNN serve as both the prior distribution p(z) and the decoding distribution p(x|z).
- This substantially improves the generative modeling performance of VAEs.
### Benchmark Results
- The model achieves new state-of-the-art results on density estimation for MNIST, OMNIGLOT, and Caltech-101 Silhouettes.
Figma encountered intermittent save-file corruption caused by an elusive C++ memory-safety bug. Conventional debugging tools failed because the web app’s asynchronous behavior made the problem nondeterministic. A keyboard-and-mouse fuzzer eventually produced reproducible failures, while understanding Emscripten’s C++-to-JavaScript memory model helped narrow the investigation.
## Detecting the Corruption
- Invalid save files appeared occasionally and could not be reliably reproduced.
- Figma’s files used ZIP containers around Google FlatBuffers documents.
- The serialized bytes looked mostly valid, but some offsets were unexpectedly zeroed.
- Data being written to the wrong location suggested a memory-safety violation such as:
- Use before initialization
- Use after free
- Out-of-bounds access
## Why C++ Made the Bug Difficult
- C++ was valuable for Figma because it provided:
- Access to libraries such as FreeType, HarfBuzz, and Skia
- Low-level control suitable for graphics software
- Mature debugging and optimization tools
- However, C++ offers no built-in protection against memory errors.
- The team tried avoiding deallocation, enabling malloc diagnostics, fixing Valgrind and Clang Analyzer findings, and upgrading the compiler, but none exposed the corruption.
## Reproducing the Failure with Fuzzing
- The team planned to eliminate nondeterminism by recording user events and replaying them deterministically.
- Building a complete session recorder was too large a project, so they limited inputs to keyboard and mouse events.
- A fuzzer generated random event sequences and ran them against the application.
- After several days, it produced multiple save failures, providing reproducible cases for debugging.
## Emscripten’s Emulated Memory Model
- Figma’s C++ editor ran in the browser through Emscripten, which compiled C++ into JavaScript.
- JavaScript typed arrays and shared `ArrayBuffer` storage allowed Emscripten to emulate contiguous C++ memory.
- In the generated code:
- Pointer loads became typed-array reads.
- Pointer stores became typed-array writes.
- Registers became local variables.
- Shared buffers enabled pointer reinterpretation between types.
- Emscripten generated asm.js-style JavaScript, using type annotations and operations optimized for JavaScript JIT compilers.
The combination of deterministic fuzzing and knowledge of Emscripten’s low-level memory representation provided the path toward isolating the corruption, even though the ultimate fix was reportedly only a three-line change.
The paper extends the Neural GPU, a model that learns algorithms such as multi-digit binary addition and multiplication in a way that generalizes to inputs of arbitrary length. The authors show that two simple changes, a carefully designed training curriculum and a larger model, substantially improve its performance. They also find that the model still fails on certain highly symmetric inputs, and these failures resemble adversarial examples.
## Improving Performance with Curriculum and Model Size
- A carefully designed curriculum and increased model size are the two main levers for better performance.
- Scaling up the model requires a memory-efficient implementation, because a naive Neural GPU is memory-intensive.
## Expanding the Set of Solvable Problems
- The improved model learns all basic arithmetic operations and generalizes to arbitrarily long numbers when inputs use decimal representation, which the authors note had not been achieved before.
- It can also evaluate long arithmetic expressions with multiple operands that must respect operator precedence.
- Expression evaluation succeeds only in binary representation and is not perfectly accurate.
## Failure Modes Resembling Adversarial Examples
- Models that generalize well to long numbers can still fail on atypical, highly symmetric inputs.
- For example, a decimal multiplication model that generalizes to 100-digit numbers can fail on 000…002 × 000…002 while correctly computing 2 × 2.
- These failures suggest that strong average generalization does not guarantee correctness on every input.
Christian’s colleagues built a Datadog dashboard to remotely track his progress in a six-day, 850 km ultramarathon. They scraped live race data from the event website, converted it into Datadog metrics, and visualized his distance, ranking, and elapsed time alongside video and other dashboard elements. At publication, Christian was leading by more than 47 km with 44 hours remaining.
## Extracting Race Data
- The event website regularly published runners’ statistics and race progress in plain HTML.
- A Python crawler using `Requests` retrieved the webpage.
- `BeautifulSoup` parsed the HTML to extract:
- Current ranking
- Total distance run
- Elapsed time
- Other race information
## Sending Metrics to Datadog
- The team used the Datadog Python client and StatsD to emit metrics through the Datadog Agent.
- For each runner, the script sent gauge metrics for:
- `runner.distance`
- `runner.ranking`
- `runner.elapsed_time`
- Metrics were tagged with each runner’s name, enabling individual tracking and comparisons.
## Building the Dashboard
- The collected metrics were combined into a Datadog dashboard.
- The dashboard included:
- Live race statistics
- A live video feed
- Animated GIFs for entertainment
- Visualizations of meaningful progress metrics
- Screens displaying the dashboard were placed in the company’s New York and Paris offices so colleagues could follow and encourage Christian throughout the race.
The project demonstrates how a lightweight web scraper, StatsD metrics, and a monitoring dashboard can turn publicly available data into a live, engaging team experience.
Did you find this article helpful? Further Reading Datadog Platform Datasheet Learn about the key components, capabilities, and features of the Datadog platform. Nadir Kadem Martin Fejoz Benjamin Fernandes One of our colleagues, Christian, is participating in a tremendous 6-day-…
Simulation is often the safer and cheaper place to develop robot control policies, but a policy that works in simulation frequently fails on a physical robot. The overall sequence of states the policy produces in simulation often still makes sense in the real world, even when the exact controls do not. The paper exploits this by keeping the simulated state trajectory and learning a real-world mapping from desired states to actions. In experiments, this approach outperforms baselines built for simulation-to-real model discrepancy, including output error control and Gaussian dynamics adaptation.
## The Simulation-to-Real Gap
- Simulated control policies come from planning, optimization, or reinforcement learning, which often needs far more data than is practical to collect on hardware.
- Mismatches in friction, contact, mass, and geometry cause simulated controls to fail on real robots.
- The high-level path the robot takes through states often remains valid even when the low-level controls do not.
## Inverse Dynamics Approach
- At each time step, the simulated policy proposes an action, and the simulator predicts the resulting next state or states.
- Rather than executing the simulated action, the robot uses a learned deep inverse dynamics model to find the real-world action that is most likely to reach that predicted next state.
- The inverse model maps (current state, desired next state) to an action, so it compensates for the real system's differences from the simulator.
## Data Collection for Learning the Model
- The authors note that a deep model is only as good as its training data, so data collection is central to the method.
- They propose a procedure for collecting real-world data that incrementally refines the inverse dynamics model.
## Experimental Comparison
- The approach is evaluated against output error control and Gaussian dynamics adaptation, two existing methods for handling model discrepancy.
- According to the abstract, the method compares favorably with these baselines.
Figma’s multiplayer editing release made real-time collaboration a core part of its design workflow. The company replaced a simple whole-document save-and-upload model after it caused overwrites, stale links, and confusing collaboration problems. Although multiplayer required major changes to conflict resolution, undo/redo, layout behavior, file formats, and performance, Figma concluded that it ultimately simplified the user experience.
## Why the Original Saving Model Failed
- Early Figma downloaded documents locally, let users edit in the browser, and periodically uploaded the entire document.
- This approach was easy to build and familiar to users of syncing services such as Dropbox.
- In team settings, however:
- Users could unknowingly overwrite one another’s work.
- Shared links could display an outdated version while changes were still saving.
- Version history preserved data, but did not prevent collaboration mistakes.
- Alternatives such as “baton-passing,” where only one person could edit at a time, lacked the simplicity and flexibility Figma wanted.
## How Figma’s Multiplayer Engine Works
- Each user’s changes are sent to the server and broadcast to other participants in real time.
- Independent simultaneous changes can coexist.
- When users modify the same property on the same object, Figma resolves the conflict by selecting the latest change.
- Implementing this model required changing fundamental parts of the editor rather than adding multiplayer as a separate synchronization layer.
## Undo, Redo, and Conflict Resolution
- Undo becomes ambiguous when other users modify the same objects afterward.
- Figma adopted a guiding principle: undoing actions, copying something, and redoing back to the present should leave the document unchanged.
- Redo therefore cannot simply reapply the original edits, since that might overwrite newer work by collaborators.
- Conflict resolution also had to account for:
- Related properties that must be changed together.
- Actions that indirectly affect multiple objects.
- Layout operations where apparently unrelated edits can interact.
- These requirements led Figma to revise aspects of its layout system.
## Performance and File-Format Changes
- Professional-quality multiplayer required extensive measurement and tuning.
- Figma overhauled its file format because the previous representation was inefficient for transmitting small incremental messages.
- The team expected additional challenges as new collaborative features were introduced.
## A Simpler Collaborative Experience
- Multiplayer reduced UX complexity by eliminating workarounds for stale files, overwrites, and coordination.
- Users can see collaborators’ mouse cursors and selections, providing immediate context about who is present and where they are working.
- Cursors can also serve as lightweight communication tools, such as pointing at an object or getting someone’s attention.
- Each participant appears as an avatar in the top-right corner.
- Clicking an avatar lets one user present to another, making presentations opt-in rather than forcing a single presenter and synchronized viewing mode.
Figma’s experience suggests that real-time collaboration is best treated as a foundational part of the editor. Despite the substantial engineering investment, multiplayer editing can make collaborative software both more powerful and easier to use.
# Infrastructure for Deep Learning Research
OpenAI's 2016 post argues that the quality of a research group's infrastructure multiplies its rate of progress in deep learning, which is an empirical science. The authors describe how deep learning work moves from rapid, ad-hoc experiments to long, carefully managed multi-GPU training runs, and explain the stack they built to support both phases. They also open-source kubernetes-ec2-autoscaler, a batch-optimized scaling manager for Kubernetes.
## The Research Workflow
Deep learning research happens in two distinct phases, and the infrastructure has to serve both:
- **Early exploration** is fast and unstructured. Researchers want to SSH into a machine, run a script in `screen`, and see a result within an hour.
- **Scaling up** requires multi-day jobs on many GPUs, careful experiment tracking, and deliberate hyperparameter selection.
- Making a model work often means watching it fail in many ways, so infrastructure must support flexible introspection of models rather than only summary statistics.
## A Worked Example: Improved GAN Training
The post traces how one idea moved from concept to large-scale result. The idea was to give the GAN discriminator a whole minibatch of samples instead of one, so it can detect when the generator collapses to a single output.
- The idea was prototyped on MNIST and CIFAR-10 with small models, producing some of the best CIFAR-10 samples the team had seen.
- Scaling to ImageNet required parallelizing across multiple GPUs, with jobs driving machines to about 90% CPU and GPU utilization and training for many days.
- The authors note that the final results were good but short of expectations, and they have not yet identified the reason.
## Software and Hardware Choices
- **Software:** Mostly Python 2.7 with TensorFlow (occasionally Theano), with Keras used on top in some cases. Anaconda handles difficult packages such as OpenCV.
- **GPUs:** Multi-GPU scaling is usually sublinear, so top-of-the-line GPUs matter. CPU-heavy workloads such as simulators and reinforcement learning environments run separately from GPU workloads.
- **Hybrid cloud:** AWS donated compute for CPU instances and horizontally scaled GPU jobs, while the team also runs physical servers, mainly with Titan X GPUs, to experiment with different hardware.
## Provisioning and Orchestration
- **Provisioning:** Terraform manages AWS resources, Chef configures Ubuntu nodes on both cloud and physical hardware, and Packer pre-bakes cluster AMIs for faster spin-up. Clusters use non-overlapping IP ranges and connect over OpenVPN and strongSwan.
- **Storage:** Home directories, datasets, and results live on NFS for physical hardware and on EFS or S3 in AWS.
- **Scheduling:** Kubernetes schedules jobs across three AWS regions, since bursty demand can exhaust capacity in a single region. Each job runs as a Docker container for dependency isolation and code snapshotting, and tooling ships laptop code into a standard image to avoid slow rebuilds.
- **Networking:** Kubernetes' flannel network is exposed directly to researchers' laptops, so services like TensorBoard are reachable without creating a Kubernetes Service for each port.
## kubernetes-ec2-autoscaler
Research workloads are bursty. One experiment grew from a single Titan X to 60 Titan Xs and then to nearly 1,600 AWS GPUs within weeks. Standard Auto Scaling policies add nodes piecemeal, and scale-in can kill in-flight jobs unless nodes are drained first.
- The autoscaler runs as a normal Pod and requires only that worker nodes belong to Auto Scaling groups.
- It polls the Kubernetes master to compute the cluster's resource demand and capacity, then sizes Auto Scaling groups to match in one step.
- Excess nodes are drained and terminated. Drained nodes can be uncordoned to skip spin-up time when demand returns.
- It handles multiple Auto Scaling groups, resources beyond CPU (memory and GPUs), and constraints such as region and instance size.
- When AWS reports capacity errors, it fails over to a secondary region.
The authors chose to build on Kubernetes rather than raw EC2 because the surrounding tooling for logging, monitoring, and managing physical nodes was worth keeping, and making Kubernetes autoscale was simpler than rebuilding that ecosystem.
Datadog built an office bathroom-availability monitor to reduce contention without compromising privacy or existing door functionality. Raspberry Pi 2 devices, GPIO-connected sensors, and simple Unix tools provided a low-maintenance way to report whether bathrooms were occupied. The project showed that the hardest parts were adapting to varied real-world hardware, mounting sensors cleanly, and dealing with unreliable Wi-Fi—not writing software.
## Project Goals
- Avoid intrusive monitoring:
- No cameras or sensors that could feel invasive.
- Provide reliable occupancy information with minimal false positives and negatives.
- Use door-lock status where possible as the occupancy signal.
- Avoid interfering with existing locks and doors.
- Keep devices secure, professional-looking, easy to maintain, and remotely updateable.
- Treat the project as a fun hardware experiment.
## Adapting to Different Bathrooms
- Bathrooms differed significantly in:
- Lock styles, including push-button handles and rotary stall locks.
- Number of rooms or stalls.
- Availability and location of power outlets.
- Wi-Fi quality, especially near concrete walls and older electrical equipment.
- These variations required different sensor designs rather than one universal installation.
## Raspberry Pi and Sensor Hardware
- Raspberry Pi 2 Model Bs served as the project’s controllers because they:
- Ran Linux.
- Supported Wi-Fi and SSH administration.
- Were compact enough to conceal.
- The team used several sensor types:
- Magnetic reed switches for detecting door position.
- Pin switches for detecting sliding stall-lock positions.
- Photoresistors were purchased as a possible way to detect darkness but were not needed in the MVP.
- For push-button locks, reed switches detected whether the door was open or closed. Although this could theoretically misreport a closed but unoccupied bathroom, it worked reliably in practice.
- Stall-lock sensors were hidden inside hollow metal panels. Automotive-style pin switches were mounted using simple carved wooden blocks that contacted the sliding lock without obstructing it.
- Wiring was concealed in wiremolding, with Raspberry Pis placed inside outlet boxes where possible.
## GPIO and Unix-Based Monitoring
- Raspberry Pi GPIO pins were accessed through files in `/sys/class/gpio/`.
- A Python script read sensor values and translated them into bathroom availability.
- Configuration handled differences between normally open and normally closed sensors.
- The service was exposed through `tcpserver` and managed with `daemontools`.
- A basic command-line client could query status with Netcat, for example:
```sh
nc 11.bathrooms.datadog-internal.com 50
```
## Making Availability Easy to Use
- Employees could check status from the command line.
- Some added bathroom availability to TextBar.
- Datadog dashboards displayed bathroom status throughout the New York office.
- The implementation required very little code; most effort went into sensor selection, physical installation, and network troubleshooting.
The project demonstrates that inexpensive, hackable hardware combined with simple Linux tools can solve a practical office problem. For similar systems, prioritize non-intrusive sensors, flexible installation designs, and secure remote management; the resulting software can remain remarkably small.