Hasty Briefsbeta

Bilingual

Are you telling me a readonly property is wrecking my performance?

4 days ago
  • #performance
  • #web-development
  • #javascript
  • A performance issue was investigated in Letta Desktop where increasing usage slowed the product, initially suspected to be due to unoptimized code.
  • The root cause was found to be the use of 'el.scrollTop = el.scrollHeight;' to scroll the UI on new messages, assuming scrollHeight was a static, performant readonly property.
  • In reality, scrollHeight is dynamic and recalculated on access, causing slowdowns when frequently updated during high message streams.
  • The chromium implementation shows scrollHeight triggers layout updates, making it non-performant for frequent use.
  • A solution was to use a very large number instead of calculating scrollHeight precisely, relying on bounding behavior.
  • Key advice: Readonly properties can be dynamic and impact performance, especially when obvious changes occur.
  • Lessons include questioning assumptions about property performance and optimizing UI interactions.