Skip to content

Conversation

@thecodacus
Copy link
Collaborator

Add Code Streaming Sampling for Performance Optimization

Overview

This PR implements a sampling mechanism for code streaming to optimize performance and prevent UI degradation during rapid stream updates. This optimization ensures smooth handling of streamed code updates while maintaining system responsiveness.

Key Changes

1. Stream Processing Architecture

  • Added createSampler utility to manage code streaming updates
  • Modified code streaming to use sampling with 100ms intervals
  • Implemented trailing update capture to prevent data loss
  • Added proper state verification for streamed code changes

2. Workbench Store Updates

  • Added actionStreamSampler for managing streamed code processing
  • Modified streaming code flow to use sampling
  • Added code state verification to prevent redundant processing
  • Updated execution queue management for non-streaming operations

3. Performance Optimizations

  • Implemented sampling to reduce rapid UI updates during code streaming
  • Added trailing update capture for stream consistency
  • Set up configurable sampling interval
  • Improved code state management during streaming

Technical Details

Sampler Utility

The new createSampler function provides:

  • Controlled processing of streamed code updates
  • Trailing update capture mechanism
  • Configurable sampling frequency
  • Type-safe implementation

Workbench Store Changes

  • Added dedicated sampler for streamed code
  • Modified code handling to separate streaming from regular updates
  • Added state verification to ensure code consistency
  • Updated queue management for non-streaming operations

Testing

  • Verified code streaming behavior under high update frequency
  • Tested sampling with different intervals
  • Confirmed trailing update capture
  • Validated code state consistency
  • Verified compatibility with existing code

Migration Impact

  • No breaking changes for existing functionality
  • Improved performance for code streaming
  • No changes required for current implementations
  • Maintains backwards compatibility

Future Improvements

  • Make sampling interval configurable

@thecodacus thecodacus changed the title fix: Add Action Streaming Sampling for Better Performance fix: Add Code Streaming Sampling for Performance Optimization Dec 11, 2024
@dustinwloring1988
Copy link
Collaborator

UI is more responsive especially on longer chats, works on Windows.

@thecodacus thecodacus merged commit 4af18c0 into stackblitz-labs:main Dec 14, 2024
2 checks passed
JJ-Dynamite pushed a commit to val-x/valenClient that referenced this pull request Jan 29, 2025
fix: Add Code Streaming Sampling for Performance Optimization
Stijnus pushed a commit to Stijnus/bolt.diy that referenced this pull request Mar 19, 2025
fix: Add Code Streaming Sampling for Performance Optimization
corbettamarco pushed a commit to corbettamarco/bolt.diy that referenced this pull request Apr 4, 2025
fix: Add Code Streaming Sampling for Performance Optimization
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