• This repository has been archived on 28/Feb/2023
  • Stars
    star
    174
  • Rank 219,104 (Top 5 %)
  • Language
    Rust
  • License
    Apache License 2.0
  • Created about 4 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

cachepot is `sccache` with extra sec, which in turn is `ccache` with cloud storage

📦️ARCHIVED 📦

Cachepot has been archived/superseded in favor of uniting the efforts under upstream sccache.

If you're still using cachepot, at this point, all of the relevant changes should be backported to sccache or are in progress. Feel free to submit a porting request at sccache referencing a PR in cachepot.

Thank you for using cachepot!

The former cachepot maintainers 🌻️


cachepot maskot image

cachepot - Shared Compilation Cache

cachepot is a ccache-like compiler caching tool. It is used as a compiler wrapper and avoids compilation when possible, storing cached results either on local disk or in one of several cloud storage backends.

It's also a fork of sccache with improved security properties and improvements all-around the code base. We upstream as much as we can back upstream, but the goals might not be a 100% match.

cachepot includes support for caching the compilation of C/C++ code, Rust, as well as NVIDIA's CUDA using nvcc.

cachepot also provides icecream-style distributed compilation (automatic packaging of local toolchains) for all supported compilers (including Rust). The distributed compilation system includes several security features that icecream lacks such as authentication, transport layer encryption, and sandboxed compiler execution on build servers. See the distributed quickstart guide for more information.


Table of Contents (ToC)


Installation

There are prebuilt x86-64 binaries available for Windows, Linux (a portable binary compiled against musl), and macOS on the releases page.

If you have a Rust toolchain installed you can install cachepot using cargo. Note that this will compile cachepot from source which is fairly resource-intensive. For CI purposes you should use prebuilt binary packages.

cargo install --git https://github.com/paritytech/cachepot

Usage

Running cachepot is like running ccache: prefix your compilation commands with it, like so:

cachepot gcc -o foo.o -c foo.c

If you want to use cachepot for caching Rust builds you can define build.rustc-wrapper in the cargo configuration file. For example, you can set it globally in $HOME/.cargo/config by adding:

[build]
rustc-wrapper = "/path/to/cachepot"

Note that you need to use cargo 1.40 or newer for this to work.

Alternatively you can use the environment variable RUSTC_WRAPPER:

RUSTC_WRAPPER=/path/to/cachepot cargo build

cachepot supports gcc, clang, MSVC, rustc, NVCC, and Wind River's diab compiler.

If you don't specify otherwise, cachepot will use a local disk cache.

cachepot works using a client-server model, where the server (which we refer to as "coordinator") runs locally on the same machine as the client. The client-server model allows the server/coordinator to be more efficient by keeping some state in memory. The cachepot command will spawn a coordinator process if one is not already running, or you can run cachepot --start-coordinator to start the background server process without performing any compilation.

You can run cachepot --stop-coordinator to terminate the coordinator. It will also terminate after (by default) 10 minutes of inactivity.

Running cachepot --show-stats will print a summary of cache statistics.

Some notes about using cachepot with Jenkins exist.

To use cachepot with cmake, provide the following command line arguments to cmake >= 3.4:

-DCMAKE_C_COMPILER_LAUNCHER=cachepot
-DCMAKE_CXX_COMPILER_LAUNCHER=cachepot

Build Requirements

cachepot is a Rust program. Building it requires cargo (and thus rustc). cachepot currently requires Rust 1.56.1. We recommend you install Rust via Rustup.

Build

If you are building cachepot for non-development purposes make sure you use cargo build --release to get optimized binaries:

cargo build --release [--no-default-features --features=s3|redis|gcs|memcached|azure]

By default, cachepot builds with support for all storage backends, but individual backends may be disabled by resetting the list of features and enabling all the other backends. Refer the Cargo Documentation for details on how to select features with Cargo.

Linux

No native dependencies.

Build with cargo and use ldd to check that the resulting binary does not depend on OpenSSL anymore.

Linux and Podman

Also you can build the repo with Parity CI Docker image:

podman run --rm -it -w /shellhere/cachepot \
                    -v "$(pwd)":/shellhere/cachepot:Z \
                    -u $(id -u):$(id -g) \
                    --userns=keep-id \
                    docker.io/paritytech/cachepot-ci:staging cargo build --locked --release
#artifacts can be found in ./target/release

If you want to reproduce other steps of CI process you can use the following guide.

macOS

No native dependencies.

Build with cargo and use otool -L to check that the resulting binary does not depend on OpenSSL anymore.

Windows

On Windows, the binary might also depend on a few MSVC CRT DLLs that are not available on older Windows versions.

It is possible to statically link against the CRT using a .cargo/config file with the following contents.

[target.x86_64-pc-windows-msvc]
rustflags = ["-Ctarget-feature=+crt-static"]

Build with cargo and use dumpbin /dependents to check that the resulting binary does not depend on MSVC CRT DLLs anymore.


Storage Options

Local

cachepot defaults to using local disk storage. You can set the CACHEPOT_DIR environment variable to change the disk cache location. By default it will use a sensible location for the current platform: ~/.cache/cachepot on Linux, %LOCALAPPDATA%\Parity\cachepot on Windows, and ~/Library/Caches/Parity.cachepot on MacOS.

The default cache size is 10 gigabytes. To change this, set CACHEPOT_CACHE_SIZE, for example CACHEPOT_CACHE_SIZE="1G".

S3

If you want to use S3 storage for the cachepot cache, you need to set the CACHEPOT_BUCKET environment variable to the name of the S3 bucket to use.

You can use AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY to set the S3 credentials. Alternately, you can set AWS_IAM_CREDENTIALS_URL to a URL that returns credentials in the format supported by the EC2 metadata service, and credentials will be fetched from that location as needed. In the absence of either of these options, credentials for the instance's IAM role will be fetched from the EC2 metadata service directly.

If you need to override the default endpoint you can set CACHEPOT_ENDPOINT. To connect to a minio storage for example you can set CACHEPOT_ENDPOINT=<ip>:<port>. If your endpoint requires TLS, set CACHEPOT_S3_USE_SSL=true.

You can also define a prefix that will be prepended to the keys of all cache objects created and read within the S3 bucket, effectively creating a scope. To do that use the CACHEPOT_S3_KEY_PREFIX environment variable. This can be useful when sharing a bucket with another application.

Redis

Set CACHEPOT_REDIS to a Redis url in format redis://[:<passwd>@]<hostname>[:port][/<db>] to store the cache in a Redis instance. Redis can be configured as a LRU (least recently used) cache with a fixed maximum cache size. Set maxmemory and maxmemory-policy according to the Redis documentation. The allkeys-lru policy which discards the least recently accessed or modified key fits well for the cachepot use case.

Redis over TLS is supported. Use the rediss:// url scheme (note rediss vs redis). Append #insecure the the url to disable hostname verification and accept self-signed certificates (dangerous!). Note that this also disables SNI.

Memcached

Set CACHEPOT_MEMCACHED to a Memcached url in format tcp://<hostname>:<port> ... to store the cache in a Memcached instance.

Google Cloud Storage

To use Google Cloud Storage, you need to set the CACHEPOT_GCS_BUCKET environment variable to the name of the GCS bucket. If you're using authentication, either set CACHEPOT_GCS_KEY_PATH to the location of your JSON service account credentials or CACHEPOT_GCS_CREDENTIALS_URL with a URL that returns the oauth token. By default, CACHEPOT on GCS will be read-only. To change this, set CACHEPOT_GCS_RW_MODE to either READ_ONLY or READ_WRITE.

Azure

To use Azure Blob Storage, you'll need your Azure connection string and an existing Blob Storage container name. Set the CACHEPOT_AZURE_CONNECTION_STRING environment variable to your connection string, and CACHEPOT_AZURE_BLOB_CONTAINER to the name of the container to use. Note that cachepot will not create the container for you - you'll need to do that yourself.

Important: The environment variables are only taken into account when the server starts, i.e. only on the first run.


