-
Notifications
You must be signed in to change notification settings - Fork 84
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
microcai
wants to merge
15
commits into
Jackarain:master
Choose a base branch
from
microcai:performence_optimize
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
性能改进 #24
Conversation
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
microcai
force-pushed
the
performence_optimize
branch
from
November 19, 2024 02:36
dbc095e
to
d59a2dc
Compare
to speed up compile, move member func to .cpp
microcai
force-pushed
the
performence_optimize
branch
from
November 19, 2024 02:40
d59a2dc
to
6d7e93d
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
一共 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。