Skip to content

Match or exceed v1 performance#580

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

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

Conversation

@jhollinger
Copy link
Copy Markdown
Contributor

@jhollinger jhollinger commented Apr 16, 2026

After V1's recent perf improvements, V2's perf was no longer looking so good. These changes make V2 competitive again:

  • Stopped using the extension API for conditionals and default values. While cool, there was an optimization ceiling.
  • Fewer method calls and allocations during serialization (particularly when extensions aren't used).
  • Removed & simplified some extraneous features not present in V1. Allowed removal of lots of tests.

Perf varies with the number of fields, objects, and collections. It can also vary between the top-level serialization being a collection or object (collections are faster b/c some overhead is shared across loops). Use of extensions also caries some overhead (none were used in the measurements below).

# 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%

One thing we lost here is the ability to have extensions that are initialized per-render. I think it's possible to add again, but it will be more complicated, so IMHO we should wait until someone needs it.

Some other changes include:

  • Allow the fields DSL method to receive options and a block
  • Rename the field from option to source (reads better)
  • Allow around_blueprint_init to modify blueprint options and field details (previously it could only change field order or filter out fields)
  • 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 added 27 commits May 21, 2026 11:25
…rnal but prefix private fields with an "_"

Signed-off-by: Jordan Hollinger <jordan.hollinger@procore.com>
…lds`

Signed-off-by: Jordan Hollinger <jordan.hollinger@procore.com>
Signed-off-by: Jordan Hollinger <jordan.hollinger@procore.com>
Signed-off-by: Jordan Hollinger <jordan.hollinger@procore.com>
Will make if/unless/default/etc options Procs and field blocks behave more similarly to V1's. They can still access the Blueprint instance through `ctx`. Format blocks still use instance_exec, b/c otherwise they couldn't access the Blueprint. And that's new functionality so no compatibility concerns.

Signed-off-by: Jordan Hollinger <jordan.hollinger@procore.com>
Signed-off-by: Jordan Hollinger <jordan.hollinger@procore.com>
Signed-off-by: Jordan Hollinger <jordan.hollinger@procore.com>
…il after that hook runs

Signed-off-by: Jordan Hollinger <jordan.hollinger@procore.com>
…sn't make sense to allow classes or procs

Signed-off-by: Jordan Hollinger <jordan.hollinger@procore.com>
… place now

Signed-off-by: Jordan Hollinger <jordan.hollinger@procore.com>
…e time/memory)

Signed-off-by: Jordan Hollinger <jordan.hollinger@procore.com>
Signed-off-by: Jordan Hollinger <jordan.hollinger@procore.com>
…round_blueprint_init. Use a single field type for fields, objects, and collections.

Signed-off-by: Jordan Hollinger <jordan.hollinger@procore.com>
…tion for collections)

Signed-off-by: Jordan Hollinger <jordan.hollinger@procore.com>
…r inclusion is changed

Signed-off-by: Jordan Hollinger <jordan.hollinger@procore.com>
Signed-off-by: Jordan Hollinger <jordan.hollinger@procore.com>
…value as 2nd arg (so that ctx is always first arg)

Signed-off-by: Jordan Hollinger <jordan.hollinger@procore.com>
Signed-off-by: Jordan Hollinger <jordan.hollinger@procore.com>
Signed-off-by: Jordan Hollinger <jordan.hollinger@procore.com>
Signed-off-by: Jordan Hollinger <jordan.hollinger@procore.com>
Signed-off-by: Jordan Hollinger <jordan.hollinger@procore.com>
Signed-off-by: Jordan Hollinger <jordan.hollinger@procore.com>
Signed-off-by: Jordan Hollinger <jordan.hollinger@procore.com>
Signed-off-by: Jordan Hollinger <jordan.hollinger@procore.com>
…result hook to run, so that it's easier for other extensions to decorate the result before it's JSONified

Signed-off-by: Jordan Hollinger <jordan.hollinger@procore.com>
Signed-off-by: Jordan Hollinger <jordan.hollinger@procore.com>
…eprint's views from V2

Signed-off-by: Jordan Hollinger <jordan.hollinger@procore.com>
@jhollinger jhollinger force-pushed the jh/release-2.0-faster branch from 26deee8 to b5543f8 Compare May 21, 2026 15:31
…d Procs

Signed-off-by: Jordan Hollinger <jordan.hollinger@procore.com>
@jhollinger jhollinger force-pushed the jh/release-2.0-faster branch from b5543f8 to a5cf165 Compare May 22, 2026 20:22
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