Skip to content

Adjust load order of libmimalloc and libbrpc#202

Merged
xiexiaoy merged 1 commit intoeloqdata:mainfrom
xiexiaoy:doc-fix
Sep 19, 2025
Merged

Adjust load order of libmimalloc and libbrpc#202
xiexiaoy merged 1 commit intoeloqdata:mainfrom
xiexiaoy:doc-fix

Conversation

@xiexiaoy
Copy link
Collaborator

@xiexiaoy xiexiaoy commented Sep 19, 2025

Summary by CodeRabbit

  • Documentation

    • Reformatted Quick Start steps with bold headings, added a download link, and included expected Mongo shell output examples for both deployment guides.
    • Converted Advanced Topics to bullet lists and fixed broken cross-reference anchors in configuration docs.
    • Added guidance on ensuring library load order at runtime and an LD_PRELOAD alternative.
  • Chores

    • Updated packaging to ensure required libraries are preloaded when the bundled database binary launches.

@coderabbitai
Copy link

coderabbitai bot commented Sep 19, 2025

Warning

Rate limit exceeded

@xiexiaoy has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 16 minutes and 4 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 2b2347a and 341eee2.

📒 Files selected for processing (5)
  • README.md (7 hunks)
  • concourse/scripts/build_tarball.bash (1 hunks)
  • concourse/scripts/build_tarball_open.bash (1 hunks)
  • docs/configuration-description.md (4 hunks)
  • docs/how-to-compile.md (1 hunks)

Walkthrough

Build scripts now reorder mongod DT_NEEDED to preload libbrpc then libmimalloc via patchelf; docs add guidance for adjusting load order and LD_PRELOAD. README formatting and sample outputs updated; several config-doc anchor slugs corrected. No exported/public API changes.

Changes

Cohort / File(s) Summary of changes
Build scripts: patchelf DT_NEEDED edits for mongod
concourse/scripts/build_tarball.bash, concourse/scripts/build_tarball_open.bash
Insert patchelf commands that remove libmimalloc.so.2 and libbrpc.so from ${DEST_DIR}/bin/mongod DT_NEEDED and re-add them in the order libbrpc.so then libmimalloc.so.2; placed after existing rpath edits and before config copying.
Documentation: README formatting and examples
README.md
Convert Step headings (Step-1…Step-7) to bold in both Quick Start sections, add line linking downloads before Step-2, include “It should output” sample mongo shell output blocks after mongo invocations, and change Advanced Topics list to Markdown bullets.
Documentation: build guidance
docs/how-to-compile.md
Add subsection "3 Adjust load order of libmimalloc and libbrpc" documenting patchelf commands to reorder DT_NEEDED for $INSTALL_PREFIX/bin/mongod and provide an LD_PRELOAD fallback.
Documentation: anchor fixes
docs/configuration-description.md
Fix anchor slug references used in descriptions: net.bindIpAll#netbindip, storage.eloq.txService.ipList slug correction, and multiple dbPath references updated to storagedbpath.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Dev as Developer
  participant Build as Build script
  participant PE as patchelf
  participant Bin as mongod (ELF)
  participant RT as Runtime loader (ld.so)

  Dev->>Build: run build_tarball*.bash
  Build->>PE: run --set-rpath (existing)
  Build->>PE: remove NEEDED: libmimalloc.so.2, libbrpc.so
  Build->>PE: add NEEDED in order: libbrpc.so, libmimalloc.so.2
  PE->>Bin: update DT_NEEDED entries
  note right of Bin: mongod now encodes libbrpc before libmimalloc
  Dev->>RT: execute mongod
  RT->>Bin: resolve DT_NEEDED and load libraries in declared order
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • lzxddz

Poem

I hopped through scripts with nimble paws,
Nudged libs in order without a pause.
Docs now bolder, outputs in view—
Load order set, the build feels new.
A tiny patch, a happy chew 🐇✨

Pre-merge checks and finishing touches and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "Adjust load order of libmimalloc and libbrpc" is concise and directly reflects the primary changes in the PR (modifications to mongod DT_NEEDED entries via patchelf and accompanying documentation). It clearly communicates the main action without unnecessary detail and is readable for teammates scanning history. Therefore it satisfies the project's title guidelines.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

Comment @coderabbitai help to get the list of available commands and usage tips.

@xiexiaoy xiexiaoy marked this pull request as ready for review September 19, 2025 09:02
@xiexiaoy
Copy link
Collaborator Author

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Sep 19, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@xiexiaoy xiexiaoy requested a review from lzxddz September 19, 2025 09:03
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (3)
concourse/scripts/build_tarball.bash (1)

290-295: Consider error handling for patchelf operations.

The patchelf commands may fail if the libraries are not currently in the DT_NEEDED entries or if the mongod binary doesn't exist. Consider adding error handling or validation to prevent silent failures.

Apply this diff to add basic error checking:

 # Preload libmimalloc and libbrpc at launch.
-patchelf --remove-needed libmimalloc.so.2 ${DEST_DIR}/bin/mongod
-patchelf --remove-needed libbrpc.so ${DEST_DIR}/bin/mongod
-patchelf --add-needed libbrpc.so ${DEST_DIR}/bin/mongod
-patchelf --add-needed libmimalloc.so.2 ${DEST_DIR}/bin/mongod
+if [ -f ${DEST_DIR}/bin/mongod ]; then
+  patchelf --remove-needed libmimalloc.so.2 ${DEST_DIR}/bin/mongod || true
+  patchelf --remove-needed libbrpc.so ${DEST_DIR}/bin/mongod || true
+  patchelf --add-needed libbrpc.so ${DEST_DIR}/bin/mongod
+  patchelf --add-needed libmimalloc.so.2 ${DEST_DIR}/bin/mongod
+else
+  echo "Warning: ${DEST_DIR}/bin/mongod not found, skipping library preload"
+fi
docs/how-to-compile.md (1)

133-137: Consider adding path validation example.

The LD_PRELOAD example uses hardcoded paths that may not exist on all systems. Consider mentioning that users should adjust the paths to match their installation.

Apply this diff to make the example more flexible:

 If you don't adjust load order, then you must set LD_PRELOAD before run EloqDoc.

 ```bash
-export LD_PRELOAD=/usr/local/lib/libmimalloc.so.2:/usr/lib/libbrpc.so
+export LD_PRELOAD=$INSTALL_PREFIX/lib/libmimalloc.so.2:$INSTALL_PREFIX/lib/libbrpc.so
+# Or adjust paths based on your system's library locations:
+# export LD_PRELOAD=/usr/local/lib/libmimalloc.so.2:/usr/lib/libbrpc.so

</blockquote></details>
<details>
<summary>README.md (1)</summary><blockquote>

`189-191`: **Consider consistent list formatting.**

The static analysis tool flagged inconsistent list formatting. According to the project's markdown style (based on the error patterns), dash-style lists are preferred over asterisk-style.


Apply this diff to use consistent list formatting:

```diff
-* Follow [compile tutorial](docs/how-to-compile.md) to learn how to compile EloqDoc-RocksDB and EloqDocRocksDBCloud from scratch.
-* Follow [deploy cluster](docs/how-to-deploy-cluster.md) to learn how to deploy an EloqDoc-RocksDBCloud cluster.
-* Follow [configuration description](docs/configuration-description.md) to learn major configuration parameters.
+- Follow [compile tutorial](docs/how-to-compile.md) to learn how to compile EloqDoc-RocksDB and EloqDocRocksDBCloud from scratch.
+- Follow [deploy cluster](docs/how-to-deploy-cluster.md) to learn how to deploy an EloqDoc-RocksDBCloud cluster.
+- Follow [configuration description](docs/configuration-description.md) to learn major configuration parameters.
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 730f614 and 2b2347a.

📒 Files selected for processing (4)
  • README.md (7 hunks)
  • concourse/scripts/build_tarball.bash (1 hunks)
  • concourse/scripts/build_tarball_open.bash (1 hunks)
  • docs/how-to-compile.md (1 hunks)
🧰 Additional context used
🪛 markdownlint-cli2 (0.17.2)
README.md

91-91: Unordered list style
Expected: dash; Actual: asterisk

(MD004, ul-style)


92-92: Unordered list style
Expected: dash; Actual: asterisk

(MD004, ul-style)


189-189: Unordered list style
Expected: dash; Actual: asterisk

(MD004, ul-style)


190-190: Unordered list style
Expected: dash; Actual: asterisk

(MD004, ul-style)


191-191: Unordered list style
Expected: dash; Actual: asterisk

(MD004, ul-style)

🔇 Additional comments (4)
docs/how-to-compile.md (1)

122-137: Good documentation of library load order requirements.

The documentation clearly explains the need for library load order adjustment and provides both the patchelf approach and the LD_PRELOAD fallback. This aligns well with the implementation in the build scripts.

README.md (2)

62-62: LGTM on step formatting improvements.

The bold formatting makes the step structure clearer and more readable.

Also applies to: 70-70


68-68: Good addition of download page reference.

Providing users with a direct link to the download page improves the user experience.

Also applies to: 124-124

concourse/scripts/build_tarball_open.bash (1)

211-216: Verify DT_NEEDED ordering and packaged libs (concourse/scripts/build_tarball_open.bash:211-216)

Patchelf here removes then re-adds libbrpc and libmimalloc to influence DT_NEEDED order; dynamic loader behavior can vary and I could not verify in the sandbox (patchelf/readelf unavailable). Run these locally to confirm DT_NEEDED order and that the .so files exist (replace ${DEST_DIR} with the actual path):

Run locally:

patchelf --print-needed ${DEST_DIR}bin/mongod
readelf -d ${DEST_DIR}bin/mongod | grep -A5 'NEEDED'
objdump -p ${DEST_DIR}bin/mongod | grep NEEDED
find . -type f -name 'libbrpc*.so*' -o -name 'libmimalloc*.so*' -print
# to observe runtime load sequence:
LD_TRACE_LOADED_OBJECTS=1 ${DEST_DIR}bin/mongod | grep -E 'libbrpc|mimalloc'

If DT_NEEDED order is not reliably enforced across target runtimes, consider an alternative (explicit RPATH/RUNPATH, LD_PRELOAD wrapper, or packaging order + SONAME verification).

@xiexiaoy xiexiaoy force-pushed the doc-fix branch 2 times, most recently from 7ca0197 to c3aad07 Compare September 19, 2025 09:15
@xiexiaoy
Copy link
Collaborator Author

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Sep 19, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@xiexiaoy xiexiaoy merged commit a6eff9f into eloqdata:main Sep 19, 2025
1 check passed
@xiexiaoy xiexiaoy deleted the doc-fix branch September 19, 2025 09:24
zhangh43 pushed a commit to zhangh43/eloqdoc that referenced this pull request Sep 28, 2025
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.

2 participants