This is a first attempt to get rid of of reference counting #1413
Basically all threads execute a global sync point, this allows
determining a time when all temporary resources (such as meshes on the
client side used in lighting on other threads) have been freed with 100%
certainty.
Remaining work:
- [x] Implement the sync point
- [x] Implement free lists and free the resources
- [x] Determine if this is worth it performance wise
- [x] Use this for chunk meshes
- [x] Remove reference counting and the locks on the chunk storage data
structure
- [x] Measure performance of gathering many light samples and compare it
with master → around 15% reduction in time
- [x] Cleanup some unused things (mesh free list)
For reference: https://github.com/ziglang/zig/pull/24329
some commits have been extracted from #1583, but the x86_64 backend has
been disabled due to its horrible performance.
Remaining work:
- [x] Wait for official builds on ziglang.org and upload them to our
repository
- [x] Add workaround for https://github.com/ziglang/zig/pull/24466
- [x] Fix TODO comment about ANSI support in stdout
- [x] Check for compile-time performance changes → it went from 13.1 to
11.9 seconds 🎉
In the process I had to improve how the player inventory is handled,
which required adding an interface to externally load an inventory for
the inventory system.
This new interface is also relevant for block inventories, which is why
I would like you to review this @Argmaster
fixes#978
* Create the foundations of the new network system.
* Fix memory leak
* Implement a simple additive-increase-multiplicative-decrease congestion control scheme.
Also fixed the locking with the send path
* Fix edge case for mismatch in read and available position
* fix formatting
* Reimplemtent network statistics of the F6 menu
* Fix problem the F6 window size
* Rename size to capacity
* Implement the advanced network debug menu
* Fix a few problems
* Actually call the handlePacketLoss function
* Reduce startup delay and fix possible problems with negative RTTs
* Fix crash in block of partially received packets.
* Use a PriorityQueue for unconfirmed packets.
Also fixed a display issue in the advanced network menu
* Always send confirmations and change how packet loss is handled to avoid killing the network connection by only resending packets outside the receive buffer.
* Use the length instead of the endIndex in the CircularBufferQueue
this just made everything more difficult to work with.
* Optimize CircularBufferQueue.enqueueSlice with memcpy
* Fix problem with zero-length packets, which is a valid use case
* Fix a small edge case
* fix formatting
* Add missing code to increase the capacity in enqueueSlice
* Don't send more data than the receive buffer can fit.
* Use a better data structures that handles the received ranges
* Use memcpy in more circular buffer functions
* Send a keepalive if the connection hasn't been established but the player was invited by the server
* Implement disconnecting for the new protocol
* Reimplement timeout
* Only add new connections when the other side actually sent an init packet.
otherwise the connections stay in the queue, and need keepalives.
also moved the code from the invite window to network.zig, where it belongs
* Don't allow queueing more than 2 GiB of data (i32 limit)
* Reimplement and simplify reconnection
* Use member functions for Socket
* React to packets using a scheme similar to TCP
TCP will send a fast retransmit on first loss discovered by DACKs, shortly after starting the RTO timer.
In essence this means that only second loss of the smallest packets is handled by congestion control.
* Increase scaling after congestion control halves bandwidth.
Now it increases it by at least 1%, isntead of only by the MTU
* Use start and len instead of start and end for the RangeBuffer
* Use ListUnmanaged in RangeBuffer
* Rename flawedReceive to tryReceive
* Add a `ms` constant to make it easier to see what units some of the constants use.
Also added a function alias for microTimestamp to make it potentially easier to change to other timestamps in the future.
* Format all the files
* Fix compilation error.
* The install scripts now patch render.zig from the zig standard library.
* Update ci.yml
* Update ci.yml
* Update ci.yml
* Update ci.yml
* Update ci.yml
* Update ci.yml
* Update ci.yml
* Update ci.yml
* Update ci.yml
* Update ci.yml
* Update ci.yml
* Update the formatter, it doesn't need to run on .zig files anymore.
* Update ci.yml
* Update ci.yml
* Add a mistake to check if it works
* IT WORKS!
* hopefully save the hand and also when the player leaves or server closes
* fixes
* change it to check the user id
* fix
* check pointers
* fix compilation error
* fix other bugs
* put player id in source
* fix error
* remove one line of code
* fix serialization
* revert < 22 to < 14
* change
* fix error where inventory not saved on alt f4
* change connected to a regular bool
* remove isConnected function
* Save the player's location and inventory, and also added the ability to load the player's location
* remove the comment from utils
* make the player save every 5 seconds
* fix gamemode loading
* remove comment
* added inventory loading
* fix bug
* fix unintentional changes
* fix segfault
* fixes
* Some small fixes.
---------
Co-authored-by: IntegratedQuantum <jahe788@gmail.com>
This is done by ensuring all the critical things are done on the server thread, while all remaining things are locked tightly with a mutex or a better data structure.
fixes#863
Also fixes a bug where item drop collection was not collecting the right amount.
Also make sure that another port is used and communicated correctly when the default port is already in use.
This allows opening multiple singleplayer worlds on the same computer.
fixes#605