Skip to content

Allocation benchmark is undeterministic #873

@mkroening

Description

@mkroening

Currently, the allocation benchmark is running for a specified amount of time:

while bench_begin_time.elapsed().as_secs_f64() <= BENCH_DURATION {

During this time, we do as many allocations and deallocations but do not deallocate everything to keep the allocator state interesting. This slowly grows the memory usage. Eventually, allocations fail. The benchmark handles manual allocation failures gracefully but pushes all results into different vectors, which will panic when the benchmark is run with little memory or on a fast machine.

This is the cause of hermit-os/kernel#2122, which was caused by the runners getting a little faster. The issue was worked around by increasing the memory.

Additionally, the benchmark uses fastrand for randomizing the allocations. The seed is never set, though, so two runs are never the same, which might increase benchmark variance by a bit.

Originally, the benchmark is from talc, where an arena is being benchmarked. In that context, pushing to vectors is not an issue, since they don't come from the arena.

For Hermit, this benchmark should be reworked. For example, by testing a given amount of allocations instead of a given amount of time and by setting a fastrand seed. A more thorough rework is also possible, though.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions