Skip to content
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

add demo to simulate usage in a game engine #603

Merged
merged 3 commits into from
Oct 11, 2018
Merged

Conversation

mdonoughe
Copy link
Contributor

It has been observed in amethyst/amethyst#780 that if you use Rayon in an environment where you are not CPU bound, you may end up using many more CPU cycles than necessary. This pull request adds an example of this problem to the demo project as a starting point towards finding a way to improve efficiency in this scenario.

The life demo now has a play mode where the same comparison of serial and parallel occurs, but with a frame (generation) per second limit in place and comparing CPU time measurements at the end.

Example output for my Ryzen 7 1800X with hyperthreading (16 logical processors) in Windows 10:

$ rayon-demo life play
  serial: 59.93 fps
    cpu usage: 4.7%
parallel: 59.97 fps
  cpu usage: 55.3%
par_bridge: 59.94 fps
  cpu usage: 1164.1%

Once there are ways to improve the overhead they should be incorporated into this demo as an example. If there are already ways to improve the demo let me know and I can try to implement them now.

@cuviper
Copy link
Member

cuviper commented Oct 7, 2018

At RustConf we were discussing the general idea that we may be too aggressive about waking threads, and too slow about putting them back to sleep. I worried about this as a broad problem as core & thread counts rise, when there won't always be enough work to spread around. So, this is great to have a real demo of the issue!

@cuviper
Copy link
Member

cuviper commented Oct 7, 2018

Ah, we were discussing wake-ups in the cross-linked issue #576 too.

Copy link
Member

@cuviper cuviper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use platform specific dependencies for libc and winapi, with appropriate cfg on their extern crate declarations too.

Otherwise, looks good to me!

@cuviper
Copy link
Member

cuviper commented Oct 11, 2018

bors r+

bors bot added a commit that referenced this pull request Oct 11, 2018
603: add demo to simulate usage in a game engine r=cuviper a=mdonoughe

It has been observed in amethyst/amethyst#780 that if you use Rayon in an environment where you are not CPU bound, you may end up using many more CPU cycles than necessary. This pull request adds an example of this problem to the demo project as a starting point towards finding a way to improve efficiency in this scenario.

The life demo now has a `play` mode where the same comparison of serial and parallel occurs, but with a frame (generation) per second limit in place and comparing CPU time measurements at the end.

Example output for my Ryzen 7 1800X with hyperthreading (16 logical processors) in Windows 10:

    $ rayon-demo life play
      serial: 59.93 fps
        cpu usage: 4.7%
    parallel: 59.97 fps
      cpu usage: 55.3%
    par_bridge: 59.94 fps
      cpu usage: 1164.1%

Once there are ways to improve the overhead they should be incorporated into this demo as an example. If there are already ways to improve the demo let me know and I can try to implement them now.

Co-authored-by: Matthew Donoughe <mdonoughe@gmail.com>
@bors
Copy link
Contributor

bors bot commented Oct 11, 2018

@bors bors bot merged commit 7222d9b into rayon-rs:master Oct 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants