Skip to content

Use one hash lookup for successful dynamic-field reads #197

Closed

Description

@dimensionscape

Both FieldMapGet overloads in src/hx/Anon.cpp check __string_hash_exists and then call __string_hash_get for successful reads. This performs two hash calculations and two chain searches for the same key.

These helpers are used by the generated dynamic-field macros in include/hx/Macros.h and MacrosFixed.h, cppia field reads and toString lookup. This is distinct from the compiler-side fixed anonymous-field lookup path.

I ran a focused native probe against checkout 03a4e8d on Linux x86_64 through WSL, Haxe 4.3.3, HXCPP_M64 and hxcpp_smart_strings. A FieldMap held 256 fields; two million successful reads cycled through their keys.

  • FieldMapGet: 29.762 ms.
  • Control calling the same backing HashBase::query(key, outValue) once: 13.908 ms.
  • Both produced checksum 254991808.

This is a single local comparison, not an application-wide speedup. It also includes the difference in helper dispatch, so do not attribute the whole timing difference solely to hashing.

Add or use a single-query helper that returns both presence and the stored Dynamic value. Preserve the distinction between an absent field and a present field containing null. The existing query method already has that contract. Preserve the current outValue behavior on misses too.

Test string-name and field-ID overloads, present null, missing keys, non-ASCII names, collisions and fields added after construction. Measure mixed hit/miss workloads and generated dynamic-class reads, not only the internal helper. This should reduce repeated work without changing table layout or GC policy.

Related: #151 for repeatable benchmark coverage.

Activity

  1. added a commit that references this issue on Oct 20, 2026
    1a20fe1
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