Skip to content

Conversation

@alexgavrushenko
Copy link

🐛 Issue

When rendering large datasets that contain newline characters, there is significant performance degradation.
This is caused by excessive GC pressure due to unnecessary .split() and .splice() operations during wrapping and height calculations.


🧪 Current Workaround

To mitigate the issue in production use, I implemented a lazy-loading approach for rendering tables (e.g., recent traceback list), loading content in parts and merging the final table at runtime.


✅ Proposed Solution

Optimize the height calculation logic by using a regex .exec() in a loop instead of .split() and .wrap() to count line breaks.
This avoids allocating large arrays and reduces GC overhead during render-heavy scenarios.


🔍 What Could Be Improved

  • Regex optimizations: Current regex expressions in wrap* functions could be reviewed and optimized for better performance.
  • Memoization opportunities:
    • Splitting and wrapping operations could potentially be memoized.
    • Alternatively, these computations might be moved outside of the render cycle if inputs don’t change.
    • Needs further investigation.
  • Potential side effects:
    • The solution introduces a looser coupling with the wrapping algorithm, which may lead to unexpected rendering behavior in some edge cases.
    • Consider making this height calculation strategy configurable, so it can be enabled explicitly when needed.

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.

1 participant