Add WASM module to generate seed data on the fly#1
Open
babit56 wants to merge 4 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add WASM module based on the rnssp lib for generating runs. Only adds the rust code and necessary stuff to load the WASM module, some UI is still needed. I added a proof of concept in
seed-select.svelteof how the module could be used.Generating on the fly is quick enough that the seed searcher could probably directly use the wasm output to display a seed (and thus support any seed, any unlock, any player count without hassle)
The two options have slightly different output due to wasm reasons(tm), see
rnssp_wasm/src/lib.rsfor some comments on that. In short, one option uses IDs instead of strings for referring to areas, which requires some minor refactoring in JS. Since both options are roughly equally fast I guess the one not requiring refactoring is better.Performance
It seems like the majority of the runtime is just simulating the seeds, not converting/moving data between wasm/js, so it seems it doesn't matter how that part is done.
Both examples I left in
reset_seed_data()for replacing seed data run in about the same time, ~40s on a 7y old Thinkpad. I assume it could take up to a couple minutes on an even worse machine.40s is still enough that firefox asks user to kill the process, so a warning or a mitigation for that is probably needed. I don't know web stuff tho. Maybe run wasm in webworker or async...?
Building wasm
Install wasm-pack. Build code with it.