Uploading several graphs rebuilds the derived computed graph after every write #16

Open
opened 2026-10-26 08:27:37 +00:00 by daniel · 0 comments
Owner

After every successful graph write, put_graph in src/routes/ingest.rs calls auto_recompute, which clears the dataset's derived computed graph and re-derives it from all source graphs, to a fixpoint, before it replies. A client that writes n graphs in a row pays for n full rebuilds, and only the last one is useful.

On a real upload of six graphs (schema 67 KB, kg 13.3 MB, labels 2.4 MB, wikidata 104 KB, cq 16 KB, doc), most of the time goes to these repeated rebuilds, not to loading. The cost grows with the dataset: the largest graph grew from about 57k to about 171k triples between two uploads.

Proposed change

Let a client defer the rebuild, then recompute once.

  • PUT, POST and DELETE on _graph accept ?recompute=false, or a request header such as Concon-Recompute: defer, which skips the automatic rebuild for that write.
  • The client calls the existing POST _recompute once after the last write.
  • Without the option, behaviour is unchanged: each write leaves computed coherent, so single-graph writes need nothing from the client.
  • The option needs the same write authorization as the write itself.

Also log the rebuild's duration in the existing "recomputed derived graph" log line, so slow uploads can be diagnosed.

Alternatives considered:

  • A deferred, coalesced rebuild: a write marks the dataset as needing a rebuild, and one background task rebuilds after a short quiet period. Writes return as soon as the load finishes, but computed is briefly stale after a write, and readers would need a way to see that a rebuild is pending.
  • An incremental rebuild of only what a changed graph affects. It is the most work and does not remove the repeated cost.

Acceptance

  • k graph writes with the option, followed by one POST _recompute, perform exactly one rebuild (test)
  • Without the option, each write leaves computed coherent, as today
  • The option requires the same write authorization as the write
  • The rebuild log line includes its duration
  • The option is documented in docs/, with an upload example
After every successful graph write, `put_graph` in `src/routes/ingest.rs` calls `auto_recompute`, which clears the dataset's derived `computed` graph and re-derives it from all source graphs, to a fixpoint, before it replies. A client that writes n graphs in a row pays for n full rebuilds, and only the last one is useful. On a real upload of six graphs (schema 67 KB, kg 13.3 MB, labels 2.4 MB, wikidata 104 KB, cq 16 KB, doc), most of the time goes to these repeated rebuilds, not to loading. The cost grows with the dataset: the largest graph grew from about 57k to about 171k triples between two uploads. # Proposed change **Let a client defer the rebuild, then recompute once.** - `PUT`, `POST` and `DELETE` on `_graph` accept `?recompute=false`, or a request header such as `Concon-Recompute: defer`, which skips the automatic rebuild for that write. - The client calls the existing `POST _recompute` once after the last write. - Without the option, behaviour is unchanged: each write leaves `computed` coherent, so single-graph writes need nothing from the client. - The option needs the same write authorization as the write itself. Also log the rebuild's duration in the existing "recomputed derived graph" log line, so slow uploads can be diagnosed. **Alternatives considered:** - **A deferred, coalesced rebuild:** a write marks the dataset as needing a rebuild, and one background task rebuilds after a short quiet period. Writes return as soon as the load finishes, but `computed` is briefly stale after a write, and readers would need a way to see that a rebuild is pending. - **An incremental rebuild** of only what a changed graph affects. It is the most work and does not remove the repeated cost. # Acceptance - [ ] k graph writes with the option, followed by one `POST _recompute`, perform exactly one rebuild (test) - [ ] Without the option, each write leaves `computed` coherent, as today - [ ] The option requires the same write authorization as the write - [ ] The rebuild log line includes its duration - [ ] The option is documented in `docs/`, with an upload example
daniel self-assigned this 2026-10-26 08:32:55 +00:00
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
daniel/concon#16
No description provided.