Closed Bug 1660006 Opened 5 years ago Closed 4 years ago

Check GC works with 16KB page sizes on Apple arm64 hardware

Categories

(Core :: JavaScript: GC, task, P1)

task

Tracking

()

RESOLVED FIXED
89 Branch
Tracking Status
firefox89 --- fixed

People

(Reporter: jonco, Assigned: allstars.chh)

References

Details

Attachments

(5 files, 9 obsolete files)

48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review

Currently all platforms we regularly test on have 4KB page size, but that will change with the new arm64 based hardware from Apple which will have 16KB page size. We need to check this doesn't break anything.

For example, I'm not sure we decommit pages where arena size is not the same as page size.

It turns out we test on ARM64 hardware, so I think we can say GC works at least:

https://treeherder.mozilla.org/#/jobs?repo=mozilla-central&group_state=expanded&searchStr=pixel%2Caarch64%2Cjit

I can see a few possibilities for this:

  1. Do nothing. Decommit won't work leading to much greater memory use.
  2. Decommit where there are appropriately sized unused regions. This is reasonably simple to implement, and would give better memory use than 1.
  3. Use a 16KB arena size on this platform. This is simple to implement and would give better memory use than 1.

I don't know which approach will have the best outcome in terms of memory use. However we can simulate the larger page size restriction with a build time configuration option and test different approaches without needing the actual hardware.

Yoshi, is this something you could take a look at when you have a moment?

Flags: needinfo?(allstars.chh)
Assignee: nobody → allstars.chh
Flags: needinfo?(allstars.chh)

Firstly these need to be run on MacOS to be as close as possible to the hardware we're targeting.

Then we need to do two comparisons:

  1. Base vs 16KB page size

This should give us an idea of how much worse memory usage is on the new hardware if we do nothing. I would expect to see reasonably large regressions.

2.) 16KB page size vs 16KB page size and 16KB arena size

This should give us an idea of how much of an improvement using 16KB arenas is. It should show reduced memory usage, but probably not back to the initial levels.

You will need to use perfherder to retrigger the benchmarks 5 times to get meaningful 'confidence' results. If you hover over a value in the 'total runs' column a button will appear to let you do this.

Priority: -- → P1

Perhherder says with 16KB page size + 16KB arena size, I got 20% regression in [Base JS After tabs open [+30s, forced GC] opt] compared with 16KB page size

https://treeherder.mozilla.org/perfherder/comparesubtest?originalProject=try&newProject=try&newRevision=9fc60e40e5ba9fdecad9aaedb4240013b547f8ee&originalSignature=2203749&newSignature=2203749&framework=4&originalRevision=eac6d63cb58c0d3aabfda3a5b671c6e4ea58bec5

However I check the memory report, although on most pages in tp6 have decommitted size increase, but the explicit allocations are slightly smaller.
And in total I only find 1% memory increased

https://docs.google.com/spreadsheets/d/1duYIFImq7RGNpqf8-qjr_5Q6ikTryiWlEZBzDkxTOHc/edit?usp=sharing

Previously in comment 10 I checked awsy, sy-tp6 report, there seems no significant change.

However after checking with other tests: ab, sy
https://treeherder.mozilla.org/jobs?repo=try&revision=9fc60e40e5ba9fdecad9aaedb4240013b547f8ee&selectedTaskRun=dcIkMRkaSGSwL2d3qoSp4w.0
https://treeherder.mozilla.org/jobs?repo=try&revision=9fc60e40e5ba9fdecad9aaedb4240013b547f8ee&selectedTaskRun=bYIFhTR6Raa1thej8XH4HA.0

I notice that unused-gc-things increases a lot.

I add another workaround to not to report gc-unused-things, and the memory regression goes awsy.

16KB Page Size + don't report unused-gc-things vs 16KB Page Size + 16KB Arena Size + don't report unused-gc-things
https://treeherder.mozilla.org/perfherder/compare?originalProject=try&originalRevision=5f454c5b2a7af6580bd0a95ff3ec261db6daf036&newProject=try&newRevision=70c084f45bb0aa2f84d1b3fc5d4d27f713fa28ff&framework=4

Here's the perfherder compared to m-c
16KB Page Size + don't report unused-gc-things vs mozilla-central
https://treeherder.mozilla.org/perfherder/compare?originalProject=try&originalRevision=ccc9365198a56d2b0bbcf7af68ed6c6a220c3331&newProject=try&newRevision=70c084f45bb0aa2f84d1b3fc5d4d27f713fa28ff&framework=4

and from unused/gc-things, objects, strings and shapes are the top 3 usages.
And the reason is for some arenas having small number of cells, its unused-gc-things will become larger because of larger ArenaSize.

Hi jonco, https://phabricator.services.mozilla.com/D104736 is the WIP for decommitFreeArenas

Flags: needinfo?(jcoppeard)
Flags: needinfo?(jcoppeard)
Attachment #9199742 - Attachment is obsolete: true
Attachment #9189128 - Attachment is obsolete: true
Attachment #9189127 - Attachment is obsolete: true

Don't set decommittedArenas[i] to true if MarkPagesUnusedSoft returns
false.

Hi Jonco
When the page size is 16KB, we didn't decommit, but we still set decommittedArenas to true.
https://searchfox.org/mozilla-central/rev/a23e65c5d69a821f61d14c8ec1f69a120e3f77d1/js/src/gc/GC.cpp#845
https://searchfox.org/mozilla-central/rev/5120ec68572d946bd15101cf2ee2eaf4a210724f/js/src/gc/Memory.cpp#774

I am wondering if we should NOT set decommittedArenas to true when we actually didn't decommit?
for example should we have the 2 patches below ?
https://phabricator.services.mozilla.com/D105347
https://phabricator.services.mozilla.com/D105348

Then the patch for decommitFreeArenas should see improvements.

Flags: needinfo?(jcoppeard)

(In reply to Yoshi Cheng-Hao Huang [:allstars.chh][:allstarschh] from comment #21)
Good catch! This doesn't affect correctness but probably means the reported memory size is wrong. That would also explain why your patch didn't improve things as much as expected.

Can you file a bug for this?

The way to fix this is to check first whether we can decommit, and then don't attempt it (for now, and then your patch in this bug would fix this). Ideally we would just assert that the length was aligned to page size in the memory functions, rather than checking DecommitEnabled().

Flags: needinfo?(jcoppeard)
Attachment #9203480 - Attachment is obsolete: true
Attachment #9203481 - Attachment is obsolete: true
Attached file Bug 1660006 - (WIP) decommit page. (obsolete) —

WIP

Add a numPagesFreeCommitted in TenuredChunkInfo.

addArenaToFreeList --> check if there's a free page, if so, numPagesFreeCommitted++

decommitFreeArenas -> check if the chunk's numPagesFreeCommitted > 0, if
so, calling decommitOneFreePage, which in turns numPagesFreeCommitted--

When allocating an arena, check if the arena coming from a free page, if
so also doing numPagesFreeCommitted--

Flags: needinfo?(jcoppeard)
Attachment #9202407 - Attachment is obsolete: true
Attachment #9206671 - Attachment description: Bug 1660006 - update DecommitEnabled → Bug 1660006 - Part 6: Update DecommitEnabled.
Attachment #9210696 - Attachment description: Bug 1660006 - Part 2: Rename decommittedArenas to decommittedPages. → Bug 1660006 - Part 2: Rename decommittedPages and update commit behavior
Attachment #9210697 - Attachment description: Bug 1660006 - Part 3: update decommitFreeArenas. → Bug 1660006 - Part 3: Update decommitFreeArenas.
Attachment #9206671 - Attachment description: Bug 1660006 - Part 6: Update DecommitEnabled. → Bug 1660006 - Part 5: Update DecommitEnabled.
Attachment #9210699 - Attachment is obsolete: true
Attachment #9199741 - Attachment description: Bug 1660006 - (For Test) Config page size to 16KB → Bug 1660006 - (For test) Config page size to 16KB
Attachment #9210698 - Attachment is obsolete: true
Attachment #9206670 - Attachment is obsolete: true
Attachment #9210695 - Attachment description: Bug 1660006 - Part 1: Add PageSize, ArenasPerPage, and PagesPerChunk → Bug 1660006 - Part 1: Add PageSize, ArenasPerPage, and PagesPerChunk.
Attachment #9210696 - Attachment description: Bug 1660006 - Part 2: Rename decommittedPages and update commit behavior → Bug 1660006 - Part 2: Rename decommittedPages and update commit behavior.
Attachment #9206671 - Attachment description: Bug 1660006 - Part 5: Update DecommitEnabled. → Bug 1660006 - Part 4: Update DecommitEnabled.
Pushed by allstars.chh@gmail.com: https://hg.mozilla.org/integration/autoland/rev/7680fff70137 Part 1: Add PageSize, ArenasPerPage, and PagesPerChunk. r=jonco https://hg.mozilla.org/integration/autoland/rev/7bc19b9ba858 Part 2: Rename decommittedPages and update commit behavior. r=jonco https://hg.mozilla.org/integration/autoland/rev/8553a9cf2027 Part 3: Update decommitFreeArenas. r=jonco https://hg.mozilla.org/integration/autoland/rev/8fc5eb4145f6 Part 4: Update DecommitEnabled. r=jonco
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: