Skip to content

[C++] Unnecessary overhead added with precedence checks #1032

Closed
@szymonwieloch

Description

@szymonwieloch

When you enable precedence checks (sbe.enable.precedence.checks=true), the generated code is supposed to be managed using the SBE_ENABLE_PRECEDENCE_CHECKS macro. The expectation is that with this flag enabled, precedence check should be enabled and with this flag NOT enabled there should be no overhead and the code should be usable in production. However upon inspection it seems that the code does have some overhead also when the macro is disabled. For example the m_codeState and corresponding pointers in the group wrappers do add some overhead. Currently user has three different options of code generation:

  1. sbe.enable.precedence.checks=false - the "standard" version without any overhead and no checks
  2. sbe.enable.precedence.checks=true and the SBE_ENABLE_PRECEDENCE_CHECKS macro enabled - debug only version with checks and significant overhead
  3. sbe.enable.precedence.checks=true and the SBE_ENABLE_PRECEDENCE_CHECKS macro disabled - quite a pointless version with zero checks but some overhead caused by adding more variables.

I can see two ways to solve this situation - either drop the SBE_ENABLE_PRECEDENCE_CHECKS macro and with the sbe.enable.precedence.checks=true flag generate code that always does precedence checks (should simplify the generated code) or polish the generated code not to have any overhead with the SBE_ENABLE_PRECEDENCE_CHECKS macro enabled. The second approach seems more complicated but also much more consistent with what other language generators do.

Activity

nbradac

nbradac commented on Dec 13, 2024

@nbradac
Contributor

This PR (#1036) has been merged to address this issue. The m_codecStatePtr won't exist when SBE_ENABLE_PRECEDENCE_CHECKS isn't set.

Are there other places where the precedence checks are adding overhead that you (@szymonwieloch) can see?

szymonwieloch

szymonwieloch commented on Dec 21, 2024

@szymonwieloch
Author

Hi. Thank you for fixing it. For now I can't see anything else that requires fixing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      [C++] Unnecessary overhead added with precedence checks · Issue #1032 · aeron-io/simple-binary-encoding