Ram usage with byte resolution

classic Classic list List threaded Threaded
6 messages Options
agostain agostain
Reply | Threaded
Open this post in threaded view
|

Ram usage with byte resolution

Hi

is it possible to investigate the RAM usage of my lua program with byte resolution?
Right now I found only collectgarbage("count") which gives me the usage in KB.

Cheers
Martin Guy Martin Guy
Reply | Threaded
Open this post in threaded view
|

Re: Ram usage with byte resolution

> is it possible to investigate the RAM usage of my lua program with byte
> resolution?
> Right now I found only collectgarbage("count") which gives me the usage in
> KB.

If you are using floating point eLua, the return value has fractional bits.

> print (collectgarbage("count"))
17.20703125
> print (17.20703125 * 1024)
17620
>

If you're using integer eLua you don't have this option.

In Lua5.2, instead, it returns the KB and fraction of a KB as two
results to address this problem. See
http://www.lua.org/manual/5.2/manual.html#pdf-collectgarbage
so another option would be for you to build your eLua by porting
Lua5.2 into it :)

    M
_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev
agostain agostain
Reply | Threaded
Open this post in threaded view
|

Re: Ram usage with byte resolution

Martin Guy wrote
> is it possible to investigate the RAM usage of my lua program with byte
> resolution?
> Right now I found only collectgarbage("count") which gives me the usage in
> KB.

If you are using floating point eLua, the return value has fractional bits.

> print (collectgarbage("count"))
17.20703125
> print (17.20703125 * 1024)
17620
>

That is not true. I dived into the code of the garbagecollector.  since lua_gc returns an int right shifted by 10 the garbagecollector function will never show me fractionals even if I compile as floating elua.




If you're using integer eLua you don't have this option.

In Lua5.2, instead, it returns the KB and fraction of a KB as two
results to address this problem. See
http://www.lua.org/manual/5.2/manual.html#pdf-collectgarbage
so another option would be for you to build your eLua by porting
Lua5.2 into it :)

    M

That would be an option but I don't know what kind of effects it would have to my actual code. Have you tried to port it?
_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev
BogdanM BogdanM
Reply | Threaded
Open this post in threaded view
|

Re: Ram usage with byte resolution

On Thu, Jul 19, 2012 at 4:19 PM, agostain <[hidden email]> wrote:

>
> Martin Guy wrote
>>
>>> is it possible to investigate the RAM usage of my lua program with byte
>>> resolution?
>>> Right now I found only collectgarbage("count") which gives me the usage
>>> in
>>> KB.
>>
>> If you are using floating point eLua, the return value has fractional
>> bits.
>>
>>> print (collectgarbage("count"))
>> 17.20703125
>>> print (17.20703125 * 1024)
>> 17620
>>>
>>
>> That is not true. I dived into the code of the garbagecollector.  since
>> lua_gc returns an int right shifted by 10 the garbagecollector function
>> will never show me fractionals even if I compile as floating elua.

Then the easiest solution is to change the code to return the int
without shifting by 10. Not sure how this would affect the rest of the
system, but it's worth a try.

Best,
Bogdan

>>
>>
>>
>>
>> If you're using integer eLua you don't have this option.
>>
>> In Lua5.2, instead, it returns the KB and fraction of a KB as two
>> results to address this problem. See
>> http://www.lua.org/manual/5.2/manual.html#pdf-collectgarbage
>> so another option would be for you to build your eLua by porting
>> Lua5.2 into it :)
>>
>>     M
>>
>> That would be an option but I don't know what kind of effects it would
>> have to my actual code. Have you tried to port it?
>> _______________________________________________
>> eLua-dev mailing list
>> eLua-dev@.berlios
>> https://lists.berlios.de/mailman/listinfo/elua-dev
>>
>
>
> --
> View this message in context: http://elua-development.2368040.n2.nabble.com/Ram-usage-with-byte-resolution-tp7577602p7577604.html
> Sent from the eLua Development mailing list archive at Nabble.com.
> _______________________________________________
> eLua-dev mailing list
> [hidden email]
> https://lists.berlios.de/mailman/listinfo/elua-dev
_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev
agostain agostain
Reply | Threaded
Open this post in threaded view
|

Re: Ram usage with byte resolution

BogdanM wrote
On Thu, Jul 19, 2012 at 4:19 PM, agostain <[hidden email]> wrote:
>
> Martin Guy wrote
>>
>>> is it possible to investigate the RAM usage of my lua program with byte
>>> resolution?
>>> Right now I found only collectgarbage("count") which gives me the usage
>>> in
>>> KB.
>>
>> If you are using floating point eLua, the return value has fractional
>> bits.
>>
>>> print (collectgarbage("count"))
>> 17.20703125
>>> print (17.20703125 * 1024)
>> 17620
>>>
>>
>> That is not true. I dived into the code of the garbagecollector.  since
>> lua_gc returns an int right shifted by 10 the garbagecollector function
>> will never show me fractionals even if I compile as floating elua.

Then the easiest solution is to change the code to return the int
without shifting by 10. Not sure how this would affect the rest of the
system, but it's worth a try.

yep. that's what I did. It won't affect the rest of the system I think.  

Best,
Bogdan

>>
>>
>>
>>
>> If you're using integer eLua you don't have this option.
>>
>> In Lua5.2, instead, it returns the KB and fraction of a KB as two
>> results to address this problem. See
>> http://www.lua.org/manual/5.2/manual.html#pdf-collectgarbage
>> so another option would be for you to build your eLua by porting
>> Lua5.2 into it :)
>>
>>     M
>>
>> That would be an option but I don't know what kind of effects it would
>> have to my actual code. Have you tried to port it?
>> _______________________________________________
>> eLua-dev mailing list
>> eLua-dev@.berlios
>> https://lists.berlios.de/mailman/listinfo/elua-dev
>>
>
>
> --
> View this message in context: http://elua-development.2368040.n2.nabble.com/Ram-usage-with-byte-resolution-tp7577602p7577604.html
> Sent from the eLua Development mailing list archive at Nabble.com.
> _______________________________________________
> eLua-dev mailing list
> [hidden email]
> https://lists.berlios.de/mailman/listinfo/elua-dev
_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev
Martin Guy Martin Guy
Reply | Threaded
Open this post in threaded view
|

Re: Ram usage with byte resolution

In reply to this post by BogdanM
On 19 July 2012 15:22, Bogdan Marinescu <[hidden email]> wrote:

> On Thu, Jul 19, 2012 at 4:19 PM, agostain <[hidden email]> wrote:
>>
>> Martin Guy wrote
>>>
>>>> is it possible to investigate the RAM usage of my lua program with byte
>>>> resolution?
>>> If you are using floating point eLua, the return value has fractional
>>> bits.
>>>
>>>> print (collectgarbage("count"))
>>> 17.20703125
>> That is not true. I dived into the code of the garbagecollector.  since
>> lua_gc returns an int right shifted by 10 the garbagecollector function
>> will never show me fractionals even if I compile as floating elua.

Ah, sorry, I was testing that under Unix Lua.

> Then the easiest solution is to change the code to return the int
> without shifting by 10.

At teh Lua level it would be nice to return what standard Lua returns:
N/1024.0 in fp Lua and, presumably, N>>10 in integer Lua

Of course, for eLua, you could implement the Lua5.2 solution of
returning two values, N/1024 and N%1024, since that would be
backwards-compatible with the current behaviour: existing code would
throw the 2nd return value away and get what it got before.
... and those in the know could pick up the 2nd value...
_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev