Closed Bug 2079421 Opened 1 month ago Closed 1 month ago

Pre-allocate viaduct buffer

Categories

(Application Services :: General, enhancement)

enhancement

Tracking

(firefox159 fixed, firefox160 fixed)

RESOLVED FIXED
160 Branch
Tracking Status
firefox159 --- fixed
firefox160 --- fixed

People

(Reporter: bdk, Assigned: bdk)

References

(Blocks 1 open bug)

Details

(Whiteboard: [fxsync-])

Attachments

(1 external file)

https://bugzilla.mozilla.org/show_bug.cgi?id=1992618 shows crash increases that are related to OOM errors. Our working theory is that this is related to large viaduct downloads. To test this theory and maybe fix the issue for some users, let's try pre-allocating our buffer when we can. This reduces the total allocated bytes because we can size the array to the exact right size rather than rely on grow-able arrays, which double in size each time they exceed the allocation. That doubling can mean we use up to 2x more memory than needed. It also reduces the total number of allocations, since we don't spend time allocating smaller arrays which get overflow and need to be replaced with larger ones.

If our theory is right than we should see some reduction in crashes when we introduce this change. I don't expect this to fix the problem altogether, but it should at least give us some info and if we're lucky it might significantly reduce the impact.

Note that we can only perform this optimization if we get a content-length header, but we should get that in most cases (sync, remote settings, etc.).

(via GitHub webhook, authenticated as shared-secret)

Authored by https://github.com/bendk
https://github.com/mozilla/application-services/commit/d4057dd5972a7c83aa279f4f342d42f4b163222c
[main] Bug 2079421 - pre-allocate viaduct buffer (#7641)

(via GitHub webhook, authenticated as shared-secret)

Status: ASSIGNED → RESOLVED
Closed: 1 month ago
Flags: qe-verify+
Resolution: --- → FIXED
Target Milestone: --- → 160 Branch
QA Whiteboard: [qa-triage-done-c161/b160]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: