-
Notifications
You must be signed in to change notification settings - Fork 321
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
fix: same TCP connection appears twice #631
Conversation
``` TCP, TCP6, UDP, and UDP6 are dynamically changing, and when we read these files, we should read them all at once. there will be data consistency issues if using line by lin reading fix: #576 ``` Signed-off-by: weidongkl <[email protected]>
Makes sense but I'm still worried about the increased memory usage here. These can be significant sized.. @SuperQ wdyt? |
net-tools used setvbuf _IOFBF to read tcp file at once too. data consistency should be more important than the increased memory usage |
|
Yeah I think we'll need to do this |
net-tools does not read the entire file at once. It merely uses buffered IO, with a buffer of PAGE_SIZE: FILE *proc_fopen(const char *name)
{
static char *buffer;
static size_t pagesz;
FILE *fd = fopen(name, "r");
if (fd == NULL)
return NULL;
if (!buffer) {
pagesz = getpagesize();
buffer = malloc(pagesz);
}
setvbuf(fd, buffer, _IOFBF, pagesz);
return fd;
} I suspect that an equivalent approach in Go, which would have only required a single line change, would be to replace the previous |
Actually, this may be worse. The proc files in question have no size.
So this change likely does not fix the problem and may make it worse. I think I'm going to revert this, without proof that this fix actually works, I think the original code is actually what we want. |
@SuperQ The
It appears to start with a 512-byte read, but gradually increases (apart from a strange decrease to 384 bytes for the second Compare that with the original
Incidentally, my suggested |
Also for comparison, the (deprecated)
So if anything, the original code most closely resembles how net-tools reads /proc/net/tcp. Now, if both prometheus/procfs and net-tools produce inconsistent / duplicated entries, then I would say that it's time to use rtnetlink to get this information, as iproute2 does with the |
We already switched to netlink in the node_exporter tcpstat collector. |
Exactly - so should these legacy functions that parse |
Yea, maybe not a bad idea. @discordianfish What do you think of marking this reader/parser as deprecated? |
@SuperQ yeah that makes sense |
) [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [github.com/prometheus/procfs](https://togithub.com/prometheus/procfs) | `v0.13.0` -> `v0.14.0` | [![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fprometheus%2fprocfs/v0.14.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2fprometheus%2fprocfs/v0.14.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2fprometheus%2fprocfs/v0.13.0/v0.14.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fprometheus%2fprocfs/v0.13.0/v0.14.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- > [!WARNING] > Some dependencies could not be looked up. Check the Dependency Dashboard for more information. --- ### Release Notes <details> <summary>prometheus/procfs (github.com/prometheus/procfs)</summary> ### [`v0.14.0`](https://togithub.com/prometheus/procfs/releases/tag/v0.14.0) [Compare Source](https://togithub.com/prometheus/procfs/compare/v0.13.0...v0.14.0) #### What's Changed - Synchronize common files from prometheus/prometheus by [@​prombot](https://togithub.com/prombot) in [https://github.com/prometheus/procfs/pull/613](https://togithub.com/prometheus/procfs/pull/613) - Synchronize common files from prometheus/prometheus by [@​prombot](https://togithub.com/prombot) in [https://github.com/prometheus/procfs/pull/615](https://togithub.com/prometheus/procfs/pull/615) - Synchronize common files from prometheus/prometheus by [@​prombot](https://togithub.com/prombot) in [https://github.com/prometheus/procfs/pull/616](https://togithub.com/prometheus/procfs/pull/616) - Synchronize common files from prometheus/prometheus by [@​prombot](https://togithub.com/prombot) in [https://github.com/prometheus/procfs/pull/621](https://togithub.com/prometheus/procfs/pull/621) - Revert add avgRTT to nfs mountstats [#​487](https://togithub.com/prometheus/procfs/issues/487) by [@​SuperQ](https://togithub.com/SuperQ) in [https://github.com/prometheus/procfs/pull/625](https://togithub.com/prometheus/procfs/pull/625) - style: returns procfs build-in error like other parsing methods by [@​weidongkl](https://togithub.com/weidongkl) in [https://github.com/prometheus/procfs/pull/630](https://togithub.com/prometheus/procfs/pull/630) - update MAINTAINERS.md by [@​pgier](https://togithub.com/pgier) in [https://github.com/prometheus/procfs/pull/629](https://togithub.com/prometheus/procfs/pull/629) - \*: `s/(%v|%s)/%w` and use `go1.20` by [@​rexagod](https://togithub.com/rexagod) in [https://github.com/prometheus/procfs/pull/617](https://togithub.com/prometheus/procfs/pull/617) - chore: Use kernel-compliant types for `{U,G}IDs` by [@​rexagod](https://togithub.com/rexagod) in [https://github.com/prometheus/procfs/pull/620](https://togithub.com/prometheus/procfs/pull/620) - Update Go versions by [@​SuperQ](https://togithub.com/SuperQ) in [https://github.com/prometheus/procfs/pull/632](https://togithub.com/prometheus/procfs/pull/632) - fix: same TCP connection appears twice by [@​weidongkl](https://togithub.com/weidongkl) in [https://github.com/prometheus/procfs/pull/631](https://togithub.com/prometheus/procfs/pull/631) - Revert "fix: same TCP connection appears twice" by [@​SuperQ](https://togithub.com/SuperQ) in [https://github.com/prometheus/procfs/pull/633](https://togithub.com/prometheus/procfs/pull/633) #### New Contributors - [@​rexagod](https://togithub.com/rexagod) made their first contribution in [https://github.com/prometheus/procfs/pull/617](https://togithub.com/prometheus/procfs/pull/617) **Full Changelog**: prometheus/procfs@v0.13.0...v0.14.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - "on tuesday" (UTC), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/open-telemetry/opentelemetry-collector-contrib). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zMTMuMSIsInVwZGF0ZWRJblZlciI6IjM3LjMxMy4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJkZXBlbmRlbmNpZXMiLCJyZW5vdmF0ZWJvdCJdfQ==--> --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: opentelemetrybot <[email protected]>
``` TCP, TCP6, UDP, and UDP6 are dynamically changing, and when we read these files, we should read them all at once. there will be data consistency issues if using line by lin reading fix: prometheus#576 ``` Signed-off-by: weidongkl <[email protected]>
…metheus#633) This reverts commit 987bedc.
/proc/net/{TCP, TCP6, UDP, UDP6} are dynamic ,
and when we read these files, we should read them all at once.
there will be data consistency issues if using line by line reading
fix: #576