Skip to content

Commit c20940e

Browse files
committed
Update to mimallc v3.6.0
1 parent 548aa32 commit c20940e

2 files changed

Lines changed: 18 additions & 14 deletions

File tree

‎Objects/mimalloc/profile/sample-guarded.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,15 +153,15 @@ void _mi_page_block_unguard(mi_page_t* page, mi_block_t* block, void* p) {
153153
const size_t bsize = mi_page_block_size(page);
154154
const size_t psize = _mi_os_page_size();
155155
mi_assert_internal(bsize > psize);
156-
mi_assert_internal(!page->memid.is_pinned);
156+
if (page->memid.is_pinned) return; // no guard page was set (see `mi_block_ptr_set_guarded`)
157157
void* gpage = (uint8_t*)block + bsize - psize;
158158
mi_assert_internal(mi_is_aligned(gpage, psize));
159159
_mi_os_unprotect(gpage, psize);
160160
}
161161

162162
// unguard a whole page (called from `mi_heap_destroy`)
163163
void _mi_page_unguard_all(mi_page_t* page) {
164-
if mi_likely(!mi_page_has_interior_pointers(page)) return;
164+
if mi_likely(!mi_page_has_interior_pointers(page) || page->memid.is_pinned) return;
165165
uint8_t* const start = mi_page_start(page);
166166
const size_t psize = mi_page_committed(page);
167167
_mi_os_unprotect(start,psize); // unprotect all at once as we cannot know which blocks are guarded

‎Objects/mimalloc/refresh.sh‎

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ if [[ "${BASH_VERSINFO[0]}" -lt 4 ]]; then
1818
exit 1
1919
fi
2020

21-
# Update this when updating to a new version after verifying that the changes
22-
# the update brings in are good. The ref can be a commit hash or a release tag
23-
# (e.g. "v3.6.0"); mimalloc v3.6 has not been released yet, so this is a commit
24-
# on the dev3 branch.
25-
expected_mimalloc_ref="caaf3bc41494e6b58ab32ed9c851b3c8b61a8f82"
26-
expected_mimalloc_sha256="d6bed4bad2fe8aea63f4ab25cabce5275aef6f2f9386266ff686ceb1eabe15bb"
21+
# Update these when updating to a new version after verifying that the changes
22+
# the update brings in are good. The tag must be a mimalloc release with a
23+
# mimalloc-<tag>-source.tar.gz asset; the SHA-256 is listed next to the asset
24+
# on the GitHub release page.
25+
expected_mimalloc_tag="v3.6.0"
26+
expected_mimalloc_sha256="05b45988f07a940831ad156f10b0aeb84805b1f030004488939efe08f718b4c7"
2727

2828
objects_dir="$(realpath "$(dirname -- "${BASH_SOURCE[0]}")")"
2929
cpython_dir="$(realpath "$objects_dir/../..")"
@@ -35,7 +35,7 @@ trap 'rm -rf "$tmp_dir"' EXIT
3535

3636
# Step 1: download and verify the mimalloc sources
3737

38-
url="https://github.com/microsoft/mimalloc/archive/${expected_mimalloc_ref}.tar.gz"
38+
url="https://github.com/microsoft/mimalloc/releases/download/${expected_mimalloc_tag}/mimalloc-${expected_mimalloc_tag}-source.tar.gz"
3939
curl --fail --location "$url" > "$tmp_dir/mimalloc.tar.gz"
4040
actual_sha256=$(sha256sum "$tmp_dir/mimalloc.tar.gz" | cut -d' ' -f1)
4141
if [[ "$actual_sha256" != "$expected_mimalloc_sha256" ]]; then
@@ -46,11 +46,15 @@ if [[ "$actual_sha256" != "$expected_mimalloc_sha256" ]]; then
4646
exit 1
4747
fi
4848

49-
# The top-level directory in the archive depends on the ref (mimalloc-<hash>
50-
# for a commit, mimalloc-<version> for a tag), so strip it.
49+
# The sources may be at the root of the archive or under a single top-level
50+
# directory.
5151
mimalloc_dir="$tmp_dir/mimalloc"
5252
mkdir "$mimalloc_dir"
53-
tar xzf "$tmp_dir/mimalloc.tar.gz" -C "$mimalloc_dir" --strip-components 1
53+
tar xzf "$tmp_dir/mimalloc.tar.gz" -C "$mimalloc_dir"
54+
top_level=("$mimalloc_dir"/*)
55+
if [[ ${#top_level[@]} -eq 1 && -d "${top_level[0]}" ]]; then
56+
mimalloc_dir="${top_level[0]}"
57+
fi
5458
if [[ ! -f "$mimalloc_dir/src/static.c" || ! -f "$mimalloc_dir/include/mimalloc.h" ]]; then
5559
echo "error: $url does not look like a mimalloc source archive" >&2
5660
exit 1
@@ -92,10 +96,10 @@ if [[ -n "$deep_files" ]]; then
9296
echo "$deep_files" | sed 's/^/ /' >&2
9397
fi
9498

95-
echo "Updated mimalloc to ${expected_mimalloc_ref}."
99+
echo "Updated mimalloc to ${expected_mimalloc_tag}."
96100
echo
97101
git status --short -- Objects/mimalloc Include/internal/mimalloc
98102
echo
99103
echo "Re-apply any changes carried on top of the upstream sources, review the"
100104
echo "changes, rebuild, and commit with a message such as:"
101-
echo " Update vendored mimalloc to ${expected_mimalloc_ref}"
105+
echo " Update vendored mimalloc to ${expected_mimalloc_tag}"

0 commit comments

Comments
 (0)