Skip to content

Performance regression: 2.7x slower since v0.10.0 #562

@rafafloresta

Description

@rafafloresta

Summary

Benchmarking revealed a significant performance regression in Blueprinter since v0.10.0:

Metric v0.10.0 v1.2.1 (current) Change
Speed (i/s) 5.16 1.92 2.7x slower
Memory 26.7 MB 112 MB 4.2x more

Benchmark Results

Speed (iterations/second, higher is better)

v0.10.0:

               panko:       10.6 i/s
             as_json:        9.9 i/s
        fast_jsonapi:        4.4 i/s - 2.42x slower
         blueprinter:        3.2 i/s - 3.33x slower

v1.2.1 (current):

               panko:        7.9 i/s
             as_json:        7.4 i/s - 1.08x slower
        fast_jsonapi:        4.7 i/s - 1.69x slower
         blueprinter:        1.5 i/s - 5.40x slower

Memory (allocated bytes, lower is better)

v0.10.0:

         blueprinter:   26.7 MB allocated - 1.16x more than as_json

v1.2.1 (current):

         blueprinter:  112.0 MB allocated - 4.86x more than as_json

Bisect Results

The regression is cumulative across multiple commits:

Commit Description i/s vs v0.10.0
v0.10.0 Baseline 5.16 1.0x
0bea7cb Add reflection/extensions 3.76 1.4x slower
0acf5d1 Fix default_transformers 3.06 1.7x slower
795953b Fallback on :default 2.75 1.9x slower
e39f3c8 Extract rendering 2.23 2.3x slower
main Current 1.92 2.7x slower

Key commits contributing to regression:

  1. 0acf5d1 - "Fix handling of configured default_transformers" (Dec 2023)

    • Added .concat().uniq operations in transformer gathering
  2. e39f3c8 - "[refactor] Extract rendering functionality and cleanup code" (Oct 2024)

    • Major refactor extracting rendering logic

Benchmark Setup

  • Ruby: 3.3.9
  • Objects: 10,000 Issue objects with nested User and Labels (2-4 labels each)
  • Tools: benchmark-ips, benchmark-memory

Reference

Based on Issue #113 benchmark by @tjwallace.

Metadata

Metadata

Assignees

Labels

bugAn issue with the system

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions