Comments (11)
正因为写入时做了快照拷贝,写入完后直接让指针指向新的数组对象,保证了线程安全。用于保存实体和区块的数组大小并不大,额外内存占用问题应该不显著。说实话,由于所有代码都在一个patch里面,我也只是粗略的看了一遍。个人觉得一些写为主的还是使用Collections.synchronizedList来做锁同步更好一点。
from hose.
虽然大小不大, 但是大量的写入, 每次都复制一份的消耗还是很可怕的. JVM的垃圾回收本来就..
from hose.
記憶體使用方面可以用jmap來監視,就我檢查過是沒問題的,gc正常運作,記憶體消耗量差異也不大,大約是spigot的120~150%。會用copyonwrite主要是因為出現concurrent exception,加上本身多數的型別都是list,為了減少修改的部分就只能先這樣,否則我都會改成queue。
另外jiongjionger提到synchronizedList的問題,經實際使用反而會導致thread blocked,所以不用,雖然concurrent的集合裡很多也是用synchronized來實作,但就是不會有問題。
最後我是臺灣人。
from hose.
from hose.
Lockfreelist看起來是個好用的東西,感謝提供lib,我會試試看的。
from hose.
我昨天测试了一下LockFreeList和LockFreeVector(说明中,LockFreeList基于链表,相当于LinkedList,LockFreeVector基于原子数组,相当于ArrayList),速度和占用内存还是有点大了..我正在试着自己用原子数组实现ConcurrentList
from hose.
无锁实现在竞争激烈的时候开销非常非常大,这个最好做对比测试再决定用哪种。
from hose.
其實我比較偏向用google或java本身的lib,畢竟相比之下更為嚴謹且集大成。
from hose.
前提是如果有. 我找了半天也就找到一个Amino了,并且在百度上的介绍也不多
很奇怪,apache-commons和guava几乎什么功能都集成了,但在并发方面一个也没有
难道真的这么难?
from hose.
併發的部分Java本身就很多了,
我列個常見的對照表:
1. CopyOnWriteArrayList (Thread safe arrayList)
2. ConcurrentLinkedDeque (Thread safe LinkedList)
3. ConcurrentHashMap (Thread safe HashMap)
4. CopyOnWriteArraySet (Thread safe HashSet)
5. ConcurrentSkipListMap (Thread Safe TreeMap)
6. ConcurrentSkipListSet (Thread Safe TreeSet)
7. ConcurrentLinkedQueue (Thread safe Priority Queue)
這些也是我優先使用的。
另外MC自己本身特化的MAP如IntHashMap我個人是改成了ConcurrentHashMap,
老實說效能沒差異,
反而避免了很多問題。
from hose.
主要是因為MC都用list,而list的大小約在1萬以下,如果使用Vector還要在執行完轉成List,否則插件跟指令會無法運作,因為怕轉換過程被插入或什麼的會導致資料不全,所以list的部分並沒有打算再修改。說個題外話,之前試著將entityslice改成vector,要改到了大約30多個檔案的宣告,而程式變得反而容易出錯,追蹤之下,最後變成要去修改官方的server.jar,光這點侵權就不適合了。但mojang確實逐步進步中,是可以期待這部分的改善的。
from hose.
Related Issues (20)
- 生成世界錯誤
- Issue starting server HOT 2
- An error has been occurred when starting HOT 1
- 作者請問能不能做 spigot 1.9.4
- 1.11 1.11.2无法正常工作 HOT 1
- where is the download link? HOT 2
- Hose 1.8.8 have error with citzens (NPC) and Holographics Displays (Holograms) and LibDisguises HOT 1
- error HOT 12
- 1.11.2 server crash HOT 1
- 1.11.2 插件不相容... 麻煩作者! 感謝 HOT 3
- 1.11.2 crash problem HOT 1
- [Question] Is this support 1.12 yet? HOT 5
- [Question] Can patch file be splited?
- Cannot start hose HOT 2
- [Question] Can you update project? HOT 2
- I do not have the technical skills needed someone could do it for spigot version 1.7.10 / .1.8? HOT 1
- [Spigot 1.8.8] Failed to handle packet (NPE)
- Crash
- Newer Minecraft versions HOT 2
- updating to newer versions
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hose.