Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

性能改进 #24

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open

Conversation

microcai
Copy link
Contributor

一共 3 个改进:

完全使用 utf-8 内码。利用 boost.nowide 实现。在 unix 平台,nowide 是个 no op 操作。避免了 utf16 和 utf8 之间来回转换。在 win 平台, boost.nowide 会对utf8 进行 转 utf16 操作,然后调用 utf16 版的 win api. 相比之前的代码,只有 win 平台有编码转换的问题。主力运行的linux平台,则 避免了转换。而且此修改代码改动极少。很多地方都是直接删除 wide_utf8/utf8_wide 之类的调用。删代码是最好的优化。

对 HTTP server 部分使用了 PMR 分配器。做到内存一次大分配,多次小碎片分配,然后连接完成再一次大释放。相比 非pmr 版本,性能有 50% 的提升。尤其是 列举一个超大的文件夹的时候。

使用asio的异步文件 stream_file 替换之前的 ifstream, 极大的提高了文件传输的效率。同时避免磁盘IO比较高的情况下卡住 web 服务器。对于不支持异步文件IO的平台,还是 fallback 到老的 ifstream。

@microcai microcai force-pushed the performence_optimize branch from dbc095e to d59a2dc Compare November 19, 2024 02:36
@microcai microcai force-pushed the performence_optimize branch from d59a2dc to 6d7e93d Compare November 19, 2024 02:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant