Skip to content

Commit

Permalink
Replace CompactValue with StyleValueHandle and StyleValuePool (#1534)
Browse files Browse the repository at this point in the history
Summary:

Now that the storage method is a hidden implementation detail, this changes the underlying data structure used to store styles, from `CompactValue` (a customized 32-bit float with tag bits), to `StyleValuePool`.

This new structure operates on 16-bit handles, and a shared small buffer. The vast majority of real-world values can be stored directly in the handle, but we allow arbitrary 32 bit (and soon 64-bit) values to be stored, where the handle then becomes an index into the styles buffer.

This results in a real-world memory usage win, while also letting us store the 64-bit values we are wanting to use for math function support (compared to doubling the storage requirements).

| | Before | After | Δ |
| `sizeof(yoga::Style)` | 208B  | 144B | -64B/-31% |
| `sizeof(yoga::Node)` | 640B  | 576B | -64B/-10% |
| `sizeof(YogaLayoutableShadowNode) ` |  920B | 856B | -64B/-7% |
| `sizeof(YogaLayoutableShadowNode) + sizeof(YogaStylableProps)` | 1296B  | 1168B | -128B/-10% |
| `sizeof(ViewShadowNode)`  |  920B | 856B | -64B/-7% |
| `sizeof(ViewShadowNode) + sizeof(ViewShadowNodeProps)` | 2000B  | 1872B | -128B/-6% |

Differential Revision: D52223122
  • Loading branch information
NickGerleman authored and facebook-github-bot committed Jan 3, 2024
1 parent 94e7336 commit ff2648f
Show file tree
Hide file tree
Showing 10 changed files with 745 additions and 535 deletions.
291 changes: 0 additions & 291 deletions tests/CompactValueTest.cpp

This file was deleted.

Loading

0 comments on commit ff2648f

Please sign in to comment.