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

perf(plugin/prometheus): generate metrics string with string.buffer #11040

Merged
merged 13 commits into from Jun 13, 2023

Conversation

chronolaw
Copy link
Contributor

@chronolaw chronolaw commented Jun 9, 2023

Summary

This a performance improvement of #10949, using string.buffer to generate metrics string,
eliminate the cost of huge table.

KAG-1783

Checklist

Full changelog

  • remove table.new
  • introduce string.buffer
  • only do gsub for string value

Copy link
Member

@oowl oowl left a comment

Choose a reason for hiding this comment

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

LGTM

kong/plugins/prometheus/prometheus.lua Outdated Show resolved Hide resolved
kong/plugins/prometheus/prometheus.lua Outdated Show resolved Hide resolved
kong/plugins/prometheus/prometheus.lua Outdated Show resolved Hide resolved
kong/plugins/prometheus/prometheus.lua Outdated Show resolved Hide resolved
@chronolaw
Copy link
Contributor Author

chronolaw commented Jun 9, 2023

@oowl , could you do the same performance test for this PR again? thanks.

kong/plugins/prometheus/prometheus.lua Outdated Show resolved Hide resolved
kong/plugins/prometheus/prometheus.lua Outdated Show resolved Hide resolved
@bungle bungle force-pushed the perf/prometheus-exporter-with-string-buffer branch from 2269692 to 9d7568f Compare June 13, 2023 09:06
@bungle bungle merged commit 94a0c66 into master Jun 13, 2023
21 checks passed
@bungle bungle deleted the perf/prometheus-exporter-with-string-buffer branch June 13, 2023 09:28
windmgc pushed a commit that referenced this pull request Jun 25, 2023
…fer (#11065)

This PR follows #11040, continue to optimize the string usage by string.buffer.

KAG-1852

Full changelog

- use table.new for seen_metrics
- buffered_print() outputs a string, not a table
- change printable_metric_data of stream to fit the new buffered_print()
- do not use ipairs to iterate array
- other small optimizations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants