Skip to content

c-deps: update jemalloc to 5.3.0#93045

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
nicktrav:nickt.jemalloc
Jan 6, 2023
Merged

c-deps: update jemalloc to 5.3.0#93045
craig[bot] merged 1 commit intocockroachdb:masterfrom
nicktrav:nickt.jemalloc

Conversation

@nicktrav
Copy link
Collaborator

@nicktrav nicktrav commented Dec 5, 2022

Update jemalloc to point to the upstream 5.3.0 release, hosted on our internal fork. This removes two custom patches that are no longer required:

Touches #83289.

Closes #17013. Closes #83289.

Epic: CRDB-20293.

Release note (performance improvement): The memory allocator, jemalloc was updated to the latest available upstream version, 5.3.0, from 4.5.0. This update pulls in a number of upstream improvements, including reduced memory fragmentation for memory allocated outside of the Go runtime (i.e. the Pebble block and table caches), resulting in better memory utilization.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@nicktrav
Copy link
Collaborator Author

nicktrav commented Dec 5, 2022

There were some memory leak concerns identified in #83289. Based on those, I took this SHA for a spin and compared it to master. I wasn't able to observe any noticeable regression in memory usage both during and after a load test.

The annotations, in order:

  • TPCC (warehouses 1000) start.
  • Tracing enabled - set cluster setting trace.debug.enable=on;
  • TPCC end.
  • KV50 start.
  • KV50 end.

There was no observable increase in RSS in the period after the load test ran.

Without patch:

Screen Shot 2022-12-03 at 10 49 04 AM

With patch:

Screen Shot 2022-12-03 at 10 49 13 AM

@nicktrav nicktrav marked this pull request as ready for review December 5, 2022 17:36
@nicktrav nicktrav requested review from a team and jbowens December 5, 2022 17:36
@rickystewart
Copy link
Collaborator

@nicktrav Did you build with --force_build_cdeps for these tests? I want to make sure that you were actually testing something here.

@nicktrav
Copy link
Collaborator Author

nicktrav commented Dec 5, 2022

Did you build with --force_build_cdeps for these tests?

Yikes! TIL. I did not build with that. Thank you for catching!

@rickystewart
Copy link
Collaborator

Yeah, so our c-deps have prebuilt archives that they pull for all builds unless you specify --force_build_cdeps. Please include that for all your testing.

When we're confident that we do want to update to this version of jemalloc, let me know and I can go through the process of building new archives for the new version, which we'll check in with this PR.

@rickystewart
Copy link
Collaborator

The file c-deps/BUILD.bazel may have to be updated depending on what changes to jemalloc have gone in in the interim, let me know if you need any help with this.

@nicktrav
Copy link
Collaborator Author

nicktrav commented Dec 5, 2022

Re-ran the same experiments with the correct build flags. There's a slight improvement in the fragmentation with the patch applied (red and orange lines closer together), and the total cgo memory is lower. No surprises here, given we're picking up a few years worth of improvements / optimizations.

I didn't see any evidence of leaking memory, though I'm going to keep this cluster up for the next day or so.

Before:
Screen Shot 2022-12-05 at 12 10 30 PM

After:

Screen Shot 2022-12-05 at 12 10 41 PM

@nicktrav
Copy link
Collaborator Author

nicktrav commented Dec 6, 2022

The patched version has held up well overnight. No signs of any memory leak when tracing is enabled.

Screen Shot 2022-12-06 at 6 58 41 AM

@nicktrav
Copy link
Collaborator Author

nicktrav commented Dec 8, 2022

Rebased on latest master and re-pushed (needed to kick the license/cla check again it seems).

Any other testing / experimenting here that folks would like to see before landing this? Ideally this has a substantial amount of burn time on master to weed out any issues ahead of the next release.

@rickystewart
Copy link
Collaborator

@nicktrav If you're comfortable with 5.3.0 I can kick off the archiving process so we can get this merged.

@nicktrav
Copy link
Collaborator Author

nicktrav commented Dec 8, 2022

If you're comfortable with 5.3.0 I can kick off the archiving process so we can get this merged.

Great - let's do that.

@rickystewart
Copy link
Collaborator

@nicktrav

Go ahead and apply the following patch to your PR and we'll check that CI is okay:

