mirror of
https://github.com/Haidra-Org/AI-Horde.git
synced 2026-11-06 05:17:31 +00:00
perf: index kudos ledger on hot path
This commit is contained in:
6 files changed
+35
-3
No files matched your search
@@ -148,6 +148,10 @@ class KudosLedger(db.Model): # type: ignore[name-defined,misc]
|
||||
"user_id",
|
||||
postgresql_where=column("applied").is_(false()),
|
||||
),
|
||||
# available_kudos() sums a payer's unapplied debits on every admission. The plain user_id index holds the
|
||||
# payer's entire history, so this covers only the pending rows. Existing deployments add it with
|
||||
# sql_statements/5.1.11.txt.
|
||||
Index("ix_kudos_ledger_unapplied_by_user", "user_id", postgresql_where=column("applied").is_(false())),
|
||||
)
|
||||
|
||||
id: Mapped[int] = mapped_column(BigInteger, primary_key=True)
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ from horde_sdk.generation_parameters.image.constraints import (
|
||||
KNOWN_SAMPLER_SOLVER_TYPES,
|
||||
)
|
||||
|
||||
HORDE_VERSION = "5.1.9"
|
||||
HORDE_VERSION = "5.1.11"
|
||||
HORDE_API_VERSION = "2.6"
|
||||
|
||||
WHITELISTED_SERVICE_IPS = {
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
[project]
|
||||
name = "AI-Horde"
|
||||
version = "5.1.9"
|
||||
version = "5.1.11"
|
||||
description = "A Crowdsourced Generative AI cluster for everyone."
|
||||
authors = [
|
||||
{name = "db0", email = "mail@dbzer0.com"},
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
-- Run with psql in its default autocommit mode. Do not pass --single-transaction:
|
||||
-- CREATE INDEX CONCURRENTLY cannot run inside a transaction block. Pass
|
||||
-- -v ON_ERROR_STOP=1 so a failure stops the migration. A failed concurrent build
|
||||
-- leaves an INVALID index; drop it and rerun after correcting the cause.
|
||||
--
|
||||
-- available_kudos() (request admission) sums a payer's unapplied debits:
|
||||
-- SELECT ... FROM kudos_ledger WHERE user_id = ? AND applied IS FALSE AND ...
|
||||
-- The plain user_id index covers the payer's whole history, so a busy payer
|
||||
-- (the anonymous account above all) walked millions of applied rows to find a
|
||||
-- handful of pending ones. This partial index covers exactly the pending rows
|
||||
-- and stays small. Index-only: no application change depends on it, so it can
|
||||
-- be applied before or after deploying 5.1.11.
|
||||
SET lock_timeout = '3s';
|
||||
|
||||
CREATE INDEX CONCURRENTLY IF NOT EXISTS ix_kudos_ledger_unapplied_by_user
|
||||
ON kudos_ledger (user_id)
|
||||
WHERE applied IS FALSE;
|
||||
|
||||
-- The partial "unapplied"/"drainable" indexes gain an entry for every inserted
|
||||
-- row and lose it only when vacuum removes the flipped tuple; a period of slow
|
||||
-- vacuuming leaves them mostly dead entries that every claim scan and health
|
||||
-- aggregate must walk. Rebuild them online if pg_relation_size() is out of all
|
||||
-- proportion to the live pending row count.
|
||||
-- REINDEX INDEX CONCURRENTLY ix_kudos_ledger_unapplied;
|
||||
-- REINDEX INDEX CONCURRENTLY ix_kudos_stat_events_drainable;
|
||||
@@ -0,0 +1,3 @@
|
||||
SPDX-FileCopyrightText: Tazlin <tazlin@haidra.net>
|
||||
|
||||
SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
Reference in new issue
Block a user