Skip to content

Upgrade to mimalloc v2.2.3 #5508

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Apr 21, 2025
Merged

Conversation

dscho
Copy link
Member

@dscho dscho commented Mar 25, 2025

Git for Windows still carries mimalloc v2.1.2, which is almost 2 years old. Let's upgrade.

dscho added 8 commits March 25, 2025 13:29
Now that Git is a bit stricter when compiling its own source, we need to
exempt mimalloc a bit more.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Instead of trying to "fix" whitespace issues in mimalloc's source,
thereby making it unnecessarily complicated to keep the vendored-in
mimalloc sources in sync, let's just prevent Git from trying to enforce
its coding style rules on said vendored-in source files.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
In preparation for upgrading to a newer mimalloc version; This patch
will not be needed anymore, as it has been implemented in a slightly
different form in upstream mimalloc: 3e1d800e (potential fix for windows
static linking with thread creation in dll's, 2022-11-07).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
In preparation for upgrading to a newer mimalloc version.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
In preparation for upgrading to a newer mimalloc version.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Update to newer mimalloc versions like this:

  update_mimalloc ()
  {
      test $# = 1 || {
          echo "Need a mimalloc version" 1>&2;
          return 1
      };
      for oneline in 'mimalloc: adjust for building inside Git' 'Import the source code of mimalloc';
      do
          git revert -n HEAD^{/^"$oneline"} && git checkout HEAD -- Makefile && git commit -sm "Temporarily revert \"$oneline\"" -m 'In preparation for upgrading to a newer mimalloc version.' || return 1;
      done;
      for file in $(git show --format='%n' --name-only --diff-filter=A HEAD^{/^"Import the source code of mimalloc "}) compat/mimalloc/arena-abandon.c compat/mimalloc/free.c compat/mimalloc/libc.c compat/mimalloc/prim/prim.c compat/mimalloc/mimalloc-stats.h;
      do
          file2=${file#compat/mimalloc/};
          case "$file2" in
              segment-cache.c)
                  : no longer needed;
                  continue
              ;;
              bitmap.h | *.c)
                  file2=src/$file2
              ;;
              *.h)
                  file2=include/$file2
              ;;
          esac;
          mkdir -p "${file%/*}" && git -C /usr/src/mimalloc/ show "$1":$file2 > "$file" && git add "$file" || {
              echo "Failed: $file2 -> $file" 1>&2;
              return 1
          };
      done;
      conv_sed='sed -n "/^ *eval/d;/      /p"' && git commit -sm "Import the source code of mimalloc $1" -m "Update to newer mimalloc versions like this:" -m "$(set | sed -n '/^update_mimalloc *() *$/,/^}/{s/^./  &/;p}')" -m '  update_mimalloc $MIMALLOC_VERSION' -m 'For convenience, you can set `MIMALLOC_VERSION` and then run:' -m '  eval "$(git show -s <this-commit> | '"$conv_sed"')"' || return 1;
      git cherry-pick HEAD^{/^'mimalloc: adjust for building inside Git'} || return 1
  }

  update_mimalloc $MIMALLOC_VERSION

For convenience, you can set `MIMALLOC_VERSION` and then run:

  eval "$(git show -s <this-commit> | sed -n "/^ *eval/d;/      /p")"

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
We want to compile mimalloc's source code as part of Git, rather than
requiring the code to be built as an external library: mimalloc uses a
CMake-based build, which is not necessarily easy to integrate into the
flavors of Git for Windows (which will be the main benefitting port).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Adjust the `Makefile` part for mimalloc v2.2.2.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
@dscho dscho self-assigned this Mar 25, 2025
@dscho dscho requested review from mjcheetham and rimrul March 25, 2025 12:36
@dscho
Copy link
Member Author

dscho commented Apr 17, 2025

In the meantime, v2.2.3 was released. I meant to update this PR but ran out of time.

