Skip to content

build: bump keepcurrent for sync memory fix#671

Merged
reflog merged 1 commit into
mainfrom
reflog/bump-keepcurrent-memory-fix
Jun 16, 2026
Merged

build: bump keepcurrent for sync memory fix#671
reflog merged 1 commit into
mainfrom
reflog/bump-keepcurrent-memory-fix

Conversation

@reflog

@reflog reflog commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Bumps github.com/getlantern/keepcurrent to include keepcurrent#9.

Why

Several 1 GB proxy hosts were tripping the SigNoz "Host memory usage high" alert (10 m avg system.memory.usage > 85%). Heap pprof from the http-proxy binary showed the dominant live allocation was io.ReadAll94.9 MB / 146 MB ≈ 65% of the Go heap — all from:

io.ReadAll → keepcurrent.(*byteChannel).UpdateFrom → (*Runner).syncOnce → Start.func2

That's getlantern/geo syncing the MaxMind GeoLite2 mmdb (~75 MB) via keepcurrent.FromTarGz(FromWeb(...)). The payload was buffered with io.ReadAll, which grows by repeated reallocation — churning through a chain of ever-larger backing arrays (the 75/60/48/38… MB generations seen in the heap) on every sync. On a 1 GB box that transient churn dominated RSS.

What

keepcurrent#9 pre-sizes those reads from the reader's known length (HTTP Content-Length, archive entry size, in-memory Len()), turning the multi-realloc read into a single allocation, with an overflow/OOM cap that falls back to io.ReadAll for bogus sizes. No public API change.

Note on diff size

This module's keepcurrent was pinned to a 2022 commit, so the bump also carries keepcurrent's mholt/archiver/v3mholt/archives migration and the minor golang.org/x/* upgrades MVS pulls in with it — hence the larger go.mod/go.sum churn. No first-party code changes; keepcurrent stays an indirect dependency.

Build

go build ./... produces no new errors — all geo-consuming packages (incl. the http-proxy main command) compile clean. The only failure is the pre-existing anacrolix/go-libutp cgo issue (typedef uint8 bool), which also fails on clean main and is unrelated to this change.

Pulls in getlantern/keepcurrent#9, which pre-sizes the reads used to sync
the MaxMind GeoLite2 mmdb (~75MB) through geo's FromTarGz(FromWeb(...))
pipeline. The old io.ReadAll grew its buffer by repeated reallocation,
churning through a chain of ever-larger backing arrays per sync; on 1GB
hosts that transient spike dominated RSS and tripped the host-memory>85%
alert.

http-proxy's keepcurrent was pinned to a 2022 commit, so the bump also
carries the transitive archiver/v3 -> mholt/archives migration and the
minor golang.org/x/* upgrades it brings in. keepcurrent stays indirect;
no first-party code changes.
@reflog reflog merged commit dd44277 into main Jun 16, 2026
1 check passed
reflog added a commit that referenced this pull request Jun 16, 2026
* build: bump keepcurrent for fileSource pre-size fix

Pulls in getlantern/keepcurrent#10, which makes fileSource size-aware so
geo's startup InitFrom(FromFile) read of the cached ~75MB mmdb stops
churning through io.ReadAll's realloc staircase. Completes the memory fix
started in #671 (which covered the web-sync path).

NOTE: pinned to the keepcurrent PR-head commit; re-pin to the squashed main
commit after keepcurrent#10 merges (go get keepcurrent@<main> && go mod tidy).

* build: re-pin keepcurrent to merged main (fileSource pre-size fix #10)

---------

Co-authored-by: Ilya Yakelzon <reflog@getlantern.org>
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.

1 participant