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

concat and observable.array #2379

Closed
logrox opened this issue Jun 19, 2020 · 14 comments
Closed

concat and observable.array #2379

logrox opened this issue Jun 19, 2020 · 14 comments

Comments

@logrox
Copy link

logrox commented Jun 19, 2020

When in the observed array I have few elements and do "concat" below, everything is as expected, but if it will be more data, eg 60,000 elements, then the problem begins.
See for yourself.

my code

@danielkcz
Copy link
Contributor

Thanks for the report. It might be a performance problem related to mobxjs/mobx-react#877.

Note that MobX is not built to be performance winner, there are better tools if you need to handle big amounts of data.

@urugator just FYI since you are rewriting array handling for V6.

@urugator
Copy link
Collaborator

Can't "debug" it because the fiddle is randomly freezing even without observable array.

@danielkcz
Copy link
Contributor

danielkcz commented Jun 19, 2020

https://codesandbox.io/s/affectionate-wildflower-x5kqu?file=/src/index.js

CodeSandbox is at least clever enough to spot a problem and doesn't freeze.

That's a different problem, but I suppose you can debug with lower number of iterations.

@mweststrate
Copy link
Member

This might be hitting the maximum function arguments somewhere, given the 60.000 number. https://stackoverflow.com/a/22747272/1983583. If we ... or .apply an array function in our concat implementation that could explain.

@mweststrate
Copy link
Member

as an work around observableArray.slice().concat(otherObservableArray.slice()) will probably work.

@urugator
Copy link
Collaborator

urugator commented Jun 19, 2020

Ah I think there was a misunderstanding this isn't about performance...
The problem is [1,2].concat(hugeObservableArray) results in [1, 2, undefined, undefined, undefined, ...]

@urugator
Copy link
Collaborator

urugator commented Jun 19, 2020

it misbehaves on observbaleArray.length >= const MAX_SPLICE_SIZE = 10000

@logrox
Copy link
Author

logrox commented Jun 19, 2020

Ah I think there was a misunderstanding this isn't about performance...
The problem is [1,2].concat(hugeObservableArray) results in [1, 2, undefined, undefined, undefined, ...]

You're right, I meant undefined

@mweststrate
Copy link
Member

mweststrate commented Jun 19, 2020 via email

@urugator
Copy link
Collaborator

urugator commented Jun 19, 2020

Current master meaning v6? I could, but note some test are already failing there. I can also add it to #2373 If you want. Btw is this even fixable? It seems to be related to that MAX_SPLICE_SIZE, but notice it's concat method of the native array (not our concat). I tried [1,2,...hugeObservableArray] but that seems to work fine, so I wonder what that native concat really does with our array?

@mweststrate
Copy link
Member

mweststrate commented Jun 19, 2020 via email

@urugator
Copy link
Collaborator

I've added the test to #2373, so feel free to merge it.
The result is different for legacy array because it's concat(object) rather than concat(proxiedArray)

@mweststrate
Copy link
Member

mweststrate commented Jun 19, 2020 via email

@logrox
Copy link
Author

logrox commented Jun 20, 2020

But when I use the na.concat(oa.toJS()) everything works as it should.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants