#Hotpatching Rust code πŸ”₯

1 messages Β· Page 4 of 1

mellow flint
#

I get around the same on the repo examples with optimized build speeds and a good cpu, so yes! πŸ™‚
depends a lot on the tip crate size

celest magnet
#

Has anyone tested it on a larger project? Does it slow down a lot once you have a more complex project?

mellow flint
#

Would interested to see @idle stone performance on hot patching Foxtrot

#

Whether you get 4x your time on the template or + 1.2 s flat

worldly ether
#

I believe there's a way to get the incremental times down even lower, but that requires implementing workspace support. I'm going to put out a new alpha and then probably leave things alone for a bit

mellow flint
vernal widget
#

Can I use hot patching while working on the engine itself?

mellow flint
vernal widget
#

Ah rip

mellow flint
#

Only the thing that holds the main.rs will be hotpatched sadcowboy

#

(Or the example)

vernal widget
#

That's fine actually

#

It probably wouldn't help with writing CPU side code in the engine for me much anyways, and I already have hot reloading for shaderd

#

But being able to move objects around easily when writing examples would be great

mellow flint
vernal widget
#

And toggle lighting stuff without having to setup a system to spawn/despawn on key press :p

mellow flint
mellow flint
raven valley
#

okay so, i am back @mellow flint do u think we should show the .with_hot_patch as a secondary example within the readme itself, alongside the #[hot] macro? or no?

#

also is mold supposed to work now? πŸ˜‚

#

and dynamic linking?

#

huh dynamic linking made my recompiles go from 500ms to 3 seconds lmao

quartz whale
elder heart
#

was any headway made on non-macro hotpatching

#

or did we all give up 🫣

#

or wait..the App extension trait works

raven valley
#

also francoi's pr doesn't require a macro

elder heart
#

this pr is elusive

#

I'm guessing it's just not public rn

raven valley
#

no it is!

mellow flint
mellow flint
mellow flint
elder heart
#

oh!

mellow flint
mellow flint
#

Actually, I just had an idea for third party macroless

#

Take the schedules, wrap all systems in a hotpatched closure, rebuild schedules, replace old ones

#

A bit like @raven valley did, but for every system

raven valley
#

can't do it

mellow flint
#

Make sure the app is added last and we can do that even before Startup

raven valley
#

schedules aren't powerful enough yet

mellow flint
raven valley
#

i think πŸ€”

#

i mean hmm

#

you can try it

#

i don't think schedules are powerful enough to do it

#

go for it

#

Hmm

#

New pr to update the readme jan

granite kraken
#

Once I push the PR I’ll put up a repo with a plugin that relies on those changes that anyone can use

#

There are some caveats with the approach but I’ll document them/make sure they are resolved by then

#

It doesn’t rely on subsecond so it’s a little more stable, at least from my experience

#

But I don’t have a lot of others testing with me yet UsagiHehe

#

So we will see if that lasts

elder heart
#

hell yeah franΓ§ois

mellow flint
#

Yeah good design @lone token πŸ˜„

raven valley
#

just recorded a 30 minute video of me using bevy hot-reloading to make flappy bird clone from scratch and i TESTED the video recording before but apparently long videos get laggy on my setup so the video is intolerably laggy

#

OKAY the issue is that minimized obs ( or possibly not on screen obs at all ) gets all choppy

#

wth

elder heart
mellow flint
#

That way, the function name becomes more meaningful πŸ™‚

#

But also, I realize this is for beginners, so if you want to skip run conditions, that makes sense

elder heart
raven valley
#

i just recorded a new video

#

gonna edit it up and upload it

lone token
quartz whale
#

You gotta link it here @raven valley ! (Sick showcase of hotpatching)
#showcase message

mellow flint
raven valley
#

@worldly ether if you want the original footage i can hand it over too you ( non-sped-up )

raven valley
# lone token opened <https://github.com/bevyengine/bevy/pull/19354> (state scoped entities en...

wait wait πŸ€” state scoped entities by default? does this mean spawn will auto-spawn a state scoped entity? if so we would be able to use a custom state that we enable at the start of StartupRerunHotpatch and then leave after StartupRerunHotpatch re-runs in order to auto-despawn all entities spawned in StartupRerunHotPatch? ( πŸ€” but this would also despawn all entities spawned in the update schedule which we don't want hng )

#

i think if we want a clean hot-reload integration with the .with_hot_patch thing as part of native bevy we would want to make some tweak tweaks to bevy to let us track which schedule an entity was spawned in, and be able to use that to clear certain entities?

#

( specifically for non-macro StartupRerunHotPatch schedule stuff, not for generally adding and removing systems at runtime )

#

ugh i'm so happy my wishlist for bevy literally was

  • async systems
  • natively supported hot-reloading
  • bsn
  • bevy editor
#

and 1 out of those 4 is already nearly across the finish line and is in a very usable state already

#

@quick bloom you didn't ping me when you finished your pr for the spawn commands! I just reviewed it, hopefully it gets in the merge train!!!!

lone token
raven valley
#

ahhh

lone token
#

also I'm pretty sure we won't have something like StartupRerunHotpatch in Bevy, at least I'm very against it for now

raven valley
#

I mean it can be a third party crate thing but i think it makes sense as first party support if we make the very smooth development process showcased in my video a golden path ( which, given how terribly productive it is i would hope so! )

lone token
#

we'll make slower progress than a third party crate in Bevy, and the third party crate is a very good ground for experimentation. but we'll probably do rerunning startup systems differently

raven valley
#

okie

#

My thoughts behind it are this:

#

if you make rerunning all startup systems the default ( within the closure )

#

then you break certain assumptions some plugins may have. it's useful to be able to create a plugin that has some startup systems that really do only run once, but that you're also editing and adding new systems to that are also startup rerun, and update and post update and such

#

there is a good question too about if new Startup systems should be run the first time upon reload but then not again πŸ€”

#

( as opposed to StartupRerunHotPatch which re-run every time )

lone token
#

I kinda feel right now we put way too much stuff in hot patch mechanism, when the proper interface would be a button "rerun this system", or a command to trigger it in the cli, or an API that would expose it to your code editor, ...

#

which Bevy already mostly support

raven valley
#

hng i actually really like being able to control things through code only, but i understand the urge and it can make sense, especially once we get an editor on our hands. But personally i would always want the ability to just, adjust things in my code editor and have it have all the features of a CLI or bevy editor

#

( for hot reloading )

#

the nice thing about code is everything u see is what you get, with cli's and such i feel like one has less, control, and ability to view what's going on

lone token
#

it's also possible through code, it's "just" running a system which you can do in any system

raven valley
#

yeah, that's how StartupRerunHotpatch works, it's just a new schedule that collects all the systems and runs them in another system

#

the update schedule in the rerun is similar ( this is actually a flaw with it currently )

#

it actually is mem swapped with a UpdateHotPatch schedule which we run within the update schedule

#

( this means you can't schedule things outside of the update within the update )

#

but with more powerful schedules hopefully we will be able to fix that and make it work just like a normal Update schedule

lone token
#

when playing with hot patch, what I'm missing currently is a way to do "run this system once after hotpatching it", which is very doable and I'll probably do as a followup in Bevy if no-one beats me to it

raven valley
#

I believe that the macro-method does have that as an option

lone token
#

(playing with Bevy builtin, not bevy_simple_subsecond_system)

raven valley
#

ahhhh

#

taking a step back just to clear up what i really want personally: the path of "write normal bevy plugins, and just put them in this special spot and you can write your whole game in hot-reload mode" is something i really wanna see make its way to native bevy, i want everyone to have the glory and power of rust as a scripting language level of iteration speeds.

lone token
#

same, but without the "put them in this special spot"

raven valley
#

ahhaha you can't get away without putting them in this special spot, as i learned the hard way. Or at least i couldn't figure it out Hehe

lone token
#

I don't want specific schedules or macros

#

you can πŸ‘Ί

raven valley
#

how can you add new systems without putting them in a non-standard spot?

lone token
#

I don't know yet, but it will happen πŸ‘

raven valley
#

i watch with great anticipation

lone token
#

just, more slowly than in bevy_simple_subsecond_system πŸ˜„

raven valley
#

the problem is you would have to reload the entire main function, which doesn't work because app runners and winit and such. Most plugins can't handle being re-built more than once, even if u don't re-run the bevy app

lone token
#

not really πŸ₯·
you hot reload building the schedule, but you don't run it, you build a graph of the original one and the new one, you isolate the differences and you focus on those

raven valley
#

yes!

#

but doing so would require some pretty drastic surgery to bevy

#

because the original schedule gets built as part of the app build process, which also contains things that can't re-run

lone token
#

heh it's kinda work that is in the path of system as entities and plugins v2

raven valley
#

yeah some massive changes to plugins in plugins v2 would make this possible, depending on how that work went ponko_nod

#

I would far prefer that, though it would still require a macro, given how subsecond works, the macro would just have to be around the App::new() instead, ( that or put it within a hot-reload closure or such ). You have to be able to rerun the code somehow

lone token
#

it will happen, just probably not for the 0.17 🀷

raven valley
#

otherwise you have no entry point to the original app build process

lone token
#

until then the third party crate is awesome

raven valley
#

yeeee

granite kraken
#

Okay gimme a couple of hours and I’ll put everything together today

raven valley
#

πŸ”₯

#

yeah ur stuff is surgery but very cool surgery ponko_nod get it together i wanna look

mellow flint
# lone token when playing with hot patch, what I'm missing currently is a way to do "run this...

What are your thoughts on "rerun this setup"? The issue with plain rerun is that any spawned entities will be spawned a second time, resulting in e.g. two GUIs.
Our current workarounds are

  • Add a marker component to your entities and despawn them at the beginning.
    • Issue: this goes beyond "just activate a feature and you get hot-patching"
  • Use the custom schedule stuff
    • Issues are apparent
      Note that states would imo not be the correct tool for this, as when I need to edit my in-game HUD's layout, I don't want to also restart the level. These are orthogonal.
      The "real" answer is of course to use hot-reloaded BSN for that or a bespoke Bevy UI editor, but that is not a reality yet.
#

Alice mentioned maybe adding some kind of tracking to entities to know which systems spawned them. That way, you could despawn all entities that were spawned in the system that will be rerun.

#

Not sure how feasible that is though, I don't know the internals good enough to tell whether that is a good call or not.

raven valley
#

what we do need rn is the macro above it

mellow flint
raven valley
#

well, one way out of it would be to track what schedule entities are spawned in

#

would require changes to bevy internals

lone token
#

it's useful to hot patching and the editor

mellow flint
mellow flint
lone token
# mellow flint Oh really?

not the editor people are working on, but the one that I want that is made to inspect / customize a running ECS

mellow flint
#

Pretty happy with 3rd party level creation tools so far

#

@raven valley another thing regarding your readme PR:
I'd like to keep the readme very clean and unintimidating, considering that new-ish users might see it now that it is linked by the jam, and highlighted by Chris, and linked in bevy_new_2d.
So as a compromise, we could leave the section in an "alternative workflow" header, but put it in <details>. Does that work?

#

Just need to be very upfront about what does and does not work

raven valley
#

Yeah that's cool

mellow flint
#

nice πŸ™‚

quick bloom
mellow flint
#

Also thinking about renaming the crate to bevy_hotpatching_prototype.

  • It would better reflect the intention of the crate as a playground
  • It reflects the fact that in 0.17, hotpatching will be simpler upstream
  • bikeshed: I still prefer hot_patching for parity with hot_reload, but since @lone token' PR uses hotpatching, I believe we should use the same spelling
    Also want some thoughts from @karmic current and @idle stone on this
vernal widget
mellow flint
mellow flint
vernal widget
languid sable
mellow flint
languid sable
#

No strong feelings on seperate words

lone token
#

and mostly because hot_patching is ... displeasing to my eyes, no idea why

mellow flint
mellow flint
#

It just bothers me that we spell these very similar things different

#

I can see users being confused when typing the features out by hand

#

though to be fair, hot reloading is actually called file_watcher bavy

#

so there's that

lone token
#

we can rename file_watcher to hotreloading

#

and then we'll have a feature caliente that will enable both, just to be sure it's not consistent

quartz whale
#

Clearly we need to rename it to "hotloading", then it can match with "hotpatching"

#

bahahha I just found 100 rustc ICE backtraces in my project from when I was trying to get hotpatching working earlier (I think they're due to turning on incremental maybe) bavy

mellow flint
#

incremental compilation + Bevy tends to produce those on my machine regularly

#

need to have them in my gitignore πŸ˜„

quartz whale
#

Rust should pay Bevy for how much it works as a stress test for rustc

#

You're a pro ice skater I see!

unique geyser
#

Has anyone gotten "The code execution cannot proceed because clfs.sys was not found. Reinstalling the program may fix this problem" when trying to use hotpatching on windows? I cannot get it to work -.-

I am running in x64 Native tools prompt, because everything else gives linker errors.

karmic current
# mellow flint Also thinking about renaming the crate to `bevy_hotpatching_prototype`. - It wo...

my only comment is that we don't define "hot patch" anywhere and its not a common enough word to avoid defining it. people searching for "hot patch" will not find anything related to what this crate does at all.

currently in the broader usage "live reload" implies some kind of application reload and "hot reload" implies injecting changed bits and retaining state, so what is "hot patching"?

mellow flint
karmic current
#

and is definitely not a recognizable branding

mellow flint
karmic current
#

I'm saying if we use that in the crate name we are resposible for telling people what it is and how its different than these other common terms

raven valley
#

there's a reason i published my videos with the term hot reloading and not hot patching ponko_nod

#

more waow factor

karmic current
#

there doesn't seem to be an explanation in the 0.7 dioxus release either, fwiw

lone token
karmic current
lone token
#

we'll also have to do that on Bevy side too, and explain the different tricks we have between hot reloading assets, hot reloading shaders, and "hot patching" code

karmic current
#

from the perspective of a new user who will be using the technologies, why is there a difference

lone token
#

heh let's rename the second "hot recompiling" shaders πŸ˜„

mellow flint
lone token
#

its all the hot features

mellow flint
#

I'm personally not married to any terminology and will use whatever lands in Bevy upstream

karmic current
#

bevy 0.17 is hothothot!

lone token
mellow flint
karmic current
#

a single --hot flag would be cool though

mellow flint
mellow flint
karmic current
#

I kind of assumed the cli was going to be necessary and the flag would need to be there, but I actually don't know that for sure

#

bevy run --hot // burn cpu pls

lone token
#

file watching and hot patching probably have different platform support

mellow flint
#

I can picture hot_reload_assets and hot_reload_code, both activated by a simple hot

idle stone
idle stone
raven valley
#

okay

#

i'm gonna look at adding the resource/event stuff so you can add new resources/events at compile time, and after that i'm gonna look at state stuff to see if i can support custom states

#

wait why does remove_resource_by_id not return an OwnedPtr

#

instead it returns Option<()> noooo

vivid ember
raven valley
#

yesss but 3 months away

#

i'll go make the pr tho

#

i wanted to be able to hot-reload add events and resources for the jam πŸ˜” q

#

Actually my arm is killing me so im gonna pause dev, but i will get that pr done probably tmrw

languid sable
raven valley
mellow flint
#

@karmic current @lone token I guess the current feature flag names also have their problems πŸ˜„

#

Didn’t even know we had embedded_watcher

mellow flint
languid sable
mellow flint
#

remove_resource_by_id_17 bavy

raven valley
#

it makes me sadge, gotta wait till 17 to be able to do everything in hot reload mode

#

( well i still haven't done states idk if i can do states but i probably can? )

#

well, hmm, actually

#

okay, i could just make it so u can never remove resources

#

lol

#

but u can still add them

#

nope wait nope

#

i need to remove the resource from ReloadWorld in order to stick it in the standard World

#

ugh frustratinggggg

#

not mad i just feel antsy cause i thought i was gonna be able to do this......

raven valley
#

OH WAIT CAN I MEM SWAP THEM?

mellow flint
#

What happens when the hot patched app does add_observer or register_type, btw? @raven valley

raven valley
mellow flint
#

Asking because I'm considering doing .with_hot_patch(foo::plugin) in Foxtrot for all plugins

raven valley
#

!! that's not how hotpatch works!

#

you can't do it multiple times

mellow flint
raven valley
#

you just add your plugins inside the with_hotpatch

mellow flint
raven valley
#

there is only one with_hot_patch, it takes in a closure to a &mut App, you just do like in my video app.add_plugins((BirdPlugins, PipePlugin))

#

yep, you can just move over where you add all your plugins into that closure ( as long as those plugins don't register events or add resources cat_sob )

#

( or do states or observers or register types cat_sob )

#

that's why i chose to have the Startup vs StartupReRunHotpatch distinction

raven valley
mellow flint
#

Neat πŸ‘€

#

Didn’t realize that, that makes the API massively more attractive

#

Could even accept a set of plugins and create the closure ourselves around app.add_plugins

raven valley
#

Clipped the section where i add both plugins in the app so u can see

mellow flint
raven valley
#

it has to be a closure

mellow flint
quartz whale
#

The problem with doing that is that it won't update, since you'll never rerun main

raven valley
#

no! It just isn't doable unless it's a closure!

#

exactly!

quartz whale
#

The trick works because you're actually rerunning the closure you passed in

mellow flint
raven valley
#

then when you change the add_hot_plugins to include D how are you getting that new state?

#

where's the entry point?

mellow flint
quartz whale
#

No, because then when you change the values it wouldn't change the code in the internal closure, so it won't update with the new values

raven valley
#

OH WAIT Brain blast,

#

brain blastttt

#

not sure if it would work though

#

no it wouldn't work

#

like 80% sure

mellow flint
#

But if you did app.add_hot_plugins(GamePlugin) you wouldn’t need to add a new plugin at runtime

raven valley
#

what if we had (A, B, C) convert into a system, but that doesn't work because ur still changing stuff outside the state change

quartz whale
#

If you rerun GamePlugin::build when that hotpatches, then that should work

raven valley
#

i think ur right

#

but GamePlugin::build has to be a FnMut

quartz whale
#

So you can in theory add stuff to all plugins by default, just not main, which is kinda annoying

raven valley
#

are all fn() ~= FnMut

#

or are they Fn

quartz whale
#

all fn are Fn, because they cannot hold state

raven valley
#

is Fn a subtype of FnMut

#

i forgor πŸ’€

mellow flint
# raven valley confused

When using the lib.rs + main.rs workflow (which subsecond does not support yet lol) you usually have a single biiig top level plugin for your game

quartz whale
#

Fn implies FnMut implies FnOnce

raven valley
#

okay! then yeah it should work

quartz whale
#

It's the opposite of the normal way because you're talking about the parameters

mellow flint
#

Build your own closure that calls Plugin::build internally if that doesn’t work

#

That one can be an FnMut

raven valley
#

no it works

mellow flint
quartz whale
#

Is there a way to ban adding anything except plugins in the top-level App

raven valley
#

We could make an app wrapper that we require for the .add_hot_plugins that only exposes add_plugins and run

quartz whale
#

I guess even adding a new plugin would be confusing, so there's no getting around it

#

We just need to teach people that "only plugins hotpatch" I think

raven valley
#

i do think i like the api of .add_hot_plugin more than .with_hot_patch but the issue is you have to have a game plugin which basically is just the with_hot_patch closure lol

mellow flint
#

That would mean opting into the workflow would require changing a single line.
If the resources and observers etc. are respected, I'd make that the new main recommendation for the crate

quartz whale
#

But this is genius, this should let bevy hotpatch everything eby default (as long as you're not modifying stuff in main), which is huge

raven valley
#

well, okay this is the issue

mellow flint
raven valley
#

lots of plugins do stuff that they only expect to happen once during their build phase

#

such as winit, and networking plugins, and such

quartz whale
#

You wouldn't hot patch DefaultPlugins anyway, they'd be added in main

idle stone
raven valley
#

if we modified bevy to make it hot-patchable

quartz whale
#

I think it's okay because those files will never change, so they'll never be hotpatched

mellow flint
raven valley
#

OH wait no, .add_plugins isn't FnMut because it takes in a &mut to self, and then we don't get to keep the plugin after we run build once right?

raven valley
#

BUT still

#

no

#

its not true

idle stone
raven valley
#

we would still rerun the build process for them

#

this happens no matter what

quartz whale
#

Why would you rerun the build of a plugin that didn't change?

raven valley
#

you rerun the builds of all plugins added in .add_plugins

#

you don't get to know which ones changed

#

dioxus doesn't give you that info πŸ˜”

lone token
#

(yet)

raven valley
#

BUT even then, it would be very complicated to deal with a partially built schedule, vs just rebuilding the whole schedule every time in the Plugins V2 francois was talking about

quartz whale
#

If people want to do stuff in main we could add a #[bevy::main] that desugars to

fn main() -> AppExit {
    App::new().add_plugins(*user_main*).run()
}
raven valley
#

if we can get plugins v2 where we have a seperation between systems added to a schedule, and resources inserted into the app ( and other misc things ) then we can pull it off

idle stone
raven valley
lone token
raven valley
raven valley
#

or impressive schedule code improvements and systems as entities

#

one or the other

idle stone
raven valley
#

but yeah, does anyone wanna open a plugin v2 working group πŸ˜‚ so we can get bevy to the state where hot reloading is seamless

#

( among other improvements )

quartz whale
#

What roughly is plugin v2?

idle stone
#

need a working group waiting list heh

raven valley
#

ahaha

#

yes

#

if we get async systems than that would make plugins v2 SOOOO cool and awesome and epic

#

πŸ₯Ί πŸ₯Ί πŸ₯Ί πŸ₯Ί πŸ₯Ί

quartz whale
#

I've heard about plugin dependencies, is there anything else?

raven valley
#

@vivid ember how many more hands does async systems have?

vivid ember
#

factorio got hands

raven valley
#

THAT it does my good sir

vivid ember
#

i havent written much this weekend beyond friday's slotmap draft

idle stone
#

which can be done if the plugin comes with a corresponding system set for all of its systems but otherwise not possible

quartz whale
#

Oh yeah that's good

raven valley
#

( from other plugins )

raven valley
quartz whale
#

It won't work without changing bevy unfortunately, but for the systems/resources split you could at least check within each add/init_resource whether you're currently hotpatching, and then become a noop for those cases

raven valley
#

oh yeah we're gonna change bevy, but for the resources thing the issue is that there is code in the build fn that runs no matter whether or not the resource actually gets added

#

the resource being added being a no-op is almost entirely irrelevant to the true issue of code running in build that u can't run twice

#

i pass in a whole new app so all the resources added don't matter, but i still can't rebuild the winit plugin

idle stone
#

plugins can run arbitrary code like creating files etc.

#

they're too flexible to reason about

raven valley
#

i mean, and they always will be able to run arbitrary code, we'll just tell people "best practicies so ur stuff works with hot-reloading ( and just in general ) is to just add systems and stuff in the systems fn and then do all your other setup in the build fn

idle stone
#

but you can at least limit what they can do to the App / World

raven valley
#

just rn there is no split

raven valley
idle stone
#

could have like Plugin::add_systems that accepts a SystemAdder that can only add systems to app and nothing else or w/e

#

to enforce a split like that

quartz whale
#

But that makes every plugin much more difficult to use, and it makes every app different from main, neither of which I think is acceptable

#

I thought subsecond gave you a way to check if the new function ptr is the same as the old one or something, and in that case no need to rerun

raven valley
languid sable
#

There's too many advantages to a structured approach

raven valley
#

Theres so much WORK TO DO

mellow flint
woven narwhal
#

Hi, I would love to test hot-patching out, but would love some help. I am on linux (fedora) and am usually using mold as the linker. Is there a way to try out hotpatch without symlinking the linker? I would avoid that if possible

mellow flint
mellow flint
#

@raven valley do you think you could add the caveats to your readme PR? I'd like to get it in before the jam πŸ™‚

raven valley
woven narwhal
# mellow flint Yeah, look at the current readme, which uses unsymlinked LLD πŸ™‚

Thanks, I got it to work πŸŽ‰
Few questions:

  • is there a way to auto despawn entities spawned in a 'rerun_on_hot_patch' system before rerunning it? I saw discussions about this earlier, just don't know the conclusion.
  • are there some tricks not in the readme, to speedup patching time? Currently 1.6 sec, which is not bad, just asking πŸ™‚
mellow flint
woven narwhal
#

Awesome, thanks. Is there a 'OnEnterRerunHotPatch' that initially runs like a normal OnEnter, but subsequently after hotpatch, if in the specified state?

raven valley
#

Not yet

#

I wanna add that but I haven't yet

mellow flint
#

@raven valley I'm experimenting with macroless right now btw

#

If this works, you may be able to take some parts of that for your implementation πŸ‘€

#

Thanks for the tip about std::mem::swap

raven valley
#

Explain

#

I have lost context πŸ˜‚

#

My context window has cleared

mellow flint
#

hehe

#

I have an idea for how to turn the API for the basic #[hot] workflow into this:

App::new()
  .add_plugins(DefaultPlugins, SimpleSubsecondPlugin)
  .add_systems(......)
  .enable_hotpatch()
  .run()
#

Without requiring any macros

#

by hacking the schedule

#

Might be unsafe or even unfeasible, let's see

#

(You're right in your remark that Schedule's API is somewhat limiting)

raven valley
woven narwhal
# raven valley I wanna add that but I haven't yet

If you manage to do it, then I guess OnExitRerunHotPatch would also be possible. With those two, we wouldn't need commands.queue for every case, since the cleanup can be (and usually is) in the OnExit event.

raven valley
#

Yeye

#

If u wanna take a stab at it the existing code that does stuff is actually pretty small and simple

#

Look at the hotpatch app file

#

You might be able to figure out how to do it with states

#

Conceptually I should explain, what we are doing is we pass a whole new app we create into the closure everytime we hot reload

#

And then we extract out the schedules like Update, and stick em in HotPatchUpdate

#

And then we run HotPatchUpdate inside of the actual original app's update

#

So it seems like you'll wanna extract out the state based schedule(s), and also rerun whichever one we are actually in as well?

celest magnet
#

Currently getttin this error on any hotpatch:

Build failed: Runtime Error: Build panicked! JoinError::Panic(Id(47), "failed to resolve patch symbols: RuntimeError(Failed to find ___aslr_reference symbol\n\nStack backtrace:\n   0: dx::build::patch::create_undefined_symbol_stub\n   1: dx::build::request::BuildRequest::build::{{closure}}\n   2: dx::build::builder::AppBuilder::patch_rebuild::{{closure}}\n   3: tokio::runtime::task::core::Core<T,S>::poll\n   4: tokio::runtime::task::harness::Harness<T,S>::poll\n   5: tokio::runtime::scheduler::multi_thread::worker::Context::run_task\n   6: tokio::runtime::context::scoped::Scoped<T>::set\n   7: tokio::runtime::context::runtime::enter_runtime\n   8: tokio::runtime::scheduler::multi_thread::worker::run\n   9: <tokio::runtime::blocking::task::BlockingTask<T> as core::future::future::Future>::poll\n  10: tokio::runtime::task::core::Core<T,S>::poll\n  11: tokio::runtime::task::harness::Harness<T,S>::poll\n  12: tokio::runtime::blocking::pool::Inner::run\n  13: std::sys::backtrace::__rust_begin_short_backtrace\n  14: core::ops::function::FnOnce::call_once{{vtable.shim}}\n  15: std::sys::pal::unix::thread::Thread::new::thread_start\n  16: start_thread\n  17: __clone3)", ...)

anyone else had this?

#

This happened since I upgraded to the latest master

#

Seems something which changed broke it on my machine.

#

(also the examples stopped working for me)

celest magnet
#

Ok seems the update broke when I use mold, but it could get it to work again with lld

mellow flint
#

It doesn't actually hot-patch yet for some reason, and it wraps all systems in an exclusive system, but it's just a little proof of concept

#

What it does is

  • Remove Schedules from the world
  • Get some owned systems out of the schedules via unsafe shallow clones
  • Do something with the owned systems (in this case try to wrap them in a hot patched closure)
    • This part here does not yet work, for some reason. It compiles and executes fine, but is not actually hot-patched
  • Build and insert a new Schedules
  • Leak the original Schedules in order to not double free memory, as the new Schedules point to the same systems and will call drop for them (So this is not an actual memory leak, I believe πŸ™‚ )
#

I believe you will find this exciting πŸ˜„

raven valley
#

Oooo

#

Can't look at it yet but will when I get home!

woven narwhal
raven valley
#

wait

#

this compiles?

#

i mean it must

#

huh

#
for (_label_ref, schedule) in old_schedules.iter_mut() {
            schedule.initialize(self.world_mut()).unwrap();
            let interned_label = schedule.label();
            for (_node_id, system) in schedule.systems().unwrap() {
                // SAFETY: we now have two `Box`es pointing to the same data, so we should absolutely never ever
                // touch the original `system` again. This includes not calling `drop` on it, see below.
                let cloned = unsafe { system.clone_shallow() };
                let hot_system = cloned.with_hotpatching();
                new_schedules.add_systems(interned_label, hot_system);
            }
        }

@mellow flint i don't think this works? as in it totally breaks relative scheduling

#

this is a very cool idea though lemme see if i can think of a way for it to work

#

hmmm what if you instead of doing the .add_systems just got a mutable reference to the systems vec to a specific system and then did a mem swap on it with an empty system. And then you took the new system u have access to, and you wrapped it in a hot func and then you mem-swapped the same spot again?

#

πŸ€”

#

I think to add on state transitions I'll have to add a new custom with_hot_patch_replace, which i don't like hng

#

OH

#

wait

#

maybe a way around it?

#

πŸ€”

#

eh idk if i even want to, i think i want to work on plugins v2, this is good enough and what i really want needs plugins v2

mellow flint
raven valley
#

Not sure it will work tho

celest magnet
#
- [linux] thread '<unnamed>' panicked at .../bevy_simple_subsecond_system-968e5cd1f3afb8e1/e6ad794/src/lib.rs:71:57:
- [linux] called `Result::unwrap()` on an `Err` value: Dlopen("../target/dx/game/debug/linux/app/libinertia_protocol-patch-1748431134872.so: cannot allocate memory in static TLS block")

currently getting this error on code change.

#

(it is a startup system with hotpatching)

#

The system which changes has this signature:

#[hot(hot_patch_signature = true)]
pub fn setup_game_ui(mut commands: Commands) {
    commands.queue(|commands: &mut World| {

Only uses command as a system parameter.

elder heart
celest magnet
mellow flint
celest magnet
#

I can paste the whole system if that helps?

elder heart
#

Sure, can you achieve what you're trying to do by changing the signature of this function to take an &mut World?

#

or maybe...huh. I wonder what happens if you pass in a function pointer

celest magnet
#
    app.with_hot_patch(|app: &mut App| {    app.add_systems(StartupRerunHotPatch, setup);
        app.add_systems(StartupRerunHotPatch, setup_game_ui);
quartz whale
#

Are you using thread local storage anywhere in your code?

celest magnet
quartz whale
#

The actual error itself is complaining about something related to thread local storage, so if you're not using that anywhere, then it must be something subsecond is doing wrong

celest magnet
#

I now also tested the same project on a mac, and I haven't had the same issue.

#

So it seems to be linux specific? but currently testing a little more.

celest magnet
#

after more extensive testing it seems to only happen on linux

quartz whale
#

Are you using mold or the default linker?

celest magnet
mellow flint
languid sable
#

Can I hotpatch consts correctly using the plugin?

raven valley
mellow flint
woven narwhal
#

That did not work for me yesterday

quartz whale
#

Modifying a const should change the function since its effectively gets inlined, so it should work

idle stone
#

can i pass a function plugin to app.with_hot_patch like app.with_hot_patch(foo::plugin)?

#

also, if i add a plugin in with_hot_patch will all of the plugin's systems be automatically hot patched without #[hot]?

#

or does that only apply to systems added directly within the closure passed to with_hot_patch

mellow flint
gentle socket
mellow flint
celest magnet
languid sable
#

Which is consistent with the standard advice for compile times

celest magnet
#

So best to have a workspace?

raven valley
#

No workspaces dont work yet

mellow flint
#

Btw @languid sable was the readme easy to follow?

languid sable
#

On my docket for today

#

Was poking at bevy_console and bevy-inspector-egui first

late stratus
#

@mellow flint since you're in the git-blame for the readme lines regarding symlinking mold: sooooooo that broke my dkms build causing graphics driver to fail to install/update because mold doesn't support some flag or other. those readme instructions for mold seem relatively dangerous, as that left me with a system which thinks its reached graphical.target but doesn't display anything

#

so just blanket symlinking mold over /usr/bin/ld isn't something i would recommend to anyone

mellow flint
mellow flint
mellow flint
late stratus
#

please for the sanity of everyone involved remove the recommendation for mold that way entirely

mellow flint
#

Symlinking cc to clang is safe at least πŸ™‚

late stratus
#

there's gotta be some way to get mold working which only affects subsecond

mellow flint
late stratus
#

maybe adding to path temporarily

obtuse sparrow
#

PATH shenanigans was going to be my suggestion, yeah

mellow flint
#

We can set it earlier in the path

#

Wanna do a PR? Otherwise I can do so myself when back home πŸ™‚

late stratus
#

i can after testing how to do this ideally

mellow flint
#

And sorry for causing you trouble with your system!

late stratus
#

i'd like some way which automatically just... only works for subsecond

late stratus
mellow flint
#

Since I believe Jon is not planning on tinkering with it for a while

raven valley
#

We should put a big WARNING: DANGER

#

Label above doing that.

#

Lmeow

late stratus
#

i am going to make a PR which removes that recommendation entirely

#

if i can make it work with PATH manipulation, great, otherwise its just gone

late stratus
#

i'll probably leave a warning "if you symlinked mold in the past, undo it ASAP"

mellow flint
#

But since that is no longer the case, I have no problem removing it

late stratus
#

success

minimal: linker path Output { status: ExitStatus(unix_wait_status(0)), stdout: "/home/a/.cargo/dx_bin/ld\n", stderr: "" }
late stratus
#

works as an alias too!

mellow flint
late stratus
#

its not caused issues so far so i can only assume its fine to store stuff there

#

so if for Mold we're gonna recommend a alias with PATH changed, why not do the same for cc/lld? overally, it feels like the far less janky solution compared to globally changing the linker binary

#

@mellow flint uhhh, the readme says to link mold over ld but the .cargo/config_faster_builds.toml says to link mold over cc... which one is it?

#

i'm assuming the latter is wrong, and linking mold over cc would not work as that makes little sense to my understanding of what cc is

late stratus
#

i'm talking about these lines:

#
[target.x86_64-unknown-linux-gnu]
# Linker commented out due to https://github.com/DioxusLabs/dioxus/issues/4193
# Instead, the global `cc` is symlinked to `clang`
# linker = "clang"
rustflags = [
    "-C",
    "link-arg=-fuse-ld=mold",
late stratus
#

wait no

#

i am blind

#

you're right

mellow flint
#

πŸ˜„

late stratus
#

i fully just read 'clang' as 'mold' there

#

anyways, still confused

#

does mold setup also need cc linked to clang?

mellow flint
#

Mayyybe also works when symlinked to gcc

late stratus
#

mine is linked to gcc and its been working anyways?

mellow flint
#

Important thing is just to to have the actual cc as cc πŸ˜„

#

That one can’t handle linker args

late stratus
#

now i'm confused even more: for me, it seems to sometimes use mold and sometimes not, and right now it doesnt

#

anyways, thats probably correct, so i can change how the docs are written again as both lld and mold need the clang symlink

#

i swear i had mold working before, wierd

late stratus
#

i think

languid sable
#

Why does the Dioxus CLI need SSL pensive_cowboy

late stratus
#

i think they fixed it

#

this commit

languid sable
late stratus
#

it could be that my dx is out of date, and this just works and nothing of this symlink bullshit is neccesary. wouldn't that be nice.

languid sable
#

Time to install clang

#

Thank god I'm on Linux today

late stratus
celest magnet
#

hotpatch builds take roughly twice as long as normal builds on my machine.

Is that to be expected?

late stratus
#

NO NO NO NO NO

#

i.. think i found the core issue why linker="clang" is broken with dx

#

if this works...

languid sable
#

Not super keen on dx silently + without prompting making changes to your Cargo.toml

mellow flint
languid sable
#

Or the mysterious "installing tooling"

languid sable
#
            Serving your Dioxus app!

This is definitely going to confuse people

#

I get why they would like to have prominent branding but...

#

Hmm. It isn't immediately working for me / on my project

#

I'm going to test the examples

late stratus
#

i desperately wish strace wouldn't slow dx serve to a crawl

mellow flint
languid sable
#

Okay great, the example works for me πŸ€”

#

I guess it's time to make my simulation repo public and ask for help troubleshooting πŸ˜…

loud narwhal
mellow flint
#

And I don’t know if cargo wants to manage that dir entirely alone or whether users are allowed to out random stuff in there

mellow flint
mellow flint
loud narwhal
late stratus
#

i kinda got sidetracked by the fact theres a DX_LINKER env var it reads out and then by the fact that the reason linker="clang" doesn't work is so dumb

#

basically

#

it seems to assume linker= contains the full path

#

yeah

#

anyways, its still error-ing for me, but at a different step. trying to trace that rn

#

but it might turn out that theres no need for PATH-shenanigans either, just setting DX_LINKER

mellow flint
#

It’s entirely possible that it all works out now, just saying πŸ™‚

late stratus
#

aye, right now i'm testing what the issue with linker="/usr/bin/clang" is

mellow flint
late stratus
#

its some other error

mellow flint
#

I suppose it’s appending it to the working directory accidentally, maybe

late stratus
#

yea

#

exactly

mellow flint
late stratus
#

i had the strace to prove it lol

late stratus
#

oh how fun, trying something which hopefully doesn't just freeze dx right now, and it needs a DKMS module

#

(sysdig)

late stratus
#

i could probably get away with auditd but that cant filter by "a process and its subprocesses" which i need

idle stone
#

regardless, hotpatching was not working for me when leaving cc as a symlink to gcc

idle stone
mellow flint
# idle stone i thought this was still the case

It worked for me without any changes, but its possible that my nightly is already using rust-lld by default.
In any case, doing no config at all used to not work, but now it does on my system πŸ™‚

idle stone
#

i couldn't get it to work without symlinking cc to clang and symlinking ld to mold after the change

mellow flint
mellow flint
mellow flint
mellow flint
#

@late stratus I'm home now, so let me know when to review the mold instructions πŸ™‚

mellow flint
late stratus
#

still tryna debug the reason why it won't just work without any changes, as the source implies it should

mellow flint
late stratus
#

fair but also, i know the fix for that one

#

just put linker="/usr/bin/clang"

#

but then theres a subsequent error which may or may not happen conditionally

#

why in the everloving fuck is dx spamming which about 100 times per second?

mellow flint
#

@languid sable I'm pretty sure I know why! You're not using the newest version of the plugin. Unfortunately, we cannot do a new release because we are waiting for a dioxus release, so you need to depend on the hotpatching stuff as a git dependency πŸ™‚

#

Let me try that real quick

#

yep that was it

#

Use

cargo add bevy_simple_subsecond_system --git https://github.com/TheBevyFlock/bevy_simple_subsecond_system
late stratus
late stratus
#

sidenote: sysdig is cool, i can write queries for syscalls and other events like: evt.type=execve and (proc.cmdline contains dx or proc.acmdline contains dx)

#

wait

#

i swear i didn't do anythin! why does it suddenly work!

languid sable
#

Okay, that fixed it πŸ™‚ Hotpatching works for me now πŸ™‚

mellow flint
languid sable
mellow flint
#

But yeah fair enough

#

(same with licenses, btw)

mellow flint
languid sable
mellow flint
#

Thanks for trying

#

Time for another bug report

mellow flint
languid sable
mellow flint
idle stone
#

oh, i don't need to symlink cc to clang if i do linker = "/usr/bin/clang" instead of linker = "clang"

idle stone
mellow flint
late stratus
#

yup

#

thats what i've been saying

mellow flint
#

huh, I have to try again

late stratus
#

it doesnt work fully

#

you cant just set -fuse-ld=mold or -fuse-ld=lld

mellow flint
#

I could have sworn I got "File not found" all the time

late stratus
#

i think that dx just... ignores those parameters so it initially builds with mold or lld, and then tries to patch with ld

#

which fails

late stratus
idle stone
#

oh wow yeah i'm getting 10-16s patches

mellow flint
idle stone
#

(it's normally 4-7s for me)

late stratus
mellow flint
late stratus
#

fwiw

mellow flint
#

But it's possible I just fat-fingered a wrong path πŸ™‚

#

I can try again

idle stone
#

so @late stratus the PATH approach worked for you as a replacement for the symlink approach?

#

if so i'll try it too

late stratus
#

uhhh

#

i've been jumping back and forth so much, but maaaybbeeee

idle stone
#

hmmm setting DX_LINKER=/usr/bin/clang and linker = "/usr/bin/clang" (and without symlinking cc to clang), i get 5s hotpatches now

#

i might only need the former

late stratus
#

uhhh

#

very strange

#

wait

#

it just works with -fuse-ld=lld now for me as well?

obtuse sparrow
idle stone
idle stone
#

hm idk, now i got a 16s patch again and this warning:

mold: warning: unknown command line option: -znostart-stop-gc
late stratus
late stratus
#

sadly

#

@idle stone for me, ld symlinked to mold broke my graphics driver DKMS module, leading to a system which wouldn't render anything

#

which is why i'm so dead-set on not needing that

#

because thats dangerous to recommend

idle stone
#

yeah that's rough

idle stone
#

i probably just didn't notice the warning before. this is also with verbose logging on

late stratus
late stratus
#

if you don't have mold symlinked, these are the errors besides that warning:

/usr/bin/ld: /home/a/rust-projects/bevy_simple_subsecond_system/target/dx/minimal/debug/linux/app/stub.o: .symtab local symbol at index 45 (>= sh_info of 1)
/usr/bin/ld: /home/a/rust-projects/bevy_simple_subsecond_system/target/dx/minimal/debug/linux/app/stub.o: error adding symbols: bad value
#

i have a horrible idea

#

intercept execve calls to /usr/bin/ld using LD_PRELOAD and direct them to Mold instead. that way the LD_PRELOAD env var can be set only for dx using an alias

#

i'm not seriously considering this but uhhhhhh it would probably work i think

languid sable
#

Man needing to annotate the systems you want to hotpatch is super annoying

#

Since then you can't just reach into random code unless you litter your whole codebase

#

Can you add new systems via hotpatching yet?

late stratus
#

yes

late stratus
# languid sable Can you add new systems via hotpatching yet?

as seen in the add_systems.rs example

        // try adding and removing systems from here! make whole new ones!
        .with_hot_patch(|app: &mut App| {
            // StartupRerunHotPatch is like Startup, but will rerun on hot-reload.
            // You need the #[hot(hot_patch_signature = true)] macro to auto-despawn entities spawned in it!
            app.add_systems(StartupRerunHotPatch, spawn_ui);
            // All other systems do not require `#[hot]`.
            // Try writing, adding, and removing new ones here at runtime!
            app.add_systems(Update, print_hello);
            app.add_systems(
                Update,
                change_text.run_if(input_just_pressed(KeyCode::Space)),
            );
        })
languid sable
#

Thank you for indulging my lazy questions ❀️

late stratus
#

its also infectious but at least not as much as #[hot]

languid sable
#

And we should be able to fix both of those with a first party solution right?

#

Hotpatching constants works perfectly BTW

idle stone
#

yeah i just got a 14s patch with both cc and ld symlinks. i think rust-analyzer check on save is interfering with the hotpatching

mellow flint
mellow flint
late stratus
#

ohh you meant francois pr

#

my bad

mellow flint
languid sable
mellow flint
late stratus
#

yea

idle stone
mellow flint
late stratus
mellow flint
late stratus
#

it really does seem like /usr/bin/ld is just hardcoded somewhere, so sadly symlinking (or intercepting with LD_PRELOAD) is the only way to use mold

mellow flint
mellow flint
late stratus
#

nothing

#

no matter which option i tried, it always ended up calling /usr/bin/ld

#

directly

#

though for anything but the last step, yes.

#

that runs the linker with stripped out linker arguments and i think this removes -fuse-ld=mold by accident

#

i can prove it in just a second though

#

i love being able to just... query syscalls and their full input/output

#

actually

#

i can't

#

damn clang argument strings are more than 4096 bytes, the limit of what sysdig captures

#

wohooo for cursed bash scripts. in this case: piping execv syscalls into a thing which quickly dumps /proc/<pid>/cmdline to get full-length arguments

#
#!/bin/bash
sudo sysdig "evt.type=execve and (proc.cmdline contains dx or proc.acmdline contains dx)" -p"%evt.time %proc.pid %proc.name" | while read time pid pname; do
    sleep 0.02
    if [ -r "/proc/$pid/cmdline" ]; then
        cmdline=$(tr '\0' ' ' < /proc/$pid/cmdline)
        echo "[$time] PID: $pid, Name: $pname, CMDLINE: $cmdline"
    fi
done
#

ah yknow just your average rustc call with 48 251 characters of arguments

late stratus
#

clang/rustc are always called with -fuse-ld=mold properly

#

wait no that makes no sense, that should shortcut if we pass DX_LINKER

#

the hecc

#

oh bother

#
    /// This means we basically ignore the linker flavor that the user configured, which could
    /// cause issues with a custom linker setup. In theory, rust translates most flags to the right
    /// linker format.

guess what chuckleheads, its literally commented in the source code. just above they match "mold" to LinkerFlavour::Gnu

#

nope i'm right!

#

at some point it forgets to pass -fuse-ld=mold

#

specifically, when starting tokio-runtime-w processes

#

which i assume is tokio::process::Command

#

it checks for -Wl,-fuse-ld in arguments to keep around, but not -fuse-ld

#

ahh, and i cant just set both variants in rustflags

23:06:15 [dev] Failed to generate fat binary: mold: warning: unknown command line option: -znostart-stop-gc
mold: fatal: -auxiliary may not be used without -shared
clang: error: linker command failed with exit code 1 (use -v to see invocation)
23:06:15 [dev] Build failed: Failed to write main executable
late stratus
#

btw

#

i'm dixing dioxus cli

#

1 line change and mold works properly

#

gonna also fix linker="" if i can

mellow flint
late stratus
#

gimme sec, PR aint done lmao

#

as i said, also fixing linker

#

which is actually a bug from cargo_config2

#

they don't resolve PATH like cargo does

mellow flint
mellow flint
late stratus
#

aye

#

hence my desire to fix both

mellow flint
#

thanks for looking into it πŸ™‚

late stratus
#

actually maybe not?

#

cargo says they resolve from PATH but they also dont?

elder heart
#

mind blown-er

elder heart
#

oh wow

elder heart
late stratus
mellow flint
mellow flint
#

yeah makes sense

mellow flint
#

But I'll update the readme according to your PR πŸ™‚

late stratus
late stratus
mellow flint
mellow flint
late stratus
late stratus
late stratus
#

thats such a small difference, i doubt it matters

#

though i have not tried it with a multi-file project yet

mellow flint
#

Just tested it, and it also works for me in isolation. The issue is from mold + some other setting

#

In a previous version, doing mold + a custom target dir + subsecond didn't work

#

So let's try that

late stratus
#

aight

late stratus
#

could be scccache, or maybe dynamic_linking?

mellow flint
mellow flint
mellow flint
#

Undid those and now it works with mold πŸ™‚

late stratus
#

i have ✨ opinions ✨

#

(tldr: don't overuse details collapse thingies, global config == bad)

mellow flint
#

@late stratus are you fine with me changing the rec to mention both global and local?

late stratus
#

sure

mellow flint
#

Cool!

#

I'll merge your PR then and do a followup

late stratus
#

i already commented on gh but do whatever you want

mellow flint
late stratus
#

i care, but i dont care that much

mellow flint
#

Oh yeah, rustdoc does not like those πŸ˜…

late stratus
mellow flint
#

Good to change that anyways, crates.io and lib.rs also don't know GitHub markdown

#

But I can do that, no worries

late stratus
#

fair

#

annoying though

mellow flint
#

Ye

late stratus
#

warning boxes are nice

#

wait

mellow flint
#

I'm just really happy I can use mold again haha

#

thanks a bunch! πŸ˜„

late stratus
#

doesnt crates have warning boxes too? what syntax are they?

late stratus
mellow flint
late stratus
#

though i do question the sanity of whovere wrote the CLI. making it a rustc wrapper, a linker and a otherwise many-purpose CLI in one is a bit eehhhh

mellow flint
mellow flint
late stratus
late stratus
#

the cli is 1000 crates!

mellow flint
late stratus
#

literal

mellow flint
#

Then it's probably to do faster compilations

#

There was an infamous blog post about how to increase parallelism by doing literal thousands of crates automatically

late stratus
#

nope

#

have you seen the cargo.toml?

mellow flint
late stratus
#

i would send just the dependency block, but it'd count as spam

mellow flint
late stratus
#

anyways, i'm gonna sleep now. i focused on this wayyyy too much and its 2am

#

ahhhhhh fuck, i forgot to eat dinner didn't i

mellow flint
mellow flint
#

merging readme now

late stratus
somber lily
#

figure id ask here

#

for some reason, the subsecond stuff isnt getting connected

calm basin
#

Is this a good place to post issues with bevy_simple_subsecond on Windows? Currently seems to be borked at least for me

lone token
somber lily
#

Ah gotcha

calm basin
#

I raised an issue on the repo. It seems I'm the root cause of all the issues on the bevy_simple_subsecond repo 🀣

late stratus
#

it seems the #[hot] macro might be swallowing system validation errors currently

mellow flint
#

The parameterless version of the macro has the same signature as the system, so that seems odd

mellow flint
mellow flint
late stratus
#

wait no, that can't have been it, it compiled correctly

#

ughhh i wish i'd taken a screenshot

mellow flint
#

Heck

late stratus
#

related: having watched a second person (after chris) try it out live, i'm convinced that for what the plugin is, it would make more sense to recommend the .with_hot_patch variant

unless i'm missing some downside of it?

mellow flint
# late stratus related: having watched a second person (after chris) try it out live, i'm convi...
  • things that look like they should work but don’t (e.g. resources)
  • your code is no longer "just Bevy" but a new API.
  • From chatting with @karmic current, that workflow requires remembering a surprising amount of steps when introducing it to your App

I'd like to recommend that workflow as our main one, but there’s a couple of things I'd like to see fixed first. Which seem to be not really addressable in a satisfactory way until Plugins V2, if I understand @raven valley correctly. That said, I also want to get the readme PR merged later so that users can even get to know this workflow.

Curious about your opinions as well @languid sable

late stratus
#

ughhh

#

ah well

#

i should also do some more readme cleanup, the way the drawbacks arr documented currently is confusing

quartz whale
#

I wonder if it's possible to emulate Plugins v2 as a crate. It would be pretty intrusive, but it might be possible to then integrate that with the hotpatching

late stratus
#

i did try to hotpatch at the level of FunctionSystem.func before (to fix the early local state issues) and that did not work out at all

#

not sure if plugins v2 would be relatef

late stratus
mellow flint
mellow flint
late stratus
#

wohoo my subsecond PR is merged

mellow flint
#

I'll update the readme to the original repo πŸ™‚

lone token
#

I think we’ll be able to do a lot in Bevy even without plugins v2, or maybe with just small changes in that direction

#

Anyway waiting for my pr to get merged which is waiting on Cart review which is waiting on a new subsecond release πŸ˜ƒ

lone token
worldly ether
mellow flint
lone token
mellow flint
lone token
#

Setup despawn and rerun need a bit more reflection… but we’ll get there

worldly ether
#

is there anything left on the subsecond end of things beyond the workspace CWD problem and workspace support?

mellow flint
# worldly ether is there anything left on the subsecond end of things beyond the workspace CWD p...

Don't know what CWD is, but these are some issues users have run into very recently:

#

Number two is somewhat important-ish, as many Linux users use mold for Bevy, but the workaround is trivial (just use lld)

#

But the big one is the length issue on Windows

lone token
worldly ether
lone token
#

@mellow flint something to investigate is how to isolate the part of the code that is rebuilt. like is it possible to have the dependencies in a dynamic lib that is not rebuilt, and just your code? that should help with larger project times

late stratus
#

(i would also love if just the "dx serve --hot-patch" could be split out into a separate tool, as 1000 dependencies is ridiculous for the very small subset of dx features we need, but thats far less critical)

obtuse sparrow
#

preach

mellow flint
worldly ether
#

long term I want to ship an scacche integration in dx that pulls precompiled deps from github ci/cdn, so initial builds are always hot

lone token
#

oh πŸ€”
I thought that wasn't the case as people are reporting longer times on projects with more dependencies

late stratus
late stratus
raven valley
#

not dependencies just raw amounts of code that is in the main.rs and related files

mellow flint
late stratus
#

could be that doesn't take noticeable extra time, but i bet it does. but i have no clue if its even possible to not do that

worldly ether
#

I'm adding some more timing/tracing to the thin linking to get a better sense but I think the scaling is just rustc, and it's likely there's not much we can do there

#

workspace support should let us operate on individual .o files which would be important to work on if the scaling is because the linking is slow

lone token
#

setup build servers that would be fast enough to offset the upload/download times πŸ˜„

worldly ether
#

a custom codegen backend would make it possible to delay codegen until the linking phase but uh... gonna have to wait a while until we get that

worldly ether
mellow flint
mellow flint
worldly ether
#

on my large project, rustc takes 1.8s and linking takes 47ms where the dx side of things takes <1ms

calm basin
#

I can't get hot reloading to work on Windows on a small/medium sized project, it panics when I save the file. The dx build also doesn't seem to reflect the code - i.e. I have a string that I change and even if I ctrl+c and run dx serve again the string isn't updated in the UI. πŸ€·β€β™‚οΈ

dx serve seems to be about 25% slower on the initial compile compared to cargo run (6.5 mins for cargo, 8 mins for dx) although its a bit unscientific.

From memory the incremental recompilation is about 10-15 times slower too than it was before with bevy/dynamic_linking enabled. (it was about 10-15 seconds from memory recompilation now takes 2 minutes).

calm basin
#

Haven't tried nightly yet Jan btw its getting pretty late. I can try foxtrot tomorrow

mellow flint
mellow flint
calm basin
#

ah ok πŸ™‚

#

I might try it as well though tbh to see if my project is the problem haha

#

if I do the jam would like to try hot reloading

mellow flint
#

do cargo add bevy_simple_subsecond_system --git https://github.com/TheBevyFlock/bevy_simple_subsecond_system

calm basin
#

its already in there from git, I just bumped the rev in Cargo.toml

calm basin
#

Hmmm I wonder if dx is ignoring the linker setting given it seems to struggle a bit with cargo workspaces πŸ€” I'm getting this warning on build:

[dev] Failed to generate fat binary: lld is a generic driver.
Invoke ld.lld (Unix), ld64.lld (macOS), lld-link (Windows), wasm-ld (WebAssembly) instead

I tried to pass dx serve --hot-patch -p tableau --rustc-args "-Clinker=rust-lld.exe" but

error: unexpected argument '-C' found
#

If I run the build with verbose/tracing enabled I see

 Running ...rustc.exe --crate-name tableau --edition=2024 crates\tableau\src\main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type bin --emit=dep-info,link -C opt-level=1 -C embed-bitcode=no -C codegen-units=1 -C debuginfo=1 --allow=clippy::type_complexity --allow=clippy::too_many_arguments --warn=clippy::nonstandard_macro_braces -C debug-assertions=on --cfg "feature=\"default\"" --cfg "feature=\"dev\"" --cfg "feature=\"dev_native\"" --check-cfg cfg(docsrs,test) --check-cfg "cfg(feature, values(\"default\", \"dev\", \"dev_native\"))" -C metadata=86b8d89efee4cd2b <sniop> --target x86_64-pc-windows-msvc -C linker=rust-lld.exe ...

so I guess it is using rust-lld πŸ€·β€β™‚οΈ

Well anyway time to clock off for me, thanks for all your help Jan

#

OK one last thing, when the hot reload fails I see some logs like this with verbose/tracing on

Ignoring file change: client is not ready to receive hotreload. Files: [ // the files ]

warning: failed to connect to jobserver from environment variable `CARGO_MAKEFLAGS="-j --jobserver-fds=__rust_jobserver_semaphore_1142413780 --jobserver-auth=__rust_jobserver_semaphore_11424137  |`: cannot open path or name __rust_jobserver_semaphore_1142413780 from the jobserver environment variable value: The system cannot find the file specified. (os error 2)
  = note: the build environment is likely misconfigured

Build completed successfully in 625251us

Undefined symbols : [ <a bunch of undefined symbols> ]

Setting builder to failed state

Build failed: Runtime Error: Build panicked! JoinError::Panic(Id(1185), "failed to resolve patch symbols: InvalidModule(\"ASLR reference is less than the main module's address
raven valley
#

( log scale, time is in milliseconds, generated the functions with this macro )

#
seq_macro::seq!(N in 0..100_000 {
    pub fn my_func~N() {
        println!("This is my_fn_{}", N);
    }
});
#

@celest magnet

#

added a 50,000 function datapoint, felt like it was needed

worldly ether
#
raven valley
#

enabling dynamic linking on bevy actually increases my reload times from 700ms to 1,700ms

worldly ether
raven valley
#

dx serve --hot-patch

#

so i believe it's in debug mode

pliant helm
#

dynamic_linking takes me from 2.5s down to 0.7s
I am using cranelift to compile the tip crate in my project

opaque mulch
#

An interesting cursed idea
Editor>edit bsn of the editor+hot-reload>making the editor in the editor.

#

God mode dog fooding

lone token
#

also that's hot reloading, not hotpatching πŸ™‚

opaque mulch
lone token
#

yup!

#

I mean, it already works, that doesn't have anything to do with what we're talking about here with subsecond

#

except some naming discutions πŸ˜„

opaque mulch
#

Subsecond is the code/rust side no?

quartz whale
#

Hotpatching is using subsecond and the dioxus tool to reload Rust code at runtime
Hotreloading is using the asset system in Bevy to use the new version of an asdet when it's changed in the filesystem.
Hotreloading is much simpler, as it's just changing data, not the code itself

pliant helm
#

I think Rin was referring to hotpatching the BSN macro's, not BSN files

opaque mulch
idle stone
#

@mellow flint iirc there was a thing where you had to use the same version of the dioxus cli + specified as a dependency in Cargo.toml as bevy_simple_subsecond_systems, is that still a thing? or maybe i'm misremembering the details

#

i want to test the version that supposedly lets me do linker = "clang"

#

although i probably want to wait for the alpha.1

pliant helm
opaque mulch
#

It'd also just improve the editor user workflow since cutdown on recompile needs

mellow flint
mellow flint
idle stone
mellow flint
#

Should be simpler again once the next dioxus alpha is release πŸ˜…

idle stone
#

well it looks like the rev hasn't changed on main of bsss anyways, still b2bd1f

quartz whale
late stratus
calm basin
late stratus
opaque mulch
calm basin
calm basin