gRPC Compilation Issues in CI
The Kessel client SDKs depend on gRPC. When using Python or Ruby, you may encounter severe CI slowdowns or timeouts if forced to compile gRPC from source. This guide explains the problem and how to fix it.
Understanding the gRPC Dependency
Section titled âUnderstanding the gRPC DependencyâLanguage-Specific Implementations
Section titled âLanguage-Specific ImplementationsâgRPC has different implementations depending on the language:
-
Native library implementations (Python, Ruby): Use C-based gRPC core for performance
- Require compilation or pre-built binaries
- Installation complexity (mitigated by pre-built binaries)
-
Pure language implementations (Go, Java, Node.js): No native dependencies
- Go: Pure Go implementation (grpc-go)
- Java: Pure Java implementation (Netty-based)
- Node.js: Pure JavaScript implementation (@grpc/grpc-js)
- No external compilation needed (no C compiler required)
Pre-built Binaries vs. Compilation
Section titled âPre-built Binaries vs. CompilationâFor languages using native libraries (Python, Ruby), installation times are not affected when using pre-built binaries. The gRPC project publishes pre-compiled wheels and gems for:
| Language | SDK Repository | Pre-built Platforms |
|---|---|---|
| Python | kessel-sdk-py | Linux (x86_64, ARM64), macOS (universal2), Windows |
| Ruby | kessel-sdk-ruby | Linux (gnu/musl, x86_64/ARM64), macOS (Intel/ARM), Windows |
Compilation is only needed when:
- Using an unsupported platform or architecture
- Using a very new language version (e.g., Python 3.15 pre-release)
- Pre-built wheels/gems are unavailable for your specific OS/architecture combination
- You explicitly force compilation (e.g.,
pip install --no-binary :all:in Python)
When compilation does occur, it:
- Requires a C/C++ compiler toolchain (gcc, clang, or MSVC)
- Only happens on first install (or when gRPC versions change)
Local Development
Section titled âLocal DevelopmentâFor SDK installation instructions and version requirements, see the Getting Started guide or the individual SDK repositories:
CI/CD Considerations
Section titled âCI/CD ConsiderationsâIn most cases, CI builds use pre-built binaries and install quickly with no special configuration needed. Enable standard package manager caching (cache: 'pip' in GitHub Actions, etc.) for faster builds.
You only need special configuration when forced to compile from source (hermetic builds, unusual platforms). See the compilation limits section below for those cases.
When You Need to Compile
Section titled âWhen You Need to CompileâIn most cases, pre-built binaries handle everything automatically. If youâre doing hermetic builds or working on an unusual platform where pre-built binaries arenât available, you may need to compile from source.
Limiting Parallel Compilation in CI
Section titled âLimiting Parallel Compilation in CIâWhen building from source, limit the number of parallel compilation threads to prevent CI hangs and timeouts:
# Limit gRPC compilation to 4 parallel jobsexport GRPC_PYTHON_BUILD_EXT_COMPILER_JOBS=4pip install kessel-sdkIn Dockerfile:
ENV GRPC_PYTHON_BUILD_EXT_COMPILER_JOBS=4RUN pip install kessel-sdkIn GitHub Actions:
- name: Install dependencies env: GRPC_PYTHON_BUILD_EXT_COMPILER_JOBS: 4 run: pip install kessel-sdk# Limit Bundler and gRPC compilationexport BUNDLE_JOBS=4export GRPC_RUBY_BUILD_PROCS=4export MAKEFLAGS="-j4"bundle installIn Dockerfile:
ENV GRPC_RUBY_BUILD_PROCS=4ENV MAKEFLAGS="-j4"RUN bundle installIn GitHub Actions:
- name: Install dependencies env: BUNDLE_JOBS: 4 GRPC_RUBY_BUILD_PROCS: 4 MAKEFLAGS: "-j4" run: bundle installReal-world example: Red Hat Insights compliance-backend PR #2621
Why this happens:
- Package managers (pip, bundler) spawn parallel download/install processes
- gRPCâs C compilation also spawns parallel build processes (one per CPU by default)
- This double parallelism might cause memory pressure and CPU thrashing
- Result: Builds slow down dramatically or timeout
Build Requirements
Section titled âBuild RequirementsâIf compilation is needed (Python, Ruby only), ensure these tools are available:
- Python: gcc, g++, python3-dev
- Ruby: gcc, make, ruby-dev
Note: Node.js, Go, and Java do not require build tools as they donât use native dependencies.
See the official gRPC installation guides for language-specific details.
Hermetic Build Systems
Section titled âHermetic Build SystemsâFor hermetic builds that force compilation from source:
- Include build dependencies (gcc, g++, python3-dev or ruby-dev)
- Limit parallel compilation (see above) to avoid resource contention and timeouts
- Expect longer build times
See gRPC build documentation for language-specific details.
Troubleshooting
Section titled âTroubleshootingâBuild Errors
Section titled âBuild ErrorsâIf you encounter build errors, theyâre typically due to missing compiler tools. Package managers provide clear error messages. Common solutions:
- Python missing compiler: Install
build-essential(Linux) orxcode-select --install(macOS) - Architecture issues: Ensure your Python/Ruby version matches your system architecture (especially on Apple Silicon)
- Long CI build times: Enable caching (see CI/CD section)
For detailed build requirements, refer to the official gRPC installation guides.
Summary
Section titled âSummaryâKey points about gRPC compilation:
- Pre-built binaries are available - Python and Ruby have pre-built wheels/gems for common platforms, avoiding compilation
- When forced to compile (hermetic builds, unusual platforms) - LIMIT parallel build threads to prevent CI timeouts (see compilation limits)
- Python and Ruby only - Node.js, Go, and Java donât use native gRPC and never need external compilation
- Docker: Use glibc-based images - Red Hat UBI or Debian images work with pre-built binaries; Alpine (musl) may force compilation
Additional Resources
Section titled âAdditional ResourcesâKessel SDK Repositories
Section titled âKessel SDK Repositoriesâ- Python SDK (kessel-sdk-py)
- Ruby SDK (kessel-sdk-ruby)
- Node.js SDK (kessel-sdk-node)
- Go SDK (kessel-sdk-go)
- Java SDK (kessel-sdk-java)