microsoft / microsoft/durabletask-dotnet

Performance: reduce per-call SHA1 allocation for deterministic orchestration GUIDs

Open
#778 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Needs: Triage :mag:
Dominant language
C#
Stars
193
Forks
60
Avg merge
3d 12h
Merged PRs (30d)
4

Description

1. What is the issue?

Each call to the deterministic orchestration NewGuid() implementation creates and disposes a new SHA1 HashAlgorithm instance.

2. Likely priority

Low. It affects orchestrations that use context.NewGuid() frequently, including some entity correlation paths, but other per-call allocations are likely larger.

3. Impact on performance

Repeated hash-algorithm construction adds allocation and disposal overhead during orchestration replay. The cost scales with the number of deterministic GUIDs generated per execution.

4. Details and code reference

Deterministic GUID implementation:

https://github.com/microsoft/durabletask-dotnet/blob/883211a3a7ab0b55bb90b9c9e498148e4d65ead9/src/Worker/Core/Shims/TaskOrchestrationContextWrapper.cs#L403-L458

SHA1 creation is here:

https://github.com/microsoft/durabletask-dotnet/blob/883211a3a7ab0b55bb90b9c9e498148e4d65ead9/src/Worker/Core/Shims/TaskOrchestrationContextWrapper.cs#L437-L446

5. Guidance for how to fix

Treat this as replay-compatibility-sensitive. Any reuse or replacement must produce byte-for-byte identical GUIDs for existing instance ID, timestamp, and counter inputs across supported target frameworks. Prefer an isolated optimization with deterministic-value regression tests before and after the change; do not change the namespace, hash input, byte ordering, SHA1 algorithm, or version-bit handling.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/Worker/Core/Shims/TaskOrchestrationContextWrapper.cs, especially the deterministic GUID implementation and SHA1 creation around lines 403-458. Compare the current behavior across supported target frameworks and add or run deterministic-value regression tests. Done means reducing the per-call allocation while preserving byte-for-byte identical GUIDs, including namespace, hash input, byte ordering, SHA1, and version bits.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend, performance
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.