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

perf(metrics): Improve Performance for Inserting/Deleting Large Numbers of Lines in Buffer #18

Closed
wants to merge 3 commits into from

Conversation

hat0uma
Copy link
Owner

@hat0uma hat0uma commented Jan 8, 2025

Overview

This PR improves the performance of handling large numbers of rows in buffers by refactoring the CsvViewMetrics:_add_row_placeholders and CsvViewMetrics:_remove_rows methods. The changes address inefficiencies in table.insert and table.remove, which are not ideal for large datasets due to their linear complexity.

Changes

  • Optimized CsvViewMetrics:_add_row_placeholders
    Replaced table.insert with a custom method that shifts elements directly. This approach significantly improves insertion performance for large buffers.

  • Optimized CsvViewMetrics:_remove_rows
    Replaced table.remove with a direct element-shifting method, enhancing efficiency when removing multiple rows.

Performance Improvements

In testing, the time required to insert or delete 100,000 rows decreased significantly—from approximately 5 seconds to just over 1 second. This represents a substantial reduction in latency for large-scale edits.

Refactor `_add_row_placeholders` and `_remove_rows` methods to enhance
performance when editing large buffers. Replace `table.insert` and
`table.remove` with more efficient operations.
Fix the logic in `_add_row_placeholders` to correctly handle the
insertion of row placeholders. Ensure that rows are shifted properly
and new placeholders are added in the correct positions.
@hat0uma hat0uma force-pushed the buffer_performance_optimization branch from 937fa4d to 1aa592d Compare January 8, 2025 13:02
@hat0uma hat0uma force-pushed the buffer_performance_optimization branch from 1aa592d to 564f454 Compare January 8, 2025 13:04
@hat0uma hat0uma closed this Jan 8, 2025
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