dscho added 6 commits April 20, 2025 20:41
In preparation for upgrading to a newer mimalloc version.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
In preparation for upgrading to a newer mimalloc version.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Update to newer mimalloc versions like this:

  update_mimalloc ()
  {
      test $# = 1 || {
          echo "Need a mimalloc version" 1>&2;
          return 1
      };
      for oneline in 'mimalloc: adjust for building inside Git' 'Import the source code of mimalloc';
      do
          git revert -n HEAD^{/^"$oneline"} && git checkout HEAD -- Makefile && git commit -sm "Temporarily revert \"$oneline\"" -m 'In preparation for upgrading to a newer mimalloc version.' || return 1;
      done;
      for file in $(git show --format='%n' --name-only --diff-filter=A HEAD^{/^"Import the source code of mimalloc "}) compat/mimalloc/arena-abandon.c compat/mimalloc/free.c compat/mimalloc/libc.c compat/mimalloc/prim/prim.c compat/mimalloc/mimalloc-stats.h;
      do
          file2=${file#compat/mimalloc/};
          case "$file2" in
              segment-cache.c)
                  : no longer needed;
                  continue
              ;;
              bitmap.h | *.c)
                  file2=src/$file2
              ;;
              *.h)
                  file2=include/$file2
              ;;
          esac;
          mkdir -p "${file%/*}" && git -C /usr/src/mimalloc/ show "$1":$file2 > "$file" && git add "$file" || {
              echo "Failed: $file2 -> $file" 1>&2;
              return 1
          };
      done;
      conv_sed='sed -n "/^ *eval/d;/      /p"' && git commit -sm "Import the source code of mimalloc $1" -m "Update to newer mimalloc versions like this:" -m "$(set | sed -n '/^update_mimalloc *() *$/,/^}/{s/^./  &/;p}')" -m '  update_mimalloc $MIMALLOC_VERSION' -m 'For convenience, you can set `MIMALLOC_VERSION` and then run:' -m '  eval "$(git show -s <this-commit> | '"$conv_sed"')"' || return 1;
      git cherry-pick HEAD^{/^'mimalloc: adjust for building inside Git'} || return 1
  }

  update_mimalloc $MIMALLOC_VERSION

For convenience, you can set `MIMALLOC_VERSION` and then run:

  eval "$(git show -s <this-commit> | sed -n "/^ *eval/d;/      /p")"

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
We want to compile mimalloc's source code as part of Git, rather than
requiring the code to be built as an external library: mimalloc uses a
CMake-based build, which is not necessarily easy to integrate into the
flavors of Git for Windows (which will be the main benefitting port).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
To support mimalloc-enabled builds also on Linux and on macOS, we need
to ship the respective backends, too.

This helped me diagnose "mimalloc vs reftable" problems much quicker
because Git's birthplace *is* Linux, and its support for debugging on
that platform is still highly unmatched by its support for any other
platform.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Let's ignore the `static void mi_stat_total_print()` function that is
not actually used. This is code vendored into Git, and we want to
deviate as minimally from upstream mimalloc as possible to make it cheap
to stay up to date.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
@dscho dscho changed the title Upgrade to mimalloc v2.2.2 Upgrade to mimalloc v2.2.3 Apr 20, 2025
@dscho dscho added this to the Next release milestone Apr 21, 2025
@dscho dscho merged commit eaeb5b5 into git-for-windows:main Apr 21, 2025
114 of 115 checks passed
@dscho dscho deleted the upgrade-to-mimalloc-v2.2.2 branch April 21, 2025 12:13
dscho added a commit that referenced this pull request Apr 25, 2025
Git for Windows still carries [mimalloc
v2.1.2](https://github.com/microsoft/mimalloc/releases/tag/v2.1.2),
which is almost 2 years old. Let's upgrade.
dscho added a commit that referenced this pull request Apr 25, 2025
Git for Windows still carries [mimalloc
v2.1.2](https://github.com/microsoft/mimalloc/releases/tag/v2.1.2),
which is almost 2 years old. Let's upgrade.
dscho added a commit that referenced this pull request Apr 25, 2025
Git for Windows still carries [mimalloc
v2.1.2](https://github.com/microsoft/mimalloc/releases/tag/v2.1.2),
which is almost 2 years old. Let's upgrade.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants