atl transform high cpu usage question

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
neowired
Regular
Posts: 199
Joined: Mon Dec 01, 2008 2:33 pm
Contact:

atl transform high cpu usage question

#1 Post by neowired »

I noticed whenever I run a transform it consumes around 50% of my cpu until it stops (I have a 2 core processor, so I assume it uses a whole core to the max.
This is so even if the transform is something like - slowly moving a random text displayable from left to right. It seems regardless of what I'm transforming, the cpu always goes up to 50%
This seems to be related to the st method(?)

I tried running a custom-made function inside a transform (with some pauses) to move things, when this function used st for calculation I think it also used 50% of my cpu, but when I modified that function to not use st, the cpu fell down to 1-2%, while still performing the same transformation.

Is there any reason why this happens, or a potential way to "fix" this? I've been looking through the forum for a while and I didn't find any explanation for this. Although the explanation will probably be beyond my understanding, I'm still curious.

As far as I can tell, st is used to synchronize renpy's display speed, but other than that I don't know.
I know that if I run the custom function on the software rendered, with a forced limited framerate, it displays with slowdown, while the normal transform displays with correct speed.

Asceai
Eileen-Class Veteran
Posts: 1258
Joined: Fri Sep 21, 2007 7:13 am
Projects: a battle engine
Contact:

Re: atl transform high cpu usage question

#2 Post by Asceai »

This still puzzles me, actually. The displayed framerate is tied to vblank so you'd expect transforms to also be evaluated only once per vblank, but it seems like they're run as often as possible.

User avatar
nyaatrap
Crawling Chaos
Posts: 1824
Joined: Mon Feb 13, 2012 5:37 am
Location: Kimashi Tower, Japan
Contact:

Re: atl transform high cpu usage question

#3 Post by nyaatrap »

It seems even without using transform, there's a case to use 100% CPU in screens. It stops music in a moment so it's a bit irritating.

Asceai
Eileen-Class Veteran
Posts: 1258
Joined: Fri Sep 21, 2007 7:13 am
Projects: a battle engine
Contact:

Re: atl transform high cpu usage question

#4 Post by Asceai »

nyaatrap wrote:It seems even without using transform, there's a case to use 100% CPU in screens. It stops music in a moment so it's a bit irritating.
What case is this? I haven't seen 100% CPU use in screens unless that screen contained an animated transform or there was an animated transform happening at the same time.

User avatar
nyaatrap
Crawling Chaos
Posts: 1824
Joined: Mon Feb 13, 2012 5:37 am
Location: Kimashi Tower, Japan
Contact:

Re: atl transform high cpu usage question

#5 Post by nyaatrap »

There are several cases, but the most noticeable one is a minimap I made by sprite manager.
Please look a class minimap on http://lemmasoft.renai.us/forums/viewto ... 51&t=19245
It seems showing heavy displayables uses 100% CPU and it blanks music play.

Asceai
Eileen-Class Veteran
Posts: 1258
Joined: Fri Sep 21, 2007 7:13 am
Projects: a battle engine
Contact:

Re: atl transform high cpu usage question

#6 Post by Asceai »

Hmm, wonder what's causing that. A sprite manager without an update method doesn't use 100% CPU in my tests, so it would seem that's not necessarily the issue. I'll grab the sample game and take a peek.

EDIT: The sample game (Dungeon_Crawl 2.0) doesn't use 100% CPU for me. Is there some menu or something I need to trigger?

neowired
Regular
Posts: 199
Joined: Mon Dec 01, 2008 2:33 pm
Contact:

Re: atl transform high cpu usage question

#7 Post by neowired »

Hmm, wonder what's causing that. A sprite manager without an update method doesn't use 100% CPU in my tests, so it would seem that's not necessarily the issue. I'll grab the sample game and take a peek.
I'm my case, I speculated that the transform takes a core and uses it in 100% as long as the transform continues.
If that is true, then in case someone has only one core available it could run his whole cpu to 100% and cause a problem/lag. But this is only a speculation and only for this specific case.
If the user has multiple cores he would likely not notice any issues (other than maybe, high cpu usage).
Last edited by neowired on Fri Mar 14, 2014 8:50 am, edited 2 times in total.

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: atl transform high cpu usage question

#8 Post by xela »

nyaatrap wrote:There are several cases, but the most noticeable one is a minimap I made by sprite manager.
Please look a class minimap on http://lemmasoft.renai.us/forums/viewto ... 51&t=19245
It seems showing heavy displayables uses 100% CPU and it blanks music play.
6 - 10% even if I move around really quickly... maybe this was valid for old versions of Ren'Py?
Like what we're doing? Support us at:
Image

User avatar
nyaatrap
Crawling Chaos
Posts: 1824
Joined: Mon Feb 13, 2012 5:37 am
Location: Kimashi Tower, Japan
Contact:

Re: atl transform high cpu usage question

#9 Post by nyaatrap »

Asceai wrote:Hmm, wonder what's causing that. A sprite manager without an update method doesn't use 100% CPU in my tests, so it would seem that's not necessarily the issue. I'll grab the sample game and take a peek.

EDIT: The sample game (Dungeon_Crawl 2.0) doesn't use 100% CPU for me. Is there some menu or something I need to trigger?
I made the sample game in safe range.
I think when I use png images on sprite manager, and also use a big size map (at least over 20x20 - 30x30 became hell to play), it causes performance problem.

I know this isn't a good code to calculate minimaps. But with recent CPU, even with this my awkward code, it could treat with no delay.
Last edited by nyaatrap on Fri Mar 14, 2014 8:57 am, edited 1 time in total.

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: atl transform high cpu usage question

#10 Post by xela »

neowired wrote:
Hmm, wonder what's causing that. A sprite manager without an update method doesn't use 100% CPU in my tests, so it would seem that's not necessarily the issue. I'll grab the sample game and take a peek.
I'm my case, I speculated that the transform takes a core and uses it in 100% as long as the transform continues.
If that is true, then in case someone has only one core available it could run his whole cpu to 100% and cause a problem/lag. But this is only a speculation and only for this specific case.
If the user has multiple cores he would likely not notice any issues (other than maybe, high cpu usage).

That might be right... I am on an old quad, CPU load spikes on moving transforms and seem to spike even further if there are a couple of transforms but that does not seem to cause any visible delays to music, code execution or even loading a lot more transforms at the same time... this does suck for laptops that overheat easily but not a big deal otherwise.
Like what we're doing? Support us at:
Image

neowired
Regular
Posts: 199
Joined: Mon Dec 01, 2008 2:33 pm
Contact:

Re: atl transform high cpu usage question

#11 Post by neowired »

xela wrote: That might be right... I am on an old quad, CPU load spikes on moving transforms and seem to spike even further if there are a couple of transforms but that does not seem to cause any visible delays to music, code execution or even loading a lot more transforms at the same time... this does suck for laptops that overheat easily but not a big deal otherwise.
I haven't noticed any lag from this 50% cpu usage on my 2 core pc (but I believe some other people who I talked with run into a lag problem in a game when I used a continuous transform, I think this may be the reason)
From what I see this looks like the transform always takes whole core regardless of the type, and the cpu usage stays the same regardless of the transform, if it uses exactly one core then it wouldn't lag on a multicore cpu (and doesn't for me)