Overwriting the cache

In situations where the cache contains broken build artifacts, it can be necessary to overwrite the contents in the cache. That can be achieved by setting the CACHEPOT_RECACHE environment variable.


Debugging

You can set the CACHEPOT_ERROR_LOG environment variable to a path and set CACHEPOT_LOG to get the server process to redirect its logging there (including the output of unhandled panics, since the server sets RUST_BACKTRACE=1 internally).

CACHEPOT_ERROR_LOG=/tmp/cachepot_log.txt CACHEPOT_LOG=debug cachepot

You can also set these environment variables for your build system, for example

CACHEPOT_ERROR_LOG=/tmp/cachepot_log.txt CACHEPOT_LOG=debug cmake --build /path/to/cmake/build/directory

Alternatively, if you are compiling locally, you can run the server manually in foreground mode by running CACHEPOT_START_SERVER=1 CACHEPOT_NO_DAEMON=1 cachepot, and send logging to stderr by setting the CACHEPOT_LOG environment variable for example. This method is not suitable for CI services because you need to compile in another shell at the same time.

CACHEPOT_LOG=debug CACHEPOT_START_SERVER=1 CACHEPOT_NO_DAEMON=1 cachepot

Interaction with GNU make jobserver

cachepot provides support for a GNU make jobserver. When the server is started from a process that provides a jobserver, cachepot will use that jobserver and provide it to any processes it spawns. (If you are running cachepot from a GNU make recipe, you will need to prefix the command with + to get this behavior.) If the cachepot server is started without a jobserver present it will create its own with the number of slots equal to the number of available CPU cores.

This is most useful when using cachepot for Rust compilation, as rustc supports using a jobserver for parallel codegen, so this ensures that rustc will not overwhelm the system with codegen tasks. Cargo implements its own jobserver (see the information on NUM_JOBS in the cargo documentation) for rustc to use, so using cachepot for Rust compilation in cargo via RUSTC_WRAPPER should do the right thing automatically.


Known Caveats

General

  • Absolute paths to files must match to get a cache hit. This means that even if you are using a shared cache, everyone will have to build at the same absolute path (i.e. not in $HOME) in order to benefit each other. In Rust this includes the source for third party crates which are stored in $HOME/.cargo/registry/cache by default.

Rust

  • Crates that invoke the system linker cannot be cached. This includes bin, dylib, cdylib, and proc-macro crates. You may be able to improve compilation time of large bin crates by converting them to a lib crate with a thin bin wrapper.
  • Incrementally compiled crates cannot be cached. By default, in the debug profile Cargo will use incremental compilation for workspace members and path dependencies. You can disable incremental compilation.

More details on Rust caveats

More Repositories

1

substrate

Substrate: The platform for blockchain innovators
Rust
8,212
star
2

polkadot

Polkadot Node Implementation
Rust
6,865
star
3

ink

Parity's ink! to write smart contracts.
Rust
1,316
star
4

wasmi

WebAssembly (Wasm) interpreter.
Rust
1,269
star
5

polkadot-sdk

The Parity Polkadot Blockchain SDK
Rust
979
star
6

jsonrpc

Rust JSON-RPC implementation
Rust
752
star
7

parity-bitcoin

The Parity Bitcoin client
Rust
726
star
8

cumulus

Write Parachains on Substrate
Rust
618
star
9

parity-signer

Air-gapped crypto wallet.
Rust
539
star
10

frontier

Ethereum compatibility layer for Substrate.
Rust
496
star
11

polkadot-launch

Simple CLI tool to launch a local Polkadot test network
TypeScript
458
star
12

jsonrpsee

Rust JSON-RPC library on top of async/await
Rust
457
star
13

parity-wasm

WebAssembly serialization/deserialization in rust
Rust
395
star
14

subxt

Submit extrinsics (transactions) to a substrate node via RPC
Rust
317
star
15

parity-bridge

Rust
317
star
16

substrate-telemetry

Polkadot Telemetry service
Rust
303
star
17

smoldot

Alternative client for Substrate-based chains.
Rust
286
star
18

parity-common

Collection of crates used in Parity projects
Rust
284
star
19

parity-bridges-common

Collection of Useful Bridge Building Tools 🏗️
Rust
265
star
20

parity-db

Experimental blockchain database
Rust
263
star
21

banana_split

Shamir's Secret Sharing for people with friends
TypeScript
259
star
22

substrate-api-sidecar

REST service that makes it easy to interact with blockchain nodes built using Substrate's FRAME framework.
TypeScript
245
star
23

parity-scale-codec

Lightweight, efficient, binary serialization and deserialization codec
Rust
244
star
24

substrate-connect

Run Wasm Light Clients of any Substrate based chain directly in your browser.
TypeScript
230
star
25

cargo-contract

Setup and deployment tool for developing Wasm based smart contracts via ink!
Rust
226
star
26

trie

Base-16 Modified Patricia Merkle Tree (aka Trie)
Rust
201
star
27

substrate-archive

Blockchain Indexing Engine
Rust
197
star
28

shasper

Parity Shasper beacon chain implementation using the Substrate framework.
Rust
196
star
29

parity-zcash

Rust implementation of Zcash protocol
Rust
184
star
30

libsecp256k1

Pure Rust Implementation of secp256k1.
Rust
172
star
31

homebrew-paritytech

Homebrew tap for ethcore
Ruby
160
star
32

zombienet

A cli tool to easily spawn ephemeral Polkadot/Substrate networks and perform tests against them.
TypeScript
158
star
33

polkadot-staking-dashboard

A dashboard for Polkadot staking and nomination pools.
TypeScript
152
star
34

xcm-format

Polkadot Cross Consensus-system Message format.
143
star
35

finality-grandpa

finality gadget for blockchains using common prefix agreement
Rust
139
star
36

substrate-contracts-node

Minimal Substrate node configured for smart contracts via pallet-contracts.
Rust
124
star
37

capi

[WIP] A framework for crafting interactions with Substrate chains
TypeScript
105
star
38

grandpa-bridge-gadget

A Bridge Gadget to Grandpa Finality.
Rust
99
star
39

substrate-debug-kit

A collection of debug tools, scripts and libraries on top of substrate.
Rust
94
star
40

ink-examples

A set of examples for ink! smart contract language. Happy hacking!
Rust
89
star
41

subport

Parity Substrate(-based) chains usage and development support
Rust
84
star
42

wasm-utils

Rust
82
star
43

trappist

Rust
82
star
44

txwrapper-core

Tools for FRAME chain builders to publish chain specific offline transaction generation libraries.
TypeScript
77
star
45

substrate-playground

Start hacking your substrate runtime in a web based VSCode like IDE
TypeScript
74
star
46

scale-info

Info about SCALE encodable Rust types
Rust
73
star
47

parity-tokio-ipc

Parity tokio-ipc
Rust
73
star
48

substrate-light-ui

Minimal, WASM-light-client-bundled Substrate wallet for balance transfers
TypeScript
72
star
49

substrate-ui

Bondy Polkadot UI
JavaScript
72
star
50

statemint

Statemint Node Implementation
Rust
71
star
51

canvas

Node implementation for Canvas ‒ a Substrate parachain for smart contracts.
Rust
69
star
52

substrate-up

Scripts for working with new Substrate projects
Shell
66
star
53

useink

A React hooks library for ink!
TypeScript
62
star
54

stateless-blockchain

Stateless Blockchain on Substrate using RSA Accumulators
Rust
60
star
55

txwrapper

Helper funtions for offline transaction generation.
TypeScript
58
star
56

contracts-ui

Web application for deploying wasm smart contracts on Substrate chains that include the FRAME contracts pallet
TypeScript
58
star
57

awesome-ink

A curated list of awesome projects related to Parity's ink!.
56
star
58

srtool

A fork of chevdor's srtool
Shell
56
star
59

cargo-unleash

cargo release automatisation tooling for massiv mono-repos
Rust
55
star
60

ss58-registry

Registry for SS58 account types
Rust
55
star
61

oo7

The Bonds framework along with associated modules.
JavaScript
53
star
62

diener

Diener - dependency diener is a tool for easily changing https://github.com/paritytech/substrate or https://github.com/paritytech/polkadot dependency versions
Rust
52
star
63

lunarity

Lunarity - a Solidity parser in Rust
Rust
50
star
64

nohash-hasher

An implementation of `std :: hash :: Hasher` which does not hash at all.
Rust
49
star
65

arkworks-extensions

Library to integrate arkworks-rs/algebra into Substrate
Rust
47
star
66

wasm-instrument

Instrument and transform wasm modules.
Rust
47
star
67

asset-transfer-api

Typescript API aiming to provide clear, and simple to use tools for transferring assets across common good parachains.
TypeScript
43
star
68

fleetwood

Testbed repo for trying out ideas of what a smart contract API in Rust would look like
Rust
41
star
69

scripts

Collection of Dockerfiles, scripts and related resources
Dockerfile
40
star
70

trappist-extra

Dart
38
star
71

polkadot-introspector

A collection of tools focused on debugging and monitoring the relay chain and parachain progress from a 🐦-view
Rust
38
star
72

parity-extension

Parity Chrome Extension
JavaScript
37
star
73

rhododendron

Asynchronously safe BFT consensus, implementation in Rust
Rust
36
star
74

desub

Decode Substrate with Backwards-Compatible Metadata
Rust
36
star
75

ethkey

Ethereum key generator
Rust
35
star
76

psvm

Polkadot SDK Version Manager
Rust
35
star
77

substrate-open-working-groups

The Susbstrate Open Working Groups (SOWG) are community-based mechanisms to develop standards, specifications, implementations, guidelines or general initiatives in regards to the Substrate framework. It could, but not restricted to, lead to new Polkadot Standards Proposals. SOWG is meant as a place to find and track ongoing efforts and enable everybody with similar interests to join and contribute.
35
star
78

substrate-bip39

Rust
34
star
79

primitives

Rust
34
star
80

parity-config-generator

Parity Config Generator
JavaScript
34
star
81

zombienet-sdk

ZombieNet SDK
Rust
33
star
82

Nomidot

Staking Portal for Polkadot and Kusama
TypeScript
32
star
83

subdb

Experimental domain-specific database for Substrate
Rust
32
star
84

polkadot-api

TypeScript
31
star
85

polkadot-testnet-faucet

TypeScript
30
star
86

polkassembly

Polkassembly now has a new home:
TypeScript
30
star
87

pallet-contracts-waterfall

Collection of simple Substrate smart contract examples written in Rust, AssemblyScript, Solang and the smart contract language ink! to test substrates pallet-contracts module
TypeScript
30
star
88

metadata-portal

Metadata portal for Parity Signer
TypeScript
29
star
89

polkadot-onboard

A wallet integration SDK to facilitate adding different type of wallets (extension, WC, Ledger) to Dapps.
TypeScript
28
star
90

vscode-substrate

Substrate Marketplace VSCode Plugin
TypeScript
28
star
91

oo7-bare

The Bond API.
JavaScript
27
star
92

bigint

Rust
27
star
93

extended-parachain-template

Node template to build parachains with all the required pallets. Slightly opinionated based on what majority of parachain teams are using.
Rust
27
star
94

orchestra

A partial actor pattern with a global orchestrator.
Rust
27
star
95

polkadot-scripts

Collection of random scripts and utilities written for Polkadot
TypeScript
27
star
96

sub-flood

Flooding substrate node with transactions
TypeScript
26
star
97

polkadot-cloud

[BETA] A library and automated platform for developing and publishing assets for Polkadot dapps.
TypeScript
25
star
98

ink-playground

Browser Based Playground for editing, sharing & compiling ink! Smart Contracts
Rust
25
star
99

link

Unstoppable URL shortener built with the ink! smart contract language.
TypeScript
25
star
100

sms-verification

SMS verification for Parity.
JavaScript
25
star