Skip to content

Performance #830

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

Closed
ghost opened this issue Apr 14, 2019 · 5 comments · Fixed by #846
Closed

Performance #830

ghost opened this issue Apr 14, 2019 · 5 comments · Fixed by #846

Comments

@ghost
Copy link

ghost commented Apr 14, 2019

How does the performance of RustPython compare (or will compare) with CPython or PyPy?

@adrian17
Copy link
Contributor

For now, short story is: the implementation follows a similar basic design to CPython, with none of its current optimizations (and some aspects done in vastly inefficient ways). It can be anywhere from 5x to 100x slower for now.

AFAIK the focus for now is to make it satisfyingly correct and complete; performance will come later.

@ghost
Copy link
Author

ghost commented Apr 14, 2019

@adrian17 Is there any potential performance edge to be gained with Rust at some point?

@Ryex
Copy link
Contributor

Ryex commented Apr 14, 2019

as I understand it may be possible to get a more efficient and predictable GC due to Rust's memory model. and it may be possible to get around the GIL with minimal performance degradation for the same reason. But afaik these are only assumptions at this point.

In truth baring a JIT approach to the VM there is little to no performance to be gained over CPython just by using Rust. however, it has other benefits: Safer language extension, and the ability to bind the runtime into other Rust applications without linking C code.

@LuoZijun LuoZijun mentioned this issue Apr 18, 2019
@LuoZijun
Copy link
Contributor

@infosisio

See #846

Result

OS: macOS High Sierra 10.13.5 (17F77)
Laptop: MacBook Pro (Retina, 15-inch, Mid 2015)
Hardware: Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz

$ cargo bench

     Running target/release/deps/parser-9219a509bec6327a

running 2 tests
test bench_parse_to_ast ... bench:  60,803,145 ns/iter (+/- 4,723,694) = 1 MB/s
test bench_tokenization ... bench:  49,881,125 ns/iter (+/- 2,945,707) = 1 MB/s

test result: ok. 0 passed; 0 failed; 0 ignored; 2 measured; 0 filtered out

     Running target/release/deps/vm-8dc2abb21006a2be

running 2 tests
test bench_mandelbrot ... bench: 6,220,665,421 ns/iter (+/- 551,599,249)
test bench_nbody      ... bench: 2,435,969,675 ns/iter (+/- 53,865,485)

@LuoZijun
Copy link
Contributor

Update:

Result

Laptop: MacBook Pro (Retina, 15-inch, Mid 2015)
OS: macOS High Sierra 10.13.5 (17F77)
Hardware: Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz

$ cargo bench

     Running target/release/deps/bench-b2ec22cae0fccc8d

running 6 tests
test bench_rustpy_tokenization  ... bench:    45,408,766 ns/iter (+/- 2,941,962) = 1 MB/s

test bench_cpython_parse_to_ast ... bench:    11,913,744 ns/iter (+/- 2,074,971) = 5 MB/s
test bench_rustpy_parse_to_ast  ... bench:    60,480,590 ns/iter (+/- 5,676,890) = 1 MB/s

test bench_cpython_nbody        ... bench:     7,578,339 ns/iter (+/- 1,184,697)
test bench_rustpy_nbody         ... bench: 2,269,100,380 ns/iter (+/- 160,567,152)

test bench_cpython_mandelbrot   ... bench:    40,546,349 ns/iter (+/- 5,426,492)
test bench_rustpy_mandelbrot    ... bench: 5,583,144,701 ns/iter (+/- 387,853,847)

RustPython vs CPython:

mandelbrot: 5_583_144_701 / 40_546_349 = 137.6978405873239
nbody:      2_269_100_380 / 7_578_339  = 299.41922365837684
parse_ast:  60_480_590 / 11_913_744    = 5.076539331380631

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 a pull request may close this issue.

3 participants