ExportXMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Unknown
    • 9.1.2
    • Affects Version/s: None
    • Component/s: Performance
    • None
    • None
    • Fully Compatible
    • Ruby Drivers
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?
    • None
    • None
    • None
    • None
    • None
    • None

      Mongoid resolves a field's stored name on every attribute read via `Mongoid::Fields.database_field_name`. For a key with no ".", it still runs `key.split('.', 2)` and dups the alias, allocating on a very hot path. Allocation profiling of a load-and-read cycle showed this method as the top source of new objects (~80% of allocations were Mongoid field handling, bson <1%).

      This is the same issue fixed for the matcher in PR #5868; `database_field_name` has the identical pattern and was not covered.

      Fix: short-circuit the no-"." case — return `aliased_fields[key] || key`. Measured ~11% fewer allocations per document.

      Benchmarked with https://gist.github.com/phedinkus/3a945c05818c88fc9b816124d01d3a64

            Assignee:
            Jamis Buck
            Reporter:
            Katie Miller (EXT)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: