Skip to content

Move Dhilly to a user-provided scratch buffer #4

@ivanmirakov

Description

@ivanmirakov

Dhilly promises to be a stack-first templating engine. However, over different iterations Dhilly has began allocating memory itself, leading to the engine itself making up to 5 allocations per template creation. This is unacceptable.

If we let the user provide a scratch buffer, Dhilly will intelligently be able to split it into different internal buffers or arenas. The first arena would simply copy all of the user-provided strings into a contiguous block. The second arena would be the "dynamic" arena and take up the rest? Assuming there isn't more data we need to store.

This will improve cpu cache locality and will allow us to make another big optimization in the string-array to string function by allowing us to intelligently copy strings by order in memory (left to right) instead of order in template, though more metadata will need to be added to make this functional.

Additionally, this would allow the user to provide an in-stack buffer, fulfilling Dhilly's goal to be usable on systems that don't support malloc.

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