The relation between megacycles and cpu used

996 views
Skip to first unread message

MyElasticEye

unread,
Aug 17, 2010, 2:38:20 AM8/17/10
to Google App Engine
Hi,

I have been trying to optimize the App Engine application my team is
working on. As I read on Google's documentation,

1 megacycles = 1/1200 cpu seconds

And if I a check how many megacycles it takes to load an empty sinlge
page without any templates using webapp.py, it takes 0 megacycles.
However, the amount of cpu miliseconds used for the request usually
becomes around 200 ms. That's understandable because of the overheads
of the request.

However, I see that when I do like:

class SomePage(..):
def get(self):
start = quota.get_request_cpu_usage()
# do some dense operations here...
end = quota.get_request_cpu_usage()
logging.info("the operation cost %d megacycles." % (start -
end))
return

I can't see a relation btw the megacycles it takes and the cpu
miliseconds used. According to the equation above, 1200 megacycles = 1
cpu second, and if the result of the operation is 2400 megacycles, it
means that it should equal to 2 cpu seconds. Let's say there is an
overhead occuring even if we load an empty page or whatever, and then
it should equal to 2400 + 200 = 2600 ms

However, the logs of the request says that it takes much more than 2
cpu secs, more like 7000 or 9000 cpu milisecs.

Why is this occuring?

Thanks

Alkis Evlogimenos ('Αλκης Ευλογημένος)

unread,
Aug 17, 2010, 2:05:56 PM8/17/10
to google-a...@googlegroups.com

The cpu in the equation is a 1ghz equivalent cpu which is not necessarily the same as the cpu you request ran on.

- alkis (mobile)

> --
> You received this message because you are subscribed to the Google Groups "Google App Engine" group.
> To post to this group, send email to google-a...@googlegroups.com.
> To unsubscribe from this group, send email to google-appengi...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.
>

MyElasticEye

unread,
Aug 17, 2010, 2:53:53 PM8/17/10
to Google App Engine
so this means that the cpu which my request ran on is a much less
powerful one. Since the request takes much more cpu secs that it
should according to that equation. Right?

On Aug 17, 9:05 pm, Alkis Evlogimenos ('Αλκης Ευλογημένος)
<al...@evlogimenos.com> wrote:
> The cpu in the equation is a 1ghz equivalent cpu which is not necessarily
> the same as the cpu you request ran on.
>
> - alkis (mobile)
>
> google-appengi...@googlegroups.com<google-appengine%2Bunsubscrib e...@googlegroups.com>
> .> For more options, visit this group at
>
> http://groups.google.com/group/google-appengine?hl=en.
>
>
>
>

Nick Johnson (Google)

unread,
Aug 18, 2010, 8:27:41 AM8/18/10
to google-a...@googlegroups.com
Hi,

It sounds like you're accounting for CPU megacycles, but not API CPU megacycles. You also need to call quota.get_request_api_cpu_usage().

-Nick Johnson

--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To post to this group, send email to google-a...@googlegroups.com.
To unsubscribe from this group, send email to google-appengi...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.




--
Nick Johnson, Developer Programs Engineer, App Engine Google Ireland Ltd. :: Registered in Dublin, Ireland, Registration Number: 368047
Google Ireland Ltd. :: Registered in Dublin, Ireland, Registration Number: 368047

MyElasticEye

unread,
Aug 18, 2010, 5:14:05 PM8/18/10
to Google App Engine
To be honest, I don't know the differene btw the API CPU cycles and
the CPU cycles.

On Aug 18, 3:27 pm, "Nick Johnson (Google)" <nick.john...@google.com>
wrote:
> > google-appengi...@googlegroups.com<google-appengine%2Bunsubscrib e...@googlegroups.com>
> > .
Reply all
Reply to author
Forward
0 new messages