diff --git a/build/bazelutil/distdir_files.bzl b/build/bazelutil/distdir_files.bzl
index 517ce8409c..e0f9385366 100644
--- a/build/bazelutil/distdir_files.bzl
+++ b/build/bazelutil/distdir_files.bzl
@@ -1007,23 +1007,23 @@ DISTDIR_FILES = {
     "https://storage.googleapis.com/public-bazel-artifacts/bazel/rules_proto-b0cc14be5da05168b01db282fe93bdf17aa2b9f4.tar.gz": "88b0a90433866b44bb4450d4c30bc5738b8c4f9c9ba14e9661deb123f56a833d",
     "https://storage.googleapis.com/public-bazel-artifacts/bazel/rules_python-0.1.0.tar.gz": "b6d46438523a3ec0f3cead544190ee13223a52f6a6765a29eae7b7cc24cc83a0",
     "https://storage.googleapis.com/public-bazel-artifacts/bazel/sqllogictest-96138842571462ed9a697bff590828d8f6356a2f.tar.gz": "f7e0d659fbefb65f32d4c5d146cba4c73c43e0e96f9b217a756c82be17451f97",
-    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20220708-170245/libgeos_foreign.linux.20220708-170245.tar.gz": "c02edafb99b5a289f04e689731f5cab498b852f3557120e329fcb842e5282471",
-    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20220708-170245/libgeos_foreign.linuxarm.20220708-170245.tar.gz": "a91006cc7b0e468feaf7b0b8ba0ce892568fc2ce21319edb843f9827a7025aba",
-    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20220708-170245/libgeos_foreign.macos.20220708-170245.tar.gz": "4d6d6ec7bd21f0b973c7b20426e509849d22d33a7a6cf995f3ddf4426bc4d904",
-    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20220708-170245/libgeos_foreign.macosarm.20220708-170245.tar.gz": "993e6d85270d01ffba87c3a65fa6e500ed0edefc169cf7e19ab5edce3b40939c",
-    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20220708-170245/libgeos_foreign.windows.20220708-170245.tar.gz": "43d69d5b3c57530fa06537afc946aa78cb84e8f0e29201c33136762fb4a1d7ea",
-    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20220708-170245/libjemalloc_foreign.linux.20220708-170245.tar.gz": "ea73589ba3b4f677e1554ab84d562bafeba0b1057b7fbd651a1bc8bfe0a361ee",
-    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20220708-170245/libjemalloc_foreign.linuxarm.20220708-170245.tar.gz": "76a6bbc84f73753bbde78d6ec02d4aded310c740c9ee90944de816ef11127905",
-    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20220708-170245/libjemalloc_foreign.macos.20220708-170245.tar.gz": "0099715b3ddbc29451138c4304c744757f1bd4288dd57fa9b1900a5fab6a667f",
-    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20220708-170245/libjemalloc_foreign.macosarm.20220708-170245.tar.gz": "5bbb74136597f560ef6584173fe535acde328b3837aec995801310e77fcf5b48",
-    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20220708-170245/libjemalloc_foreign.windows.20220708-170245.tar.gz": "b4cc4f08df6a6701036a24150236a2012688d81f11a635dd372dbedcedae919f",
-    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20220708-170245/libkrb5_foreign.linux.20220708-170245.tar.gz": "53712526d4fcd4f13d019f0c9b789bbca13ba11cf3f1574fa9a1db576c82aecd",
-    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20220708-170245/libkrb5_foreign.linuxarm.20220708-170245.tar.gz": "83c5110940056cdad028ef7265a0a0f1602a1e578a67cbe5849104f1db31bfa0",
-    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20220708-170245/libproj_foreign.linux.20220708-170245.tar.gz": "a25bfdadf958955e8559ac2e03d5a76748919a838be07afef00635cc774b66c4",
-    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20220708-170245/libproj_foreign.linuxarm.20220708-170245.tar.gz": "0c6c1c795e9e8f30e68a6d4fec738fae8c7773fef4fddd8ace2e633cff76eea1",
-    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20220708-170245/libproj_foreign.macos.20220708-170245.tar.gz": "fd342ce3e99d9df6de8fcdf09ff9735887d7025d88ba9814b4c73cff24691b26",
-    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20220708-170245/libproj_foreign.macosarm.20220708-170245.tar.gz": "6394f40dbc799909ee239e42c25d08b5b2af0ad0c8aa30f37553e936f1c1dc4e",
-    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20220708-170245/libproj_foreign.windows.20220708-170245.tar.gz": "233c6cecef5e826bd1aea7c7c603fb86fc78299d2016c4d3afcb0c1509eff001",
+    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20221208-201744/libgeos_foreign.linux.20221208-201744.tar.gz": "1c6592aa8507bd83a7252143578bc84e9731d09ac79f7dda69b1476ce11653d6",
+    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20221208-201744/libgeos_foreign.linuxarm.20221208-201744.tar.gz": "0e09b30a9ca8872fce51ed115d27cb29c1e3586f433c2e805b396358e9e86adc",
+    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20221208-201744/libgeos_foreign.macos.20221208-201744.tar.gz": "f7505ee5db337b8fe722bb9bf00dbf53ff2f11eb4e1929ac3bec75ecedc0f783",
+    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20221208-201744/libgeos_foreign.macosarm.20221208-201744.tar.gz": "bd8bb1e92279abacb2bb7c8c76eb21c85c1f41ddc28e559e9ac78fc08d52716c",
+    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20221208-201744/libgeos_foreign.windows.20221208-201744.tar.gz": "371e8f91d10b6a12c7d22f91b0e612f61a405f90c86d7affd05ed56d748089a6",
+    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20221208-201744/libjemalloc_foreign.linux.20221208-201744.tar.gz": "d84c705dc75d7b5287a62d10f9c54fb6a8e36920ec421d03fe5711e23af43c15",
+    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20221208-201744/libjemalloc_foreign.linuxarm.20221208-201744.tar.gz": "68996e395f5520026f753d2485cecf1fe67f190f11bc9436852afbf7e2702eef",
+    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20221208-201744/libjemalloc_foreign.macos.20221208-201744.tar.gz": "a87b5e57be46c7e8fad37417d880edfe8616ac44613d4921e1a8d72913713ae4",
+    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20221208-201744/libjemalloc_foreign.macosarm.20221208-201744.tar.gz": "8eec1e0ebe5d64a8b28da8b880b106201c66659c322f958a3e9394f5dced77f8",
+    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20221208-201744/libjemalloc_foreign.windows.20221208-201744.tar.gz": "5ddec132e1f075eb3664630eeb5ac208588de01a56a8ac70e3a7cf4762ab55c1",
+    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20221208-201744/libkrb5_foreign.linux.20221208-201744.tar.gz": "ff6fd6cd17600c3fb4571edf0400d27d7d606c25ba0ed04c9459dbeafbab07a2",
+    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20221208-201744/libkrb5_foreign.linuxarm.20221208-201744.tar.gz": "eb5e5be91b772d3324be722d6a12d033f9194c66b7dd46b99c0ec4684ab02062",
+    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20221208-201744/libproj_foreign.linux.20221208-201744.tar.gz": "94bef24e6d7b2e82282a83f4fc33fe47e455e8ea75f3509c45790bf082321e5a",
+    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20221208-201744/libproj_foreign.linuxarm.20221208-201744.tar.gz": "1053bef2dfaee4a3a9da9cd8c8a821603435ca8d228fe45d68b98e0ea12b5bd9",
+    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20221208-201744/libproj_foreign.macos.20221208-201744.tar.gz": "5543ef1db69587d96187ce1ab4e5ea1e6966effa9f8c8c5f577b96b1bba5bf87",
+    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20221208-201744/libproj_foreign.macosarm.20221208-201744.tar.gz": "9919729ba645a327cbe2c2b5a9c7c4baeeff45a65ae810045ea5bc7b678e352e",
+    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20221208-201744/libproj_foreign.windows.20221208-201744.tar.gz": "a4a9c582c89b3f30a0e41f755c8ef0f374bec345856243b08d676737486a28c9",
     "https://storage.googleapis.com/public-bazel-artifacts/go/20220907-175858/go1.19.1.darwin-amd64.tar.gz": "96a164130f532c0ed65e437aaf9cc66b518f0b887d5830b2dc01ebfee9d58f52",
     "https://storage.googleapis.com/public-bazel-artifacts/go/20220907-175858/go1.19.1.darwin-arm64.tar.gz": "e46aecce83a9289be16ce4ba9b8478a5b89b8aa0230171d5c6adbc0c66640548",
     "https://storage.googleapis.com/public-bazel-artifacts/go/20220907-175858/go1.19.1.freebsd-amd64.tar.gz": "db5b8f232e12c655cc6cde6af1adf4d27d842541807802d747c86161e89efa0a",
diff --git a/c-deps/REPOSITORIES.bzl b/c-deps/REPOSITORIES.bzl
index e690116702..be3d0f3b02 100644
--- a/c-deps/REPOSITORIES.bzl
+++ b/c-deps/REPOSITORIES.bzl
@@ -39,85 +39,85 @@ def c_deps():
     archived_cdep_repository(
         lib = "libgeos",
         config = "linux",
-        sha256 = "c02edafb99b5a289f04e689731f5cab498b852f3557120e329fcb842e5282471",
+        sha256 = "1c6592aa8507bd83a7252143578bc84e9731d09ac79f7dda69b1476ce11653d6",
     )
     archived_cdep_repository(
         lib = "libjemalloc",
         config = "linux",
-        sha256 = "ea73589ba3b4f677e1554ab84d562bafeba0b1057b7fbd651a1bc8bfe0a361ee",
+        sha256 = "d84c705dc75d7b5287a62d10f9c54fb6a8e36920ec421d03fe5711e23af43c15",
     )
     archived_cdep_repository(
         lib = "libkrb5",
         config = "linux",
-        sha256 = "53712526d4fcd4f13d019f0c9b789bbca13ba11cf3f1574fa9a1db576c82aecd",
+        sha256 = "ff6fd6cd17600c3fb4571edf0400d27d7d606c25ba0ed04c9459dbeafbab07a2",
     )
     archived_cdep_repository(
         lib = "libproj",
         config = "linux",
-        sha256 = "a25bfdadf958955e8559ac2e03d5a76748919a838be07afef00635cc774b66c4",
+        sha256 = "94bef24e6d7b2e82282a83f4fc33fe47e455e8ea75f3509c45790bf082321e5a",
     )
     archived_cdep_repository(
         lib = "libgeos",
         config = "linuxarm",
-        sha256 = "a91006cc7b0e468feaf7b0b8ba0ce892568fc2ce21319edb843f9827a7025aba",
+        sha256 = "0e09b30a9ca8872fce51ed115d27cb29c1e3586f433c2e805b396358e9e86adc",
     )
     archived_cdep_repository(
         lib = "libjemalloc",
         config = "linuxarm",
-        sha256 = "76a6bbc84f73753bbde78d6ec02d4aded310c740c9ee90944de816ef11127905",
+        sha256 = "68996e395f5520026f753d2485cecf1fe67f190f11bc9436852afbf7e2702eef",
     )
     archived_cdep_repository(
         lib = "libkrb5",
         config = "linuxarm",
-        sha256 = "83c5110940056cdad028ef7265a0a0f1602a1e578a67cbe5849104f1db31bfa0",
+        sha256 = "eb5e5be91b772d3324be722d6a12d033f9194c66b7dd46b99c0ec4684ab02062",
     )
     archived_cdep_repository(
         lib = "libproj",
         config = "linuxarm",
-        sha256 = "0c6c1c795e9e8f30e68a6d4fec738fae8c7773fef4fddd8ace2e633cff76eea1",
+        sha256 = "1053bef2dfaee4a3a9da9cd8c8a821603435ca8d228fe45d68b98e0ea12b5bd9",
     )
     archived_cdep_repository(
         lib = "libgeos",
         config = "macos",
-        sha256 = "4d6d6ec7bd21f0b973c7b20426e509849d22d33a7a6cf995f3ddf4426bc4d904",
+        sha256 = "f7505ee5db337b8fe722bb9bf00dbf53ff2f11eb4e1929ac3bec75ecedc0f783",
     )
     archived_cdep_repository(
         lib = "libjemalloc",
         config = "macos",
-        sha256 = "0099715b3ddbc29451138c4304c744757f1bd4288dd57fa9b1900a5fab6a667f",
+        sha256 = "a87b5e57be46c7e8fad37417d880edfe8616ac44613d4921e1a8d72913713ae4",
     )
     archived_cdep_repository(
         lib = "libproj",
         config = "macos",
-        sha256 = "fd342ce3e99d9df6de8fcdf09ff9735887d7025d88ba9814b4c73cff24691b26",
+        sha256 = "5543ef1db69587d96187ce1ab4e5ea1e6966effa9f8c8c5f577b96b1bba5bf87",
     )
     archived_cdep_repository(
         lib = "libgeos",
         config = "macosarm",
-        sha256 = "993e6d85270d01ffba87c3a65fa6e500ed0edefc169cf7e19ab5edce3b40939c",
+        sha256 = "bd8bb1e92279abacb2bb7c8c76eb21c85c1f41ddc28e559e9ac78fc08d52716c",
     )
     archived_cdep_repository(
         lib = "libjemalloc",
         config = "macosarm",
-        sha256 = "5bbb74136597f560ef6584173fe535acde328b3837aec995801310e77fcf5b48",
+        sha256 = "8eec1e0ebe5d64a8b28da8b880b106201c66659c322f958a3e9394f5dced77f8",
     )
     archived_cdep_repository(
         lib = "libproj",
         config = "macosarm",
-        sha256 = "6394f40dbc799909ee239e42c25d08b5b2af0ad0c8aa30f37553e936f1c1dc4e",
+        sha256 = "9919729ba645a327cbe2c2b5a9c7c4baeeff45a65ae810045ea5bc7b678e352e",
     )
     archived_cdep_repository(
         lib = "libgeos",
         config = "windows",
-        sha256 = "43d69d5b3c57530fa06537afc946aa78cb84e8f0e29201c33136762fb4a1d7ea",
+        sha256 = "371e8f91d10b6a12c7d22f91b0e612f61a405f90c86d7affd05ed56d748089a6",
     )
     archived_cdep_repository(
         lib = "libjemalloc",
         config = "windows",
-        sha256 = "b4cc4f08df6a6701036a24150236a2012688d81f11a635dd372dbedcedae919f",
+        sha256 = "5ddec132e1f075eb3664630eeb5ac208588de01a56a8ac70e3a7cf4762ab55c1",
     )
     archived_cdep_repository(
         lib = "libproj",
         config = "windows",
-        sha256 = "233c6cecef5e826bd1aea7c7c603fb86fc78299d2016c4d3afcb0c1509eff001",
+        sha256 = "a4a9c582c89b3f30a0e41f755c8ef0f374bec345856243b08d676737486a28c9",
     )
diff --git a/c-deps/archived.bzl b/c-deps/archived.bzl
index 79aa681e89..b1114facac 100644
--- a/c-deps/archived.bzl
+++ b/c-deps/archived.bzl
@@ -4,7 +4,7 @@ load("@rules_cc//cc:find_cc_toolchain.bzl", "find_cc_toolchain")
 
 # NB: URL_TMPL and LOC are used by generate-distdir. Don't change the format or
 # name of these definitions unless you update generate-distdir accordingly.
-LOC = "20220708-170245"
+LOC = "20221208-201744"
 URL_TMPL = "https://storage.googleapis.com/public-bazel-artifacts/c-deps/{loc}/{lib}_foreign.{config}.{loc}.tar.gz"
 
 # NB: When we link with the krb5 libraries, we want the linker to see them in

@nicktrav nicktrav requested a review from a team as a code owner December 9, 2022 18:45
@nicktrav
Copy link
Collaborator Author

nicktrav commented Dec 9, 2022

@rickystewart - thanks for that. Just pushed a new commit with the changes. Happy to squash that into the first commit too.

@rickystewart
Copy link
Collaborator

@nicktrav Let's squash into one commit, since all these changes should be atomic and bundled together. Let's check CI and make sure everything looks good.

@nicktrav
Copy link
Collaborator Author

nicktrav commented Dec 9, 2022

Let's squash into one commit, since all these changes should be atomic and bundled together. Let's check CI and make sure everything looks good.

Ack. Done. Also rebased on latest master.

@nicktrav
Copy link
Collaborator Author

nicktrav commented Dec 9, 2022

@rickystewart - any insight into these test failures on for macOS? Looks like it's failing during linking, plus a nil pointer issue:

https://teamcity.cockroachdb.com/viewLog.html?buildId=7905609&tab=buildResultsDiv&buildTypeId=Cockroach_Ci_Builds_BuildMacOSArm64

https://teamcity.cockroachdb.com/viewLog.html?buildId=7905595&tab=buildResultsDiv&buildTypeId=Cockroach_UnitTests_BazelBuildMacOSCross

I hit the same issue on my linux box doing a cross-compile for macos.

$ ./dev build short --cross=macos
...
external/go_sdk/pkg/tool/linux_amd64/link: running external/cross_x86_64_macos_toolchain/bin/x86_64-apple-darwin21.2-cc failed: exit status 1
Undefined symbols for architecture x86_64:
  "_je_zone_register", referenced from:
      __cgo_dba21935bf37_Cfunc_je_zone_register in 000013.o
     (maybe you meant: __cgo_dba21935bf37_Cfunc_je_zone_register)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

link: error running subcommand external/go_sdk/pkg/tool/linux_amd64/link: exit status 2

@rickystewart
Copy link
Collaborator

       __cgo_dba21935bf37_Cfunc_je_zone_register in 000013.o
     (maybe you meant: __cgo_dba21935bf37_Cfunc_je_zone_register)

Is it just me, or are these two strings exactly the same?

I'll try to figure out what's going on here, might take me a little bit though.

@nicktrav
Copy link
Collaborator Author

nicktrav commented Dec 9, 2022

Is it just me, or are these two strings exactly the same?

Yeah ... goofy.

@rickystewart
Copy link
Collaborator

OK. I can get a working build if I make this change. I have no idea why the je_ prefix is missing from this function now.

diff --git a/pkg/server/status/runtime_jemalloc_darwin.go b/pkg/server/status/runtime_jemalloc_darwin.go
index a1ba4e3a9b2..57154378830 100644
--- a/pkg/server/status/runtime_jemalloc_darwin.go
+++ b/pkg/server/status/runtime_jemalloc_darwin.go
@@ -13,11 +13,11 @@
 
 package status
 
-// extern void je_zone_register();
+// extern void zone_register();
 import "C"
 
 func init() {
-	// On macOS, je_zone_register is run at init time to register jemalloc with
+	// On macOS, zone_register is run at init time to register jemalloc with
 	// the system allocator. Unfortunately, all the machinery for this is in a
 	// single file, and is not referenced elsewhere, causing the linker to omit
 	// the file's symbols. Manually force the presence of these symbols on macOS
@@ -29,5 +29,5 @@ func init() {
 	//
 	// See https://github.com/jemalloc/jemalloc/issues/708 and the references
 	// within.
-	C.je_zone_register()
+	C.zone_register()
 }

@nicktrav
Copy link
Collaborator Author

nicktrav commented Dec 9, 2022

Strange .. the upstream source doesn't have je_zone_register. It has zone_register, and it's been like that for a while from what I can tell.

https://github.com/jemalloc/jemalloc/blob/54eaed1d8b56b1aa528be3bdd1877e59c56fa90c/src/zone.c#L438

I can push the patch to update the function call. I assume that wasn't failing prior to applying your initial patch as it was using the older artifacts?

@nicktrav
Copy link
Collaborator Author

nicktrav commented Dec 9, 2022

I found #35620. Possibly related? That issue was fixed on the upstream project from what I can tell. And we have that patch in 5.3.0.

@nicktrav
Copy link
Collaborator Author

nicktrav commented Dec 9, 2022

Is it possible that our previous build of jemalloc added that prefix? And now we're stripping it?

@rickystewart - let me know whether you think it's worth removing the prefix in the Go code, or if you think it's worth digging into the build of jemalloc. I might need some help in that case.

@rickystewart
Copy link
Collaborator

I assume that wasn't failing prior to applying your initial patch as it was using the older artifacts?

Yes, CI was not failing prior to my patch as it was still using the older prebuilt artifacts.

@rickystewart - let me know whether you think it's worth removing the prefix in the Go code, or if you think it's worth digging into the build of jemalloc. I might need some help in that case.

I think I am not the person you should ask this question to. From my perspective as long as the build is working and the executable runs, I'm happy. :) However there may be others on the team who are more acutely interested in the anomaly.

Since the bugs you linked talk about the possibility of deadlocks, I would do some local testing on a macOS machine before making any decision. Testing the build from a normal local ./dev build short and running some basic commands successfully is probably sufficient.

@nicktrav
Copy link
Collaborator Author

Since the bugs you linked talk about the possibility of deadlocks, I would do some local testing on a macOS

Not too worried about the deadlock issue in that linked issue. We have that patch now in upstream 5.3.0. Basic testing locally, on macOS, did not reveal anything weird.

I think I am not the person you should ask this question to. From my perspective as long as the build is working and the executable runs, I'm happy. :)

Understood - could this be a build system thing though? Looking at the prebuilt artifacts in the patch you had me include, I see the _je_zone_register symbol in the old binary, but it looks like it's called _zone_register in the new binary:

# Old: https://storage.googleapis.com/public-bazel-artifacts/c-deps/20220708-170245/libjemalloc_foreign.macos.20220708-170245.tar.gz
$ nm -am ./libjemalloc-before.a 2> /dev/null | grep _zone_register
0000000000000000 (__TEXT,__text) external _je_zone_register
                 (undefined) external _malloc_zone_register

# New: https://storage.googleapis.com/public-bazel-artifacts/c-deps/20221208-201744/libjemalloc_foreign.macos.20221208-201744.tar.gz
$ nm -am ./libjemalloc-after.a 2> /dev/null | grep _zone_register
                 (undefined) external _malloc_zone_register
0000000000000000 (__TEXT,__text) external _zone_register

I also built this natively on macOS and I get the expected symbols:

$ bazel build //pkg/cmd/cockroach-short:cockroach-short --force_build_cdeps
$ nm -am _bazel/bin/c-deps/libjemalloc_foreign/lib/libjemalloc.a 2> /dev/null | grep _zone_register
0000000000000000 (__TEXT,__text) external _je_zone_register
                 (undefined) external _malloc_zone_register

In the jemalloc configure script, I see a --with-private-namespace flag, that can be used to set the JEMALLOC_PRIVATE_NAMESPACE variable. Looks like it defaults to je_.

I also found this commit in another project that has an explanation for why the symbols may not be prefixed.

Is it possible our artifact creation scripts are different now, and aren't doing the mangling we need?

@rickystewart
Copy link
Collaborator

Understood - could this be a build system thing though?

Yes, I would say some build system thing is the likeliest explanation for the symbol name mismatch. I would expect the quirk to be inside of jemalloc's cmake scripts rather than in "our" build. If we need to pass some extra flag to cmake then we can update c-deps/BUILD.bazel.

@nicktrav
Copy link
Collaborator Author

How does one build the artifacts? I'll run that locally and see if I can fix it to include the correct cmake flags.

@rickystewart
Copy link
Collaborator

bazel build c-deps:libjemalloc --force_build_cdeps should be sufficient for local testing. The libjemalloc_foreign target in c-deps/BUILD.bazel is the one you should update to add cmake flags or whatever.

Note that the build in Bazel is single-threaded so you can't really quickly iterate on it. You might find it faster to just cd c-deps/jemalloc and use cmake directly.

@nicktrav
Copy link
Collaborator Author

I think I'm getting closer to understanding the actual reason this isn't linking when doing a cross-compile for macOS.

  • The cross compile runs on a Linux platform (inside a build Linux container).
  • When building on a Linux platform, the jemalloc build does not set the je_ prefix for symbols. When linking, our Go code looks for _je_zone_register, but the symbol in the jemalloc binary is _zone_register.
  • One can use the configure flags to set the prefix. Under the hood, the jemalloc build uses nm and an awk script to rewrite the symbols. However, as the binary has been cross-compiled for macOS, nm can't read the binary.
  • The resulting jemalloc binary therefore doesn't contain the _je prefix, and the cockroach binary fails to link.

Here's what I see in the build log from within the build container:

$ bazel build //c-deps:libjemalloc_foreign --force_build_cdeps -s --verbose_failures --sandbox_debug --config=crossmacos
...
INFO: Build completed successfully, 2 total actions
$ cat _bazel/out/k8-fastbuild/bin/c-deps/libjemalloc_foreign_foreign_cc/Configure.log
...
nm -a src/jemalloc.sym.o | mawk -f include/jemalloc/internal/private_symbols.awk > src/jemalloc.sym
nm: src/jemalloc.sym.o: file format not recognized
...
$ file /home/roach/.cache/bazel/_bazel_roach/cc377fc379544923cc7508dd261e4a48/sandbox/processwrapper-sandbox/1/execroot/com_github_cockroachdb_cockroach/bazel-out/k8-fastbuild/bin/c-deps/libjemalloc_foreign.build_tmpdir/src/jemalloc.sym.o
/home/roach/.cache/bazel/_bazel_roach/cc377fc379544923cc7508dd261e4a48/sandbox/processwrapper-sandbox/1/execroot/com_github_cockroachdb_cockroach/bazel-out/k8-fastbuild/bin/c-deps/libjemalloc_foreign.build_tmpdir/src/jemalloc.sym.o: Mach-O 64-bit x86_64 object, flags:<|SUBSECTIONS_VIA_SYMBOLS>

One solution is to make the s/je_zone_register/zone_register/ change suggested above. However, this will result in a build failure on macOS when running with the --force_build_cdeps flag - as on a macOS platform, jemalloc will produce a binary with the _je prefix, and nm works fine with binaries compiled for the platform for which itself was compiled, but we are now looking for the zone_register symbol in our Go code.

Building on the above, we could set the prefix to "" when building for the macOS platform as a workaround. That said, I'm not confident that doing so will break something else on macOS. Relevant comment in jemalloc is here.

Alternatively, if we can work out how to make the nm inside the build container work with Mach-O binaries, that feels more like "doing things the right way". I believe that would involve a cross-compiled nm.

@rickystewart - any thoughts on any of this?

@rickystewart
Copy link
Collaborator

Alternatively, if we can work out how to make the nm inside the build container work with Mach-O binaries, that feels more like "doing things the right way". I believe that would involve a cross-compiled nm.

To me this seems like a very probably huge amount of work with dubious benefit.

Building on the above, we could set the prefix to "" when building for the macOS platform as a workaround. That said, I'm not confident that doing so will break something else on macOS. Relevant comment in jemalloc is here.

This seems like the sanest approach to me. Making sure the symbol name is consistent across all versions of the library (prebuilt, non-prebuilt) seems like a good idea.

@nicktrav
Copy link
Collaborator Author

I was able to confirm that this upstream commit is the one that breaks things for us. Unsurprisingly, it introduces nm to do the rewriting of symbols.

This seems like the sanest approach to me. Making sure the symbol name is consistent across all versions of the library (prebuilt, non-prebuilt) seems like a good idea.

I'll try this and report back.

@nicktrav
Copy link
Collaborator Author

Ok I think I have a workable solution to this. LLVM's nm is smart enough to be able to detect the platform, so it should be able to interpret the Mach-O binaries the jemalloc build spits out when building in the Linux container.

To test this out, I added llvm-nm to the build container with the following patch:

diff --git a/build/bazelbuilder/Dockerfile b/build/bazelbuilder/Dockerfile
index 4360b2affb..7fda560fcf 100644
--- a/build/bazelbuilder/Dockerfile
+++ b/build/bazelbuilder/Dockerfile
@@ -76,6 +76,10 @@ RUN case ${TARGETPLATFORM} in \
       google-chrome-stable ;; \
     esac

+# Replace nm with llvm-nm
+RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends llvm \
+ && ln -sf /usr/bin/llvm-nm /usr/bin/nm
+
 RUN apt-get purge -y \
     apt-transport-https \
     flex \

I was then able to build jemalloc, and the resulting artifact had the symbols that the linker expects.

Artifact with the current build container (cockroachdb/bazel:20220328-163955):

$ nm -a ./artifacts/libjemalloc.a.old 2>/dev/null | grep '_zone_register'
                 U _malloc_zone_register
0000000000000000 T _zone_register

Artifact from the patched build container:

$ nm -a ./artifacts/libjemalloc.a.new 2>/dev/null | grep '_zone_register'
0000000000000000 T _je_zone_register
                 U _malloc_zone_register

Note the _je prefix.

@rickystewart - what do you think about using LLVM's nm in the build containers? I assume I should put that patch up separately and publish new build containers, etc? Then I can rebase this, republish the c-deps, update the c-dep artifact paths, and we should be good to go 🤞

@rickystewart
Copy link
Collaborator

@nicktrav Yeah, please get the nm change into a separate PR, then I can rebuild the image, and we can verify that nothing else breaks in CI given the change.

nicktrav added a commit to nicktrav/cockroach that referenced this pull request Jan 4, 2023
Currently, the build containers contain the standard GNU version of
`nm`. This version of the tool is sufficient for the current build,
which does not need to directly interact with binaries cross compiled
for platforms other than Linux.

When pulling in the latest version of `jemalloc` (`5.3.0`), builds for
cross compiled for macOS requiring using `nm` to perform name mangling.
As the GNU version of `nm` in the Linux build container does not know
how to read Macho-O binaries, the name mangling does not occur, and the
Cockroach binary will fail to link.

Use the version of `nm` that ships with LLVM (`llvm-nm`) in place of GNU
`nm`. This version of `nm` can understand Macho-O binaries and perform
the name mangling as intended, resolving the linking issue.

Update the build container version to `20230103-212639`.

Touches cockroachdb#83289.

Informs cockroachdb#93045.

Release note: None.
craig bot pushed a commit that referenced this pull request Jan 4, 2023
94196: build: use llvm-nm in place of nm r=rickystewart a=nicktrav

Currently, the build containers contain the standard GNU version of `nm`. This version of the tool is sufficient for the current build, which does not need to directly interact with binaries cross compiled for platforms other than Linux.

When pulling in the latest version of `jemalloc` (`5.3.0`), builds for cross compiled for macOS requiring using `nm` to perform name mangling. As the GNU version of `nm` in the Linux build container does not know how to read Macho-O binaries, the name mangling does not occur, and the Cockroach binary will fail to link.

Use the version of `nm` that ships with LLVM (`llvm-nm`) in place of GNU `nm`. This version of `nm` can understand Macho-O binaries and perform the name mangling as intended, resolving the linking issue.

Touches #83289.

Informs #93045.

Release note: None.

Epic: CRDB-20293

94700: kvserver: fix race in TestSchedulerBuffering r=erikgrinaker a=pavelkalinnikov

In TestSchedulerBuffering there is a race between adding a new event to the
queue and finishing the processing of the previous event. The scheduler
processes this correctly, but when the ticks need to be dropped, the number of
processed ticks is non-deterministic.

This commit fixes the flake. It introduces a Raft ready interceptor which
effectively allows blocking the processing loop while ticks are being added.
This imitates the real world scenario.

Fixes #94303
Epic: none

94709: replicastats: keep locality during mistmatch  r=andrewbaptist a=kvoli

Previously it was possibly for a panic to occur due to a nil ptr de-reference in `replicastats.PerLocalityDecayingRate()`. This situation arose when merging/splitting replica stats' with mismatched locality tracking; where one replicastats tracked the locality of requests and the other did not.

This occurence was infrequent however could occur
when merge or split is called with a replica which existed before the storepool initialization and a replica which was created after.

This patch resolves this issue by ensuring that the the locality tracking on either side post-(split|merge) is consistent with the initial locality tracking, rather than attempting to reset either partially.

fixes: #94696

Release note: None

94721: scripts: `dev generate` before updating dependencies r=jbowens a=jbowens

See #94712 (review)

Epic: None
Release note: None

Co-authored-by: Nick Travers <travers@cockroachlabs.com>
Co-authored-by: Pavel Kalinnikov <pavel@cockroachlabs.com>
Co-authored-by: Austen McClernon <austen@cockroachlabs.com>
Co-authored-by: Jackson Owens <jackson@cockroachlabs.com>
@nicktrav
Copy link
Collaborator Author

nicktrav commented Jan 4, 2023

@rickystewart - rebased and pushed. I assume we'll need another patch with the pre-built c-deps, as above?

@rickystewart
Copy link
Collaborator

Not sure if this will be sufficient or if we need more changes to the BUILD files, but I am kicking off a pre-build now.

@rickystewart
Copy link
Collaborator

Try the following patch now.

diff --git a/build/bazelutil/distdir_files.bzl b/build/bazelutil/distdir_files.bzl
index 23e7ecf931f..b151a9edf5e 100644
--- a/build/bazelutil/distdir_files.bzl
+++ b/build/bazelutil/distdir_files.bzl
@@ -1009,23 +1009,23 @@ DISTDIR_FILES = {
     "https://storage.googleapis.com/public-bazel-artifacts/bazel/rules_proto-b0cc14be5da05168b01db282fe93bdf17aa2b9f4.tar.gz": "88b0a90433866b44bb4450d4c30bc5738b8c4f9c9ba14e9661deb123f56a833d",
     "https://storage.googleapis.com/public-bazel-artifacts/bazel/rules_python-0.1.0.tar.gz": "b6d46438523a3ec0f3cead544190ee13223a52f6a6765a29eae7b7cc24cc83a0",
     "https://storage.googleapis.com/public-bazel-artifacts/bazel/sqllogictest-96138842571462ed9a697bff590828d8f6356a2f.tar.gz": "f7e0d659fbefb65f32d4c5d146cba4c73c43e0e96f9b217a756c82be17451f97",
-    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20220708-170245/libgeos_foreign.linux.20220708-170245.tar.gz": "c02edafb99b5a289f04e689731f5cab498b852f3557120e329fcb842e5282471",
-    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20220708-170245/libgeos_foreign.linuxarm.20220708-170245.tar.gz": "a91006cc7b0e468feaf7b0b8ba0ce892568fc2ce21319edb843f9827a7025aba",
-    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20220708-170245/libgeos_foreign.macos.20220708-170245.tar.gz": "4d6d6ec7bd21f0b973c7b20426e509849d22d33a7a6cf995f3ddf4426bc4d904",
-    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20220708-170245/libgeos_foreign.macosarm.20220708-170245.tar.gz": "993e6d85270d01ffba87c3a65fa6e500ed0edefc169cf7e19ab5edce3b40939c",
-    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20220708-170245/libgeos_foreign.windows.20220708-170245.tar.gz": "43d69d5b3c57530fa06537afc946aa78cb84e8f0e29201c33136762fb4a1d7ea",
-    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20220708-170245/libjemalloc_foreign.linux.20220708-170245.tar.gz": "ea73589ba3b4f677e1554ab84d562bafeba0b1057b7fbd651a1bc8bfe0a361ee",
-    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20220708-170245/libjemalloc_foreign.linuxarm.20220708-170245.tar.gz": "76a6bbc84f73753bbde78d6ec02d4aded310c740c9ee90944de816ef11127905",
-    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20220708-170245/libjemalloc_foreign.macos.20220708-170245.tar.gz": "0099715b3ddbc29451138c4304c744757f1bd4288dd57fa9b1900a5fab6a667f",
-    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20220708-170245/libjemalloc_foreign.macosarm.20220708-170245.tar.gz": "5bbb74136597f560ef6584173fe535acde328b3837aec995801310e77fcf5b48",
-    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20220708-170245/libjemalloc_foreign.windows.20220708-170245.tar.gz": "b4cc4f08df6a6701036a24150236a2012688d81f11a635dd372dbedcedae919f",
-    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20220708-170245/libkrb5_foreign.linux.20220708-170245.tar.gz": "53712526d4fcd4f13d019f0c9b789bbca13ba11cf3f1574fa9a1db576c82aecd",
-    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20220708-170245/libkrb5_foreign.linuxarm.20220708-170245.tar.gz": "83c5110940056cdad028ef7265a0a0f1602a1e578a67cbe5849104f1db31bfa0",
-    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20220708-170245/libproj_foreign.linux.20220708-170245.tar.gz": "a25bfdadf958955e8559ac2e03d5a76748919a838be07afef00635cc774b66c4",
-    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20220708-170245/libproj_foreign.linuxarm.20220708-170245.tar.gz": "0c6c1c795e9e8f30e68a6d4fec738fae8c7773fef4fddd8ace2e633cff76eea1",
-    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20220708-170245/libproj_foreign.macos.20220708-170245.tar.gz": "fd342ce3e99d9df6de8fcdf09ff9735887d7025d88ba9814b4c73cff24691b26",
-    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20220708-170245/libproj_foreign.macosarm.20220708-170245.tar.gz": "6394f40dbc799909ee239e42c25d08b5b2af0ad0c8aa30f37553e936f1c1dc4e",
-    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20220708-170245/libproj_foreign.windows.20220708-170245.tar.gz": "233c6cecef5e826bd1aea7c7c603fb86fc78299d2016c4d3afcb0c1509eff001",
+    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20230105-170607/libgeos_foreign.linux.20230105-170607.tar.gz": "ba5abd50a78c37460b3bf71e511c27c9ccee47b62f39fb95e2f0484ca81e7483",
+    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20230105-170607/libgeos_foreign.linuxarm.20230105-170607.tar.gz": "0817ec0f0b6487c8204e7456025ad9bf2aad644e67842d2089c79e8eed0e64ea",
+    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20230105-170607/libgeos_foreign.macos.20230105-170607.tar.gz": "10bcfd316c047afe00bb6d5ad519cbd2b4c8b9d35ca197fed771f6d3fbbb7b66",
+    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20230105-170607/libgeos_foreign.macosarm.20230105-170607.tar.gz": "1db3ec640b3992a2dd693df9bf5c52c55b43f387399ca885f1692fbbfa6baf88",
+    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20230105-170607/libgeos_foreign.windows.20230105-170607.tar.gz": "221408632feebb02f0793900aea1ed477fbb51cf8b278c4d6eea61f38870ffb4",
+    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20230105-170607/libjemalloc_foreign.linux.20230105-170607.tar.gz": "fc49f5f31603c20743eb6278497777d18681c7ad51a0ed32fe246e7d1c55f12e",
+    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20230105-170607/libjemalloc_foreign.linuxarm.20230105-170607.tar.gz": "b6c969eb34369e5964f3d8d41efe4d0d19a1dd298ed8f217cfbaa2718e77dc9b",
+    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20230105-170607/libjemalloc_foreign.macos.20230105-170607.tar.gz": "9f786e0e8200ce8f55f0328c283ddbbb77a5fcd03437319335e0fddf9fb27a66",
+    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20230105-170607/libjemalloc_foreign.macosarm.20230105-170607.tar.gz": "06f046643bbcbf071108c4dc21f5bc9b843f597871d88f95760eda63d4ade822",
+    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20230105-170607/libjemalloc_foreign.windows.20230105-170607.tar.gz": "1f5ca83705c961b89745fc4f80b8363995f973800be210a5a5fd423d6bd17a22",
+    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20230105-170607/libkrb5_foreign.linux.20230105-170607.tar.gz": "0ab2d7116f5c52c7f035e492b8899f9e632450f4c0c1db81b9da45bb40317950",
+    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20230105-170607/libkrb5_foreign.linuxarm.20230105-170607.tar.gz": "624631c7c8e79ec97074ab7bf2c19102c82a2c897fa3465a97c21809a3c35579",
+    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20230105-170607/libproj_foreign.linux.20230105-170607.tar.gz": "bfb537ee11fb1442d77e26d273c42a06366b2687e1936cca166f4fd25ccd42dc",
+    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20230105-170607/libproj_foreign.linuxarm.20230105-170607.tar.gz": "e9fce505246165c34c4cb00b67076cae2319c5203db11a378a76c17cea204722",
+    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20230105-170607/libproj_foreign.macos.20230105-170607.tar.gz": "7706dcc20f083f621ba891eb82864e980ae352f34add33753100085d12ab91ec",
+    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20230105-170607/libproj_foreign.macosarm.20230105-170607.tar.gz": "1ab617eb51b017d27d71ba08a065b6a08ef5410e9aa5554669196b7cf28214c1",
+    "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20230105-170607/libproj_foreign.windows.20230105-170607.tar.gz": "b819b17740b2a3418d62d2f6db8b245094458180e1e5e301e9f0f4257696fef5",
     "https://storage.googleapis.com/public-bazel-artifacts/go/20221219-000617/go1.19.4.darwin-amd64.tar.gz": "6fa1e9087b36fba65625869c885ca9c6f1db734306d8e74836b212248c20d55d",
     "https://storage.googleapis.com/public-bazel-artifacts/go/20221219-000617/go1.19.4.darwin-arm64.tar.gz": "bb3bc5d7655b9637cfe2b5e90055dee93b0ead50e2ffd091df320d1af1ca853f",
     "https://storage.googleapis.com/public-bazel-artifacts/go/20221219-000617/go1.19.4.freebsd-amd64.tar.gz": "84489ebb63f1757b79574d7345c647bd40bc6414cecb868c93e24476c2d2b9b6",
diff --git a/c-deps/REPOSITORIES.bzl b/c-deps/REPOSITORIES.bzl
index e6901167021..5bded782be8 100644
--- a/c-deps/REPOSITORIES.bzl
+++ b/c-deps/REPOSITORIES.bzl
@@ -39,85 +39,85 @@ def c_deps():
     archived_cdep_repository(
         lib = "libgeos",
         config = "linux",
-        sha256 = "c02edafb99b5a289f04e689731f5cab498b852f3557120e329fcb842e5282471",
+        sha256 = "ba5abd50a78c37460b3bf71e511c27c9ccee47b62f39fb95e2f0484ca81e7483",
     )
     archived_cdep_repository(
         lib = "libjemalloc",
         config = "linux",
-        sha256 = "ea73589ba3b4f677e1554ab84d562bafeba0b1057b7fbd651a1bc8bfe0a361ee",
+        sha256 = "fc49f5f31603c20743eb6278497777d18681c7ad51a0ed32fe246e7d1c55f12e",
     )
     archived_cdep_repository(
         lib = "libkrb5",
         config = "linux",
-        sha256 = "53712526d4fcd4f13d019f0c9b789bbca13ba11cf3f1574fa9a1db576c82aecd",
+        sha256 = "0ab2d7116f5c52c7f035e492b8899f9e632450f4c0c1db81b9da45bb40317950",
     )
     archived_cdep_repository(
         lib = "libproj",
         config = "linux",
-        sha256 = "a25bfdadf958955e8559ac2e03d5a76748919a838be07afef00635cc774b66c4",
+        sha256 = "bfb537ee11fb1442d77e26d273c42a06366b2687e1936cca166f4fd25ccd42dc",
     )
     archived_cdep_repository(
         lib = "libgeos",
         config = "linuxarm",
-        sha256 = "a91006cc7b0e468feaf7b0b8ba0ce892568fc2ce21319edb843f9827a7025aba",
+        sha256 = "0817ec0f0b6487c8204e7456025ad9bf2aad644e67842d2089c79e8eed0e64ea",
     )
     archived_cdep_repository(
         lib = "libjemalloc",
         config = "linuxarm",
-        sha256 = "76a6bbc84f73753bbde78d6ec02d4aded310c740c9ee90944de816ef11127905",
+        sha256 = "b6c969eb34369e5964f3d8d41efe4d0d19a1dd298ed8f217cfbaa2718e77dc9b",
     )
     archived_cdep_repository(
         lib = "libkrb5",
         config = "linuxarm",
-        sha256 = "83c5110940056cdad028ef7265a0a0f1602a1e578a67cbe5849104f1db31bfa0",
+        sha256 = "624631c7c8e79ec97074ab7bf2c19102c82a2c897fa3465a97c21809a3c35579",
     )
     archived_cdep_repository(
         lib = "libproj",
         config = "linuxarm",
-        sha256 = "0c6c1c795e9e8f30e68a6d4fec738fae8c7773fef4fddd8ace2e633cff76eea1",
+        sha256 = "e9fce505246165c34c4cb00b67076cae2319c5203db11a378a76c17cea204722",
     )
     archived_cdep_repository(
         lib = "libgeos",
         config = "macos",
-        sha256 = "4d6d6ec7bd21f0b973c7b20426e509849d22d33a7a6cf995f3ddf4426bc4d904",
+        sha256 = "10bcfd316c047afe00bb6d5ad519cbd2b4c8b9d35ca197fed771f6d3fbbb7b66",
     )
     archived_cdep_repository(
         lib = "libjemalloc",
         config = "macos",
-        sha256 = "0099715b3ddbc29451138c4304c744757f1bd4288dd57fa9b1900a5fab6a667f",
+        sha256 = "9f786e0e8200ce8f55f0328c283ddbbb77a5fcd03437319335e0fddf9fb27a66",
     )
     archived_cdep_repository(
         lib = "libproj",
         config = "macos",
-        sha256 = "fd342ce3e99d9df6de8fcdf09ff9735887d7025d88ba9814b4c73cff24691b26",
+        sha256 = "7706dcc20f083f621ba891eb82864e980ae352f34add33753100085d12ab91ec",
     )
     archived_cdep_repository(
         lib = "libgeos",
         config = "macosarm",
-        sha256 = "993e6d85270d01ffba87c3a65fa6e500ed0edefc169cf7e19ab5edce3b40939c",
+        sha256 = "1db3ec640b3992a2dd693df9bf5c52c55b43f387399ca885f1692fbbfa6baf88",
     )
     archived_cdep_repository(
         lib = "libjemalloc",
         config = "macosarm",
-        sha256 = "5bbb74136597f560ef6584173fe535acde328b3837aec995801310e77fcf5b48",
+        sha256 = "06f046643bbcbf071108c4dc21f5bc9b843f597871d88f95760eda63d4ade822",
     )
     archived_cdep_repository(
         lib = "libproj",
         config = "macosarm",
-        sha256 = "6394f40dbc799909ee239e42c25d08b5b2af0ad0c8aa30f37553e936f1c1dc4e",
+        sha256 = "1ab617eb51b017d27d71ba08a065b6a08ef5410e9aa5554669196b7cf28214c1",
     )
     archived_cdep_repository(
         lib = "libgeos",
         config = "windows",
-        sha256 = "43d69d5b3c57530fa06537afc946aa78cb84e8f0e29201c33136762fb4a1d7ea",
+        sha256 = "221408632feebb02f0793900aea1ed477fbb51cf8b278c4d6eea61f38870ffb4",
     )
     archived_cdep_repository(
         lib = "libjemalloc",
         config = "windows",
-        sha256 = "b4cc4f08df6a6701036a24150236a2012688d81f11a635dd372dbedcedae919f",
+        sha256 = "1f5ca83705c961b89745fc4f80b8363995f973800be210a5a5fd423d6bd17a22",
     )
     archived_cdep_repository(
         lib = "libproj",
         config = "windows",
-        sha256 = "233c6cecef5e826bd1aea7c7c603fb86fc78299d2016c4d3afcb0c1509eff001",
+        sha256 = "b819b17740b2a3418d62d2f6db8b245094458180e1e5e301e9f0f4257696fef5",
     )
diff --git a/c-deps/archived.bzl b/c-deps/archived.bzl
index 79aa681e891..9c77f632281 100644
--- a/c-deps/archived.bzl
+++ b/c-deps/archived.bzl
@@ -4,7 +4,7 @@ load("@rules_cc//cc:find_cc_toolchain.bzl", "find_cc_toolchain")
 
 # NB: URL_TMPL and LOC are used by generate-distdir. Don't change the format or
 # name of these definitions unless you update generate-distdir accordingly.
-LOC = "20220708-170245"
+LOC = "20230105-170607"
 URL_TMPL = "https://storage.googleapis.com/public-bazel-artifacts/c-deps/{loc}/{lib}_foreign.{config}.{loc}.tar.gz"
 
 # NB: When we link with the krb5 libraries, we want the linker to see them in

Update jemalloc to point to the upstream 5.3.0 release, hosted on our
internal fork. This removes two custom patches that are no longer
required:

- Fix deadlock in multithreaded fork in OS X - fix upstreamed in
  jemalloc/jemalloc#954.
- Fix JEMALLOC_MUTEX_INIT_CB to only be set if OSS_PINLOCK is false -
  spinlock support was removed upstream in jemalloc/jemalloc#1367

Touches cockroachdb#83289.

Epic: CRDB-20293.

Release note: None.
@nicktrav
Copy link
Collaborator Author

nicktrav commented Jan 5, 2023

I think we're looking good here. Everything green in CI. I also tested the following combinations:

  • Build platform: Darwin, Build target: Darwin
  • Build platform: Darwin, Build target: Linux (cross)
  • Build platform: Linux, Build target: Linux
  • Build platform: Linux, Build target: Darwin (cross)

Everything linked and I could run without issue on the appropriate target platform.

Putting this into the queue ... TFTR!

bors r=rickystewart

@jbowens
Copy link
Contributor

jbowens commented Jan 5, 2023

Nice!

@craig
Copy link
Contributor

craig bot commented Jan 5, 2023

Build failed (retrying...):

@craig
Copy link
Contributor

craig bot commented Jan 6, 2023

Build succeeded:

@craig craig bot merged commit 71f9712 into cockroachdb:master Jan 6, 2023
@nicktrav nicktrav deleted the nickt.jemalloc branch January 6, 2023 02:09
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.

c-deps: update jemalloc stability: OOMs on v1.1x due to jemalloc 5.0.0 changes.

4 participants