Skip to content

Logs performance benchmarks#115358

Merged
k8s-ci-robot merged 5 commits into
kubernetes:masterfrom
pohly:logs-performance-benchmarks
Mar 7, 2023
Merged

Logs performance benchmarks#115358
k8s-ci-robot merged 5 commits into
kubernetes:masterfrom
pohly:logs-performance-benchmarks

Conversation

@pohly

@pohly pohly commented Jan 27, 2023

Copy link
Copy Markdown
Contributor

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

Improves usability and realism of the performance tests for logging.

Does this PR introduce a user-facing change?

NONE

/assign @serathius

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. area/test sig/instrumentation Categorizes an issue or PR as relevant to SIG Instrumentation. sig/testing Categorizes an issue or PR as relevant to SIG Testing. wg/structured-logging Categorizes an issue or PR as relevant to WG Structured Logging. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Jan 27, 2023
@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 27, 2023
@pohly pohly mentioned this pull request Jan 27, 2023
@pohly

pohly commented Jan 27, 2023

Copy link
Copy Markdown
Contributor Author

@serathius wrote in #115277 (comment):

Overall benchmark changes makes sense for me, however I'm not sure why we need the symlink magic. Could you explain more about why you added it?

With the directories set up like this, running benchmarks against some log files from the CI only need a single command as setup (the gsutil mentioned in the updated README). I could keep the symlinks out of the commit, but creating them or moving files is complicated enough that I then would have to add a script instead that users need to invoke - I don't think that this will be simpler.

Without any symlinks, the same file would have to be replicated in different places (once for each verbosity level).

@pohly

pohly commented Jan 27, 2023

Copy link
Copy Markdown
Contributor Author

Hmm, I had forgotten about the additional mangling of the files. Perhaps a script is better after all.

@pohly pohly force-pushed the logs-performance-benchmarks branch from a2caa47 to 037aba8 Compare January 27, 2023 14:38
@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 Jan 27, 2023

@serathius serathius Jan 27, 2023

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why ln -s and not mv? What's the benefit of using symlinks here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The same file gets referenced in two different directories and then serves as input for different test cases (default log level and v 3). I could copy it, but that seems wasteful.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@serathius: I've added some comments to the script about this and also completed the support for running the script multiple times (would have failed when symlinks already exist).

@pohly pohly force-pushed the logs-performance-benchmarks branch from 037aba8 to 6d69ee9 Compare January 28, 2023 13:05
@pohly

pohly commented Jan 28, 2023

Copy link
Copy Markdown
Contributor Author

/retest

@serathius

serathius commented Jan 30, 2023

Copy link
Copy Markdown
Contributor

Not super convinced on necessity of symlinks in repo. Would love some second opinion. cc @dims

@dims

dims commented Jan 30, 2023

Copy link
Copy Markdown
Member

looks like this is a developer oriented script right? let's leave it simple (and have them duplicated)

@pohly

pohly commented Jan 30, 2023

Copy link
Copy Markdown
Contributor Author

Not super convinced on necessity of symlinks in repo.

I already removed them?

@logicalhan

Copy link
Copy Markdown

/triage accepted

@k8s-ci-robot k8s-ci-robot added the triage/accepted Indicates an issue or PR is ready to be actively worked on. label Feb 9, 2023
@k8s-ci-robot k8s-ci-robot removed the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Feb 9, 2023
@pohly

pohly commented Feb 10, 2023

Copy link
Copy Markdown
Contributor Author

@dims, @serathius: what exactly do you want me to change?

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 1, 2023
@pohly pohly force-pushed the logs-performance-benchmarks branch from 6d69ee9 to 1ac27c6 Compare March 7, 2023 14:09
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 7, 2023
@pohly

pohly commented Mar 7, 2023

Copy link
Copy Markdown
Contributor Author

Not super convinced on necessity of symlinks in repo.

I replaced with plain copies.

There was a merge conflict because v1.Container was modified by some different PR in the meantime. To avoid having to update the load_test.go each time that happens, I added one commit where I picked some different struct to test with.

@serathius: please take another look.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this still needed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, simplified.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this still needed as we removed symlinks?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, removed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this still needed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hmm, now I regret that we are not symlinking anymore. Each individual copy of a file gets printed again, which can lead to substantial redundant output.

Let me replace with hashing the file content.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done. While at it, I switched from "path" to "path/filepath" because it works better on Windows.

@serathius serathius Mar 7, 2023

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One problem I expect for this script is log format changing and we forget how the original logs looked. Without knowing original log lines we will loose understanding what sed script did.

Can you provide an example what you expect this sed does? A example of line before, and example of line after. Note in commit message is ok, but git history might get obfuscated.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added as comments.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ditto

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added.

pohly added 5 commits March 7, 2023 16:03
When trying again with recent log files from the CI job, it was found that some
JSON messages get split across multiple lines, both in container logs and in
the systemd journal:

   2022-12-21T07:09:47.914739996Z stderr F {"ts":1671606587914.691,"caller":"rest/request.go:1169","msg":"Response ...
   2022-12-21T07:09:47.914984628Z stderr F 70 72  6f 78 79 10 01 1a 13 53 ... \".|\n","v":8}

Note the different time stamp on the second line. That first line is
long (17384 bytes). This seems to happen because the data must pass through a
stream-oriented pipe and thus may get split up by the Linux kernel.

The implication is that lines must get merged whenever the JSON decoder
encounters an incomplete line. The benchmark loader now supports that. To
simplifies this, stripping the non-JSON line prefixes must be done before using
a log as test data.

The updated README explains how to do that when downloading a CI job
result. The amount of manual work gets reduced by committing symlinks under
data to the expected location under ci-kubernetes-kind-e2e-json-logging and
ignoring them when the data is not there.

Support for symlinks gets removed and path/filepath is used instead of path
because it has better Windows support.
The same effect can be achieved with `-bench=BenchmarkEncoding/none`.
For long strings the output of assert.Contains is not very readable.
The benchmarks and unit tests were written so that they used custom APIs for
each log format. This made them less realistic because there were subtle
differences between the benchmark and a real Kubernetes component. Now all
logging configuration is done with the official
k8s.io/component-base/logs/api/v1.

To make the different test cases more comparable, "messages/s" is now reported
instead of the generic "ns/op".
v1.Container is still changing a log which caused the test to fail each time a
new field was added. To test loading, let's better use something that is
unlikely to change. The runtimev1.VersionResponse gets logged by kubelet and
seems to be stable.
@pohly pohly force-pushed the logs-performance-benchmarks branch from 1ac27c6 to 5ee679b Compare March 7, 2023 15:06
@serathius

Copy link
Copy Markdown
Contributor

/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 Mar 7, 2023
@k8s-ci-robot

Copy link
Copy Markdown
Contributor

LGTM label has been added.

DetailsGit tree hash: b6baedab2557474afb9edeb68dc5cdc47d73e7c9

@k8s-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: pohly, serathius

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

The pull request process is described here

Details 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

@pohly

pohly commented Mar 7, 2023

Copy link
Copy Markdown
Contributor Author

/retest

@k8s-ci-robot k8s-ci-robot merged commit 7ec3c27 into kubernetes:master Mar 7, 2023
@k8s-ci-robot k8s-ci-robot added this to the v1.27 milestone Mar 7, 2023
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. area/test cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. release-note-none Denotes a PR that doesn't merit a release note. sig/instrumentation Categorizes an issue or PR as relevant to SIG Instrumentation. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on. wg/structured-logging Categorizes an issue or PR as relevant to WG Structured Logging.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants