Skip to content

Match or exceed v1 performance - #580

Open
jhollinger wants to merge 54 commits into
release-2.0from
jh/release-2.0-faster
Open

Match or exceed v1 performance#580
jhollinger wants to merge 54 commits into
release-2.0from
jh/release-2.0-faster

Conversation

@jhollinger

@jhollinger jhollinger commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

After V1's recent perf improvements, V2 wasn't looking so great. These changes make V2 competitive again:

# Collection results (20 fields, 5 objects, 2 collections)
1,000 widgets 100x: V2 change: -59.72%
500 widgets 100x: V2 change: -60.23%
250 widgets 100x: V2 change: -60.50%
100 widgets 100x: V2 change: -61.48%
25 widgets 100x: V2 change: -62.42%
5 widgets 100x:  V2 change: -60.14%
1 widgets 100x:  V2 change: -54.12%

# Object results (20 fields, 5 objects, 2 collections)
1,000 widgets 100x: V2 change: -32.68%
500 widgets 100x: V2 change: -33.49%
250 widgets 100x: V2 change: -32.39%
100 widgets 100x: V2 change: -35.35%
25 widgets 100x: V2 change: -36.85%
5 widgets 100x:  V2 change: -54.16%
1 widgets 100x:  V2 change: -52.25%

Some major changes include:

  • The DSL now builds what is essentially an AST that's evaluated on first render or reflection. Among other things, this allows use to behave like a macro within the DSL.
  • The ability to use the DSL in Ruby modules, then include them in Bluerprints/views.
  • around_blueprint_init can now modify blueprint options and field details.
  • Lots of "legacy" extensions to ease the transition. Covers legacy if/unless options, extractors, transformers, dynamic options, and more.
  • Documentation branch: jh/release-2.0-docs

@jhollinger
jhollinger force-pushed the jh/release-2.0-faster branch 4 times, most recently from cf26f1a to 43f7db0 Compare April 16, 2026 19:21
@jhollinger jhollinger closed this Apr 18, 2026
@jhollinger jhollinger reopened this Apr 18, 2026
@jhollinger jhollinger changed the title Match v1 performance Match or exceed v1 performance Apr 18, 2026
@jhollinger
jhollinger force-pushed the jh/release-2.0-faster branch 18 times, most recently from 98b34e4 to 5841499 Compare April 22, 2026 20:18
@jhollinger
jhollinger marked this pull request as ready for review April 22, 2026 20:27
@jhollinger
jhollinger requested review from a team and ritikesh as code owners April 22, 2026 20:27
@jhollinger
jhollinger force-pushed the jh/release-2.0-faster branch from e83ea61 to b3d8412 Compare April 24, 2026 20:48
@jhollinger
jhollinger force-pushed the jh/release-2.0-faster branch from a5cf165 to c065be7 Compare May 26, 2026 19:20
@jhollinger
jhollinger force-pushed the jh/release-2.0-faster branch 7 times, most recently from b9d79a6 to 2dc9670 Compare June 2, 2026 14:53
- No longer need `use!` since `use` is now positional.
- The DSL now builds a series of nodes which are evaled later.
- Replace `view`'s `empty` arg with the `exclude_all` DSL method.
- Options and extensions are now blocks (so they can interact properly with other DSL nodes)

Signed-off-by: Jordan Hollinger <[email protected]>
…artials can be inherited

Signed-off-by: Jordan Hollinger <[email protected]>
@jhollinger
jhollinger force-pushed the jh/release-2.0-faster branch from 2dc9670 to 6e5c009 Compare June 3, 2026 14:11
jhollinger added 11 commits June 3, 2026 10:22
…ir own views in associations (without using a Proc).

Signed-off-by: Jordan Hollinger <[email protected]>
Signed-off-by: Jordan Hollinger <[email protected]>
…d/missing partials.

Helpful because the `use` could be located in a parent Blueprint, parent view, or a nested `use`.

Signed-off-by: Jordan Hollinger <[email protected]>
…ents from partials.

`exclude` now only works on inheritance. `use` has its own exclusion arguments.

Signed-off-by: Jordan Hollinger <[email protected]>
@jhollinger

jhollinger commented Jun 24, 2026

Copy link
Copy Markdown
Contributor Author

@lessthanjacob This PR has really ballooned, so here are some notes:

  1. Speed changes are largely isolated to serializer.rb, field_serializers.rb, and hooks.rb.
  2. Changes in v2/base.rb, dsl.rb, and specification.rb (new) are largely about making the DSL build a sort of AST. This helped fix some edge cases and opened up some cool possibilities (i.e. modules).
  3. Quite a few "legacy compatibility" extensions have been added under lib/blueprinter/extensions. Will help people (and agents) simplify upgrades.

Signed-off-by: Jordan Hollinger <[email protected]>
…ey can be included by Blueprints.

Signed-off-by: Jordan Hollinger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants