Skip to content

Conversation

@Jefftree
Copy link
Member

@Jefftree Jefftree commented Aug 2, 2023

goos: linux
goarch: amd64
pkg: k8s.io/kube-openapi/pkg/spec3
cpu: Intel(R) Xeon(R) CPU @ 2.20GHz
                                               │  old1.txt   │              new1.txt              │
                                               │   sec/op    │   sec/op     vs base               │
OpenAPIV3Serialize/appsv1spec.json-24            30.60m ± 2%   12.41m ± 3%  -59.43% (p=0.002 n=6)
OpenAPIV3Serialize/authorizationv1spec.json-24   2.541m ± 1%   1.143m ± 1%  -55.04% (p=0.002 n=6)
geomean                                          8.818m        3.766m       -57.29%

                                               │   old1.txt    │              new1.txt               │
                                               │     B/op      │     B/op      vs base               │
OpenAPIV3Serialize/appsv1spec.json-24            10.586Mi ± 1%   5.175Mi ± 3%  -51.11% (p=0.002 n=6)
OpenAPIV3Serialize/authorizationv1spec.json-24    931.7Ki ± 0%   538.6Ki ± 0%  -42.19% (p=0.002 n=6)
geomean                                           3.103Mi        1.650Mi       -46.83%

                                               │  old1.txt   │              new1.txt              │
                                               │  allocs/op  │  allocs/op   vs base               │
OpenAPIV3Serialize/appsv1spec.json-24            34.00k ± 0%   20.03k ± 0%  -41.08% (p=0.002 n=6)
OpenAPIV3Serialize/authorizationv1spec.json-24   3.021k ± 0%   2.025k ± 0%  -32.96% (p=0.002 n=6)
geomean                                          10.13k        6.369k       -37.15%

Slightly less improvement than OpenAPI V2 which is somewhat expected because of the smaller size of OpenAPI V3.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Aug 2, 2023
@k8s-ci-robot k8s-ci-robot requested review from philips and sttts August 2, 2023 17:25
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Aug 2, 2023
@Jefftree Jefftree force-pushed the v3-marshal branch 3 times, most recently from d5518e9 to 5f7f131 Compare August 2, 2023 17:42
@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 2, 2023
@Jefftree
Copy link
Member Author

Jefftree commented Aug 2, 2023

/assign @apelisse
/cc @alexzielenski

Copy link
Member

@apelisse apelisse left a comment

Choose a reason for hiding this comment

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

Thanks,
I've compared this to the v2 versino of the same PR and looked at each individual comments I got on that other PR. I checked all the fields to make sure nothing was missing. Looks good to me, two minor questions/comments.

@apelisse
Copy link
Member

I'm personally good with this, lgtm & approve for me.
Anybody else wants to have a look @sttts @liggitt ?

@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Aug 11, 2023
Copy link
Member

@alexzielenski alexzielenski left a comment

Choose a reason for hiding this comment

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

mostly lgtm with few nits/questions

var x struct {
Ref string `json:"$ref,omitempty"`
spec.Extensions
ResponseProps `json:",inline"`
Copy link
Member

Choose a reason for hiding this comment

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

These extra structs caused by Refable and VendorExtensible make me sad but do not see a way around them without breaking changes to the type.

}
x.Ref = p.Refable.Ref.String()
x.Extensions = internal.SanitizeExtensions(p.Extensions)
x.ParameterProps = parameterPropsOmitZero(p.ParameterProps)
Copy link
Member

Choose a reason for hiding this comment

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

Could changing these parameterPropsOmitZero, operationsPropsOmitZero, etc. types to a pointer avoid a copy and boost performance at all?

Copy link
Member Author

Choose a reason for hiding this comment

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

I tried something like

    var x struct {
        Ref            string                 `json:"$ref,omitempty"`
+       ParameterProps *parameterPropsOmitZero `json:",inline"`
        spec.Extensions
    }
    ...
+   tmp := parameterPropsOmitZero(p.ParameterProps)
+   x.ParameterProps = &tmp
    ...

and performance numbers look identical. Is this what you mean by changing them to pointers?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, Jordan called out the same thing in my PR for V2, and I ran the same experiment :-)

Copy link
Member

@alexzielenski alexzielenski Aug 17, 2023

Choose a reason for hiding this comment

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

I meant using like this:

x.ParameterProps = (*parameterPropsOmitZero)(&p.ParameterProps)

In my other comment I had a toy example that seemed to compile at least. Doing the cast with the pointer this way may avoid a copy

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

| Name                                               | Before       | After        |
| (appsv1)OpenAPIV3Deserialize/jsonv2-24             | 13.68m ± 1%  | 13.65m ± 1%  |
| (authorizationv1)OpenAPIV3Deserialize/jsonv2#01-24 | 1.199m ± 1%  | 1.192m ± 2%  |
| (appsv1)OpenAPIV3Deserialize/jsonv2-24             | 5.260Mi ± 0% | 5.260Mi ± 0% |
| (authorizationv1)OpenAPIV3Deserialize/jsonv2#01-24 | 525.4Ki ± 0% | 525.4Ki ± 0% |
| (appsv1)OpenAPIV3Deserialize/jsonv2-24             | 26.89k ± 0%  | 26.89k ± 0%  |
| (authorizationv1)OpenAPIV3Deserialize/jsonv2#01-24 | 2.517k ± 0%  | 2.517k ± 0%  |

Copy link
Member

Choose a reason for hiding this comment

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

Yeah doesn’t seem to do anything

@apelisse
Copy link
Member

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 18, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: apelisse, Jefftree

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants