Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New approach to squashfs images #798

Draft
wants to merge 173 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
173 commits
Select commit Hold shift + click to select a range
88747a4
very much wip
mattgodbolt Sep 5, 2022
5937368
some docs
mattgodbolt Sep 5, 2022
6368502
Some updates
mattgodbolt Sep 7, 2022
59f7794
LLVM 15 (#799)
thedmd Sep 6, 2022
bf7dc83
Merge remote-tracking branch 'origin/main' into mg/squashfsallthethings
mattgodbolt Sep 7, 2022
9dc26f6
Refactor and splitting. Renames
mattgodbolt Sep 7, 2022
396f775
Look for any python but...not a good solution to 'what about python3.…
mattgodbolt Sep 7, 2022
5cf9df0
Revert "Look for any python but...not a good solution to 'what about …
mattgodbolt Sep 7, 2022
f3afbcc
arg
mattgodbolt Sep 7, 2022
20da37f
arg
mattgodbolt Sep 7, 2022
f301769
Maybe will regret this
mattgodbolt Sep 7, 2022
7d9b365
bleh
mattgodbolt Sep 7, 2022
8256cf2
Oops
mattgodbolt Sep 7, 2022
7e7dbcc
todo
mattgodbolt Sep 7, 2022
84c6006
some refacotring from laptop
mattgodbolt Sep 11, 2022
e678255
Merge remote-tracking branch 'origin/main' into mg/squashfsallthethings
mattgodbolt Sep 11, 2022
ff1c254
More wip
mattgodbolt Sep 11, 2022
69cb7df
More wip
mattgodbolt Sep 12, 2022
9bde0e1
Add some squash and autofs tooling
mattgodbolt Sep 12, 2022
da42017
python3.9 is minimum now
mattgodbolt Sep 12, 2022
f195911
Merge remote-tracking branch 'origin/main' into mg/squashfsallthethings
mattgodbolt Sep 12, 2022
5838663
Horrible copy paste fest leading to import
mattgodbolt Sep 13, 2022
1c6b082
Merge remote-tracking branch 'origin/main' into mg/squashfsallthethings
mattgodbolt Sep 13, 2022
51dbec4
More WIP
mattgodbolt Sep 13, 2022
031b7d9
zomg
mattgodbolt Sep 13, 2022
02d44a2
More TODOs
mattgodbolt Sep 14, 2022
b791c4c
Merge remote-tracking branch 'origin/main' into mg/squashfsallthethings
mattgodbolt Sep 15, 2022
6e286a7
Merge remote-tracking branch 'origin/main' into mg/squashfsallthethings
mattgodbolt Sep 22, 2022
5511adc
Implement remove
mattgodbolt Sep 22, 2022
0305f2a
Merge remote-tracking branch 'origin/main' into mg/squashfsallthethings
mattgodbolt Sep 26, 2022
16b20fa
Merge remote-tracking branch 'origin/main' into mg/squashfsallthethings
mattgodbolt Oct 11, 2022
3ae515b
Merge remote-tracking branch 'origin/main' into mg/squashfsallthethings
mattgodbolt Oct 11, 2022
b94eef9
First non-exploding lib installation
mattgodbolt Oct 11, 2022
b9b0bf8
Merge remote-tracking branch 'origin/main' into mg/squashfsallthethings
mattgodbolt Oct 13, 2022
09bc573
Bump alert
mattgodbolt Oct 25, 2022
51b729f
fix google benchmark 1.6.2
partouf Oct 29, 2022
77ec7dc
Add Loongarch64 config (#853)
dkm Oct 31, 2022
a9b0b63
Fix trailing whitespaces
dkm Oct 31, 2022
c4a6c80
updated OSACA to 0.4.12 (#848)
JanLJL Nov 1, 2022
d3b25ce
Add FRC 2023 Support (#851)
RyanHir Nov 1, 2022
8096c25
Minor tweaks
mattgodbolt Nov 1, 2022
70e48db
add stdexec C++ library (#854)
trxcllnt Nov 1, 2022
07af06f
add nvhpc-sdk C++ compilers (#855)
trxcllnt Nov 1, 2022
0376a2f
Fix %% in output
mattgodbolt Nov 1, 2022
67c5cca
Fix up nvhpc-sdk (cc @trxcllnt)
mattgodbolt Nov 1, 2022
b5c196e
Add SeqAn3 C++ library (#856)
eseiler Nov 1, 2022
620a1d0
Update Crystal 1.6.0 -> 1.6.1 (#858)
HertzDevil Nov 1, 2022
8593cb8
Commenting out aarch64. CC @trxcllnt
mattgodbolt Nov 1, 2022
720686a
Check for origin/branch before using it, so we fix tags
mattgodbolt Nov 1, 2022
2c4d913
Add Python 3.11 (#860)
Nov 1, 2022
9fa9141
Add python-builder to bespoke builds
mattgodbolt Nov 2, 2022
cd01f50
Ahem
mattgodbolt Nov 2, 2022
bfa981a
Rust 1.65.0 (#862)
ojeda Nov 4, 2022
756bc4d
run makelocalrc with explicit paths to GCC toolchains (#859)
trxcllnt Nov 4, 2022
a57701e
draft (#863)
partouf Nov 4, 2022
306d598
add make
partouf Nov 4, 2022
d06705c
comment
partouf Nov 4, 2022
163166a
attempt to add gpu node
partouf Nov 4, 2022
c7da1ae
fix
partouf Nov 4, 2022
a5b9691
oops
partouf Nov 4, 2022
942f2cf
Update site-staging.sh
partouf Nov 4, 2022
619f510
change node installer url
partouf Nov 4, 2022
fd9e810
new ami
partouf Nov 4, 2022
2d6d0e1
gpu things
partouf Nov 4, 2022
704598a
i have no idea what im doing
partouf Nov 4, 2022
d82e1df
rename
partouf Nov 4, 2022
4b71d78
use different port for gpu instance
partouf Nov 4, 2022
8b9af68
new ami
partouf Nov 4, 2022
9f6119f
install nvidia driver
partouf Nov 4, 2022
3f54db1
fix env
partouf Nov 4, 2022
b81916c
new ami
partouf Nov 5, 2022
e99cd72
new dbtable
partouf Nov 5, 2022
4586349
errorfix
partouf Nov 5, 2022
f07aeb6
fix devices
partouf Nov 5, 2022
639afc7
attempt at rewrite script to pass shellcheck
partouf Nov 5, 2022
1662a55
new ami
partouf Nov 5, 2022
ef720bc
policy things
partouf Nov 5, 2022
9093e7c
enable gpu devices every startup
partouf Nov 5, 2022
b9780bb
surprise!
partouf Nov 5, 2022
e39c632
Add c6x config (#864)
dkm Nov 6, 2022
6a6ec55
trap later
partouf Nov 11, 2022
3cce9ae
move openssl to libraries yaml (#866)
partouf Nov 11, 2022
d70d51a
Add fmt 9.0.0 & 9.1.0 (#867)
AbrilRBS Nov 11, 2022
90293eb
nevermind, not the issue
partouf Nov 11, 2022
0a6f23d
hint type, but python typesystem is useless
partouf Nov 11, 2022
24e0c10
fixes
partouf Nov 11, 2022
ce85ab2
resilient post
partouf Nov 11, 2022
da3189e
dont ignore
partouf Nov 12, 2022
8b3412e
Add sparc, sparc64 and sparc-leon compilers (#868)
dkm Nov 11, 2022
06e2f90
Add ROCm 5.3.2 (#857)
cgmb Nov 12, 2022
d8029e5
Add new version of Kalray's KVX compiler (#870)
dkm Nov 12, 2022
8da75c8
attempt to add logspout to librarybuilder
partouf Nov 12, 2022
d9aa5d6
fix paramnames
partouf Nov 12, 2022
e0cf86e
Add Python 3.11 to the testing (#865)
cclauss Nov 14, 2022
c72c42b
Alternative packer setup for gpu
mattgodbolt Nov 15, 2022
903a855
Alternative packer setup for gpu
mattgodbolt Nov 15, 2022
96b672d
Alternative packer setup for gpu
mattgodbolt Nov 15, 2022
6aaa452
more tweaks
mattgodbolt Nov 15, 2022
adec3b5
add gpu env
mattgodbolt Nov 15, 2022
8435826
WIP on gpu refactor
mattgodbolt Nov 15, 2022
9ce0737
Add llvm-mos trunk. (#874)
mysterymath Nov 15, 2022
32d55d1
zomg bash
mattgodbolt Nov 15, 2022
6e8bf4c
As terraformed
mattgodbolt Nov 15, 2022
bc1cb93
Remove older resources
mattgodbolt Nov 15, 2022
7156e7c
Spot pricing for GPU
mattgodbolt Nov 15, 2022
69d8e88
autoscale the GPUses
mattgodbolt Nov 16, 2022
f8edc1a
add nvhpc-sdk 22.11 (#877)
trxcllnt Nov 17, 2022
92f73e9
Update Crystal 1.6.1 -> 1.6.2 (#879)
HertzDevil Nov 18, 2022
693ba2c
Wait for 3.11 until we install it
AbrilRBS Nov 18, 2022
e85769f
Fix hpcsdk download
partouf Nov 18, 2022
ed04c1a
add llvmmos compiler
partouf Nov 19, 2022
b160680
Update admin-daily-builds.sh
partouf Nov 19, 2022
5503cfb
move cmake install to yaml (#871)
partouf Nov 20, 2022
af67bdd
add ninja to yaml (#872)
partouf Nov 20, 2022
51fb2d6
Bump cryptography from 38.0.1 to 38.0.3 (#873)
dependabot[bot] Nov 20, 2022
44ab97b
Keep old gpu builds too (#881)
mattgodbolt Nov 20, 2022
f7aeb34
Adding tarfile member sanitization to extractall() (#878)
TrellixVulnTeam Nov 20, 2022
00a2df1
Fix lint
mattgodbolt Nov 21, 2022
42ea267
Dear me...budgetary updates
mattgodbolt Nov 21, 2022
fff936a
xsimd: Add a selection of 8.x and latest 9.x versions (#885)
amyspark Nov 23, 2022
c260522
Makefile: Add Python 3.11 (#876)
cclauss Nov 23, 2022
ea7af50
add oneapi 2022.2.0 2022.2.1 (#884)
rscohn2 Nov 23, 2022
b7bada2
Remove odin language
mattgodbolt Nov 24, 2022
1f3845f
Update dotnet.yaml (#869)
kasperk81 Nov 24, 2022
efdec92
Remove nuget dependency (#886)
hez2010 Nov 24, 2022
de0b4bd
Add newer dot nets with their fix(es). Remove old dotnet, will be sup…
mattgodbolt Nov 25, 2022
9a49bd4
zomg testing
mattgodbolt Nov 25, 2022
df408d3
Hacky ci setup
mattgodbolt Nov 25, 2022
92760c6
Take two at ci
mattgodbolt Nov 25, 2022
0ef4ccb
Erk, that's embarrassing
mattgodbolt Nov 25, 2022
339f2fa
More tweaks to ci setup
mattgodbolt Nov 25, 2022
47264f6
Fix rust installer
partouf Nov 26, 2022
9a7240e
Fix make clean. Closes #861. Good spot @partouf
mattgodbolt Nov 26, 2022
77aabe1
Move to new syntax for output variables. See #849 (#888)
mattgodbolt Nov 26, 2022
c5cf1f5
add trunk in dotnet (#887)
kasperk81 Nov 26, 2022
22a57c6
add our own branch
partouf Nov 26, 2022
ae0b630
Add Zip 0.10.0 (#889)
dkm Nov 28, 2022
01598e2
fix #880 (#890)
partouf Nov 28, 2022
1d06cfc
new staging ami
partouf Nov 28, 2022
878fad8
bugfix staging
partouf Nov 28, 2022
e57267f
fix beta
partouf Nov 28, 2022
25e7650
new amis
partouf Nov 28, 2022
e89c75c
Update dotnet.yaml
partouf Nov 30, 2022
f72082b
Update dotnet.yaml
partouf Nov 30, 2022
4965282
Update dotnet.yaml
partouf Nov 30, 2022
1cfb80d
fix #891
partouf Dec 3, 2022
573b9b9
add some libs
partouf Dec 6, 2022
82ecd81
Add dart 2.18 and dart dev version (#895)
miDeb Dec 10, 2022
55f7fd6
Bump certifi from 2022.9.24 to 2022.12.7 (#893)
dependabot[bot] Dec 10, 2022
ff22d76
Alternative poetry setup (#897)
mattgodbolt Dec 13, 2022
25115be
test runner wrapperscripts
partouf Dec 14, 2022
d913968
fix ce scripts exitcode
partouf Dec 14, 2022
9e918df
Add ISPC builder
mattgodbolt Dec 15, 2022
a0476cb
Rust 1.66.0 (#902)
ojeda Dec 15, 2022
ce0f027
add: gcc bpf cross compiler (#894)
dkm Dec 15, 2022
8791049
Install our own ispcs
mattgodbolt Dec 16, 2022
0596cb1
update pahole and elfutils (#899)
madhur4127 Dec 16, 2022
318d1aa
Fix tests
mattgodbolt Dec 16, 2022
8c0432b
Revert "update pahole and elfutils (#899)"
mattgodbolt Dec 16, 2022
2879146
Build in release
mattgodbolt Dec 16, 2022
688da99
pahole from nightly ce_install
mattgodbolt Dec 16, 2022
4223240
Add Josutti's Belleviews library (#900)
correaa Dec 17, 2022
13e71ab
Alternative way of specifying instance types
mattgodbolt Dec 18, 2022
f36063c
Merge remote-tracking branch 'origin/main' into mg/squashfsallthethings
mattgodbolt Dec 19, 2022
3f7b34f
Merge remote-tracking branch 'origin/main' into mg/squashfsallthethings
mattgodbolt Dec 19, 2022
66f1ab1
Fix tests
mattgodbolt Dec 20, 2022
2b53fb3
Merge remote-tracking branch 'origin/main' into mg/squashfsallthethings
mattgodbolt Dec 23, 2022
ad5f6cc
Merge remote-tracking branch 'origin/main' into mg/squashfsallthethings
mattgodbolt Jan 24, 2023
94703e4
Merge remote-tracking branch 'origin/main' into mg/squashfsallthethings
mattgodbolt Jan 27, 2023
986a91a
Merge remote-tracking branch 'origin/main' into mg/squashfsallthethings
mattgodbolt Feb 28, 2023
bf2d653
Merge remote-tracking branch 'origin/main' into mg/squashfsallthethings
mattgodbolt Mar 3, 2023
94779bb
Merge remote-tracking branch 'origin/main' into mg/squashfsallthethings
mattgodbolt Mar 25, 2023
e899d6d
Merge remote-tracking branch 'origin/main' into mg/squashfsallthethings
mattgodbolt Jun 20, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .idea/infra.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions .idea/runConfigurations/bin_lib_cefs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/runConfigurations/ce_install.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions bin/cefs
88 changes: 83 additions & 5 deletions bin/lib/ce_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@
import yaml

from lib.amazon_properties import get_properties_compilers_and_libraries
from lib.cefs.config import CefsConfig
from lib.cefs.root import CefsFsRoot
from lib.cefs.squash import SquashFsCreator
from lib.config_safe_loader import ConfigSafeLoader
from lib.installable.installable import Installable
from lib.installation import installers_for
from lib.installation_context import InstallationContext
from lib.installable.installable import Installable
from lib.library_yaml import LibraryYaml

_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -206,7 +209,7 @@ def cli(
file_handler.setFormatter(formatter)
root_logger.addHandler(file_handler)
if not log or log_to_console:
console_handler = logging.StreamHandler(sys.stdout)
console_handler = logging.StreamHandler(sys.stderr)
console_handler.setFormatter(formatter)
root_logger.addHandler(console_handler)
context = InstallationContext(
Expand All @@ -228,12 +231,15 @@ def cli(

@cli.command(name="list")
@click.pass_obj
@click.option("--json", is_flag=True, help="Output in JSON format")
@click.option("--installed-only", is_flag=True, help="Only output installed targets")
@click.argument("filter_", metavar="FILTER", nargs=-1)
def list_cmd(context: CliContext, filter_: List[str]):
def list_cmd(context: CliContext, filter_: List[str], json: bool, installed_only: bool):
"""List installation targets matching FILTER."""
print("Installation candidates:")
for installable in context.get_installables(filter_):
print(installable.name)
if installed_only and not installable.is_installed():
continue
print(installable.to_json() if json else installable.name)
_LOGGER.debug(installable)


Expand Down Expand Up @@ -341,6 +347,78 @@ def squash(context: CliContext, filter_: List[str], force: bool, image_dir: Path
installable.squash_to(destination)


CEFS_ROOT = Path("/cefs")


@cli.command()
@click.pass_obj
@click.option("--force", is_flag=True, help="Force even if would otherwise skip")
@click.option(
"--cefs-mountpoint",
default=Path("/cefs"),
metavar="MOUNTPOINT",
type=click.Path(file_okay=False, path_type=Path),
help="Install or assume cefs is to use MOUNTPOINT",
show_default=True,
)
@click.option(
"--squash-image-root",
default=Path("/opt/cefs-images"),
metavar="IMAGE_DIR",
type=click.Path(file_okay=False, path_type=Path),
help="Store or look for squashfs images in IMAGE_DIR",
show_default=True,
)
@click.argument("filter_", metavar="FILTER", nargs=-1)
def buildroot(context: CliContext, filter_: List[str], force: bool, squash_image_root: Path, cefs_mountpoint: Path):
"""Squash all things matching to a single layer."""

installation_context = context.installation_context
cefs_config = CefsConfig(mountpoint=cefs_mountpoint, image_root=squash_image_root)
fs_root = CefsFsRoot(fs_root=installation_context.destination, config=cefs_config)

current_image = fs_root.read_image()
to_install = []
for installable in context.get_installables(filter_):
if force or installable.should_install():
to_install.append(installable)
dest_path = installation_context.destination / installable.install_path
if dest_path.exists() and not dest_path.is_symlink():
_LOGGER.error("Found an installable that wasn't a symlink: %s", dest_path)
sys.exit(1)

install_creator = SquashFsCreator(config=cefs_config)
with install_creator.creation_path() as tmp_path:
_LOGGER.info("Installing everything to a temp dir: %s", tmp_path)
installation_context.set_temp_destination(tmp_path)
num_installed = 0
for installable in to_install:
installable.install()
if not installable.is_installed():
_LOGGER.error("%s installed OK, but doesn't appear as installed after", installable.name)
sys.exit(1)
current_image.add_metadata(f"Installing {installable.install_path} from {installable}")
num_installed += 1

if not num_installed:
click.echo("No changes: not updating base image")
return

new_squashfs_cefs = install_creator.cefs_path
for installable in to_install:
current_image.link_path(Path(installable.install_path), new_squashfs_cefs / installable.install_path)

_LOGGER.info("Building new root fs")
root_creator = SquashFsCreator(config=cefs_config)
with root_creator.creation_path() as tmp_path:
current_image.render_to(tmp_path)

new_squashfs_cefs = root_creator.cefs_path

click.echo(f"Built to {new_squashfs_cefs}")
fs_root.update(new_squashfs_cefs)


@cli.command()
@click.pass_obj
@click.option(
Expand Down
61 changes: 61 additions & 0 deletions bin/lib/cefs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
## CEFS

The Compiler Explorer File System manages a read-only, layered, hierarchy of squashfs images.
It's designed for compilers and libraries in Compiler Explorer, but any read-only content would work. It's not really a file system, either. So it's a terrible name. But hey!

### Why!

We use immutable squashfs images on NFS for the compilers and libraries. That's great, fast performance, great caching behaviour. But, mounting each compiler squashfs individually is slow for system startup (~1m for ~1000). We ideally want fewer squashfs mounts, but with the ability to "overlay" changes (like daily builds) without totally rebuilding everything every time.

### Overview

There is an autofs mount at `/cefs` which automounts squashfs images of the form `/cefs/ID` to `/opt/cefs-images/ID.sqfs`. The filesystem root is a symlink to a squashfs image in cefs. The root itself is a number of symlinks - one per managed directory - to other locations in cefs.

As an example:

- `/opt/compiler-explorer` would be the root, and is a symlink to `/cefs/SOME-ROOT-ID`.
- `/cefs/SOME_ROOT_ID` maps to a squashfs image `/opt/cefs-images/SOME_ROOT_ID.sqfs`.
- `/opt/cefs-images/SOME_ROOT_ID.sqfs` contains symlinks for each compiler maybe something like:
- `gcc-12.1.0` -> `/cefs/SOME_INSTALL_ID/gcc-12.1.0`
- `gcc-12.2.0` -> `/cefs/SOME_INSTALL_ID/gcc-12.2.0`
- `gcc-trunk` -> `/cefs/DIFFERENT_ID/gcc-trunk`
- Here we see the advantage of cefs: we minimize the number of actual squashfs images by relying on several installations being in the "same" squashfs image. We can consolidate images over time too.

The expectation is there's one big squashfs install image holding all the stable compilers, regenerated monthly. And then several overlaying images, some for ad hoc builds of new compilers (e.g. new releases of GCC), and some for the daily builds.

## Using

To set up you'll need to run `sudo cefs install`. (it needs root to fiddle with autofs)

I locally link `/opt/compiler-explorer` to `~/ce` in this instance so I can update it quickly as a mortal user without making `/opt` writable to my user.

To make an empty root like this:

```
$ sudo ln -sfT ~/ce /opt/compiler-explorer # one-time setup only as root
$ cefs create-root ~/ce
...lots of output...
Fresh new cefs root created at /cefs/662a3bd6f57ac05b28032dbb5dd2bb489e9761c7
$ ls /opt/compiler-explorer
metadata.txt
$ cat /opt/compiler-explorer/metadata.txt
Initial empty image created at 2022-09-05 22:56:03.530590 by mgodbolt
```

Now you have an empty base layer. After that you can layer on things using `ce_install buildroot` (terrible name needs changing):

```
$ ce_install buildroot gcc # literally all the GCCs...
[...lots of work...]
$ ls -l /opt/compiler-explorer/
$ ls -l /opt/compiler-explorer/
lrwxrwxrwx 1 root root 57 Sep 5 18:02 gcc-12.1.0 -> /cefs/fad719bc481ff3dbaffc7f5ef804c4b5ffc281d1/gcc-12.1.0/
lrwxrwxrwx 1 root root 57 Sep 5 18:02 gcc-12.2.0 -> /cefs/fad719bc481ff3dbaffc7f5ef804c4b5ffc281d1/gcc-12.2.0/
...etc
```

## TODO

- cleanup
- consolidation
- everything, really
Empty file added bin/lib/cefs/__init__.py
Empty file.
Loading
Loading