Ray's Knowledge Base
Unlock

Layer modules by dependencies and bundle shared libraries sparingly

DecisionVerified 5 Oct 2026Holds anywhere
Decision. The context, the choice, why, and the options that were turned down.

Context#

Proposed dftracer-utils module layering and library layout.

Decision#

A module may include only modules below it, and one source directory is one library. The proposed order, lowest first, is core, json, duql, dataframe, io, index, trace (views), plugins and server. The io layer holds compress, gzip writers and readers, the gzip checkpoint index (moved from index/gzip), hashing and sketches. The index layer holds trace-format headers and the Fold interface. Move the query cache and aggregation view tier from index to trace because they run View plans. Give each module its own private include directory.

Ship a few shared libraries: core, json, duql, dataframe, and one shared library for levels from io up. Add a separate shared library only when a real user needs a subset, such as io without RocksDB.

Why#

Putting src/ for every target on every include path caused include cycles. One shared library per module duplicates static data. LLVM and DuckDB also ship few libraries. The user's earlier draft ordered index directly above dataframe and utilities above index; that was wrong because index needs low-level utilities such as gzip, writers, sketches and trace-format headers.

Rejected options#

A separate shared library for every module.

Evidence#

This was a proposed module plan, not yet approved or built in the source note. LLVM's guidance says distributions must not use BUILD_SHARED_LIBS because static data is duplicated across shared libraries; it ships a single libLLVM. CMake rejects cycles between shared targets, so a shared-library chain that links proves acyclicity. On macOS, a dylib fails to link when symbols are missing, and otool -L on each library shows the real dependency chain. A clean library chain does not prove directory layering inside a single combined library: inspect includes directly.

Also found by searching

  • how should shared library modules be layered without include cycles
  • what is the dependency order for dftracer-utils modules
  • how many shared libraries should a modular C++ project ship
  • where do trace views and gzip index code belong in the module graph