NAME

Protobuf::Internal - Internal XS functions and utilities

VERSION

version 0.04

SYNOPSIS

use Protobuf::Internal;

# Typically, the functions here are called by other Protobuf modules
# and not directly by end users.

DESCRIPTION

This module serves as the primary interface to the C/XS layer for the Protobuf distribution. It uses XSLoader to load functions implemented in C, which interact directly with the upb library.

Key functionalities provided through this module include:

  • Initializing the per-interpreter registry (init_registry).

  • Accessing and managing the object cache (get_obj_cache, set_cache_capacity).

  • Retrieving cache audit logs and contention statistics (get_cache_audit_log, get_contention_stats).

  • Core type conversion functions between Perl SVs and upb types.

METHODS

Most functions in this module are not intended for public use. The following are called during initialization:

init_registry()

Called once when Protobuf is loaded to initialize the per-interpreter C-level registry, which holds the object cache, audit log, and other global states for the current Perl interpreter.

INTERNAL XS FUNCTIONS

The following functions are exposed from the XS layer but are for internal use by other Protobuf::* modules only:

  • class_name_to_full_name

  • clear_cache

  • delete_cache_entry

  • delete_cache_ptr

  • find_by_fingerprint

  • full_name_to_class_name

  • get_cache_audit_log

  • get_cache_capacity

  • get_contention_stats

  • get_cpu_features

  • get_fingerprint

  • preallocate_arena

  • register_fingerprint

  • set_cache_capacity

  • set_chaos_enabled

  • set_chaos_params

  • class_name_to_full_name

    Converts a Perl class name (e.g., My::Package::Message) to a fully qualified protobuf message name (e.g., my.package.Message).

  • clear_cache

    Clears the internal object cache.

  • delete_cache_entry

    Deletes a specific entry from the object cache.

  • delete_cache_ptr

    Deletes a cache entry based on a pointer.

  • find_by_fingerprint

    Finds an object in the cache by its fingerprint.

  • full_name_to_class_name

    Converts a fully qualified protobuf message name to a Perl class name.

  • get_cache_audit_log

    Retrieves the cache audit log.

  • get_cache_capacity

    Gets the current capacity of the object cache.

  • get_contention_stats

    Retrieves cache contention statistics.

  • get_cpu_features

    Detects CPU features relevant to upb.

  • get_fingerprint

    Gets the fingerprint for a given object.

  • preallocate_arena

    Preallocates memory within an arena.

  • register_fingerprint

    Registers an object's fingerprint in the cache.

  • set_cache_capacity

    Sets the capacity of the object cache.

  • set_chaos_enabled

    Enables or disables chaos testing features.

  • set_chaos_params

    Sets parameters for chaos testing.

  • verify_binary_diff

    Verifies binary differences between messages.

SEE ALSO

Protobuf

AUTHOR

C.J. Collier <cjac@google.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2026 by Google LLC.

This is free software; you can redistribute it and/or modify it under the terms of the BSD 3-Clause License.