Skip to content

Fix camelCase convertion and remove List.fold_left in style_tag#556

Merged
davesnx merged 9 commits intomainfrom
fix-css-eff
Jun 3, 2025
Merged

Fix camelCase convertion and remove List.fold_left in style_tag#556
davesnx merged 9 commits intomainfrom
fix-css-eff

Conversation

@davesnx
Copy link
Owner

@davesnx davesnx commented Jun 2, 2025

This PR removes two problems affecting the performance of a hot path in native rendering:

  • Refactor List.fold_left + string contact by a Buffer (created a new string by copy and also grows each iteration) in get_string_style_hashes 8b5ee07
  • Remove memory allocations due to string creation and list items 70f78c7

Small benchmark result embedded in this PR

Testing with 5000 hashes + 2000 camelCase conversions

OLD total time: 0.0947 seconds
OLD stress test: 80248252 words allocated (612.25 MB)
NEW total time: 0.0003 seconds
NEW stress test: 107793 words allocated (0.82 MB)

@vercel
Copy link

vercel bot commented Jun 2, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
styled-ppx ⬜️ Ignored (Inspect) Visit Preview Jun 3, 2025 11:06am

@github-actions
Copy link

github-actions bot commented Jun 3, 2025

New nightly version has been published to the NPM registry: @davesnx/styled-ppx@0.56.1-f574e46.0.
Install it with npm install @davesnx/styled-ppx@nightly or npm install @davesnx/styled-ppx@0.56.1-f574e46.0.

@davesnx davesnx merged commit e9afcdf into main Jun 3, 2025
9 checks passed
davesnx added a commit that referenced this pull request Jun 3, 2025
* Remove List.fold_left in get_string_style_hashes

* Remove String.make on camelCaseToKebabCase

* Push benchmark for CSS

* Use List.iteri instead of ref first

* Remove dep on benchmark

* Add random message in benchmark main

* Use ubuntu-latest

* Update version ocaml/setup-ocaml

* Push more ubuntu-latest in CI
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