CPU, memory info and lua VM

Things that we aren't going to implement
Post Reply
sebgggg
Burner Inserter
Burner Inserter
Posts: 15
Joined: Tue Aug 09, 2016 6:57 am
Contact:

CPU, memory info and lua VM

Post by sebgggg »

Hello,

Could you add a cpu and memory properties to the game object please?
It could be useful to implement "smart" coroutines for heavy calculations, it does not need to be precise, just an indication like low, mid, high.

Is it also possible to add integer and bit ops to the lua VM? It could tremendously help performance for, say, neural networks :)

Edit:
I forgot, can you also add a function get_tiles(area) ?

Thanks!

User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: CPU, memory info and lua VM

Post by aubergine18 »

Using coroutines will likely break MP games due to desync...

I thought the bitop stuff was already present (vague memory - have a root around on _G)...

For getting tiles in area, you could use these from any LuaSurface:

.get_tileproperties(x, y) → TileProperties Get tile properties.
.set_tiles(tiles, correct_tiles) Set tiles at specified locations.
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13235
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: CPU, memory info and lua VM

Post by Rseding91 »

This already exists. Just hit F4 in-game and enable the debug times option to see how much CPU time is spent on each mod.
If you want to get ahold of me I'm almost always on Discord.

sebgggg
Burner Inserter
Burner Inserter
Posts: 15
Joined: Tue Aug 09, 2016 6:57 am
Contact:

Re: CPU, memory info and lua VM

Post by sebgggg »

aubergine18 wrote:Using coroutines will likely break MP games due to desync...

I thought the bitop stuff was already present (vague memory - have a root around on _G)...

For getting tiles in area, you could use these from any LuaSurface:

.get_tileproperties(x, y) → TileProperties Get tile properties.
.set_tiles(tiles, correct_tiles) Set tiles at specified locations.
I meant in-game routines, based on the on_tick event, although true MP co routines would be nice :)
And about get_tiles, i meant a function returning an array of tiles.

Thanks for your answer though :)

sebgggg
Burner Inserter
Burner Inserter
Posts: 15
Joined: Tue Aug 09, 2016 6:57 am
Contact:

Re: CPU, memory info and lua VM

Post by sebgggg »

Rseding91 wrote:This already exists. Just hit F4 in-game and enable the debug times option to see how much CPU time is spent on each mod.
No, i meant programatically get the CPU load, in a mod. There's nothing like that on http://lua-api.factorio.com unless i'm missing something?

Thanks for your time :)

Rseding91
Factorio Staff
Factorio Staff
Posts: 13235
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: CPU, memory info and lua VM

Post by Rseding91 »

sebgggg wrote:
Rseding91 wrote:This already exists. Just hit F4 in-game and enable the debug times option to see how much CPU time is spent on each mod.
No, i meant programatically get the CPU load, in a mod. There's nothing like that on http://lua-api.factorio.com unless i'm missing something?

Thanks for your time :)
That information wouldn't be deterministic at all and as such would desync and break replays if mods had access to it - which is why they don't.
If you want to get ahold of me I'm almost always on Discord.

User avatar
Afforess
Filter Inserter
Filter Inserter
Posts: 422
Joined: Tue May 05, 2015 6:07 pm
Contact:

Re: CPU, memory info and lua VM

Post by Afforess »

Essentially what you really need is a way to schedule lazy execution of certain code when the game has free time slices available. Right now there isn't a way to do that, and I gather what @sebgggg is asking for would let him build one.

Sure, code execution can be smeared over on_tick but that's not a perfect solution, as it gives no indication of what else might also be running.

User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: CPU, memory info and lua VM

Post by aubergine18 »

I'm sure I read somewhere in these forums that events will wait until later tick before triggering handlers if too much time has been taken on tick where event fired (not sure if this is only vanilla events of if it works for custom events too?)
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.

Post Reply

Return to “Won't implement”