Skip to content

Conversation

LukeButters
Copy link
Contributor

@LukeButters LukeButters commented Sep 12, 2025

Background

We would re-register the types each time the serializer was built, since that is built with this lambda each time we serialise or deserialize a message:

image

With these changes we just register the types once, rather than over and over again.

This as a hot spot was somehow found with a profiler.

With this change we instead call register once for the Request and Response types rather than each time we serialise or deserialise a message (including in and out of the queue). This should have no impact other than improving performance.

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.

@LukeButters LukeButters force-pushed the luke/perf-msg-serializer branch from 8c95dd0 to 296247c Compare September 12, 2025 04:13
@LukeButters LukeButters changed the title Faster serialization Don't call RegisterType twice for each RPC and with the redis queue it was 4 times! Sep 12, 2025
@LukeButters LukeButters marked this pull request as ready for review September 12, 2025 04:19
@LukeButters LukeButters requested a review from a team as a code owner September 12, 2025 04:19
Copy link
Contributor

@rhysparry rhysparry left a comment

Choose a reason for hiding this comment

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

A couple of nits. The typo in the method name being actually somewhat important.

AddProtocolTupesToTypeRegistry(this.typeRegistry);
}

public static void AddProtocolTupesToTypeRegistry(ITypeRegistry typeRegistry)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: should be AddProtocolTypesToTypeRegistry (i.e. Types not Tupes)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🤦 sorry yes how did i miss that.


public static void AddProtocolTupesToTypeRegistry(ITypeRegistry typeRegistry)
{
foreach (var protocolType in protocolTypes) typeRegistry.RegisterType(protocolType, protocolType.Name, true);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: if we're moving this anyway, let's format it with curly braces across multiple lines.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

@LukeButters LukeButters enabled auto-merge (squash) September 14, 2025 22:29
@LukeButters LukeButters merged commit f9e3028 into main Sep 14, 2025
17 checks passed
@LukeButters LukeButters deleted the luke/perf-msg-serializer branch September 14, 2025 22:55
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