Skip to content

Commit 7006bdc

Browse files
Quota enforcing sector allocator
``` Moves disk quota enforcement to sector allocator, this allows the file pool to have arbitrary large sparse files without running into quota issues. A consequence of this is that very large sparse files are now a first class citizen of Buildbarn. We have therefore modified the sparse files implementation to use a struct inspired by the unix inode pointer struct. ```
1 parent ab42e02 commit 7006bdc

12 files changed

+1046
-340
lines changed

cmd/bb_worker/main.go

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ func main() {
7676
// currently only used by the virtual file system to store
7777
// output files of build actions. Going forward, this may be
7878
// used to store core dumps generated by build actions as well.
79-
filePool, err := pool.NewFilePoolFromConfiguration(configuration.FilePool)
79+
filePoolFactory, baseSectorAllocator, sectorSizeBytes, err := pool.NewFilePoolFactoryFromConfiguration(configuration.FilePool)
8080
if err != nil {
81-
return util.StatusWrap(err, "Failed to create file pool")
81+
return util.StatusWrap(err, "Failed to create file pool factory")
8282
}
8383

8484
// Storage access.
@@ -490,13 +490,21 @@ func main() {
490490
return util.StatusWrapf(err, "Invalid instance name prefix %#v", runnerConfiguration.InstanceNamePrefix)
491491
}
492492

493+
maximumSectors := runnerConfiguration.MaximumFilePoolSizeBytes / uint64(sectorSizeBytes)
494+
runnerFilePool := pool.NewQuotaEnforcingFilePool(
495+
filePoolFactory.NewFilePool(
496+
pool.NewQuotaEnforcingSectorAllocator(
497+
baseSectorAllocator,
498+
int64(maximumSectors),
499+
),
500+
),
501+
int64(runnerConfiguration.MaximumFilePoolFileCount),
502+
)
503+
493504
buildClient := builder.NewBuildClient(
494505
schedulerClient,
495506
buildExecutor,
496-
pool.NewQuotaEnforcingFilePool(
497-
filePool,
498-
runnerConfiguration.MaximumFilePoolFileCount,
499-
runnerConfiguration.MaximumFilePoolSizeBytes),
507+
runnerFilePool,
500508
clock.SystemClock,
501509
workerID,
502510
instanceNamePrefix,

pkg/filesystem/pool/BUILD.bazel

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ go_library(
1111
"hole_source.go",
1212
"metrics_file_pool.go",
1313
"quota_enforcing_file_pool.go",
14+
"quota_enforcing_sector_allocator.go",
15+
"quota_metric.go",
1416
"sector_allocator.go",
17+
"sector_map.go",
1518
],
1619
importpath = "github.com/buildbarn/bb-remote-execution/pkg/filesystem/pool",
1720
visibility = ["//visibility:public"],
@@ -33,6 +36,8 @@ go_test(
3336
"block_device_backed_file_pool_test.go",
3437
"empty_file_pool_test.go",
3538
"quota_enforcing_file_pool_test.go",
39+
"quota_enforcing_sector_allocator_test.go",
40+
"sector_map_test.go",
3641
],
3742
deps = [
3843
":pool",

0 commit comments

Comments
 (0)