Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass pointer to schema to (*Spec).analyzeSchema instead of copying #54

Merged
merged 1 commit into from
Feb 27, 2020
Merged

Pass pointer to schema to (*Spec).analyzeSchema instead of copying #54

merged 1 commit into from
Feb 27, 2020

Conversation

tklauser
Copy link
Contributor

This allows to reduce the memory consumption during loads.Analyzed
significantly.

before:

 2076.76kB 21.23% 21.23%  2076.76kB 21.23%  github.com/go-openapi/analysis.(*Spec).reset
 1024.06kB 10.47% 57.11%  1024.06kB 10.47%  github.com/go-openapi/analysis.(*Spec).analyzeSchema

after (analyzeSchema doesn't even show up in the memory profile anymore):

 1034.66kB 15.31% 15.31%  1034.66kB 15.31%  github.com/go-openapi/analysis.(*Spec).reset

Signed-off-by: Tobias Klauser tklauser@distanz.ch

This allows to reduce the memory consumption during loads.Analyzed
significantly.

before:

```
 2076.76kB 21.23% 21.23%  2076.76kB 21.23%  github.com/go-openapi/analysis.(*Spec).reset
 1024.06kB 10.47% 57.11%  1024.06kB 10.47%  github.com/go-openapi/analysis.(*Spec).analyzeSchema
```

after (analyzeSchema doesn't even show up in the memory profile anymore):

```
 1034.66kB 15.31% 15.31%  1034.66kB 15.31%  github.com/go-openapi/analysis.(*Spec).reset
```

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
@codecov
Copy link

codecov bot commented Feb 26, 2020

Codecov Report

Merging #54 into master will increase coverage by 0.03%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #54      +/-   ##
==========================================
+ Coverage   92.23%   92.27%   +0.03%     
==========================================
  Files           7        7              
  Lines        1817     1825       +8     
==========================================
+ Hits         1676     1684       +8     
  Misses         90       90              
  Partials       51       51              

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 01a3bda...dbc4182. Read the comment docs.

@casualjim
Copy link
Member

We are copying so that modifications to elements in the analyzed schema don't show up in the spec.
But there are other ways to work around that too. I'll merge the PR and watch for unintended consequences of this.

@casualjim casualjim merged commit 2f85fce into go-openapi:master Feb 27, 2020
@tklauser tklauser deleted the analyze-pass-pointer-to-schema branch February 27, 2020 10:48
tklauser added a commit to cilium/cilium that referenced this pull request Feb 27, 2020
This will pull in memory usage improvements from go-openapi/analysis#54

Updates #10056

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
aanm pushed a commit to cilium/cilium that referenced this pull request Feb 27, 2020
This will pull in memory usage improvements from go-openapi/analysis#54

Updates #10056

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
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.

None yet

2 participants