performance optimization#139
Conversation
- adapted Backend CreateTaskHub and DeleteTaskHub to call Start and Stop methods instead of directly manage backend database
…ods-implementation - implemented Backend Start and Stop methods
…s not nil and handle error from Stop method if it happens
refactoring for sqliteBackend.DeleteTaskHub just to delete db if db is not nil and handle error from Stop method if it happens
… hub method for sqlite backend
There was a problem hiding this comment.
Pull request overview
This PR updates Durable Task Go to use time-ordered UUIDv7s and applies a few Postgres-specific changes intended to improve throughput and query performance during orchestration event and activity task processing.
Changes:
- Bumps
github.com/google/uuidto v1.6.0 and switches multiple ID generation sites to UUIDv7. - Adds a Postgres index for
Instances.ParentInstanceIDand adjusts dequeue/locking queries. - Refactors Postgres orchestration work-item retrieval to reduce time spent inside the transaction (by unmarshalling after commit).
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| samples/parallel/parallel.go | Uses UUIDv7 for sample device IDs. |
| internal/helpers/worker.go | Prefers UUIDv7 for default worker name uniqueness. |
| internal/helpers/history.go | Uses UUIDv7 for ExecutionId in execution-started events (with fallback). |
| go.mod | Updates github.com/google/uuid to v1.6.0. |
| go.sum | Adds v1.6.0 checksums for github.com/google/uuid. |
| client/client_grpc.go | Uses UUIDv7 for autogenerated orchestration instance IDs. |
| backend/postgres/schema.sql | Adds an index on Instances(ParentInstanceID). |
| backend/postgres/postgres.go | Updates worker name UUID, changes dequeue ordering, and refactors orchestration work-item event handling/commit timing. |
| backend/client.go | Uses UUIDv7 for autogenerated orchestration instance IDs. |
Comments suppressed due to low confidence (1)
backend/client.go:53
- This introduces a new failure mode (UUID generation can now fail the entire scheduling call). Previously this path always generated an ID; consider falling back to
uuid.NewString()on error to preserve robustness while still preferring v7 when available.
u, err := uuid.NewV7()
if err != nil {
return api.EmptyInstanceID, fmt.Errorf("failed to generate instance ID: %w", err)
}
req.InstanceId = u.String()
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
@cgillum , please approve those changes for performance improvements |
|
Hi @mrjmarcelo - thanks for opening up this PR. I've reviewed it briefly and I'm good with these changes in principle. I've triggered the CI automation just now. Please take a look at the Copilot generated comments and reply back once this is ready for a final human review. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
| evt, err := backend.UnmarshalHistoryEvent(e.payload) | ||
| if err != nil { | ||
| return nil, err | ||
| } |
| defer events.Close() | ||
|
|
this includes changes mainly from @jeanmartins for performance optimization on events and tasks processing in durable task go.