Skip to content

Conversation

@yeswanth-s1th
Copy link

@yeswanth-s1th yeswanth-s1th commented Jul 24, 2025

closes #13661
docs: improve local editing experience

This commit introduces a new serve-local command to the Makefile that allows for a much faster local build of the documentation.

The serve-local command works by creating symbolic links to the local docs and javadoc directories instead of pulling all the versioned documentation from the remote repository. This significantly reduces the build time, making it much easier to edit and preview the documentation locally.

The following changes were made:

  • A new pull_local_docs function was added to site/dev/common.sh that creates symbolic links to the local docs and javadoc directories.
  • The site/dev/setup_env.sh script was modified to include a --local flag that triggers the use of the pull_local_docs function.
  • The site/dev/serve.sh script was modified to accept and pass on the --local flag.
  • A new serve-local command was added to the site/Makefile that executes serve.sh with the --local flag.

@kevinjqliu
Copy link
Contributor

thank you for working on this! could you also try to benchmark how long make serve takes before and after this change?
Speed is one of the primary motivation for #13661

@yeswanth-s1th
Copy link
Author

Hi @kevinjqliu,
I’ve measured the cold‑start latency of make serve before vs. after this patch using a simple start‑to‑banner timer:

Ref Startup Time
main 733 s
PR #13664 345 s
Δ ≈ 53 % faster

These results demonstrate a ~53 % acceleration in our docs‑serve delivery pipeline, significantly reducing the turnaround for iterative doc previews. Tested on macOS (M1 Pro, Python 3.8.2). No functional regressions observed.

Let me know if you’d like any additional profiling data or comparisons on other platforms.
Thanks for reviewing!

@yeswanth-s1th
Copy link
Author

Hi @kevinjqliu 👋

Thanks for reviewing this enhancement. Unless you have any blocking concerns, I’m ready for approval and merge. Would you mind giving this PR a 👍 and approving/merging it when you have a moment?

Appreciate your time! 🚀

@yeswanth-s1th
Copy link
Author

Hi @electrum / @kevinjqliu / @martint,
Would you mind reviewing this enhancement. Unless you have any blocking concerns, I’m ready for approval and merge. Would you mind giving this PR a 👍 and approving/merging it when you have a moment?

Appreciate your time!

then
/usr/bin/sed -i '' -E "s/(^site\_name:[[:space:]]+docs\/).*$/\1${ICEBERG_VERSION}/" ${ICEBERG_VERSION}/mkdocs.yml
/usr/bin/sed -i '' -E "s/(^[[:space:]]*-[[:space:]]+Javadoc:.*\/javadoc\/).*$/\1${ICEBERG_VERSION}/" ${ICEBERG_VERSION}/mkdocs.yml
/usr/bin/sed -i '' -E "s/(^site\_name:[[:space:]]+docs\/).*$/${ICEBERG_VERSION}/" ${ICEBERG_VERSION}/mkdocs.yml
Copy link
Member

Choose a reason for hiding this comment

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

whi is this changed?

Copy link
Author

Choose a reason for hiding this comment

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

You’re right. Those sed replacements were corrupted — the \1 backreference ended up as a control char (^A), and I mistakenly escaped site_name. I’ll fix both Darwin and Linux blocks to consistently use \1${ICEBERG_VERSION} and quote paths. No behavior change beyond correcting the bug.

# Modify .md files to exclude versioned documentation from search indexing
python3 -c "import os
for f in filter(lambda x: x.endswith('.md'), os.listdir()): lines = open(f).readlines(); open(f, 'w').writelines(lines[:2] + ['search:\n', ' exclude: true\n'] + lines[2:]);"
for f in filter(lambda x: x.endswith('.md'), os.listdir()): lines = open(f).readlines(); open(f, 'w').writelines(lines[:2] + ['search:
Copy link
Member

Choose a reason for hiding this comment

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

what's changed here?

Copy link
Author

Choose a reason for hiding this comment

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

Nothing editor messed up in multiple places where some newline characters are replaced with an actual new line.
fixed in recent commit, Thanks for reviewing.

@@ -15,12 +15,17 @@

.PHONY: help
help: # Show help for each of the Makefile recipes.
Copy link
Member

Choose a reason for hiding this comment

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

why is this changed?

Copy link
Author

Choose a reason for hiding this comment

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

Good catch. That change was unintentional—my editor converted \033 into literal ESC bytes and the line also lost the \n. I’ll revert to a portable version. To avoid CI/non-TTY issues, I’ll drop raw colors and keep plain output so this PR stays focused on the local docs fast-path.

echo "Latest version is: ${latest_version}"

# Create the 'latest' version of documentation
create_latest "${latest_version}"
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to create the latest version? I think we only work on nightly version.

Copy link
Author

Choose a reason for hiding this comment

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

That’s a good point: for the fast-path (--local) build, we don’t actually need to generate the latest version. Skipping it speeds things up. I’ll update the local path so it only creates (or symlinks) the nightly version, leaving the full latest creation only in normal builds.

…quote paths)

- Fixed sed replacements in site/dev/common.sh:
  * Restored correct \1 backreferences (removed stray ^A control chars).
  * Corrected `site_name` key (removed accidental escape).
  * Quoted mkdocs.yml paths for safety.
  * Made Darwin and Linux blocks consistent.

No functional change beyond correcting the replacements. This addresses
the reviewer comment on unexpected edits in common.sh.
Replying to comment, https://github.com/apache/iceberg/pull/13664/files#r2278265126:
That’s a good point: for the fast-path (--local) build, we don’t actually need to generate the latest version. Skipping it speeds things up. I’ll update the local path so it only creates (or symlinks) the nightly version, leaving the full latest creation only in normal builds.

# Update version information within the mkdocs.yml file using sed commands
if [ "$(uname)" == "Darwin" ]
# Update version information within the mkdocs.yml file using sed commands
Copy link
Member

Choose a reason for hiding this comment

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

Nit: extra indent

Copy link
Author

Choose a reason for hiding this comment

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

fixed it, removed extra indent

# Update version information within the mkdocs.yml file using sed commands
if [ "$(uname)" == "Darwin" ]
# Update version information within the mkdocs.yml file using sed commands
if [ "$(uname)" = "Darwin" ];
Copy link
Member

Choose a reason for hiding this comment

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

do we need to change this part?

Copy link
Author

Choose a reason for hiding this comment

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

not necessary, fixed it

@manuzhang manuzhang changed the title Fix issue 13661 Docs: improve local editing experience Aug 28, 2025
@yeswanth-s1th
Copy link
Author

yeswanth-s1th commented Aug 28, 2025

@manuzhang
Thanks for the thorough review. All the comments raised so far were formatting/stray edits on my side (extra ;, accidental ESC chars, duplicate sed lines, etc.). I’ve cleaned those up and reverted the noise so the PR now only contains the intended local-docs changes. Sorry for the unnecessary churn earlier, and appreciate you catching them.

Could you please take another look and let me know if it’s good to approve?

/usr/bin/sed -i '' -E "s/(^site\_name:[[:space:]]+docs\/).*$/\1${ICEBERG_VERSION}/" ${ICEBERG_VERSION}/mkdocs.yml
/usr/bin/sed -i '' -E "s/(^[[:space:]]*-[[:space:]]+Javadoc:.*\/javadoc\/).*$/\1${ICEBERG_VERSION}/" ${ICEBERG_VERSION}/mkdocs.yml
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]
/usr/bin/sed -i '' -E "s/(^site_name:[[:space:]]+docs\/).*$/\1${ICEBERG_VERSION}/" "${ICEBERG_VERSION}/mkdocs.yml"
Copy link
Member

Choose a reason for hiding this comment

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

@yeswanth-s1th can you check this change again?

Copy link
Author

Choose a reason for hiding this comment

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

I rechecked the block and made a small adjustment: on Linux I kept the original token-level pattern ([^[:space:]]+) so only the version number gets replaced and nothing else on the line is touched. On macOS and for the Javadoc lines I left them as they are in main (.*$) so behavior there doesn’t change. I also added quotes around $(uname -s) for safety. This keeps the change minimal but addresses the concern you raised.

Copy link
Member

Choose a reason for hiding this comment

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

@yeswanth-s1th have you checked this?

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for following up. Yes, I’ve rechecked this.

On Linux, I kept the original token-level pattern ([^[:space:]]+) so it only replaces the version number after docs/ without affecting anything else on the line. On macOS and for the Javadoc lines, I left them as they are in main (.*$) so their behavior doesn’t change.

I also added quotes around $(uname -s) for safety. This keeps the behavior consistent with main while addressing the earlier concern, and keeps the change minimal.

Copy link
Member

Choose a reason for hiding this comment

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

But I don't think the change is related to this PR. I'd prefer having the enhancement in a separate PR.

Copy link
Author

Choose a reason for hiding this comment

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

@manuzhang
Makes sense. I’ve reverted this block to match main so the PR stays focused. I’ll open a separate PR for the small sed/quoting cleanups.

Fix sed patterns in mkdocs.yml update script

- Keep Linux site_name pattern token-level ([^[:space:]]+) so only the
  version number is replaced, avoiding clobbering the rest of the line.
- Leave Darwin and Javadoc patterns unchanged (.*$) to match main.
- Add quotes around $(uname -s) for safety.

Keeps behavior consistent with main while addressing reviewer concern
with minimal changes.
@yeswanth-s1th
Copy link
Author

@manuzhang

Thanks for the thorough review. All the comments raised so far were formatting/stray edits on my side (extra ;, accidental ESC chars, duplicate sed lines, etc.). I’ve cleaned those up and reverted the noise so the PR now only contains the intended local-docs changes. Sorry for the unnecessary churn earlier, and appreciate you catching them.

Could you please take another look and let me know if it’s good to approve?

@manuzhang Could you please take another look and let me know if it’s good to approve?

@yeswanth-s1th
Copy link
Author

@manuzhang

Thanks for the thorough review. All the comments raised so far were formatting/stray edits on my side (extra ;, accidental ESC chars, duplicate sed lines, etc.). I’ve cleaned those up and reverted the noise so the PR now only contains the intended local-docs changes. Sorry for the unnecessary churn earlier, and appreciate you catching them.

Could you please take another look and let me know if it’s good to approve?

@manuzhang Could you please take another look and let me know if it’s good to approve?

@manuzhang

Just following up — Could you take another look when you get a chance? Let me know if anything else needs to be addressed. Thanks!

@manuzhang
Copy link
Member

@yeswanth-s1th have you checked my latest comments?

@yeswanth-s1th
Copy link
Author

@yeswanth-s1th have you checked my latest comments?

Yes, I’ve replied in the thread with the details.

reverting this block to match main so the PR stays focused. I’ll open a separate PR for the small sed/quoting cleanups.
@manuzhang
Copy link
Member

@yeswanth-s1th could you please rebase on latest main branch?

@manuzhang
Copy link
Member

@yeswanth-s1th local build failed for me. Could you please check?

make serve-local
dev/serve.sh --local
 --> clean
 --> install deps
 --> pull local docs (fast local mode)
ls: docs/docs/[0-9]*: No such file or directory
Latest version is:
 --> create nightly
 --> update version: nightly
/Users/tianlzhang/git/iceberg/site
/Users/tianlzhang/git/iceberg/site
INFO    -  DeprecationWarning: warning_filter doesn't do anything since MkDocs 1.2 and will be removed soon. All messages on the
           `mkdocs` logger get counted automatically.
             File "/Users/tianlzhang/miniconda3/lib/python3.10/site-packages/mkdocs_monorepo_plugin/parser.py", line 22, in <module>
               from mkdocs.utils import yaml_load, warning_filter, dirname_to_title, get_markdown_title
             File "/Users/tianlzhang/miniconda3/lib/python3.10/site-packages/mkdocs/utils/__init__.py", line 403, in __getattr__
               warnings.warn(
INFO    -  Building documentation...
INFO    -  [macros] - No default module `main` found
[mkdocs-monorepo] The file path /Users/tianlzhang/git/iceberg/site/docs/docs/latest/mkdocs.yml does not exist, is not valid YAML, or does not contain a valid 'site_name' and 'nav' keys.
make: *** [serve-local] Error 1

@kevinjqliu
Copy link
Contributor

hey @yeswanth-s1th thanks for working on this! I tried to run this locally too and got the same error

I took a look at the code path for make serve and it looks like we're pulling all versions of the docs. This is the main cause of the slowness since we are rendering 10+ versions of the same docs.

I think this PR is on the right track; for local rendering, we just need the "latest" version of the docs.

@yeswanth-s1th
Copy link
Author

hey @yeswanth-s1th thanks for working on this! I tried to run this locally too and got the same error

I took a look at the code path for make serve and it looks like we're pulling all versions of the docs. This is the main cause of the slowness since we are rendering 10+ versions of the same docs.

I think this PR is on the right track; for local rendering, we just need the "latest" version of the docs.

Thanks for letting me know I will work on this weekend and try to fix the issue.

Thanks
Yeswanth

@github-actions
Copy link

This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the dev@iceberg.apache.org list. Thank you for your contributions.

@github-actions github-actions bot added the stale label Oct 21, 2025
@kevinjqliu
Copy link
Contributor

hey @yeswanth-s1th thanks for working on this. I gave it a try locally and was not able to run make serve-local succesfully.

I think I found 2 major causes for the slowdown, please take a look at #14267 (review)

@github-actions github-actions bot removed the stale label Oct 27, 2025
@kevinjqliu
Copy link
Contributor

closing this in favor of #14267. Thanks again for working on it.

please try out the new make serve-dev, it was super fast for me

INFO - Documentation built in 9.59 seconds

@kevinjqliu kevinjqliu closed this Nov 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docs: improve local editing experience

3 participants