Repository navigation
mmaptrim-probe: the alignment is a no, and the run found a ceiling - #714
Merged
Merged
Conversation
Measured on 9front/amd64. Section 0: 0 of 8 aligned, and every one misaligned by exactly 0x1ff000 -- 0xfedff000, 0xfebff000, 0xfe9ff000 and so on, spaced 2MB apart, each starting one page below a 2MB boundary. So segattach places on a 2MB grid, off by 4096, and zend_mm_chunk_alloc_int would trim. Sections 2 and 3 both survived, so the partial-unmap arm works on the machine as well as the host. But three of section 0's eight mmap calls FAILED, and that is the bigger finding. Five 2MB mappings is 10MB, which is nothing, so it is not memory -- it is a limit on how many mappings a process may hold, and p9_mmap_impl spends a Plan 9 segment slot on every mapping at or above SEG_THRESHOLD. A ceiling of about five live mappings is a harder limit for php than any amount of trimming, since Zend allocates the heap in 2MB chunks. Section 0b separates the two hypotheses, with the prediction written down first: if the limit is slots, the count is the same small number at every size and the bytes held differ by orders of magnitude for no reason; if it is address space, the count falls roughly as 1/size. The smallest of its three sizes is deliberately just under SEG_THRESHOLD, so it is malloc-backed, takes no slot, and should run to the array's end -- the control. On the host all three hit 64, which shows only that the section runs; Linux has no slot limit to find. Section 1's over-sized mapping came back 2MB-aligned, which contradicts section 0's five and so is recorded as one sample of a size-dependent placement rule rather than generalised. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGAwvvTwDg2yknFkmZ3qzs
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.
Measured on 9front/amd64. Section 0: 0 of 8 aligned, and every one misaligned by exactly 0x1ff000 -- 0xfedff000, 0xfebff000, 0xfe9ff000 and so on, spaced 2MB apart, each starting one page below a 2MB boundary. So segattach places on a 2MB grid, off by 4096, and zend_mm_chunk_alloc_int would trim. Sections 2 and 3 both survived, so the partial-unmap arm works on the machine as well as the host.
But three of section 0's eight mmap calls FAILED, and that is the bigger finding. Five 2MB mappings is 10MB, which is nothing, so it is not memory -- it is a limit on how many mappings a process may hold, and p9_mmap_impl spends a Plan 9 segment slot on every mapping at or above SEG_THRESHOLD. A ceiling of about five live mappings is a harder limit for php than any amount of trimming, since Zend allocates the heap in 2MB chunks.
Section 0b separates the two hypotheses, with the prediction written down first: if the limit is slots, the count is the same small number at every size and the bytes held differ by orders of magnitude for no reason; if it is address space, the count falls roughly as 1/size. The smallest of its three sizes is deliberately just under SEG_THRESHOLD, so it is malloc-backed, takes no slot, and should run to the array's end -- the control. On the host all three hit 64, which shows only that the section runs; Linux has no slot limit to find.
Section 1's over-sized mapping came back 2MB-aligned, which contradicts section 0's five and so is recorded as one sample of a size-dependent placement rule rather than generalised.
Claude-Session: https://claude.ai/code/session_01WGAwvvTwDg2yknFkmZ3qzs