Skip to content
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

[Use consultation] How do you parse only part of the data? #116

Open
zaigie opened this issue Feb 2, 2024 · 4 comments
Open

[Use consultation] How do you parse only part of the data? #116

zaigie opened this issue Feb 2, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@zaigie
Copy link

zaigie commented Feb 2, 2024

First of all, I would like to extend my heartfelt thanks for your project, which has solved many of my problems! I have developed a visualization tool for server management palworld-server-tool based on your project.

In the part that I wrote myself, particularly in structure.py, I only utilized CharacterSaveParameterMap and GroupSaveDataMap. I did not use any of the other data.

Before you updated the code on parsing WorkSaved data, my entire parsing process took less than 60 seconds, but now it generally exceeds 90 seconds.

I suspect that the increase in parsing data is the reason behind the longer processing time and higher memory usage (I am also aiming to keep memory usage as low as possible).

Hence, I am raising this issue to seek your advice on customizing the parsing of certain data, as I am somewhat at a loss.

@cheahjs cheahjs added the enhancement New feature or request label Feb 2, 2024
@cheahjs
Copy link
Owner

cheahjs commented Feb 2, 2024

In your case, when you call GvasFile.read(raw_gvas, PALWORLD_TYPE_HINTS, PALWORLD_CUSTOM_PROPERTIES), you can replace PALWORLD_CUSTOM_PROPERTIES with the subset of RawData structs that you're interested in, eg

PALWORLD_CUSTOM_PROPERTIES: = {
    ".worldSaveData.GroupSaveDataMap": (group.decode, group.encode),
    ".worldSaveData.CharacterSaveParameterMap.Value.RawData": (
        character.decode,
        character.encode,
    ),
}

This would skip processing of the other data that I have added.

In the future, I might look into lazily evaluating the RawData structs such that you don't incur the parsing cost until you access it (if you consume the library, or if you dump it as JSON), or provide configuration options in the CLI to pick and choose.

@zaigie
Copy link
Author

zaigie commented Feb 2, 2024

Thanks, that helps!

@vegeto079
Copy link

Thanks for working on 4f8234f, that made this better!

For context, I am building a C# app that runs palworld-save-tools on a frequently-scheduled basis to pull out JSONified server data for monitoring.

On my server I am finding that the processing time is faster with the new --custom-properties option, but saving the JSON is still quite long, due to it saving >500MB of data. The saving action now takes 90% of the total execution time.

If I understand correctly, --custom-properties is reducing the PALWORLD_CUSTOM_PROPERTIES list, but regardless of that, everything inside PALWORLD_TYPE_HINTS is still being processed and saved.

My thought would be that passing in properties would exclude all other properties from the result. Ideally, I could pass .worldSaveData.CharacterSaveParameterMap.Value.RawData and receive a JSON result that would only contain that key path and it's children.

Would you have any idea on how to accomplish that, aiming to reduce the overall execution time by reducing the payload needing to be saved?

@cheahjs
Copy link
Owner

cheahjs commented Feb 8, 2024

You can take a look at what https://github.com/magicbear/palworld-server-toolkit does to skip processing various properties.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants