-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The CL adds a two-layer, segregated fit allocator, as described by http://www.gii.upv.es/tlsf/files/papers/ecrts04_tlsf.pdf This allocator can satisfy requests quickly, as the cost of the overhead of its 2D array of buckets. This performs about the same as the WorstFitAllocator, i.e ~22 us per request when the allocator is tracking several thousand allocations. It has much better fragmentation, however, with a fragmentation score of ~3% to WorstFitAllocator's 56%. This leads to more usable memory being available under the same circumstances, e.g. 37M out of 64M as opposed to WorstFit's 20.5M. Change-Id: I12fe987d32d50377418f2108f22a752f25bdfa52 Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/234818 Reviewed-by: Wyatt Hepler <[email protected]> Commit-Queue: Aaron Green <[email protected]> Lint: Lint 🤖 <[email protected]>
- Loading branch information
1 parent
8be090f
commit f674d68
Showing
14 changed files
with
598 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright 2024 The Pigweed Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
// use this file except in compliance with the License. You may obtain a copy of | ||
// the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
// License for the specific language governing permissions and limitations under | ||
// the License. | ||
|
||
#include <array> | ||
#include <cstddef> | ||
#include <cstdint> | ||
|
||
#include "pw_allocator/benchmarks/benchmark.h" | ||
#include "pw_allocator/benchmarks/config.h" | ||
#include "pw_allocator/tlsf_allocator.h" | ||
|
||
namespace pw::allocator { | ||
|
||
constexpr metric::Token kTlsfBenchmark = | ||
PW_TOKENIZE_STRING("two-layer, segregated-fit benchmark"); | ||
|
||
std::array<std::byte, benchmarks::kCapacity> buffer; | ||
|
||
void DoTlsfBenchmark() { | ||
TlsfAllocator allocator(buffer); | ||
DefaultBlockAllocatorBenchmark benchmark(kTlsfBenchmark, allocator); | ||
benchmark.set_prng_seed(1); | ||
benchmark.set_available(benchmarks::kCapacity); | ||
benchmark.GenerateRequests(benchmarks::kMaxSize, benchmarks::kNumRequests); | ||
benchmark.metrics().Dump(); | ||
} | ||
|
||
} // namespace pw::allocator | ||
|
||
int main() { | ||
pw::allocator::DoTlsfBenchmark(); | ||
return 0; | ||
} |
Oops, something went wrong.