-
-
Notifications
You must be signed in to change notification settings - Fork 564
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
fastring: 多线程问题与内存管理问题 #6
Comments
第一个问题这两天在考虑中,fastring 在多线程环境下复制确实不安全,应该用原子操作,调用 base/atomic.h 提供的 atomic_inc 与 atomic_dec 即可。可以提一个 PR。 Json 中的引用计数也没有使用原子操作,则是出于性能上的考虑,一般不会在多线程中复制 Json 对象。 第二个问题可能不需要考虑,推荐使用 jemalloc 进行内存优化。 |
替换全局的 operator new,operator delete,使用 jemalloc, tcmalloc 这类库应该就可以了 |
allocator 显然应该是可替换的,标准库的容器几乎都支持(除了
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
fastring
类的引用计数未使用原子对象。这显然会造成多线程同时修改时的数据竞争。希望作者注明这种设计是否有意的。fastring
类的内存分配、释放函数是不能替换的。我认为替换全局的operator new
和operator delete
是在一定应用条件下提高性能的做法,但fastring
并不能从中受益。The text was updated successfully, but these errors were encountered: