Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Replace vendored SQLite amalgamation with build-time generation.#21779

Open
vkalintiris wants to merge 1 commit intonetdata:masterfrom
vkalintiris:cmake-sqlite
Open

Replace vendored SQLite amalgamation with build-time generation.#21779
vkalintiris wants to merge 1 commit intonetdata:masterfrom
vkalintiris:cmake-sqlite

Conversation

@vkalintiris
Copy link
Contributor

@vkalintiris vkalintiris commented Feb 17, 2026

SQLite was vendored as the full amalgamation (sqlite3.c at ~9 MB) in src/database/sqlite/vendored/. With ~10 updates in git history, this accumulated ~65 MB of uncompressible blob storage, growing by ~9 MB per version bump.

This replaces the vendored files with a new CMake module (NetdataSQLite.cmake) that uses ExternalProject_Add to fetch the SQLite source tree and generate the amalgamation at build time with --enable-update-limit (required for the UDL-capable parser grammar).

By default, sources are fetched as a tarball from sqlite.org (~14 MB). A -DSQLITE_USE_GIT=ON option is available to use a shallow git clone from GitHub instead.


Summary by cubic

Replaced the vendored SQLite amalgamation with a CMake module that downloads the source and builds the amalgamation at compile time. This cuts repository growth (~65 MB to date, ~9 MB per bump) and keeps UPDATE/DELETE ... LIMIT support.

  • Dependencies

    • Added NetdataSQLite.cmake to fetch SQLite and generate the amalgamation at build time (--enable-update-limit).
    • Default: sqlite.org tarball (~14 MB); optional -DSQLITE_USE_GIT=ON for a shallow GitHub clone.
    • Integrated as a static library via include(NetdataSQLite) and netdata_bundle_sqlite3().
    • Removed vendored sqlite3*, sqlite3recover*, and dbdata.c; updated includes to "sqlite3.h"/"sqlite3recover.h".
  • Migration

    • Builds now download SQLite; ensure network access or use CI caching/mirrors.
    • If sqlite.org is blocked, pass -DSQLITE_USE_GIT=ON.

Written for commit 9e18d04. Summary will update on new commits.

SQLite was vendored as the full amalgamation (sqlite3.c at ~9 MB) in
src/database/sqlite/vendored/. With ~10 updates in git history, this
accumulated ~65 MB of uncompressible blob storage, growing by ~9 MB
per version bump.

This replaces the vendored files with a new CMake module
(NetdataSQLite.cmake) that uses ExternalProject_Add to fetch the
SQLite source tree and generate the amalgamation at build time with
--enable-update-limit (required for the UDL-capable parser grammar).

By default, sources are fetched as a tarball from sqlite.org (~14 MB).
A -DSQLITE_USE_GIT=ON option is available to use a shallow git clone
from GitHub instead.
@vkalintiris vkalintiris requested a review from stelfrag February 17, 2026 12:40
@vkalintiris vkalintiris self-assigned this Feb 17, 2026
@vkalintiris vkalintiris added area/database area/build Build system (autotools and cmake). labels Feb 17, 2026
@github-actions github-actions bot added area/packaging Packaging and operating systems support area/docs area/ml Machine Learning Related Issues labels Feb 17, 2026
@vkalintiris
Copy link
Contributor Author

@stelfrag I didn't enable git sources by default, because it added >1m for clean builds.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 16 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.
Architecture diagram
sequenceDiagram
    participant Build as Build System (CMake/Make)
    participant Remote as SQLite Sources (sqlite.org / GitHub)
    participant FS as Build Directory (Binary Tree)
    participant Lib as Static Library (libsqlite3)
    participant Netdata as Netdata Core (libnetdata)

    Note over Build,Netdata: Build-Time SQLite Generation Flow

    Build->>Build: include(NetdataSQLite)
    
    alt NEW: Default Flow (Tarball)
        Build->>Remote: Fetch sqlite-src-xxx.zip (sqlite.org)
    else NEW: Git Flow (-DSQLITE_USE_GIT=ON)
        Build->>Remote: Shallow clone (GitHub)
    end
    
    Remote-->>FS: SQLite Source Tree
    
    Build->>FS: NEW: configure --enable-update-limit
    Build->>FS: NEW: make sqlite3.c sqlite3.h
    Note right of FS: Generates UDL-capable parser
    
    FS->>FS: NEW: Copy artifacts to output directory
    Note right of FS: sqlite3.c, sqlite3.h, sqlite3recover.c, etc.

    Build->>Lib: Compile generated sources
    Lib-->>Netdata: CHANGED: Link as static library
    
    Note over Netdata,Lib: Runtime Interaction
    
    Netdata->>Lib: API calls (e.g., sqlite3_open)
    Note left of Netdata: Headers resolved via<br/>Generated Include Dirs
Loading

@vkalintiris vkalintiris enabled auto-merge (squash) February 17, 2026 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/build Build system (autotools and cmake). area/database area/docs area/ml Machine Learning Related Issues area/packaging Packaging and operating systems support

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant