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

feat(store): compute FieldLayout at compile time #1508

Merged
merged 6 commits into from
Sep 16, 2023

Conversation

Boffee
Copy link
Contributor

@Boffee Boffee commented Sep 15, 2023

Followup to #1336
Fixes #1327

Computing FieldLayout bytes from schema field type array is expensive (~500 + 500 * # of schema fields). This change precomputes the FieldLayout offchain inside codegen and hardcodes the byte into the auto-generated table libraries.

@Boffee Boffee requested review from alvrs and dk1a as code owners September 15, 2023 20:26
@changeset-bot
Copy link

changeset-bot bot commented Sep 15, 2023

🦋 Changeset detected

Latest commit: 9c956ca

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 28 packages
Name Type
@latticexyz/cli Patch
@latticexyz/store Patch
@latticexyz/world Patch
@latticexyz/dev-tools Patch
@latticexyz/react Patch
@latticexyz/store-indexer Patch
@latticexyz/store-sync Patch
@latticexyz/abi-ts Patch
@latticexyz/block-logs-stream Patch
@latticexyz/common Patch
@latticexyz/config Patch
create-mud Patch
@latticexyz/ecs-browser Patch
@latticexyz/gas-report Patch
@latticexyz/network Patch
@latticexyz/noise Patch
@latticexyz/phaserx Patch
@latticexyz/protocol-parser Patch
@latticexyz/recs Patch
@latticexyz/schema-type Patch
@latticexyz/services Patch
@latticexyz/solecs Patch
solhint-config-mud Patch
solhint-plugin-mud Patch
@latticexyz/std-client Patch
@latticexyz/std-contracts Patch
@latticexyz/store-cache Patch
@latticexyz/utils Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Boffee Boffee changed the title feat(store,world): codegen hardcoded FieldLayout feat(store,world): hardcode FieldLayout Sep 15, 2023
@@ -32,9 +36,7 @@ struct Dynamics1Data {
library Dynamics1 {
/** Get the table values' field layout */
function getFieldLayout() internal pure returns (FieldLayout) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this method anymore?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems fine for completeness (so the methods match what you can get from the Tables table), if it's not used anywhere it's also not included in the bytecode

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why anyone would choose the less efficient one (function call) over the more efficient one though (importing the _fieldLayout directly)

Copy link
Member

@alvrs alvrs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

amazing, thank you!!

alvrs
alvrs previously approved these changes Sep 16, 2023
@alvrs alvrs changed the title feat(store,world): hardcode FieldLayout feat(store): compute FieldLayout at compile time Sep 16, 2023
@alvrs alvrs merged commit 211be2a into latticexyz:main Sep 16, 2023
alvrs added a commit to Boffee/mud that referenced this pull request Sep 16, 2023
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.

Encode table schemas and fieldLayout at compile time
3 participants