all: Combine sequential appends (#8461)

This commit is contained in:
Jakob Borg 2022-07-28 17:28:24 +02:00 committed by GitHub
parent f3835122bb
commit 388e4db9cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 60 additions and 78 deletions

View File

@ -785,72 +785,53 @@ func getReport(db *sql.DB) map[string]interface{} {
} }
} }
var categories []category categories := []category{
categories = append(categories, category{ {
Values: statsForInts(totFiles), Values: statsForInts(totFiles),
Descr: "Files Managed per Device", Descr: "Files Managed per Device",
}) }, {
Values: statsForInts(maxFiles),
categories = append(categories, category{ Descr: "Files in Largest Folder",
Values: statsForInts(maxFiles), }, {
Descr: "Files in Largest Folder", Values: statsForInt64s(totMiB),
}) Descr: "Data Managed per Device",
Unit: "B",
categories = append(categories, category{ Type: NumberBinary,
Values: statsForInt64s(totMiB), }, {
Descr: "Data Managed per Device", Values: statsForInt64s(maxMiB),
Unit: "B", Descr: "Data in Largest Folder",
Type: NumberBinary, Unit: "B",
}) Type: NumberBinary,
}, {
categories = append(categories, category{ Values: statsForInts(numDevices),
Values: statsForInt64s(maxMiB), Descr: "Number of Devices in Cluster",
Descr: "Data in Largest Folder", }, {
Unit: "B", Values: statsForInts(numFolders),
Type: NumberBinary, Descr: "Number of Folders Configured",
}) }, {
Values: statsForInt64s(memoryUsage),
categories = append(categories, category{ Descr: "Memory Usage",
Values: statsForInts(numDevices), Unit: "B",
Descr: "Number of Devices in Cluster", Type: NumberBinary,
}) }, {
Values: statsForInt64s(memorySize),
categories = append(categories, category{ Descr: "System Memory",
Values: statsForInts(numFolders), Unit: "B",
Descr: "Number of Folders Configured", Type: NumberBinary,
}) }, {
Values: statsForFloats(sha256Perf),
categories = append(categories, category{ Descr: "SHA-256 Hashing Performance",
Values: statsForInt64s(memoryUsage), Unit: "B/s",
Descr: "Memory Usage", Type: NumberBinary,
Unit: "B", }, {
Type: NumberBinary, Values: statsForInts(numCPU),
}) Descr: "Number of CPU cores",
}, {
categories = append(categories, category{ Values: statsForInts(uptime),
Values: statsForInt64s(memorySize), Descr: "Uptime (v3)",
Descr: "System Memory", Type: NumberDuration,
Unit: "B", },
Type: NumberBinary, }
})
categories = append(categories, category{
Values: statsForFloats(sha256Perf),
Descr: "SHA-256 Hashing Performance",
Unit: "B/s",
Type: NumberBinary,
})
categories = append(categories, category{
Values: statsForInts(numCPU),
Descr: "Number of CPU cores",
})
categories = append(categories, category{
Values: statsForInts(uptime),
Descr: "Uptime (v3)",
Type: NumberDuration,
})
reportFeatures := make(map[string][]feature) reportFeatures := make(map[string][]feature)
for featureType, versions := range features { for featureType, versions := range features {

View File

@ -80,18 +80,19 @@ func (s *sentFolderDownloadState) update(pullers []*sharedPullerState) []protoco
if !pullerVersion.Equal(localFile.version) || !pullerCreated.Equal(localFile.created) { if !pullerVersion.Equal(localFile.version) || !pullerCreated.Equal(localFile.created) {
// The version has changed or the puller was reconstrcuted due to failure. // The version has changed or the puller was reconstrcuted due to failure.
// Clean up whatever we had for the old file, and advertise the new file. // Clean up whatever we had for the old file, and advertise the new file.
updates = append(updates, protocol.FileDownloadProgressUpdate{ updates = append(updates,
Name: name, protocol.FileDownloadProgressUpdate{
Version: localFile.version, Name: name,
UpdateType: protocol.FileDownloadProgressUpdateTypeForget, Version: localFile.version,
}) UpdateType: protocol.FileDownloadProgressUpdateTypeForget,
updates = append(updates, protocol.FileDownloadProgressUpdate{ },
Name: name, protocol.FileDownloadProgressUpdate{
Version: pullerVersion, Name: name,
UpdateType: protocol.FileDownloadProgressUpdateTypeAppend, Version: pullerVersion,
BlockIndexes: pullerBlockIndexes, UpdateType: protocol.FileDownloadProgressUpdateTypeAppend,
BlockSize: pullerBlockSize, BlockIndexes: pullerBlockIndexes,
}) BlockSize: pullerBlockSize,
})
localFile.blockIndexes = pullerBlockIndexes localFile.blockIndexes = pullerBlockIndexes
localFile.updated = pullerBlockIndexesUpdated localFile.updated = pullerBlockIndexesUpdated
localFile.version = pullerVersion localFile.version = pullerVersion