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

output/cloudv2: Flush the aggregated metrics #3083

Merged
merged 2 commits into from
May 30, 2023
Merged

Conversation

codebien
Copy link
Contributor

@codebien codebien commented May 21, 2023

It implements the drain of the queue of the aggregated metrics and the conversion to Protobuf.

@codebien codebien self-assigned this May 21, 2023
@github-actions github-actions bot requested review from imiric and mstoykov May 21, 2023 20:30
@codebien codebien force-pushed the cloud-v2-flushing branch from 6ef4fd7 to ae25fa1 Compare May 21, 2023 20:31
@codebien codebien mentioned this pull request May 21, 2023
@codebien codebien requested review from na-- and removed request for mstoykov May 21, 2023 20:38
@codecov-commenter
Copy link

codecov-commenter commented May 21, 2023

Codecov Report

Merging #3083 (4f14ff8) into master (ecca789) will decrease coverage by 0.10%.
The diff coverage is 54.86%.

❗ Current head 4f14ff8 differs from pull request most recent head 1d7eed8. Consider uploading reports for the commit 1d7eed8 to get more accurate results

@@            Coverage Diff             @@
##           master    #3083      +/-   ##
==========================================
- Coverage   73.70%   73.61%   -0.10%     
==========================================
  Files         239      240       +1     
  Lines       18258    18364     +106     
==========================================
+ Hits        13457    13518      +61     
- Misses       3933     3974      +41     
- Partials      868      872       +4     
Flag Coverage Δ
ubuntu 73.61% <54.86%> (-0.10%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
output/cloud/expv2/metrics_client.go 58.00% <ø> (ø)
output/cloud/expv2/mapping.go 40.27% <40.27%> (ø)
output/cloud/expv2/output.go 80.45% <70.00%> (-1.25%) ⬇️
output/cloud/expv2/flush.go 83.87% <83.87%> (-16.13%) ⬇️

... and 4 files with indirect coverage changes

@codebien codebien requested a review from oleiade May 23, 2023 13:59
Copy link
Member

@oleiade oleiade left a comment

Choose a reason for hiding this comment

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

Looks good as far as I can tell 🤝

I've left a couple of nit comments. There are a lot of TODOs left, and I didn't know if we should consider them blocking ❓

return nil
}

// pivot of the data structure (slice of time buckets)
Copy link
Member

Choose a reason for hiding this comment

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

I unfortunately didn't understand this sentence 😢

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Extended

TestRunID string
AggregationPeriodInSeconds uint32

// TODO: the pointer here needs to be removed asap
Copy link
Member

Choose a reason for hiding this comment

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

Not being extremely familiar with the plumber of the Go runtime, I had to do a bit of research to understand what was meant by this comment.

Here is an explanation for others who might bump into the same question: the Go memory model does not guarantee the safety of pointers in maps, and the Garbage Collector does not track the usage of pointers as map keys either. It means that the object the pointer points to could be moved or collected by the GC while still being used as a map key, leading to hard-to-diagnose errors. Although I understand that objects are not moved (their address does not change) once they've been allocated in the current version of Go?

Copy link
Member

Choose a reason for hiding this comment

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

Regardless, if we expect this map to remain small, my first intuition was to switch to a slice or array as commented indeed.

Copy link
Contributor

Choose a reason for hiding this comment

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

@codebien atlas/tagset also depends on this or at least a lot of code using it depend on it.

I can't find any plans on go moving to a moving gc.

There is already a project that just checks that you are using a go version that is known to not have a moving gc - https://github.com/go4org/unsafe-assume-no-moving-gc.

Support for a way to pin memory is already merged, although the use case there is different.

Also, AFAIK using a pointer a map key is not as uncommon and likely will break quite a lot of software, so again - very unlikely to happen. And likely will have a lot of additional problems across the ecosystem.

Maybe open an issue either way?

Copy link
Contributor Author

@codebien codebien May 26, 2023

Choose a reason for hiding this comment

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

Removed, not really necessary to hurry about this. The real improvement is mostly to change to the ID or having some slice/array but we need to know better about the tracking/untracking.

TestRunID string
AggregationPeriodInSeconds uint32

// TODO: the pointer here needs to be removed asap
Copy link
Contributor

Choose a reason for hiding this comment

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

@codebien atlas/tagset also depends on this or at least a lot of code using it depend on it.

I can't find any plans on go moving to a moving gc.

There is already a project that just checks that you are using a go version that is known to not have a moving gc - https://github.com/go4org/unsafe-assume-no-moving-gc.

Support for a way to pin memory is already merged, although the use case there is different.

Also, AFAIK using a pointer a map key is not as uncommon and likely will break quite a lot of software, so again - very unlikely to happen. And likely will have a lot of additional problems across the ecosystem.

Maybe open an issue either way?

@codebien codebien force-pushed the cloud-v2-handle-flush-err branch from 0e50e23 to 9531f91 Compare May 25, 2023 21:53
@codebien codebien force-pushed the cloud-v2-flushing branch from ae25fa1 to 5d1444d Compare May 25, 2023 22:17
mstoykov
mstoykov previously approved these changes May 26, 2023
Copy link
Contributor

@mstoykov mstoykov left a comment

Choose a reason for hiding this comment

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

LGTM!

The gauge comment is the most blockign, but even that isn't really blocking, just checking why are we sending so many stuff for gauge.

@codebien codebien force-pushed the cloud-v2-handle-flush-err branch from b5e3a64 to 9a9adc1 Compare May 26, 2023 11:07
@codebien codebien force-pushed the cloud-v2-flushing branch 3 times, most recently from 0bf7552 to 06f65e0 Compare May 27, 2023 13:07
Base automatically changed from cloud-v2-handle-flush-err to master May 29, 2023 10:05
@codebien codebien force-pushed the cloud-v2-flushing branch from 06f65e0 to e2152b8 Compare May 29, 2023 10:26
@codebien codebien force-pushed the cloud-v2-flushing branch from e2152b8 to 1d7eed8 Compare May 29, 2023 11:13
@codebien codebien requested review from oleiade and mstoykov and removed request for oleiade and na-- May 29, 2023 11:13
Copy link
Contributor

@mstoykov mstoykov left a comment

Choose a reason for hiding this comment

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

LGTM! Left a not blocking comment.

@oleiade oleiade self-requested a review May 30, 2023 08:08
@codebien codebien merged commit 31d9302 into master May 30, 2023
@codebien codebien deleted the cloud-v2-flushing branch May 30, 2023 08:11
@codebien codebien added this to the v0.45.0 milestone May 30, 2023
@codebien codebien mentioned this pull request Jun 8, 2023
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.

4 participants