wasi-nn icon indicating copy to clipboard operation
wasi-nn copied to clipboard

Return errors as records, not resources

Open abrown opened this issue 1 year ago • 1 comments

This change migrates the error type to return as a record instead of a resource. The previous logic behind #64, IIRC, is that users that may not wish to copy the potentially-large data string across the canonical ABI would not have to--they could call the data method on the resource if they really needed it.

Technical complexity during implementation is making me reconsider this decision. While implementing this in Wasmtime, I realized that after an error happens, the current "error as resource" scheme results in a multi-step failure algorithm:

  • construct the internal host error
  • register the host error in the resource table--this may fail!
  • return the host error as a resource

This complexity does not mean necessarily that the spec must be changed; I believe there is a way to "make it work." But if users end up troubleshooting a resource failure that happens during a wasi-nn failure, we risk making things a bit too complex for them. And, if indeed the original argument for using resources was avoiding performance overhead, there is a case to be made that in failure modes performance is not the most critical for users.

I'll open this seeking feedback, not to merge immediately.

abrown avatar Jul 31 '24 22:07 abrown

cc: @shschaefer

abrown avatar Jul 31 '24 22:07 abrown