Skip to content

Conversation

@takaokouji
Copy link

Summary

This PR implements data delta transmission for Mesh v2 (Phase 2 of #79) to reduce infrastructure costs.

Implementation Details

  • Modified MeshV2Service.sendData to filter out items that haven't changed since the last successful transmission.
  • Updated lastSentData in _reportData only after a successful mutation.
  • This significantly reduces the number of mutations and payload size when only a subset of variables or lists are changing.

Test Coverage

  • Added test/unit/extension_mesh_v2_delta.js with comprehensive test cases:
    • Initial data transmission (all items sent).
    • Skipping transmission when data is unchanged.
    • Sending only changed items (delta).
    • Handling new items.
    • Handling single-item sendData calls common in index.js.
  • Verified all existing Mesh V2 unit tests pass.

Cost Impact

This change is expected to reduce AppSync mutation costs by 50-70% in typical usage scenarios where many variables are registered but only few change frequently.

Part of #79

Co-Authored-By: Gemini noreply@google.com

takaokouji and others added 3 commits January 4, 2026 13:27
- Only send data items that have actually changed since the last successful transmission
- Reduces the number of mutations and payload size for better cost-effectiveness
- Added unit tests to verify delta transmission logic

Part of #79 (Phase 2)

Co-Authored-By: Gemini <noreply@google.com>
- Removed unused 'maxPerSecond' from RateLimiter
- Added interval logging for Mesh v2 timers (data update, event batch, heartbeat, periodic sync)
- Updated unit tests to match RateLimiter constructor changes

Co-Authored-By: Gemini <noreply@google.com>
- Added MESH_PERIODIC_DATA_SYNC_INTERVAL_MS environment variable
- Default and production value set to 15000ms (15 seconds)
- Updated MeshV2Service to use the new environment variable
- Updated .env.example

Part of #79

Co-Authored-By: Gemini <noreply@google.com>
- Introduced latestQueuedData to track the most recent data sent to RateLimiter
- Added final delta check in _reportData to skip mutations if data matches lastSentData
- Added reproduction unit tests to verify the fix

Co-Authored-By: Gemini <noreply@google.com>
@takaokouji takaokouji merged commit 8b640a0 into develop Jan 4, 2026
1 check passed
@takaokouji takaokouji deleted the feature/issue-79-mesh-v2-delta-transmission branch January 4, 2026 08:11
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