Skip to content

Conversation

tuguzT
Copy link
Contributor

@tuguzT tuguzT commented Oct 1, 2025

Required by Rust-GPU/cargo-gpu#117

It was suggested to rewrite API from scratch instead of patching the existing one.

My idea now is to expose refactored Watcher, which could just return CompileResult on recv(), then we don't need to accept any callbacks, users don't need to differentiate first compile result from others, etc.

@tuguzT
Copy link
Contributor Author

tuguzT commented Oct 1, 2025

I thought CI issues were already resolved at GitHub side?
Besides, it's ready to be reviewed.

@tuguzT tuguzT marked this pull request as ready for review October 1, 2025 20:48
@Firestar99
Copy link
Member

Firestar99 commented Oct 2, 2025

CI failing is just #407, recently introduced in #400

@Firestar99 Firestar99 force-pushed the spirv-builder-watch-channel branch from e5e56df to f956b84 Compare October 2, 2025 08:45
Copy link
Member

@Firestar99 Firestar99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love the new design!

Just iterated some more on it, so I'll let others do the reviewing

My changes to it:

  • we can just consume SpirvBuilder, if users need to clone it they can
  • changing a file during recompilation no longer throws errors in stdout but will trigger exactly one recompile when you call recv() again
  • wgpu example had a race condition between the first and watched compiles

@Firestar99 Firestar99 force-pushed the spirv-builder-watch-channel branch from 4a9a64c to aefe49e Compare October 2, 2025 10:02
@Firestar99
Copy link
Member

Firestar99 commented Oct 2, 2025

I added a non-blocking try_recv() function as well, required me to refactor some of the internal state machine

@Firestar99 Firestar99 force-pushed the spirv-builder-watch-channel branch from aefe49e to 13a80b7 Compare October 2, 2025 10:08
return Err(SpirvWatcherError::WatchWithPrintMetadata.into());
}

let (tx, rx) = sync_channel(1);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've noticed that cargo-gpu produces duplicate last messages (finished compiling or failure) on branch Rust-GPU/cargo-gpu#117 on Windows.
Previously provided value was 0, now it is 1. Could this be the reason?

Copy link
Member

@Firestar99 Firestar99 Oct 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it is. When a file changes while a recompilation was running, your version would spit out an error into stderr due to the channel being full. This version uses () to record that something has happened and discards all further messages that fail to send due to the channel being full. Which allows edits during recompilation to correctly retrigger a followup recompilation. But it seems like most fs changes emit more than one event, so (almost*) all recompilations will trigger a second time. But I'd rather recompile again to figure out nothing has changed, than having a stale state due to dropping events during ongoing compilation.

(*it is a race condition between the notif thread submitting all events and the polling thread polling an event)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants