perf(s3): HEAD-based existence + parallel tile upload (MAPCO-11322) - #257
Open
shimoncohen wants to merge 4 commits into
Open
shimoncohen wants to merge 4 commits into
shimoncohen wants to merge 4 commits into
Conversation
Scoped I/O wins for the S3 path (full end-to-end async deferred to its own change). - S3Client.GetTileKey: existence/key lookup did a full GetObjectAsync, which downloads the whole object body just to read its key. Use a single prefixed ListObjectsV2 (MaxKeys=1) instead — no body transfer. - S3.InternalUpdateTiles: upload the batch's tiles with Parallel.ForEach instead of one blocking PutObject at a time. Tiles are materialized first so the single-threaded grid/origin projection runs before the uploads fan out; the S3 client and PutObject are independent per tile. - Raise ServicePointManager.DefaultConnectionLimit (default 2) so parallel PUTs are not serialized on the connection pool. TileExists client test now drives ListObjectsV2; the S3 UpdateTiles data-type test no longer sequences UpdateTile (uploads are unordered) but still asserts one upload per tile. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
ServicePointManager.DefaultConnectionLimit governs the legacy HttpWebRequest stack; on net6 the AWS SDK's HttpClient/SocketsHttpHandler ignores it, so the line never capped anything. Drop it and its misleading comment — pure dead-code removal, no behavior change. Bounding the S3 upload fan-out (config-driven MaxDegreeOfParallelism + AmazonS3Config.MaxConnectionsPerServer, value from a load test) is deferred to MAPCO-11364 (P15). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
shimoncohen
force-pushed
the
logic-3-io-async
branch
from
August 5, 2026 09:00
063e1a1 to
655c4e3
Compare
shimoncohen
marked this pull request as ready for review
August 5, 2026 09:53
shimoncohen
requested review from
CL-SHLOMIKONCHA,
almog8k,
asafmas-rnd,
razbroc and
syncush
August 5, 2026 09:53
syncush
approved these changes
Aug 5, 2026
This was referenced Aug 6, 2026
Open
Open
asafmas-rnd
requested changes
Aug 6, 2026
The projection is effectively pure; ToList is for range-partitioning, not thread-safety. State the real reason (avoids the shared-enumerator lock). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
asafmas-rnd
approved these changes
Aug 6, 2026
A prefix ListObjectsV2 scans the bucket index, which does not scale on the billions-of-objects bucket (MAPCO-7954). GetTileKey/TileExists now issue a GetObjectMetadata (HEAD) — an O(1) key lookup — for each candidate extension in the historical Jpeg-then-Png order, resolving existence and the real key without touching the index. HEAD 404 (not the GET "NoSuchKey") drives miss detection. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Collaborator
Author
|
Existence path changed: LIST → HEAD.
Trade-off: an unknown-extension miss costs up to two HEADs (Jpeg + Png) — both index-free, cheaper than one prefix LIST on a large bucket. Collapsing to a single HEAD needs the per-source extension (MAPCO-11382). Title + description updated. Suite: 1141 passed, 0 failed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
LOGIC-3 of MAPCO-11317. Scoped S3 I/O wins.
Scope decision
"Async end-to-end" taken literally would convert the whole tile pipeline (
IDataUtils/IData/ITileMerger/Process/TaskExecutor) to async — a large rewrite that collides with SVC-1 and the other PRs. This PR delivers the self-contained I/O wins and leaves full pipeline-async as a follow-up.Changes
S3Client.GetTileKey(used byTileExists) did a fullGetObjectAsync, downloading the entire object body just to read its.Key. Now aGetObjectMetadata(HEAD) per candidate extension (Jpeg, then Png) — an O(1) key lookup that resolves existence + the real extension with no body transfer and no bucket-index scan. A prefixListObjectsV2was deliberately rejected: LIST scans the bucket index, which does not scale on the billions-of-objects bucket (MAPCO-7954).S3.InternalUpdateTilesuploaded tiles one blockingPutObjectat a time. NowParallel.ForEach, materializing tiles first so the single-threaded grid/origin projection completes before uploads fan out. (chore: update logs + add parallel.for when putting updating tiles to S3 #112 attempted this viaTask.Run(...).Wait(), which isn't actually parallel; this supersedes it.)ServicePointManager.DefaultConnectionLimitline that was added alongside the parallel upload.ServicePointManagergoverns the legacyHttpWebRequeststack; on net6 the AWS SDK'sHttpClient/SocketsHttpHandlerignores it, so it never capped anything. Pure dead-code removal.Deferred (follow-ups) — tracked in MAPCO-11364
.Result).GetTilestill probes Jpeg-then-Png (up to 2 full GETs/tile); the speculative probe was not dropped. (OnlyGetTileKey/TileExistsmoved to HEAD here.)FolderExistsloop 0..24) to discover the zoom set → singleListObjectsV2withDelimiter="/".Parallel.ForEachhas no deliberate ceiling: concurrency tracks ThreadPool sizing (blockingPutObjectbodies) and socket count is unbounded (SocketsHttpHandler.MaxConnectionsPerServerdefault =int.MaxValue). Follow-up adds a config-drivenMaxDegreeOfParallelismpaired withAmazonS3Config.MaxConnectionsPerServer(the real net6 lever), value from a load test.Existence uses HEAD (
GetObjectMetadataAsync), matching parent-ticket P5 and MAPCO-7954 — no bucket-index LIST on the billions-object bucket. Trade-off: an unknown-extension miss costs up to two HEADs (Jpeg + Png); both are index-free O(1) lookups, cheaper than one prefix LIST on a large bucket. Passing the extension per source to collapse this to a single HEAD is tracked in MAPCO-11382.Testing
Full suite: 1141 passed, 0 failed.
TileExistsclient test drivesGetObjectMetadata(HEAD) per extension and asserts Png is only probed after a Jpeg 404; the S3UpdateTilesdata-type test no longer sequencesUpdateTile(uploads are unordered) but still asserts one upload per tile.Supersedes / relates
🤖 Generated with Claude Code