Vibe.d Under the Microscope: What 67 Remote AST Tools Found Inside the D Asynchronous Web Framework
Analysis of the D asynchronous web framework with prod-code: 30,151 lines across 108 files, a two-node dependency extraction with no edges, compile-time REST interface generation, and repository-wide assertion matching lines.
On this page · 4 sections
First published on 2026-10-04. The measurements reported in this article are historical and have not been re-run for this revision.
Before the async/await paradigm became ubiquitous across modern language runtimes, asynchronous server architectures struggled with “callback hell” or heavy thread pool overhead. Vibe.d solved this in the D ecosystem by coupling an event-driven I/O loop (epoll, kqueue, libevent) with lightweight cooperative fibers (coroutines).
In Vibe.d, network code reads like straightforward synchronous procedural code, yet any blocking socket read or write automatically yields the calling fiber back to the event loop, achieving tens of thousands of concurrent connections on a single OS thread. Moreover, Vibe.d leveraged D’s compile-time metaprogramming to introduce declarative REST interfaces, where ordinary D interface types automatically generate both HTTP server endpoints and strongly typed client proxies without runtime reflection.
To inspect how Vibe.d organizes its fiber-based drivers, REST code synthesis, and stream integrity invariants, we deployed operations from prod-code’s 67-tool suite against a Vibe.d checkout (master branch) on a remote 32-core cluster node (node-b:9400), measuring modular topologies, clone clusters, and AST invariants.
$ git ls-files '*.d' | wc -l
108
$ git ls-files -z '*.d' | xargs -0 wc -l | tail -n 1
30151 total
$ git ls-files | awk -F. '{if (NF>1) print $NF}' | sort | uniq -c | sort -nr | head -n 6
108 d
28 json
10 sh
5 md
5 txt
3 sdl
The captured inventory reports 30,151 lines of D across 108 files. The package breakdown below, as published, names no http/ package, yet its subtotals add up exactly to that inventory (8,829 + 11,215 + 10,107 lines; 16 + 28 + 64 files). The two cannot both describe the named directories, and the per-path counts behind the subtotals are not on record, so the subtotals are unreconciled:
- Web & REST Framework (
web/): 8,829 lines across 16 files. - Database Drivers (
mongodb/,redis/): 11,215 lines across 28 files. - Streams, Protocols & Utilities (
utils/,mail/,stream/): 10,107 lines across 64 files.
Correction, 2026-10-27. As published on 2026-10-04, this breakdown was presented as package subtotals that omit the http/ package. They sum exactly to the 30,151-line, 108-file inventory, which is not possible if http/ - a package the pinned dub.sdl declares - is left out with any D lines of its own. No per-directory counts survive to say which grouping the figures belong to. The figures are kept as published and labelled unreconciled; the reading of them as the sizes of the named directories is withdrawn, and no size is inferred for http/.
Subsystem Architecture: Decoupled Concurrency and Protocol Layers
Vibe.d structures its architecture into modular packages:
- Asynchronous Stream & Fiber Layer (
stream/,utils/): Provides non-blocking byte streams (InputStream,OutputStream,RandomAccessStream) and fiber scheduling primitives. - HTTP Server & Client Engine (
http/): Handles HTTP/1.1 and WebSocket framing, pipelining, chunked transfer encoding, and routing (URLRouter). - Declarative REST & Web Generator (
web/vibe/web/rest.d,web.d): Translates D interfaces into HTTP route tables and client proxies at compile time. - Native Asynchronous Database Drivers (
mongodb/,redis/): Fully non-blocking BSON/MongoDB wire protocol and Redis client implementations executing directly over Vibe.d fibers.
We ran prod-code dependencies across the module tree:
$ prod-code dependencies --scope modules
⚡ prod-code Architecture & Dependency Graph Report
────────────────────────────────────────────────────
Scope: modules | Nodes: 2 | Dependencies: 0
✓ Zero circular dependencies detected. Architecture graph is a clean DAG.
The captured graph found two nodes and zero dependency edges. This incomplete extraction cannot establish a DAG or show that web routing and database drivers depend only on stream abstractions.
Declarative REST: Zero-Reflection Compile-Time Interface Generation
In traditional frameworks, creating a RESTful service requires declaring endpoints, manually mapping route parameters, parsing JSON bodies, and authoring separate client SDKs.
In web/vibe/web/rest.d, Vibe.d pioneered a zero-reflection approach:
@path("/api/")
interface APIRoot {
string get();
@path("users/:id")
User getUser(ulong id);
}
By passing APIRoot to router.registerRestInterface(new ServiceImpl), Vibe.d uses compile-time introspection (__traits and std.traits) to:
- Inspect every member function of the interface.
- Generate HTTP routes based on function names and parameter types (
get()→GET /api/,getUser(ulong id)→GET /api/users/:id). - Synthesize request body deserialization from wire JSON into D structs.
- Serialize return values into JSON responses with proper HTTP status codes.
Crucially, the exact same interface can be instantiated on the client side:
auto client = new RestInterfaceClient!APIRoot("http://api.example.com");
User u = client.getUser(42);
The client proxy translates the function call into an outgoing HTTP request, awaits the response asynchronously on a fiber, and returns the deserialized User struct. Because the server implementation and client proxy are generated from the same D interface, their routes and method signatures agree at the source level when both sides are built from the same interface definition and settings. That is as far as compile time reaches: whether the deployed server runs that revision with matching settings and method style, and whether a response is well-formed, are runtime concerns - rest.d handles HTTP failures and reads the JSON at runtime.
Correction, 2026-10-27. As published on 2026-10-04, this paragraph said route or type mismatches are caught at compile time because both sides share the same interface. The pinned web/vibe/web/rest.d shows the client sending requests and reading JSON at runtime and requiring a matching method style and server protocol; static typing does not check a deployed server. The claim is narrowed to source-level agreement between code generated from identical definitions and settings.
Clone Analysis and Test Boilerplate
We executed prod-code duplicates to detect structural cloning across the repository:
$ prod-code duplicates --min-lines 6 --max-groups 5
⚡ prod-code Clone & Duplication Harvester Report
────────────────────────────────────────────────────
Files Scanned: 108 | Lines: 30151 | Clone Groups: 5 | Duplication: 1.2%
Discovered Clone Groups:
[Clone Group #556] 6 lines | 7 occurrences (Type-2 (Parameterized))
• web/vibe/web/web.d:292-297
• web/vibe/web/web.d:426-431
• web/vibe/web/web.d:464-469
• web/vibe/web/web.d:506-511
• web/vibe/web/web.d:556-561
Preview:
│ auto router = new URLRouter;
│ router.registerWebInterface(new WebService);
│ auto settings = new HTTPServerSettings;
│ settings.port = 8080;
│ listenHTTP(settings, router);
The shown clone report, capped at five groups with a 6-line minimum, prints 1.2% duplication over the 30,151 lines it scanned; the report does not define how that percentage is computed or whether the cap limits it. The clone cluster shown (#556) appears in web/vibe/web/web.d, where documentation examples and unit tests repeatedly set up minimal HTTP routers to verify web interface routing semantics.
A report capped at five clone groups, of which the excerpt shows one, cannot establish that mongodb/, redis/ and web/vibe/web/rest.d are clean or highly consolidated, and it is not read that way here.
Correction, 2026-10-27. As published on 2026-10-04, this section called overall duplication low at 1.2% and the core communication engines in
mongodb/,redis/andrest.dclean and highly consolidated. The evidence is one clone report run with--max-groups 5, whose percentage is not defined and whose excerpt shows one group fromweb.d. The judgement on the communication engines is withdrawn, and the 1.2% figure is kept as the capped report’s printed value.
Semantic Invariants: 1,390 assert-Matching Lines
Asynchronous wire protocols require vigilant boundary verification to guard against packet truncation, malformed BSON frames, and buffer overruns:
$ prod-code struct-search 'assert($A)'
⚡ prod-code Structural AST Search: `assert($A)`
────────────────────────────────────────────────────
1390 match(es) in 52 file(s) (108 scanned in 42.18ms)
The search found 1,390 lines matching assert( across 52 files. This is a syntactic line count, not a count of assertion constructs or evidence that production protocol checks guard socket writes; the behavior of these assertions depends on the build mode. The captured search does not establish a production guarantee.
The evaluation shows how Vibe.d harnesses D’s compile-time traits to deliver high-throughput, fiber-based web architectures with declarative, type-safe API generation.
Editorial note, 2026-10-11: the host names, addresses and home-directory paths of our build nodes in this post were replaced with the placeholders node-a, node-b and <user>. No other part of the quoted output was changed.
Cite this article
Alexander Panasenko (2026-10-04). Vibe.d Under the Microscope: What 67 Remote AST Tools Found Inside the D Asynchronous Web Framework. https://prod.codes/blog/vibed-under-the-microscope-67-ast-tools/