Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache ReMappedLegacyTypes since we found threads spending time re-creating these under high load. #760

Merged
merged 3 commits into from
Jan 10, 2024

Conversation

LukeButters
Copy link
Contributor

@LukeButters LukeButters commented Jan 9, 2024

Background

While running simulations when deploying to 20k targets we found that process dumps would often show threads in

                             8 Octopus.Tentacle.Contracts.Legacy.ReMappedLegacyTypes..ctor(String[])
                             8 Octopus.Tentacle.Contracts.Legacy.NamespaceMappingSerializationBinderDecorator..ctor(ISerializationBinder, String, String)
                             8 Octopus.Tentacle.Contracts.Legacy.MessageSerializerBuilderExtensionMethods.AddLegacyContractSupportToJsonSerializer(JsonSerializerSettings)
                             8 Octopus.Tentacle.Contracts.Legacy.MessageSerializerBuilderExtensionMethods+<>c.<WithLegacyContractSupport>b__2_0(JsonSerializerSettings)
                             8 Halibut.Transport.Protocol.MessageSerializerBuilder+<>c__DisplayClass11_0.<Build>g__StreamCapturingSerializer|1()
                             8 Halibut.Transport.Protocol.MessageSerializer+<WriteMessageAsync>d__11<System.__Canon>.MoveNext()
                             8 System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start(<WriteMessageAsync>d__11<__Canon> ByRef)
                             8 Halibut.Transport.Protocol.MessageSerializer.WriteMessageAsync(Stream, __Canon, CancellationToken)
                       10 Halibut.Transport.Protocol.MessageExchangeStream+<SendAsync>d__41<System.__Canon>.MoveNext()

this PR fixes that by:

  • Making ReMappedLegacyTypes thread safe
  • Caching ReMappedLegacyTypes to be used across requests.

Fixes: https://github.com/OctopusDeploy/ResearchAndDevelopment/issues/665

[SC-67485]

How to review this PR

Quality ✔️

Pre-requisites

  • I have read How we use GitHub Issues for help deciding when and where it's appropriate to make an issue.
  • I have considered informing or consulting the right people, according to the ownership map.
  • I have considered appropriate testing for my change.

Copy link

@@ -34,7 +35,8 @@ internal ReMappedLegacyTypes(params string[] nameSpaces)
}
}

FullNameOfTypesToRemap = set;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hashset might be thread safe when used in read only, but immutable hashset is safer.

@LukeButters LukeButters marked this pull request as ready for review January 9, 2024 22:11
@LukeButters LukeButters requested a review from a team as a code owner January 9, 2024 22:11
@LukeButters LukeButters changed the title Cache ReMappedLegacyTypes Cache ReMappedLegacyTypes since we found threads spending time re-creating these under high load. Jan 9, 2024
@LukeButters LukeButters merged commit f9750c0 into main Jan 10, 2024
48 checks passed
@LukeButters LukeButters deleted the sast/cache-ReMappedLegacyTypes branch January 10, 2024 05:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants