KonaeAkira / raphael-rs

Crafting rotation optimizer / macro generator for Final Fantasy XIV
https://www.raphael-xiv.com/
Apache License 2.0
67 stars 14 forks source link

Add native (non-wasm) target #68

Closed baldurk closed 1 month ago

baldurk commented 1 month ago

Hi, I really appreciate you making Raphael and have been using it for a few weeks now since I found it.

I prefer to have it running locally on my machine rather than on a website, so I wondered whether you'd be open to supporting that build even if you don't actually ship it anywhere? This might be something you actively don't want to mess with, which is fair enough.

FWIW I grabbed the source and tried to build it and I found that mostly it works fine, I had to make some trivial changes in src/main.rs to launch the program via eframe::run_native, the only big change I had to make was to use a thread instead of the webworker and gloo stuff in src/app.rs because it only runs on wasm I presume.

I got it working with some clueless hacks since I am not really familiar with rust and had to do some trial and error to fix compile errors with the type system that I didn't really understand - the MacroSolverApp.data_update I switched to Arc<Mutex<Option<SolverEvent>>> and then I use a lock to query its contents in update and instead of sending async via the bridge I spawn a thread and lock for the updates in the callbacks.

KonaeAkira commented 1 month ago

Hi, thank you for taking the time to investigate this, but supporting a native build has very low priority right now, mainly because:

But I won't deny that there are some nice benefits to having a native build (e.g. better performance, no 4gb memory limit) so I will keep this issue open :)

Human-Hamster commented 1 month ago

@baldurk I arrived at a similar conclusion to you as well. I made a fork here that can build to both WASM and native here.

I think the main benefit so far is that it's faster than the WASM version, about 20-30% from my testing. But it seems like it's the only way to support the Ensure 100% reliability option for now.

highlyunavailable commented 1 month ago

Let me add my voice as a request for a native version as well - this might also help with the issue that solving for guaranteed shortest macro (that is, MuMe rotations) could take advantage of the RAM as well - you were saying a while ago that it would sometimes take ~12 GB of RAM to solve for shortest macro and I'd still like to have that option.

KonaeAkira commented 1 month ago

Looks like demand for it is higher than I thought. I will start working on it then :)

@Human-Hamster Thank you for providing a working example. I'll use it as a starting point.

Human-Hamster commented 1 month ago

Looks like demand for it is higher than I thought. I will start working on it then :)

@Human-Hamster Thank you for providing a working example. I'll use it as a starting point.

HI @KonaeAkira I can put together a proper PR request if you'd like. Happy to work on this

KonaeAkira commented 1 month ago

@Human-Hamster Sure! Please branch out from develop/0.13.0. Also, you used flume in your working example. It should be possible to use std::thread with no extra dependencies.