Files
black-sliverandFabian Dill 5442df64fd MultiServer, customserver: move data package handling, optimize RAM usage (#5981)
* MultiServer, customserver: move data package handling

Create a new class that handles conversion worlds+embedded -> context data.
Create a derived class that uses static_server_data+pony instead.
There is also a not very efficient feature to deduplicate strings (may need perf testing).

By moving code around, we can simplify a lot of the world loading.
Where code lines were touched, some typing and some reformatting was added.
The back compat for GetDataPackage without games was finally dropped.
This was done as a cleanup because the refactoring touched those lines anyway.

Also reworked the per-context dicts and the RoomInfo to hopefully be more efficient
by ignoring unused games. (Generating the list of used games was required for the new
code anyway.)

Side effect of the MultiServer cache: we now load worlds lazily (but still all at once)
and don't modify the games package in place. If needed we create copies.
This almost gets us to the point where MultiServer doesn't need worlds - it still needs
them for the forbidden items.
There is a bonus optimization that deduplicates strings in name_groups that may have bad
performance and may need some perf testing if we run into issues.

* MultiServer: fix string deduplication in data package cache

* MultiServer, customserver: minor formatting fixes

* MultiServer: fix data package cache for missing checksum case

* MultiServer: improve string deduplication in games package cache

* customserver: handle missing checksum in datapackage cache

* customserver: typing cleanup in games package cache

* Test, MultiServer, customser: add tests for games package cache

* Test, MultiServer: reorder imports

Hopefully this fixes the random test failures with pytest-xdist

* customserver: make WebHost import lazy in games package cache

and fix test

* customserver: games package cache: fix py3.11 compat

* MultiServer, customserver: cache: typing improvements

* customserver: cache: reformat

* Test: move customserver tests to not interfere with webhost

* MultiServer, customserver: cache: rename module

* Multiserver: better error message for missing Datapackage

* customserver: cache: invert if for readability

* customserver: optimize non_hintable_names

* Use an empty frozenset singleton
* Only include non-empty sets in static_server_data
* Only prefill dict with played games

This should save ~2-4KB per room and slightly speedup lookup.

---------

Co-authored-by: Fabian Dill <[email protected]>
2026-09-24 23:33:30 +02:00

0 lines
0 B
Python