49 Commits
Author SHA1 Message Date
wwqgtxx b59a7e7baf chore: sharing synthetic datasets used for build benchmarking 2026-09-11 07:53:18 +08:00
wwqgtxx ebf82e2962 chore: reuse queues during DomainSet build
Build the succinct domain index one level at a time and alternate two reusable queues instead of retaining every processed node until construction completes.

Keep explicit node IDs to preserve terminal ordering, Foreach output, and binary serialization. Query logic and the serialized layout remain unchanged.

This reduces peak build memory and improves construction time for DomainMap. In isolated measurements, the mixed 100k-rule workload used about 53% less peak memory and completed about 11% faster, while deep 100k-rule input used about 72% less peak memory and completed about 24% faster.
2026-09-11 06:51:26 +08:00
wwqgtxx f6a038ce0f chore: add some benchmark code for new DomainMap 2026-09-11 00:05:21 +08:00
wwqgtxx d37f58e768 chore: add new DomainMap implement based on succinct DomainSet 2026-09-10 22:49:36 +08:00
wwqgtxx 77b9393c32 fix: preserve domain rules across Foreach round trips
The +.domain syntax includes both the domain itself and its subdomains. Using it for a suffix-only terminal adds an unintended exact match when the output is reinserted and can overwrite a separately stored exact value.

Emit .domain for suffix-only entries in DomainTrie and DomainSet Foreach, keeping exact entries separate. Preserve the internal '+' marker when converting Trie to Set, and combine MRS entries into +.domain only when both exact and suffix entries exist.

Add regression coverage for matching behavior and distinct values after reinsertion, as well as MRS deduplication and compact output. Query logic and binary layouts remain unchanged.
2026-09-10 18:52:49 +08:00
wwqgtxx 4aa9cc17fc chore: avoid redundant select calculations in DomainSet
Once the key is exhausted, a terminal node completes the match; otherwise only saved wildcard branches can still succeed. No input remains to match the current node's child edges, so their starting position is unnecessary.

Defer the child-edge select in Has until more input needs matching, both after matching a byte and when restoring a wildcard. Keep the node-terminator select needed to resume saved wildcard branches.

Earlier candidate benchmarks show median query times ~3%/~1% lower for short/long queries and ~11%/~8% lower for exact/mixed-rule workloads, with no additional allocations or changes to the index layout.
2026-09-10 09:25:15 +08:00
wwqgtxx 8e2f18a1a9 chore: avoid redundant rank calculations in DomainSet
Child edges are 0 bits and each node ends with a 1 bit in labelBitmap. An edge of nodeId has exactly nodeId preceding 1 bits, so its label index is bmIdx - nodeId. Child nodes follow the same order as labels, starting at 1 because node 0 is the root. Therefore, the child node ID is bmIdx - nodeId + 1.

Use this identity in Has and keys instead of countZeros. Keep rank for wildcard restoration, where the cursor lacks the parent node ID.

Existing short/long query benchmarks take ~12%/~11% less time, with no additional allocations or changes to the index layout.
2026-09-10 09:04:52 +08:00
wwqgtxx 5f9510988c fix: DomainSet wildcard matching with overlapping rules
These queries now correctly return true:

- Query: a.example.com
  Rules: [*.example.com, dead.a.example.com]

- Query: b.a.example.com
  Rules: [*.*.example.com, dead.*.a.example.com, dead.b.a.example.com]

- Query: b.c.a.example.com
  Rules: [*.*.*.example.com, *.a.example.com]
2026-09-10 08:19:36 +08:00
wwqgtxx bbb8cb924b chore: add standalone DomainSetBuilder 2026-09-08 10:27:49 +08:00
wwqgtxx 2f7eae5a26 chore: report detailed errors for invalid Clash-style domain patterns 2026-08-17 09:35:10 +08:00
Ember Moth 26c635f69b chore: avoid string reversal allocation in DomainSet.Has (#3049) 2026-07-30 15:25:45 +08:00
wwqgtxx 6bb8b98314 chore: strictly verify the syntax for Clash-style domain wildcards 2026-07-26 13:13:59 +08:00
wwqgtxx 7dafe7889e chore: disallow space at begin or end in DomainTrie 2024-09-21 21:03:59 +08:00
wwqgtxx 4fecf68b8b chore: add sourceGeoIP and sourceIPASN to metadata 2024-08-28 12:25:45 +08:00
wwqgtxx 4c10d42fbf fix: normal rule not working in fake-ip-filter 2024-08-15 07:42:59 +08:00
wwqgtxx 7fd0467aef feat: sniffer's force-domain and skip-domain support rule-set: and geosite: 2024-08-14 23:29:53 +08:00
wwqgtxx c830b8aaf7 feat: support convert mrs format back to text format 2024-07-28 11:00:27 +08:00
wwqgtxx 4f8a5a5f54 feat: add mrs format ipcidr ruleset 2024-07-27 10:36:11 +08:00
wwqgtxx 303f6e4567 feat: add mrs format domain ruleset 2024-07-26 22:30:42 +08:00
Larvan2 6bc915526f fix: resolve IPv6 rule-set issue #959. 2024-01-06 17:54:09 +08:00
wwqgtxx 17c9d507be chore: hello mihomo 2023-11-03 21:58:21 +08:00
Skyxim 603d0809b4 fix: panic when add 4in6 ipcidr 2023-06-26 21:04:54 +08:00
wwqgtxx ad11a2b813 fix: go1.19 compile 2023-06-06 10:47:50 +08:00
Skyxim a7233f6036 fix: wildcard matching problem 2023-04-28 16:55:35 +00:00
Skyxim d8db25ee89 fix: domain-set wildcard match 2023-04-26 02:49:16 +00:00
Skyxim 7513761540 fix: not match top domain 2023-04-20 05:45:22 +00:00
wwqgtxx 54cad53f5f chore: DomainSet now build from a DomainTrie 2023-04-01 12:15:03 +08:00
Skyxim cfd03a99c2 feat: nameserver-policy support use rule-providers and reduce domain-set memory 2023-04-01 11:53:39 +08:00
wwqgtxx bc5ab3120f fix: use same strClone function 2022-11-30 20:38:03 +08:00
wwqgtxx df8e129fc6 chore: optimize DomainTrie for only one child 2022-11-30 19:42:05 +08:00
wwqgtxx 84caee94af chore: decrease DomainTrie's memory use 2022-11-30 18:50:46 +08:00
wwqgtxx 22fb219ad8 chore: trie.DomainTrie will not depend on zero value 2022-11-02 22:28:18 +08:00
yaling888 a6eb11ce18 Refactor: DomainTrie use generics 2022-04-12 18:45:47 +08:00
Skyxim b2981f921c chore: reduce a little memory 2022-04-09 22:24:48 +08:00
MetaCubeX 609d69191a Merge remote-tracking branch 'clash/dev' into Alpha
# Conflicts:
#	.github/workflows/docker.yml
#	adapter/outboundgroup/fallback.go
#	adapter/outboundgroup/loadbalance.go
#	adapter/outboundgroup/relay.go
#	adapter/outboundgroup/selector.go
#	adapter/outboundgroup/urltest.go
#	config/config.go
#	go.mod
#	go.sum
#	main.go
#	test/go.mod
#	test/go.sum
2022-03-17 01:41:51 +08:00
Dreamacro 6a661bff0c Migration: go 1.18 2022-03-16 12:10:13 +08:00
MetaCubeX 68fccfacc0 [Skip CI] 2022-03-15 02:20:19 +08:00
Clash-Mini 1cdaf782ba Merge remote-tracking branch 'clash/dev' into Feature 2022-02-04 02:38:32 +08:00
Dreamacro b1a639feae Fix: domain trie search 2022-01-26 22:28:13 +08:00
Skyxim c6f923041f Feature:Supported Rule-Set 2021-12-02 22:56:17 +08:00
Maze.tsz 35cf39e415 Revert "[test] rule providers"
This reverts commit 078389f4f6.
2021-11-26 00:57:41 +08:00
maze.y2b@gmail.com 078389f4f6 [test] rule providers 2021-11-25 23:14:31 +08:00
Dreamacro f1cf7e9269 Style: use gofumpt for fmt 2021-10-10 23:44:09 +08:00
Rusty Pen 0778591524 Feature: dns resolve domain through nameserver-policy (#1406) 2021-05-19 11:17:35 +08:00
Dreamacro d759d16944 Style: cleanup code 2021-03-24 01:00:21 +08:00
Kr328 14c9cf1b97 Fix: domain trie crash if not match in #758 (#762) 2020-06-24 19:46:37 +08:00
Kr328 3dfff84cc3 Fix: domain trie should backtrack to parent if match fail (#758) 2020-06-24 18:41:23 +08:00
Dreamacro fb628e9c62 Feature: add default hosts localhost 2020-06-07 17:25:51 +08:00
Dreamacro 8d0c6c6e66 Feature: domain trie support wildcard alias 2020-05-28 12:13:05 +08:00