Rust bindings: MiMalloc::allocate should return actual usable size

未关闭 适合新手
#1,513 6 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
66/100
Issue 类型
功能
描述清晰度
描述清楚
活跃度
活跃
技术栈
rust
领域
tooling

调研方向

从 contrib/rust/src/allocator.rs 中当前正好返回 layout.size() 的 allocate 方法附近开始,并阅读链接的 purpleprotocol nightly_allocator_api.rs 以了解该模式。检查 mimalloc 如何通过同一 crate 中现有的 FFI 绑定暴露其可用大小函数,然后改为返回该值。在 contrib/rust 中运行 cargo test;完成意味着分配器在仍然满足 Allocator 契约的同时报告更大的可用块。

由索引模型根据 Issue 内容生成。

描述

Connections

https://github.com/microsoft/mimalloc/issues/1405 - Support official Rust FFI bindings

Summary

The Rust bindings for mimalloc always return an allocation of exactly the requested size:

https://github.com/microsoft/mimalloc/blob/1d8fd85aa3abe719cd9c42c855f1fc27dbccf84d/contrib/rust/src/allocator.rs#L28-L36

However, the allocator API says:

The returned block may have a larger size than specified by layout.size()

As such, I'd propose doing something similar to what purpleprotocol's Rust bindings do:

https://github.com/purpleprotocol/mimalloc_rust/blob/a35cc759c071fd7bd586685048367839002b95dd/src/nightly_allocator_api.rs#L7-L36

This would help improve the performance of collection types (like Vec) by allowing them to use the full space of the allocation.

主要语言
C
星标
13.6k
派生
1.2k
平均合并
12 小时 35 分钟
30 天内合并 PR
18

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

microsoft/mimalloc 的其他 Issue

查看 microsoft/mimalloc 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。