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

table performance degradation with big integer keys #41

Open
door opened this issue May 15, 2014 · 3 comments
Open

table performance degradation with big integer keys #41

door opened this issue May 15, 2014 · 3 comments

Comments

@door
Copy link

door commented May 15, 2014

Try this:

luerl:do("x={};x[100000000]=1;for i,v in pairs(x) do print(i,v) end").

It takes a long time, while in vanilla lua such construction runs instantly.

@rvirding
Copy link
Owner

That is a "feature" of the implementation of the array part of a table. It uses the erlang array module which has not fast way of stepping to the next index which has a value. You basically have to test each value. It could be done more efficiently by explicitly working with the internal representation.

An alternative would be to use the same type of tree for the array part of a table as for the rest. It does a next call but it is generally slower than using arrays.

I will test maps when they can handle larger numbers of elements, but they don't have a call to get the next index.

Is is a serious problem which needs addressing?

@door
Copy link
Author

door commented May 22, 2014

I think this feature should be noted in README.

@rvirding
Copy link
Owner

I am sure of the best way to express it. It is not a problem of having a large table or large indexes per se. It is really a problem with pairs in that when pairs goes from one integer key to the next it has to literally loop over each key until it gets to one which has been set. Or rather the internal representation of this part of a table does not properly support this type of operation.

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

No branches or pull requests

2 participants