Skip to content

util/interval/generic: avoid new allocations in btree benchmarks#44617

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
nvb:nvanbenschoten/intervalBtreeBench
Feb 3, 2020
Merged

util/interval/generic: avoid new allocations in btree benchmarks#44617
craig[bot] merged 1 commit intocockroachdb:masterfrom
nvb:nvanbenschoten/intervalBtreeBench

Conversation

@nvb
Copy link
Copy Markdown
Contributor

@nvb nvb commented Feb 1, 2020

The generic template for interval btree makes an attempt to work with
both value and pointer parameterized types. To facilitate this option
in tests, it used reflection to create new instances of the item type.
This reflection was preventing allocations of the item type from being
inlined and avoided by escape analysis, which was skewing benchmarks.

This commit fixes this by avoiding the reflection and instead adding
a constructor to the contract of the parameterized type. This is cleaner
and allows the allocations to be avoided in these benchmarks.

Here's the new benchdiff output of the latch manager's btree from
before #43850 to after this change: benchdiff sheet.

@nvb nvb requested a review from sumeerbhola February 1, 2020 02:08
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

Copy link
Copy Markdown
Collaborator

@petermattis petermattis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @sumeerbhola)

Copy link
Copy Markdown
Collaborator

@sumeerbhola sumeerbhola left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewable status: :shipit: complete! 2 of 0 LGTMs obtained (waiting on @sumeerbhola)

The generic template for interval btree makes an attempt to work with
both value and pointer parameterized types. To facilitate this option
in tests, it used reflection to create new instances of the item type.
This reflection was preventing allocations of the item type from being
inlined and avoided by escape analysis, which was skewing benchmarks.

This commit fixes this by avoiding the reflection and instead adding
a constructor to the contract of the parameterized type. This is cleaner
and allows the allocations to be avoided in these benchmarks.
@nvb nvb force-pushed the nvanbenschoten/intervalBtreeBench branch from fb6c093 to f80ed60 Compare February 2, 2020 22:40
@nvb
Copy link
Copy Markdown
Contributor Author

nvb commented Feb 3, 2020

bors r+

craig bot pushed a commit that referenced this pull request Feb 3, 2020
44617: util/interval/generic: avoid new allocations in btree benchmarks r=nvanbenschoten a=nvanbenschoten

The generic template for interval btree makes an attempt to work with
both value and pointer parameterized types. To facilitate this option
in tests, it used reflection to create new instances of the item type.
This reflection was preventing allocations of the item type from being
inlined and avoided by escape analysis, which was skewing benchmarks.

This commit fixes this by avoiding the reflection and instead adding
a constructor to the contract of the parameterized type. This is cleaner
and allows the allocations to be avoided in these benchmarks.

Here's the new `benchdiff` output of the latch manager's btree from
before #43850 to after this change: [benchdiff sheet](https://docs.google.com/spreadsheets/d/1ZxtPPSWV0z76msCiwIyqL0xnUQF530ZwnbnfrvEzNAE/edit#gid=4).

Co-authored-by: Nathan VanBenschoten <nvanbenschoten@gmail.com>
@craig
Copy link
Copy Markdown
Contributor

craig bot commented Feb 3, 2020

Build succeeded

@craig craig bot merged commit f80ed60 into cockroachdb:master Feb 3, 2020
@nvb nvb deleted the nvanbenschoten/intervalBtreeBench branch February 4, 2020 00:53
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.

4 participants