-
Notifications
You must be signed in to change notification settings - Fork 10
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
high memory usage on loop #101
Comments
What is the global table in Hilbish? If its __index metamethod is
redefined (as a function) then the runtime will try to call it when it
retrieves the value of `n`, as `n` is short for `_G["n"]`. If you do that
100 million times, youi will create 10 billion terminations, which will
make the go GC busy. But that's an interesting point, in the past I added
object pools for continuations and register sets because the Go runtime was
spending a lot of time garbage collecting those. Perhaps a similar
approach could be taken with terminations.
EDIT: to check my theory is right, you can declare `n` as local. This should make it fast again.
EDIT 2: 100 million -> 10 billion
…On Tue, 19 Dec 2023 at 01:49, sammyette ***@***.***> wrote:
i'm not sure how to title this or to properly report this.
n = 0; while n < 10000000000 do n = n + 1 end
running this sample of code in hilbish (which in reality just uses golua)
and I get this:
<https://camo.githubusercontent.com/7fff5053af0d54616241fde0257251807d7962f7679201dc803347ca4d9c500d/68747470733a2f2f736166652e736179612e6d6f652f6761524646493279644370432e706e67>
<https://camo.githubusercontent.com/5af21c1e34e375f5210debdcb0181af4bfdf3fc1d60fdd87a28b72cd0db3e4ca/68747470733a2f2f736166652e736179612e6d6f652f37346e4d447572466d686c4a2e706e67>
<https://camo.githubusercontent.com/7897fd75c3ad3d15d1b1c7b11c7bc45db96164f40870e60fa87d27c749e249e9/68747470733a2f2f736166652e736179612e6d6f652f5a3377546a4c724148647a682e706e67>
for some reason, this doesn't happen in golua-repl
—
Reply to this email directly, view it on GitHub
<#101>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAMJKOLKM2KU3P2XNRV4L5TYKDXCNAVCNFSM6AAAAABA2NIW3KVHI2DSMVQWIX3LMV43ASLTON2WKOZSGA2DONZXGI2DKOA>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
I set it in Lua to define global variables as environment variables. It can be seen here: https://github.com/Rosettea/Hilbish/blob/master/nature/init.lua#L35-L63
yes, no change in memory usage at all. |
Ah, so does it mean every time |
Ok, so your code snippet basically calls I think a termination pool might mitigate that, as I mentioned previously. It's something I can try implementing - it might be straightforward enough as it could be modelled on continuation pool implementations. I don't know if I would have time to do that soon though. Another approach would be to convince the Go compiler that the termination created in the |
i'm not sure how to title this or to properly report this.
n = 0; while n < 10000000000 do n = n + 1 end
running this sample of code in hilbish (which in reality just uses golua) and I get this:
for some reason, this doesn't happen in golua-repl
The text was updated successfully, but these errors were encountered: