BufferedSessionService can't batch writes: DatabaseSessionService has no append_events

Offen
#8,256 1 Kommentar 0 Reaktionen 2 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 3 Tagen

@Jacksunwei arbeitet bereits daran.

Seit 20.11.2026.

  • #8257 von @EdwardGlockner — offen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Beschreibung

needs review services

Is your feature request related to a problem?

BufferedSessionService (e1deb17f5, f4fab7885) sends a session's queued events in one append_events call when the wrapped store overrides that method. No built-in store does: DatabaseSessionService, SqliteSessionService and InMemorySessionService all keep the base method. So with every store ADK ships, max_write_delay and max_batch_events have no effect, and every event still costs its own transaction. The buffer guide says so too: "ADK's built-in session services keep it, so for them each event is sent in its own append_event call."

On a SQLite file through DatabaseSessionService (Windows, Python 3.11), each append_event takes about 140 ms. Flushing 20 buffered events takes about 2.6 s.

Describe the solution you'd like

DatabaseSessionService.append_events that stores the batch in one transaction: one stale-session check, the state deltas merged in order, one row per event, and one commit. That follows the contract in the base docstring (all or none, in order, same effect as one append_event per event). append_event can become a one-event call to it, so there is one write path.

PR with the implementation and tests: #8257. Timings on that setup:

main with append_events
10 events, append_event each vs one append_events 1400 ms 119 ms
50 events, same 8211 ms 152 ms
BufferedSessionService over it, flush 20 events 2608 ms 125 ms

Stored events, session state and last_update_time are identical either way.

Describe alternatives you've considered

Keeping one transaction per event and relying on max_write_delay alone, which can't help without an append_events override.

Additional context

SqliteSessionService could get the same override in a follow-up.

Vorherrschende Sprache
Python
Sterne
22.3k
Forks
4.4k
Ø Merge
1 T. 2 Std.
Gemergte PRs (30 T.)
6

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus google/adk-python

Alle Issues in google/adk-python

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.