Update Log 10/08/2022 - Lag Fix Attempt 1

Status
Not open for further replies.
Messages
133
Reaction score
99
Points
345
Location
Poland
Well, I don't understand point of "50 packs of 200 cocaine" instead of 1 pack of 10,000 coca, can you explain that? Also, if this kind of change affects your server's RAM usage, it means you need to distribute the memory a bit better, have you considered using Redis? It is a reliable and scalable key:value database in-memory value.

Professionally I create a large video and chat streaming platform, I know something about optimization, I will be happy to help if you need it.
 
Messages
700
Reaction score
5,368
Points
735
It's not immediately an issue with RAM, it's an issue with Garry's Mod's garbage collector. This update fixes that by reducing the number of live objects simultaneously. This essentially divides items used by drugs by 200, thus massively speeding up the garbage collector.)

Redis would not help at all in this case, we do already have a database that is _very_ fast, but we also cache all items of players on the server in the server's ram. Changing this would be the ideal solution, but would both slow down accessing inventories significantly and take a long time to change the code.
 
Messages
9,094
Reaction score
11,454
Points
935
Location
REHAB
Well, I don't understand point of "50 packs of 200 cocaine" instead of 1 pack of 10,000 coca, can you explain that? Also, if this kind of change affects your server's RAM usage, it means you need to distribute the memory a bit better, have you considered using Redis? It is a reliable and scalable key:value database in-memory value.

Professionally I create a large video and chat streaming platform, I know something about optimization, I will be happy to help if you need it.
Because that would allow players to sell 1.5 Million worth of cocaine maybe? If the drug limit was kept at 15, this would allow users to sell 22500000 worth of cocaine at once if they were to get that much cocaine (Which is doable)
 
Messages
133
Reaction score
99
Points
345
Location
Poland
It's not immediately an issue with RAM, it's an issue with Garry's Mod's garbage collector. This update fixes that by reducing the number of live objects simultaneously. This essentially divides items used by drugs by 200, thus massively speeding up the garbage collector.)

Redis would not help at all in this case, we do already have a database that is _very_ fast, but we also cache all items of players on the server in the server's ram. Changing this would be the ideal solution, but would both slow down accessing inventories significantly and take a long time to change the code.
Well, I can't agree that it's gmod issue, the issue is that you're storing items in wrong way, even if the GC would work better - at some point you'd have similar issue

I don't know how you store such items, but for instance
It's more expensive to have
{id: 1, owner: 2137, name: "Coke"}
{id: 2, owner: 2137, name: "Coke"}
{id: 3, owner: 2137, name: "Coke"}
{id: 4, owner: 2137, name: "Coke"}
... and 9996 more items allocated
than
{id: 1, value: 10000, owner: 2137, item_id: 22}
If you need to perform actions such as selling, dragging and etc - you can implement it somewhere else, the domain side (logic) of project shouldn't be affected of how data is being stored according to DDD which is great approach for delivering reliable software

@Bnej It can be fixed in several ways, you can make drug dealer be able to buy only x of drug, you bring him 1 item of 10.000 coke, and he says you that he can take only 2000g at this time from you.
 
Messages
700
Reaction score
5,368
Points
735
I don't know how you store such items, but for instance
It's more expensive to have
{id: 1, owner: 2137, name: "Coke"}
{id: 2, owner: 2137, name: "Coke"}
{id: 3, owner: 2137, name: "Coke"}
{id: 4, owner: 2137, name: "Coke"}
... and 9996 more items allocated
than
{id: 1, value: 10000, owner: 2137, item_id: 22}
The first way of storing items is the "correct" way, especially in a database (except for storing the name on every object).
  • It allows for tracking exactly what happens to which item in the logs.
  • It prevents duplication glitches since an item can only be in one inventory at a time
  • It allows for restoring specific items and saving specific items to be restored (notice how no other gmod server has a restore system like ours)
  • It allows for storing specific properties for each item. Each of our guns has several properties, such as fire select mode and bullet count. Drugs like meth have purity associated with them
And as I said, this is absolutely an issue with the Lua GC since it is incredibly outdated and does not run concurrently with the application. Instead, it requires pauses after each tick to mark garbage and a big pause after each cycle to free and finalize dead objects. A modern GC (especially a generational one), would have 0 issues with the number of objects on our server.

The best fix, as I already said, would be to not store all these items in the server's ram but to keep them in the database. But it would be too significant of a change.

By the way, the "hack" for cocaine and weed is precisely what you describe. Instead of storing each cocaine item individually, an item now has a count property for how many packs of drugs are in it.
 
Messages
2,215
Reaction score
3,123
Points
985
Location
United Kingdom
It does boggle the mind how people can hoard so much stuff ;)
4wUE4Nt.png
 
Status
Not open for further replies.
Top