Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(sdk): sim.Resource #6389

Merged
merged 99 commits into from May 14, 2024
Merged

feat(sdk): sim.Resource #6389

merged 99 commits into from May 14, 2024

Conversation

Chriscbr
Copy link
Contributor

@Chriscbr Chriscbr commented Apr 30, 2024

Introduces sim.Resource, a primitive for creating stateful resources running in the Wing simulator. Check out the new documentation here for usage examples and an API reference.

Misc:

  • Fix E2E tests for cloud.Function timeouts
  • Converted the simulator implementation of cloud.Counter to use sim.Resource. It will be a bit of a manual process to do this for the other cloud resources.
  • Improved the robustness of the log/event streaming facilities in the CLI. There were occasions where an error stack trace might not get printed to STDOUT because the formatting work was happening asynchronously.

Follow-up:

  • Convert other cloud resource implementations to use sim.Resource internally
  • Deprecate sim.State
  • Deprecate ctx.log(message, level) in favor of log(message, level: level)
  • Enforce serializable types for inflight methods on preflight classes
    • We could also consider loosening type constraints on sim.IResource implementations to allow private methods and fields to use non-serializable types.
  • Improve DX around serializing and deserializing types

Checklist

  • Title matches Winglang's style guide
  • Description explains motivation and solution
  • Tests added (always)
  • Docs updated (only required for features)
  • Added pr/e2e-full label if this feature requires end-to-end testing

By submitting this pull request, I confirm that my contribution is made under the terms of the Wing Cloud Contribution License.

Copy link

Thanks for opening this pull request! 🎉
Please consult the contributing guidelines for details on how to contribute to this project.
If you need any assistence, don't hesitate to ping the relevant owner over Slack.

Topic Owner
Wing SDK and utility APIs @chriscbr
Wing Console @ainvoner, @skyrpex, @polamoros
JSON, structs, primitives and collections @hasanaburayyan
Platforms and plugins @hasanaburayyan
Frontend resources (website, react, etc) @tsuf239
Language design @chriscbr
VSCode extension and language server @markmcculloh
Compiler architecture, inflights, lifting @yoav-steinberg
Wing Testing Framework @tsuf239
Wing CLI @markmcculloh
Build system, dev environment, releases @markmcculloh
Library Ecosystem @chriscbr
Documentation @hasanaburayyan
SDK test suite @tsuf239
Examples @hasanaburayyan
Wing Playground @eladcon

@monadabot
Copy link
Contributor

monadabot commented May 1, 2024

Console preview environment is available at https://wing-console-pr-6389.fly.dev 🚀

Last Updated (UTC) 2024-05-14 20:09

@monadabot
Copy link
Contributor

monadabot commented May 1, 2024

Benchmarks

Comparison to Baseline 🟥⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜
Benchmark Before After Change
version 55ms±0.47 57ms±0.71 +2ms (+3.21%)🟥
functions_1.test.w -t sim 406ms±16.51 401ms±3.98 -6ms (-1.37%)⬜
functions_1.test.w -t tf-aws 814ms±6.6 837ms±17.57 +23ms (+2.84%)⬜
jsii_big.test.w -t sim 2767ms±16.75 2790ms±10.99 +23ms (+0.82%)⬜
jsii_big.test.w -t tf-aws 2987ms±11.97 2986ms±10.58 -1ms (-0.04%)⬜
functions_10.test.w -t sim 484ms±11.56 495ms±7.42 +11ms (+2.22%)⬜
functions_10.test.w -t tf-aws 2007ms±19.04 2015ms±9.07 +8ms (+0.42%)⬜
jsii_small.test.w -t sim 369ms±4.21 370ms±2.09 +1ms (+0.26%)⬜
jsii_small.test.w -t tf-aws 602ms±4.37 602ms±2.37 +0ms (+0.01%)⬜
empty.test.w -t sim 360ms±3.14 361ms±3.41 +2ms (+0.43%)⬜
empty.test.w -t tf-aws 585ms±5.81 591ms±3.2 +6ms (+1.08%)⬜
hello_world.test.w -t sim 391ms±4.15 397ms±4.6 +6ms (+1.56%)⬜
hello_world.test.w -t tf-aws 1502ms±7.65 1520ms±6.73 +17ms (+1.15%)⬜

⬜ Within 1.5 standard deviations
🟩 Faster, Above 1.5 standard deviations
🟥 Slower, Above 1.5 standard deviations

Benchmarks may vary outside of normal expectations, especially when running in GitHub Actions CI.

Results
name mean min max moe sd
version 57ms 56ms 60ms 1ms 1ms
functions_1.test.w -t sim 401ms 393ms 411ms 4ms 6ms
functions_1.test.w -t tf-aws 837ms 812ms 902ms 18ms 25ms
jsii_big.test.w -t sim 2790ms 2767ms 2810ms 11ms 15ms
jsii_big.test.w -t tf-aws 2986ms 2962ms 3011ms 11ms 15ms
functions_10.test.w -t sim 495ms 476ms 510ms 7ms 10ms
functions_10.test.w -t tf-aws 2015ms 1992ms 2034ms 9ms 13ms
jsii_small.test.w -t sim 370ms 365ms 375ms 2ms 3ms
jsii_small.test.w -t tf-aws 602ms 596ms 606ms 2ms 3ms
empty.test.w -t sim 361ms 355ms 369ms 3ms 5ms
empty.test.w -t tf-aws 591ms 584ms 596ms 3ms 4ms
hello_world.test.w -t sim 397ms 387ms 408ms 5ms 6ms
hello_world.test.w -t tf-aws 1520ms 1506ms 1537ms 7ms 9ms
Last Updated (UTC) 2024-05-14 18:59

Copy link
Contributor

@eladb eladb left a comment

Choose a reason for hiding this comment

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

❣️

examples/tests/sdk_tests/resource/resource.test.w Outdated Show resolved Hide resolved
libs/wingsdk/src/target-sim/resource.inflight.ts Outdated Show resolved Hide resolved
libs/wingsdk/src/target-sim/resource.ts Outdated Show resolved Hide resolved
libs/wingsdk/src/target-sim/resource.ts Outdated Show resolved Hide resolved
@monadabot monadabot added the ⚠️ pr/review-mutation PR has been mutated and will not auto-merge. Clear this label if the changes look good! label May 1, 2024
@Chriscbr Chriscbr changed the title [WIP] sim.Resource [WIP] feat(sdk): sim.Resource May 3, 2024
Copy link
Contributor

@eladb eladb left a comment

Choose a reason for hiding this comment

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

Amazing job man!

docs/docs/04-standard-library/sim/resource.md Outdated Show resolved Hide resolved
docs/docs/04-standard-library/sim/resource.md Outdated Show resolved Hide resolved
libs/wingsdk/src/target-sim/counter.backend.ts Outdated Show resolved Hide resolved
libs/wingsdk/src/target-sim/resource.ts Show resolved Hide resolved
examples/tests/sdk_tests/resource/call.test.w Show resolved Hide resolved
libs/wingsdk/src/target-sim/queue.ts Outdated Show resolved Hide resolved
@Chriscbr Chriscbr removed the ⚠️ pr/review-mutation PR has been mutated and will not auto-merge. Clear this label if the changes look good! label May 14, 2024
@monadabot monadabot added the ⚠️ pr/review-mutation PR has been mutated and will not auto-merge. Clear this label if the changes look good! label May 14, 2024
@Chriscbr Chriscbr removed the ⚠️ pr/review-mutation PR has been mutated and will not auto-merge. Clear this label if the changes look good! label May 14, 2024
@monadabot monadabot added the ⚠️ pr/review-mutation PR has been mutated and will not auto-merge. Clear this label if the changes look good! label May 14, 2024
@Chriscbr Chriscbr removed the ⚠️ pr/review-mutation PR has been mutated and will not auto-merge. Clear this label if the changes look good! label May 14, 2024
Copy link
Contributor

mergify bot commented May 14, 2024

Thanks for contributing, @Chriscbr! This PR will now be added to the merge queue, or immediately merged if rybickic/sim-resource2 is up-to-date with main and the queue is empty.

@mergify mergify bot merged commit 58493d3 into main May 14, 2024
25 checks passed
@mergify mergify bot deleted the rybickic/sim-resource2 branch May 14, 2024 20:19
@monadabot
Copy link
Contributor

Congrats! 🚀 This was released in Wing 0.73.43.

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

Successfully merging this pull request may close these issues.

None yet

4 participants