Skip to content

Commit

Permalink
Changed status and object cache file serialization from JSON to Messa…
Browse files Browse the repository at this point in the history
…gePack; implemented StringBuilderPool to minimize allocations; various other bug fixes and perf/allocation improvements.
  • Loading branch information
ScottArbeit committed Dec 21, 2024
1 parent 4043124 commit 5c49ed0
Show file tree
Hide file tree
Showing 38 changed files with 1,352 additions and 694 deletions.
18 changes: 18 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Be more formal in the information presented, but not in addressing the user. Give longer, more comprehensive answers when answering questions, but not when performing tasks like writing code or generating text. Assume the user has a post-graduate level of education and is an experienced programmer.

When asked for help organizing a task, assume the user has inattentive-type ADHD and needs help breaking the task down into multiple, smaller steps. Use knowledge from CBT for ADHD as guidance and assist the user in getting started.

For questions about programming, assume the programming language is F#, unless told otherwise.
Code samples should be provided in F#, unless told otherwise.
All scripts should be generated in PowerShell unless told otherwise.
All F# code uses the `task { }` computation expression to handle asynchronous operations.
All F# code should be written in a functional style, using immutability and pure functions where possible.
All F# code should the new syntax when referring to arrays, lists, and sequences: use `myArray[0]` instead of `myArray.[0]`.

All code output should be complete, exhaustive, and full, and should be ready for copy/paste. Include comments in the code where appropriate, and informational logging of important variable values for any functions longer than ten lines.

Provide an English description of the generated code.

If task breakdown is requested for programming, generate discrete steps that could be placed on a Kanban board as separate tasks.

If you don't know the answer to a question, simply say "I don't know."
5 changes: 3 additions & 2 deletions src/CosmosSerializer/CosmosJsonSerializer.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
Expand All @@ -9,7 +9,8 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Azure.Core" Version="1.44.1" />
<PackageReference Include="Microsoft.Azure.Cosmos" Version="3.46.0-preview.2" />
<PackageReference Include="Ben.Demystifier" Version="0.4.1" />
<PackageReference Include="Microsoft.Azure.Cosmos" Version="3.46.0" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
Expand Down
2 changes: 1 addition & 1 deletion src/Grace.Actors/Branch.Actor.fs
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ module Branch =
return
Error(
GraceError.Create
$"{actorName} does not process reminder type {discriminatedUnionCaseName reminder.ReminderType}."
$"{actorName} does not process reminder type {getDiscriminatedUnionCaseName reminder.ReminderType}."
this.correlationId
)
}
Expand Down
5 changes: 0 additions & 5 deletions src/Grace.Actors/Context.Actor.fs
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,5 @@ module Context =
/// Setter for memory cache
let setMemoryCache (cache: IMemoryCache) = memoryCache <- cache

let mutable internal stringBuilderPool: ObjectPool<StringBuilder> = null

/// Setter for the string builder pool
let setStringBuilderPool (pool: ObjectPool<StringBuilder>) = stringBuilderPool <- pool

let mutable internal timings = ConcurrentDictionary<CorrelationId, List<Timing>>()
let setTimings (timing: ConcurrentDictionary<CorrelationId, List<Timing>>) = timings <- timing
2 changes: 1 addition & 1 deletion src/Grace.Actors/Diff.Actor.fs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ module Diff =
return
Error(
(GraceError.Create
$"{actorName} does not process reminder type {discriminatedUnionCaseName reminder.ReminderType}."
$"{actorName} does not process reminder type {getDiscriminatedUnionCaseName reminder.ReminderType}."
this.correlationId)
.enhance ("IsRetryable", "false")
)
Expand Down
2 changes: 1 addition & 1 deletion src/Grace.Actors/DirectoryVersion.Actor.fs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ module DirectoryVersion =
return
Error(
(GraceError.Create
$"{actorName} does not process reminder type {discriminatedUnionCaseName reminder.ReminderType}."
$"{actorName} does not process reminder type {getDiscriminatedUnionCaseName reminder.ReminderType}."
this.correlationId)
.enhance ("IsRetryable", "false")
)
Expand Down
7 changes: 4 additions & 3 deletions src/Grace.Actors/Grace.Actors.fsproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
Expand Down Expand Up @@ -50,10 +50,11 @@
<PackageReference Include="Azure.Storage.Blobs" Version="12.23.0" />
<PackageReference Include="Azure.Storage.Blobs.Batch" Version="12.20.0" />
<PackageReference Include="Azure.Storage.Common" Version="12.22.0" />
<PackageReference Include="Ben.Demystifier" Version="0.4.1" />
<PackageReference Include="Dapr.Actors" Version="1.14.0" />
<PackageReference Include="Dapr.Client" Version="1.14.0" />
<PackageReference Include="FSharpPlus" Version="1.6.1" />
<PackageReference Include="Microsoft.Azure.Cosmos" Version="3.46.0-preview.2" />
<PackageReference Include="FSharpPlus" Version="1.7.0" />
<PackageReference Include="Microsoft.Azure.Cosmos" Version="3.46.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="9.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Nito.AsyncEx" Version="5.1.2" />
Expand Down
2 changes: 1 addition & 1 deletion src/Grace.Actors/Organization.Actor.fs
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ module Organization =
return
Error(
GraceError.Create
$"{actorName} does not process reminder type {discriminatedUnionCaseName reminder.ReminderType}."
$"{actorName} does not process reminder type {getDiscriminatedUnionCaseName reminder.ReminderType}."
this.correlationId
)
}
Expand Down
2 changes: 1 addition & 1 deletion src/Grace.Actors/Owner.Actor.fs
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ module Owner =
return
Error(
GraceError.Create
$"{actorName} does not process reminder type {discriminatedUnionCaseName reminder.ReminderType}."
$"{actorName} does not process reminder type {getDiscriminatedUnionCaseName reminder.ReminderType}."
this.correlationId
)
}
Expand Down
6 changes: 3 additions & 3 deletions src/Grace.Actors/Reference.Actor.fs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ module Reference =
return
Error(
(GraceError.Create
$"{actorName} does not process reminder type {discriminatedUnionCaseName reminder.ReminderType}."
$"{actorName} does not process reminder type {getDiscriminatedUnionCaseName reminder.ReminderType}."
this.correlationId)
.enhance ("IsRetryable", "false")
)
Expand Down Expand Up @@ -305,7 +305,7 @@ module Reference =
.enhance(nameof (BranchId), $"{referenceDto.BranchId}")
.enhance(nameof (ReferenceId), $"{referenceDto.ReferenceId}")
.enhance(nameof (DirectoryVersionId), $"{referenceDto.DirectoryId}")
.enhance(nameof (ReferenceType), $"{discriminatedUnionCaseName referenceDto.ReferenceType}")
.enhance(nameof (ReferenceType), $"{getDiscriminatedUnionCaseName referenceDto.ReferenceType}")
.enhance (nameof (ReferenceEventType), $"{getDiscriminatedUnionFullName referenceEvent.Event}")

return Ok graceReturnValue
Expand All @@ -319,7 +319,7 @@ module Reference =
.enhance(nameof (BranchId), $"{referenceDto.BranchId}")
.enhance(nameof (ReferenceId), $"{referenceDto.ReferenceId}")
.enhance(nameof (DirectoryVersionId), $"{referenceDto.DirectoryId}")
.enhance(nameof (ReferenceType), $"{discriminatedUnionCaseName referenceDto.ReferenceType}")
.enhance(nameof (ReferenceType), $"{getDiscriminatedUnionCaseName referenceDto.ReferenceType}")
.enhance (nameof (ReferenceEventType), $"{getDiscriminatedUnionFullName referenceEvent.Event}")

return Error graceError
Expand Down
2 changes: 1 addition & 1 deletion src/Grace.Actors/Repository.Actor.fs
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ module Repository =
return
Error(
GraceError.Create
$"{actorName} does not process reminder type {discriminatedUnionCaseName reminder.ReminderType}."
$"{actorName} does not process reminder type {getDiscriminatedUnionCaseName reminder.ReminderType}."
this.correlationId
)
}
Expand Down
Loading

0 comments on commit 5c49ed0

Please sign in to comment.