ValveSoftware / ValveSoftware/GameNetworkingSockets

Provide API to pool `CSteamNetworkingMessage`

Open
#369 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
C++
Stars
9.9k
Forks
749
Avg merge
1d 2h
Merged PRs (30d)
1

Description

It seems that CSteamNetworkingMessage doesn't pool messages.
This means that for each call to ISteamNetworkingUtils::AllocateMessage(), it dynamically allocates 264 bytes structure (on 64-bit environments).
This could be slow if you need to send loads of messages frequently.

I tried providing my own version of AllocateMessage() that allocates a message from my own pool, and initialize the CSteamNetworkingMessage properly.
But I realized you can't do that, because there's no way to initialize CSteamNetworkingMessage's private fields: m_links & m_linksSecondaryQueue
(Well, technically, I can just memset(msg, 0, 264) to initialize the hidden fields...
But not only that's UB, I can't tell if Steamworks SDK version of the message uses the same CSteamNetworkingMessage under the hood.)

It would be nice if there's an way to pool the message structure itself with the exposed m_pfnRelease,
like you can with m_pfnFreeData for the payloads.

Also, it would be great if you can also pool the message structure for the received messages too.

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 by reviewing src/steamnetworkingsockets/clientlib/steamnetworkingsockets_connections.cpp around CSteamNetworkingMessage, including AllocateMessage(), m_links, and m_linksSecondaryQueue. Trace the exposed m_pfnRelease and m_pfnFreeData APIs and consider how pooling should work for both allocated and received messages. Done means the API provides a supported way to reuse message structures without relying on private fields or layout assumptions.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
networking
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.