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

Simplify Map.Render() #3135

Merged
merged 4 commits into from
Apr 10, 2018
Merged

Simplify Map.Render() #3135

merged 4 commits into from
Apr 10, 2018

Conversation

bboreham
Copy link
Collaborator

@bboreham bboreham commented Apr 9, 2018

Make all MapFuncs return a single Node instead of a set.

This lets us save a bit of time by not creating all those maps, and re-integrate the adjacency mapping code that was split out into joinResults.

Benchmarks, using a set of reports from Weave Cloud - the timings are a bit mixed but bytes and allocations are generally in the right direction:

benchmark                            old ns/op      new ns/op      delta
BenchmarkReportUnmarshal-2           1355945521     1327087556     -2.13%
BenchmarkReportUpgrade-2             70184976       69354449       -1.18%
BenchmarkReportMerge-2               878730403      921976801      +4.92%
BenchmarkRenderList-2                561471520      563783165      +0.41%
BenchmarkRenderHosts-2               403998863      413859127      +2.44%
BenchmarkRenderControllers-2         337145280      350440707      +3.94%
BenchmarkRenderPods-2                324643559      311958921      -3.91%
BenchmarkRenderContainers-2          205667797      191406825      -6.93%
BenchmarkRenderProcesses-2           122603018      125965319      +2.74%
BenchmarkRenderProcessNames-2        147378216      140242434      -4.84%
BenchmarkSummarizeHosts-2            150408         149442         -0.64%
BenchmarkSummarizeControllers-2      818615         815577         -0.37%
BenchmarkSummarizePods-2             2529781        2434542        -3.76%
BenchmarkSummarizeContainers-2       52026615       43669700       -16.06%
BenchmarkSummarizeProcesses-2        57518841       56164831       -2.35%
BenchmarkSummarizeProcessNames-2     585876         647129         +10.45%
BenchmarkSmartMerger-2               36967279       36809862       -0.43%
BenchmarkDumbMerger-2                369488313      388092696      +5.04%

benchmark                            old allocs     new allocs     delta
BenchmarkReportUnmarshal-2           2631054        2631052        -0.00%
BenchmarkReportUpgrade-2             24845          24804          -0.17%
BenchmarkReportMerge-2               1709529        1734064        +1.44%
BenchmarkRenderList-2                797837         765970         -3.99%
BenchmarkRenderHosts-2               603998         581912         -3.66%
BenchmarkRenderControllers-2         429361         405592         -5.54%
BenchmarkRenderPods-2                383985         364901         -4.97%
BenchmarkRenderContainers-2          253973         236530         -6.87%
BenchmarkRenderProcesses-2           119581         119582         +0.00%
BenchmarkRenderProcessNames-2        164271         163203         -0.65%
BenchmarkSummarizeHosts-2            246            246            +0.00%
BenchmarkSummarizeControllers-2      1821           1821           +0.00%
BenchmarkSummarizePods-2             7081           7081           +0.00%
BenchmarkSummarizeContainers-2       80308          80309          +0.00%
BenchmarkSummarizeProcesses-2        69815          69815          +0.00%
BenchmarkSummarizeProcessNames-2     1674           1674           +0.00%
BenchmarkSmartMerger-2               107931         109682         +1.62%
BenchmarkDumbMerger-2                571237         571248         +0.00%

benchmark                            old bytes     new bytes     delta
BenchmarkReportUnmarshal-2           427341952     427345056     +0.00%
BenchmarkReportUpgrade-2             5255060       5255462       +0.01%
BenchmarkReportMerge-2               339534452     344383964     +1.43%
BenchmarkRenderList-2                91196588      85036244      -6.76%
BenchmarkRenderHosts-2               65665560      61840421      -5.83%
BenchmarkRenderControllers-2         47093261      43204658      -8.26%
BenchmarkRenderPods-2                41887292      38614284      -7.81%
BenchmarkRenderContainers-2          28809066      26086785      -9.45%
BenchmarkRenderProcesses-2           13984302      13983102      -0.01%
BenchmarkRenderProcessNames-2        18026190      17906446      -0.66%
BenchmarkSummarizeHosts-2            35020         35016         -0.01%
BenchmarkSummarizeControllers-2      183358        183362        +0.00%
BenchmarkSummarizePods-2             650411        650386        -0.00%
BenchmarkSummarizeContainers-2       10504803      10505320      +0.00%
BenchmarkSummarizeProcesses-2        7626475       7626508       +0.00%
BenchmarkSummarizeProcessNames-2     131706        131705        -0.00%
BenchmarkSmartMerger-2               29837290      30311163      +1.59%
BenchmarkDumbMerger-2                155934731     155937024     +0.00%

bboreham added 3 commits April 9, 2018 13:16
This is the last MapFunc which returns multiple Nodes, so by turning
it into a Renderer we open the door to simplifing every other MapFunc.
Save time creating a map for the results which contains at most one entry
joinResults grew out of a special case of Map.Render(), so now we
merge the two lines back together and have just one way to accumulate
results and remap adjacencies.
render/render.go Outdated
// If the output is empty, the node shall be omitted from the rendered topology.
type MapFunc func(report.Node) report.Nodes
// If the output ID is blank, the node shall be omitted from the rendered topology.
type MapFunc func(report.Node) report.Node

This comment was marked as abuse.

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