Skip to content

DSE Memoization + Statistics#1586

Open
agusaldasoro wants to merge 8 commits into
masterfrom
dse/memoization
Open

DSE Memoization + Statistics#1586
agusaldasoro wants to merge 8 commits into
masterfrom
dse/memoization

Conversation

@agusaldasoro

@agusaldasoro agusaldasoro commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Adds memoization to the Z3 SMT solver to skip redundant Docker executions for identical SQL queries
  • Introduces Z3Result (SAT/UNSAT/ERROR) to replace Optional<Map<String, SMTLibValue>>, making error handling explicit and enabling cache-safe distinction between UNSAT and transient errors
  • Adds optional DSE statistics (collectDseStats flag) tracking SAT/UNSAT/error counts, timing, SMT-LIB size, and query uniqueness — written to CSV only when enabled
  • Fixes AI classifier stable feature-space keying via modelKeys (parameter path strings), so each parameter always maps to the same input dimension across calls
  • Fixes NN400EndpointModel.initializeIfNeeded to guard against re-initialization — without this, weight matrices were re-allocated and trained weights discarded on every
    classify()/updateModel() call

Motivation

The solver was re-running expensive Docker Z3 executions for the same SQL constraint on repeated calls. Memoizing SAT/UNSAT results avoids this. Errors are not cached to tolerate transient Docker
failures. The collectDseStats flag gives observability into DSE efficiency with zero overhead when disabled. The modelKeys fix ensures classifiers train on a consistent feature space rather
than one that shifts as new parameters are observed.

New Stats

CSV column Description
dseTotalQueries Total solver invocations (SAT + UNSAT + errors + parse failures)
dseUniqueQueries Distinct queries seen (by hash)
dseDuplicateQueries Invocations that hit the memoization cache
dseSat Queries Z3 solved as SAT
dseUnsat Queries Z3 solved as UNSAT
dseErrors Queries that returned a Z3/Docker error
dseParseFailures Queries that failed SQL→SMT-LIB parsing
dseZ3TotalMs Total wall time spent in Z3 (ms)
dseSmtlibGenTotalMs Total wall time generating SMT-LIB (ms)
dseAvgSmtlibSizeBytes Average SMT-LIB file size (bytes)

@agusaldasoro agusaldasoro changed the title Dse/memoization Add DSE Metrics + Memoization Jun 16, 2026
@agusaldasoro agusaldasoro requested a review from jgaleotti June 16, 2026 01:45
agusaldasoro and others added 4 commits June 17, 2026 04:17
`config` is injected via DI but tests create the solver directly without
a DI container. Guard the access with isInitialized so stats collection
is simply skipped when config is not available (e.g., in unit tests).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@agusaldasoro agusaldasoro changed the title Add DSE Metrics + Memoization DSE Memoization + Statistics Jun 18, 2026
@agusaldasoro agusaldasoro marked this pull request as ready for review June 18, 2026 11:52
This reverts commit a5b31d5.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant