Skip to content

[CI] Improve ccache performance for Windows Python builds (make wheel build directory consistent across runs)#42212

Closed
murgatroid99 wants to merge 2 commits into
grpc:masterfrom
murgatroid99:python_windows_ccache_basedir
Closed

[CI] Improve ccache performance for Windows Python builds (make wheel build directory consistent across runs)#42212
murgatroid99 wants to merge 2 commits into
grpc:masterfrom
murgatroid99:python_windows_ccache_basedir

Conversation

@murgatroid99

@murgatroid99 murgatroid99 commented Apr 22, 2026

Copy link
Copy Markdown
Member

We see ccache cache misses because each python build runs in a different temporary directory, and some header file names in the cache entry's manifest appear to use the full file path, so they fail to match. This change resolves that by making the build directory consistent for each build type.

ref:

@murgatroid99

Copy link
Copy Markdown
Member Author

The job finished in 48 minutes with a 100% cache hit rate.

@sergiitk

sergiitk commented Apr 22, 2026

Copy link
Copy Markdown
Member

https://btx.cloud.google.com/invocations/e2c298cf-c5f2-480b-9f33-4d36fa21b230/log

For posterity:

T:\altsrc\github\grpc>ccache --show-stats 
Cacheable calls:    7300 / 7300 (100.0%)
  Hits:             7300 / 7300 (100.0%)
    Direct:         7300 / 7300 (100.0%)
    Preprocessed:      0 / 7300 ( 0.00%)
  Misses:              0 / 7300 ( 0.00%)
Local storage:
  Cache size (GiB):  4.5 /  5.0 (90.11%)
  Hits:             2531 / 7300 (34.67%)
  Misses:           4769 / 7300 (65.33%)
Remote storage:
  Hits:             4769 / 4769 (100.0%)
  Misses:              0 / 4769 ( 0.00%)

Great job, @murgatroid99!

@sergiitk

Copy link
Copy Markdown
Member

FYI @sreenithi @asheshvidyut

@sergiitk sergiitk changed the title Make Python build directory consistent across runs [CI] Improve ccache performance for Windows Python builds (make wheel build directory consistent across runs) Apr 23, 2026
Comment on lines +49 to +50
python -m build --no-isolation --sdist || goto :error
python -m build --no-isolation --wheel || goto :error

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should add a comment explaining why we ended up breaking it into two steps - and explain that we can try reverting it to a single build command if after upgrading ccache/compilers/setuptools the hit rate remains around 100% on the second run.

But we can add a comment in a separate PR; I'm looking forward to getting this merged way too much 😄

asheshvidyut pushed a commit to asheshvidyut/grpc that referenced this pull request Apr 23, 2026
… build directory consistent across runs) (grpc#42212)

We see ccache cache misses because each python build runs in a different temporary directory, and some header file names in the cache entry's manifest appear to use the full file path, so they fail to match. This change resolves that by making the build directory consistent for each build type.

ref:
- b/501458064
- Previous change: grpc#42195

Closes grpc#42212

COPYBARA_INTEGRATE_REVIEW=grpc#42212 from murgatroid99:python_windows_ccache_basedir a29d1bb
PiperOrigin-RevId: 904139620
@asheshvidyut

Copy link
Copy Markdown
Member

FYI @sreenithi @asheshvidyut

Ack

@sreenithi

Copy link
Copy Markdown
Contributor

Ohh.. did you compare and inspect the tar.gz and .whl contents before and after this PR?

While I worked on pyproject.toml migration, i remember I was initially building the sdist and wheels on 2 different lines like in this PR at first and that resulted in some unwanted files (files in third_party IIRC) getting included in the artifacts.
And the only way to fix that was to build them both together in the same command (without providing -sdist and -wheel flags explicitly), because the 'build' package treats them differently for some reason. Did that in this commit: bf94c71

So, just to be sure, can you manually compare the contents of the wheel and tar.gz before and after this PR and see if it's not getting affected.

@sreenithi

Copy link
Copy Markdown
Contributor

ok nvm, manually verified the artifact contents, and there are no extra files like I suspected.

I probably resolved the problem at that time through some other way and misunderstood that building together was the fix. Sorry for the false alarm :)

asheshvidyut pushed a commit to a-detiste/grpc that referenced this pull request Jun 10, 2026
… build directory consistent across runs) (grpc#42212)

We see ccache cache misses because each python build runs in a different temporary directory, and some header file names in the cache entry's manifest appear to use the full file path, so they fail to match. This change resolves that by making the build directory consistent for each build type.

ref:
- b/501458064
- Previous change: grpc#42195

Closes grpc#42212

COPYBARA_INTEGRATE_REVIEW=grpc#42212 from murgatroid99:python_windows_ccache_basedir a29d1bb
PiperOrigin-RevId: 904139620
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants