🐦 Pidgeon: The PID Controller
Delivering Rock-Solid Performance Since 2024 - No War Zone Required
What is Pidgeon?
Pidgeon is a high-performance, thread-safe PID controller library written in Rust. Unlike actual pigeons that poop on your freshly washed car, this Pidgeon delivers precisely controlled outputs without any messy side effects.
The name pays homage to history's most battle-tested messengers. In both World Wars, carrier pigeons maintained 98% delivery rates while flying through artillery barrages, poison gas, and enemy lines. Cher Ami, a famous war pidgeon, delivered a critical message despite losing a leg, an eye, and being shot through the chest. Like these feathered veterans, our PID controller is engineered to perform reliably when everything else fails. It might not win the Croix de Guerre like Cher Ami did, but it'll survive your chaotic production environment with the same unflappable determination.
Why Pidgeon?
Because while Google has advanced AI systems that can recognize cats in YouTube videos, sometimes you just need a reliable PID controller that doesn't require a PhD in machine learning or a fleet of TPUs to operate.
Features
- Thread-safe: Unlike that "concurrent" Java code you wrote during your internship, Pidgeon won't race your conditions.
- Use case agnostic: From temperature control to flight stabilization to maintaining optimal coffee-to-code ratios, Pidgeon doesn't judge your control theory applications.
- Written in Rust: Memory safety without garbage collection, because who needs garbage when you've got ownership?
- Minimal dependencies: Doesn't pull in half of npm or require weekly security patches.
Quick Start
use ;
use thread;
use Duration;
For thread-safe operation in a real HVAC system with multiple sensors:
use ;
use Arc;
use thread;
use Duration;
// Mock functions for the example
FAQ
Q: Is this better than the PID controller I wrote in my CS controls class?
A: Yes, unless you're that one person who actually understood eigenvalues.
Q: Can I use this in production?
A: You could, but maybe don't control nuclear reactors with it just yet.
Q: Why is it called Pidgeon?
A: Because "CarrierPidgeon" was too long, and like the bird, this library delivers... but with better spelling.
License
Pidgeon is licensed under either of:
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Performance Benchmarks
Pidgeon is designed for high-performance control applications. Below are benchmark results showing how the library performs in different scenarios:
| Benchmark | Time (ns) | Operations/sec | Description |
|---|---|---|---|
pid_compute |
394.23 ns | 2,536,590/s | Single-threaded PID controller processing 100 consecutive updates |
thread_safe_pid_compute |
673.21 ns | 1,485,420/s | Thread-safe PID controller without concurrent access |
multi_threaded_pid |
26,144 ns | 38,250/s | Concurrent access with one thread updating and another reading |
What Each Benchmark Measures
-
pid_compute:
- Tests the raw performance of the non-thread-safe
PidController - Represents the absolute fastest performance possible
- Ideal for single-threaded applications or embedded systems with limited resources
- Tests the raw performance of the non-thread-safe
-
thread_safe_pid_compute:
- Measures the overhead introduced by the thread-safe wrapper
- Uses the
ThreadSafePidControllerbut without actual concurrent access - Approximately 70% slower than the non-thread-safe version due to mutex overhead
- Provides a good balance of safety and performance for most applications
-
multi_threaded_pid:
- Simulates a real-world scenario with concurrent access
- One thread continuously updates the controller with new errors
- Another thread reads the control signal in parallel
- Demonstrates thread contention effects in a realistic use case
These benchmarks show that while thread-safety introduces some overhead, Pidgeon remains highly efficient for real-time control applications. A single controller can comfortably handle update rates of 1 MHz in single-threaded mode or 30-40 kHz in a heavily multi-threaded environment.
Running Benchmarks
To run these benchmarks yourself: