]> dreyeck.freedombox.rocks Git - topic-maps.git/commit
perf(tmdm): index topic normalization merge candidates
authorrgb <ralf.barkow@me.com>
Wed, 28 Oct 2026 06:01:47 +0000 (07:01 +0100)
committerrgb <ralf.barkow@me.com>
Wed, 28 Oct 2026 06:01:47 +0000 (07:01 +0100)
commit6162ed68c94ea4796b8cf2282edd347d9607b08c
treea4e787b08ff74447c9d55d442969b42560faaa8e
parentb2eecffa05de4fce41c10ae1ada9ae11a0c6e7dc
perf(tmdm): index topic normalization merge candidates

normalize-topic-map chose the next pair of Topics to merge by comparing
all Topic pairs; each pair without a shared identifier called
topic-reified, which enumerates every information item. Reading the
1,855-line HyperDoc project CTM did not finish in 120 s.

next-topic-merge returns the same pair through an index built for one
search and dropped with it: identifier keys (item and subject identifiers
in one namespace, subject locators apart) and a table of reified items for
the nonconflicting-reifier preference. A Topic that reifies two items, or
a listed Topic that is not its own representative, falls back to
scan-next-topic-merge, the unchanged pairwise search, so the conditions
and the moment they are signalled stay as they were. Nothing outlives a
call, so no invalidation rule exists.

The project CTM now reads in about 29-31 s (median of three fresh runs in
two independent reproductions); its semantic signature and CXTM are
byte-identical to the 5a4a668 reference. The Association pair search is
the remaining cost and is left unchanged.

tests/normalization-index.lisp (120 checks): CXTM and rejection outcomes
recorded from unchanged b2eecffa, staged-import reifier preference,
retained handles, index-versus-pairwise comparison on random maps, merge
walks and CTM documents, stale references, a positive control and scale.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
29 files changed:
scripts/fresh-sbcl.lisp
src/tmdm/merging.lisp
tests/fixtures/normalization-index/associations-equal-after-topic-merge.cxtm [new file with mode: 0644]
tests/fixtures/normalization-index/chain-40-topics.cxtm [new file with mode: 0644]
tests/fixtures/normalization-index/equal-owners-make-the-reified-associations-equal.cxtm [new file with mode: 0644]
tests/fixtures/normalization-index/equal-reifiers-of-equal-items.cxtm [new file with mode: 0644]
tests/fixtures/normalization-index/identifier-acquisition.cxtm [new file with mode: 0644]
tests/fixtures/normalization-index/ii-si-cross-identity.cxtm [new file with mode: 0644]
tests/fixtures/normalization-index/import-cascade.cxtm [new file with mode: 0644]
tests/fixtures/normalization-index/import-reifier-chain.cxtm [new file with mode: 0644]
tests/fixtures/normalization-index/import-reifier-first.cxtm [new file with mode: 0644]
tests/fixtures/normalization-index/isa-ako.cxtm [new file with mode: 0644]
tests/fixtures/normalization-index/isa-duplicates-merge.cxtm [new file with mode: 0644]
tests/fixtures/normalization-index/n-ary-duplicate-roles.cxtm [new file with mode: 0644]
tests/fixtures/normalization-index/reified-30-associations-merging-reifiers.cxtm [new file with mode: 0644]
tests/fixtures/normalization-index/reified-30-associations.cxtm [new file with mode: 0644]
tests/fixtures/normalization-index/reified-duplicate-associations.cxtm [new file with mode: 0644]
tests/fixtures/normalization-index/reified-duplicate-names.cxtm [new file with mode: 0644]
tests/fixtures/normalization-index/reifier-acquires-another-topics-identifier.cxtm [new file with mode: 0644]
tests/fixtures/normalization-index/reifier-merges-by-identifier.cxtm [new file with mode: 0644]
tests/fixtures/normalization-index/rejections.sexp [new file with mode: 0644]
tests/fixtures/normalization-index/si-and-sl-stay-apart.cxtm [new file with mode: 0644]
tests/fixtures/normalization-index/subject-locator-merge.cxtm [new file with mode: 0644]
tests/fixtures/normalization-index/topic-map-reifier.cxtm [new file with mode: 0644]
tests/fixtures/normalization-index/transitive-late-chain.cxtm [new file with mode: 0644]
tests/fixtures/normalization-index/transitive-through-third.cxtm [new file with mode: 0644]
tests/fixtures/normalization-index/wildcard-merge.cxtm [new file with mode: 0644]
tests/normalization-index.lisp [new file with mode: 0644]
topic-maps.asd