but the cpu can go above 50% if other things run on top of the transform.

I think it could cause some problems with laptops and smartphones. In my case it's only a bit annoying, because when I run renpy while doing something else, it can keep my cpu above 50% and then my pc fans get all loud.

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: atl transform high cpu usage question

#12 Post by xela »

Code: Select all

stage1=Stage([
            "1111111111111111111111111111111111111",
            "1111011000010001000000000000000000011",
            "1000000000000000000000000000000000001",
            "1110111100000000000000000000000000001",
            "1000000000000000000000000000000000001",
            "1000000000000000000000000000000000001",
            "1000000000000000000000000000000000001",
            "1000000000000000000000000000000000001",
            "1000000000000001111111101111111100001",
            "1000000000000000101010101000000000001",
            "1000000000000000000000000000011111111",
            "1000000000000000001111110000000000001",
            "1111111111111111111111111111111111111",
            ],
            enemy=goblin)
4 - 12% with this map as well, I cannot see any visible changes compared to the original map.

Also that might not be the best way to calc a minimap but it's the most used and convenient way to do so :)
Like what we're doing? Support us at:
Image

User avatar
nyaatrap
Crawling Chaos
Posts: 1824
Joined: Mon Feb 13, 2012 5:37 am
Location: Kimashi Tower, Japan
Contact:

Re: atl transform high cpu usage question

#13 Post by nyaatrap »

So issue I have might be:
loading png image for minimap
Images I showed on dungeon background (No animation, but multi layered with using Transform xzoom -1)
My GPU

Anyway, there must be an issue which delays my PC somewhere. I'm using core i3 btw.

neowired
Regular
Posts: 199
Joined: Mon Dec 01, 2008 2:33 pm
Contact:

Re: atl transform high cpu usage question

#14 Post by neowired »

nyaatrap wrote:So issue I have might be:
loading png image for minimap
Images I showed on dungeon background (No animation, but multi layered with using Transform xzoom -1)
My GPU

Anyway, there must be an issue which delays my PC somewhere.

Here's something else I just remembered. In the past when I tried using a conditional branch in some Livecomposites I think it also resulted in this constant 50% cpu usage. It could be related.
(I ended up using variables directly in the filenames in a python livecomposite instead, it was a workaround)

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]