Skip to content

Efficient object updates for closed records #3244

Closed
fehrenbach wants to merge 5 commits intopurescript:masterfrom
fehrenbach:updated-closed-records
Closed

Efficient object updates for closed records #3244
fehrenbach wants to merge 5 commits intopurescript:masterfrom
fehrenbach:updated-closed-records

Conversation

@fehrenbach
Copy link
Copy Markdown
Contributor

See #1493.

This uses @matthewleon 's newly introduced CoreFn optimization infrastructure (#3218).

@kritzcreek
Copy link
Copy Markdown
Member

We're making a trade-off here, right? This will increase the size of the generated JS depending on how large of a record we are copying.

Should we pick a number of record properties at which we switch back to the loop?

@garyb
Copy link
Copy Markdown
Member

garyb commented Mar 23, 2018

I think we can set that threshold pretty high if we're going to have it, like 100 or something.

@fehrenbach
Copy link
Copy Markdown
Contributor Author

It certainly is a trade-off. The appropriate measure to optimize for generated code size would be something like sum of length of field names that are not updated compared to size of the update loop.

In my dreams, we would just generate Object.assign({}, inputRecord, {up: "-dated", "field":'s'}) which is short and JS engines would be clever, recognizing this as a copy with updates, but alas they are not and it's ES2015 anyway.

I can add a threshold, in whatever form, but to be honest I'd rather wait for someone to actually have a problem with huge records.

@fehrenbach
Copy link
Copy Markdown
Contributor Author

@garyb
Copy link
Copy Markdown
Member

garyb commented Mar 23, 2018

I can add a threshold, in whatever form, but to be honest I'd rather wait for someone to actually have a problem with huge records.

I'd tend to agree with that 👍

@garyb
Copy link
Copy Markdown
Member

garyb commented Mar 23, 2018

Also, sorry we're only getting around to commenting on this now - but big thanks! This is something I've wanted to do for a long time.

@garyb garyb closed this in #3321 Apr 25, 2018
@fehrenbach fehrenbach deleted the updated-closed-records branch October 21, 2018 16:39
nwolverson added a commit to purerl/purerl that referenced this pull request Aug 24, 2021
…ct update

to record literal purescript/purescript#3244

Not possible to reverse this without type info.

Fix #19
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.

4 participants