-
-
Notifications
You must be signed in to change notification settings - Fork 237
Performance optimizations and bug fixes #2816
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
DL6ER
wants to merge
172
commits into
development
Choose a base branch
from
tweak/performance
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 145 commits
Commits
Show all changes
172 commits
Select commit
Hold shift + click to select a range
d9ae86a
perf(shmem): replace O(n) memmem() scan in addstr() with O(1) hash table
DL6ER ba3fc20
findQueryID: O(1) direct-mapped cache for dnsmasq ID -> query index
DL6ER f020963
GC: eliminate O(n) queries memmove via deferred compaction
DL6ER 7b7bad2
perf(gc): eliminate O(queries) scan in recycle() via incremental refc…
DL6ER 1ea4c79
perf(db): replace heap-allocated asprintf with stack buffer in DB wri…
DL6ER 38bb955
perf(gc): batch lookup table removals into single compaction pass
DL6ER eb1c719
perf(gc): single-pass lookup table recycle+compact in GC
DL6ER 638658e
Regex: check query-type filter before running regexec
DL6ER 3a9559c
Defer ABP pattern generation until after gravity exact-match
DL6ER d2edd03
EDNS0: move cookie processing into debug-only block
DL6ER fb2629d
Remove dead gettimeofday call and duplicate DNSSEC check
DL6ER 8f8fd45
API: heap-based top-K selection for domains and clients
DL6ER ecdd530
Minor hot-path micro-optimizations
DL6ER ec122fe
Add related CI tests
DL6ER 58d7a53
perf: batch dedup linking table INSERTs + remove sqlite3_clear_bindings
DL6ER e0926fc
perf: use in_database bool flag instead of generation counter
DL6ER e90bed8
perf: cache linking table row IDs, eliminate 3 REPLACE subqueries
DL6ER 044135f
perf: cache addinfo row IDs, eliminate last REPLACE subquery
DL6ER 0eaec20
perf: skip antigravity check when no allow-adlists exist
DL6ER b18378e
perf: split queries_to_database() into three phases to reduce SHM loc…
DL6ER d4a0646
perf: move find_mac() outside SHM lock to avoid kernel I/O under mutex
DL6ER 1d495d3
perf: cache resolved interface in _FTL_iface() to skip repeated loops
DL6ER 727532a
perf(gravity): skip exact allowlist/denylist SQLite lookups when list…
DL6ER eb88067
perf(gravity): replace cJSON heap allocations with stack-based ABP pa…
DL6ER 54cdf40
Reduce per-query overhead: fused strcpy_tolower, conditional clock_ge…
DL6ER 6594635
Reduce branching and buffer waste in hot query path
DL6ER 909f346
fix: assign stmt in in_gravity() after lazy initialization
DL6ER 88eff62
fix: use !blockDomain instead of blockDomain == NOT_FOUND
DL6ER 5ef1557
perf: skip time() call in gravityDB_client_check_again() for mature c…
DL6ER 3c4a1fd
perf: cache suffix lengths in is_pihole_domain() to short-circuit str…
DL6ER 5fde06a
Eliminate redundant copies and use strcmp for pre-lowered domains
DL6ER 0c86f1c
perf: remove two unused gettimeofday() calls
DL6ER 15dfd7f
perf: replace strlen(interface) with direct char checks
DL6ER d9d4d40
perf: replace strlen() with O(1) char checks in ESNI domain test
DL6ER bf956ab
perf: hoist per-client regex row pointer out of match_regex() loop
DL6ER 811af23
perf: replace time(NULL) in upstream-blocked debug log with query->ti…
DL6ER 5475569
perf: pass domain string into FTL_check_blocking() to skip getstr()
DL6ER 9dfdc88
perf: replace snprintf with memcpy in ABP pattern loop
DL6ER ac52a73
fix: pass OPT RR length to FTL_parse_pseudoheaders in UDP/TCP receive…
DL6ER fd42aa2
fix: correct EDE info-code byte-order read in FTL_parse_pseudoheaders
DL6ER 10878ca
perf: eliminate redundant strcpy_tolower in FTL_check_blocking
DL6ER 43e009f
perf: eliminate all redundant SHM lookups in FTL_check_blocking
DL6ER 8e9fb7c
perf: pre-compute ABP suffix lengths in abp_patterns struct
DL6ER 02872d1
perf: replace time(NULL) with query->timestamp in _query_set_status
DL6ER 151be9f
docs: correct stale SELECT EXISTS() comment in gravityDB_prepare_clie…
DL6ER ecbfa47
perf: set synchronous=NORMAL on WAL-mode disk database
DL6ER 6e31b8f
fix: correct swapped bind parameters in db_update_disk_counter and SQ…
DL6ER b8a3b0b
fix: use sqlite3_bind_int64 for time_t fields in insert_netDB_device
DL6ER 7df6463
fix: close db on all error paths and use int64 for time_t columns
DL6ER 445e9cd
fix: free escaped_status unconditionally in format_gravity_restored_m…
DL6ER dd0571c
fix: finalize stmt before returning DB_FAILED on step error in db_que…
DL6ER 766ea74
fix: close db on error paths in flush_network_table
DL6ER 62b154f
fix: defer sqlite3_reset() until after hwaddr use in unify_hwaddr()
DL6ER c478309
fix: close db and return proper error on prepare failure in api_histo…
DL6ER ff9a38f
fix: close db on prepare failures in api_history_database_clients()
DL6ER cfbb297
fix: use sqlite3_bind_double() for from/until in api_history_database…
DL6ER 5cffaf4
fix: use sqlite3_column_int64/time_t for timeslot timestamps (Y2038)
DL6ER 7fc1400
fix: close db on prepare failure in api_stats_database_upstreams()
DL6ER ae97b50
fix: close db on networkTable_deleteDevice() failure in api/network.c
DL6ER 0a0c495
fix: use sqlite3_column_int64() for lastQuery in api/network.c (Y2038)
DL6ER 5d04034
fix: use sqlite3_column_int64() for lastQuery in api/network.c (Y2038)
DL6ER dee813c
fix: return DB_FAILED on bind error in db_query_int_from_until[_type]()
DL6ER 89ce3c3
perf: prepare query-types statement once outside the loop
DL6ER ff7cb71
fix: rollback transaction on early return in parse_neighbor_cache()
DL6ER 1b8ae6f
fix: rollback transaction on all early returns in parse_neighbor_cache()
DL6ER a73c0c0
fix: add missing ROLLBACK before early returns inside open transactions
DL6ER 1d71531
fix: return false after ROLLBACK in gravityDB_delFromTable() failure …
DL6ER a93c2bb
fix: abort on bind error in db_query_int_int() and db_query_int_str()
DL6ER 9d43d46
fix: free querystr on like_name allocation failure in gravityDB_readT…
DL6ER 69d0189
fix: only record last_insert_rowid on successful INSERT in _add_messa…
DL6ER 4ceacab
fix: check sqlite3_bind_int() return value in delete_message()
DL6ER d5ba5ad
fix: correct cacheID sentinel check in _query_set_status()
DL6ER aadb96a
fix: propagate LIST_NOT_AVAILABLE from ABP gravity pattern loop
DL6ER de8cdc5
fix: correct upstreamID sentinel checks from > 0 to > -1
DL6ER 7cd0fd9
fix: include query ID 0 in recent-blocked reverse scans
DL6ER 0a368bf
fix: return success instead of true in update_netDB_interface()
DL6ER 881b26a
fix: add_local_interfaces_to_network_table() returned SQLITE_ERROR in…
DL6ER d3a2526
fix: unlock SHM before continue when getClient() returns NULL in pars…
DL6ER 49f3266
fix: log correct old_status in _query_set_status() debug message
DL6ER cebad70
fix: use & 0xFF instead of % 0xFF to extract EDNS VERSION byte
DL6ER 7582b64
fix: resolve_this_name() disables IPv6 resolution when resolveIPv4=false
DL6ER fbc922f
fix: calloc in new_sqlite3_stmt_vec() allocates n² items instead of n
DL6ER 68a19ba
fix: zombie detection in process_alive() never matches
DL6ER 67391c1
fix: session cookie always uses default timeout instead of configured…
DL6ER 0ebae9a
fix: zero-initialise vendor buffer in updateMACVendorRecords()
DL6ER d549f2a
fix: guard freeaddrinfo() calls in resolve_regex_cnames() on getaddri…
DL6ER b1e2ac6
fix: add missing space in SQL JOIN clause in api_stats_database_top_i…
DL6ER a47fd50
fix: correct wait-for argc guard from 5 to 6
DL6ER 9fe755f
fix: prevent OOB write and missing NUL in add_to_fifo_buffer()
DL6ER e268566
fix: return VERIFY_ERROR when sha256sum() fails in verify_FTL()
DL6ER 98251fc
fix: null-check aliasclient pointer in change_clientcount()
DL6ER 72bfeb6
fix: sort top upstreams by query count, not response count
DL6ER ff377fc
fix: correct inet_pton assignment precedence in validate_cidr()
DL6ER 414a30f
fix: replace strncat with snprintf in validate_regex_array() error path
DL6ER d8bdc27
fix: null-check getClient() result in recompute_aliasclient()
DL6ER 2f51202
fix: free getline buffer when target line not found in get_dnsmasq_li…
DL6ER 863ee09
fix: use AF_INET6 instead of AF_INET when parsing REPLY_ADDR6 in lega…
DL6ER 05137fc
fix: guard against NULL current_user in set_config_from_CLI() permiss…
DL6ER 8dd2999
fix: free addrDB before early return on invalid CIDR in subnet_match()
DL6ER ee09e2d
fix: prevent double sqlite3_finalize() on bind failure in _add_message()
DL6ER a8dc9f8
fix: use escaped strings in format_connection_error() HTML output
DL6ER 0039eb2
fix: rollback transaction and reset statement on bind failure in expo…
DL6ER 191b1db
fix: guard against out-of-bounds device[] access in process_arp_reply()
DL6ER dc73466
fix: free path buffer in rotation-file cleanup loop in teleporter import
DL6ER 252836b
fix: free json_files cJSON array on ZIP teleporter import error path
DL6ER 250c107
fix: free punycode buffer when domain validation fails in list API
DL6ER 592152b
fix: close sqlite3 handle on early return in teleporter database vali…
DL6ER 31296f5
fix: free top_blocked and top_clients cJSON objects in api_padd()
DL6ER 61f36f1
fix: close local db handle instead of global gravity_db in gravity_up…
DL6ER 9c5da7f
Minor test suite improvement
DL6ER 043326c
gravity-db: use mmap I/O to eliminate pread() overhead for blocklist …
DL6ER 46afd53
perf: add debug.performance flag for measuring gravity.db and FTL cac…
DL6ER 1113fff
Remove stray newline character
DL6ER 79ae962
Merge branch 'development' into tweak/performance
DL6ER 38f7322
perf: pre-warm gravity.db page cache on startup with posix_fadvise
DL6ER 52c7c49
perf + mem: reorder queriesData and clientsData for memory savings an…
DL6ER 67fa7db
perf: replace locale tolower() with branchless ASCII bit-trick in str…
DL6ER d485061
perf: defer double_time() past pi.hole early exit in FTL_reply
DL6ER 70ce302
perf: instrument FTL_new_query() and FTL_reply() hot-path components
DL6ER bf196c8
perf + mem: shrink DNSCacheData from 48 to 36 bytes on all architectures
DL6ER 6b7e0c8
docs: correct and expand alignment/cache comments in datastructure.h
DL6ER ddc02b7
fix: correct uint64 underflow in performance timing macros
DL6ER 002f72b
perf: replace Jenkins' One-at-a-Time hash with FNV-1a in hashStr()
DL6ER ef28a61
perf: enable mmap I/O for the on-disk query database
DL6ER 4edba81
fix: add missing gravity/antigravity domain indexes to test schema
DL6ER 7944b66
perf: use shared gravity statements with carray() binding
DL6ER 0d33119
refactor: store client group IDs as int arrays in shared memory
DL6ER aa5439b
perf: convert all group-filtered queries to shared carray() statements
DL6ER e3a2128
cleanup: remove unused sqlite3_stmt_vec infrastructure
DL6ER 503fddc
refactor: store adlist IDs in SHM intarray alongside group IDs
DL6ER 5cd86f7
perf: add ANTIGRAVITY_TABLE support, dedup regex queries, and add jun…
DL6ER 5008c11
fix: revert adlist ID caching, query gravity views live for correctness
DL6ER abc8f7e
perf: skip redundant carray rebinds, use WITHOUT ROWID on junction ta…
DL6ER 263808b
fix: re-fetch SHM pointers after find_mac() unlock/relock cycle
DL6ER 6445513
fix: add missing comma in index_creation array in query-table.h
DL6ER c10a432
fix: sort database top_domains/top_clients by count and push LIMIT in…
DL6ER 0892ff0
perf: replace correlated subqueries with LEFT JOINs in queries VIEW (…
DL6ER 1e52321
fix: correct "NOL NULL" typo to "NOT NULL" on client.ip in gravity sc…
DL6ER f039bff
perf: use PK lookup in update triggers instead of UNIQUE text column
DL6ER dab1001
fix: add missing NULL check after calloc in gravityDB_readTable()
DL6ER dbe385b
fix: guard against NULL from strtok_r in compile_regex()
DL6ER 72c756b
fix: handle realloc failure in teleporter file upload handler
DL6ER 1da2c16
fix: use alternate signal stack and reset-on-entry for crash handlers
DL6ER b7a71e3
fix: make SIGTERM and RT signal handlers async-signal-safe
DL6ER f9cb973
style: format crash backtraces in GDB-style output
DL6ER 511d5cf
fix: zero-initialize hwaddr buffer before find_mac() call
DL6ER 81966b6
fix: add missing ROLLBACK on calloc failure in parse_neighbor_cache()
DL6ER 063c7aa
fix: add missing ROLLBACK in replace_queries_view_with_joins()
DL6ER 46fef48
fix: prevent NULL deref in get_top_domains/get_top_clients when count<=0
DL6ER 9370f29
fix: correct SHM_TIME_EPOCH to match 2026-01-01 00:00:00 UTC
DL6ER 078ce69
fix: skip performance stats dump on fresh start, fix duplicate PID log
DL6ER 136cdee
Increate timeout for build job. 15 minutes is sometimes not enough fo…
DL6ER c83a24d
Merge branch 'development' into tweak/performance
DL6ER 39bbec8
Merge branch 'development' into tweak/performance
DL6ER d2f040d
Improve test script harness cleanup/preparation steps
DL6ER 861666b
Fix a stale free(punycode) left over from the merge resolution during…
DL6ER 4a4830a
Merge branch 'development' into tweak/performance
DL6ER 1f889cd
Fix duplicated DNSSEC pre-warm query accidentally slipped through in …
DL6ER f99b052
Mitigate possible race window after Teleporter test
DL6ER 9049c51
Merge branch 'development' into tweak/performance
DL6ER 336f316
perf: cap SQLite rollback journal / WAL at 32 MiB
DL6ER 967fdbe
cleanup: fetch page_count and page_size in a single round trip
DL6ER fb134df
docs: pin SQLITE_STATIC lifetime contract on carray binding
DL6ER 0ff71fb
perf: open pihole-FTL.db without per-call mutex
DL6ER a988fb5
perf: extend SQLITE_OPEN_NOMUTEX to other single-threaded opens
DL6ER 0175e53
perf: shrink SQLite per-connection page cache from ~64 MiB to ~16 MiB
DL6ER 5f386d4
perf: split check_blocking perf timing into allowlist and denylist slots
DL6ER 5807edc
perf: attribute check_blocking outliers to caller and sub-engine
DL6ER c690cbb
perf: time the non-step wrapper work inside in_gravity()
DL6ER 749024d
perf: defer client group re-check reloads to the database thread
DL6ER e02f95d
perf: move client group re-checks off the DNS hot path to the DB thread
DL6ER bcf3e7d
Skip aliasclients in the new gravityDB_recheck_clients()
DL6ER File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -264,8 +264,6 @@ set(sources | |
| signals.h | ||
| timers.c | ||
| timers.h | ||
| vector.c | ||
| vector.h | ||
| version.c | ||
| version.h | ||
| ) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.