Skip to content

Add some extra profiling trace points. #1169

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

Merged
merged 6 commits into from
Jul 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@

## Code organization

- `bytecode/src`: python bytecode representation in rust structures
- `compiler/src`: python compilation to bytecode
- `parser/src`: python lexing, parsing and ast
- `Lib`: Carefully selected / copied files from CPython sourcecode. This is
the python side of the standard library.
- `vm/src`: python virtual machine
- `builtins.rs`: Builtin functions
- `compile.rs`: the python compiler from ast to bytecode
- `obj`: python builtin types
- `stdlib`: Standard library parts implemented in rust.
- `src`: using the other subcrates to bring rustpython to life.
- `docs`: documentation (work in progress)
- `py_code_object`: CPython bytecode to rustpython bytecode converter (work in
Expand All @@ -28,8 +33,7 @@ To test rustpython, there is a collection of python snippets located in the

```shell
$ cd tests
$ pipenv install
$ pipenv run pytest -v
$ pytest -v
```

There also are some unit tests, you can run those with cargo:
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ Documentation HTML files can then be found in the `target/doc` directory.
## Contributing

Contributions are more than welcome, and in many cases we are happy to guide
contributors through PRs or on gitter.
contributors through PRs or on gitter. Please refer to the
[development guide](DEVELOPMENT.md) as well for tips on developments.

With that in mind, please note this project is maintained by volunteers, some of
the best ways to get started are below:
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ use clap::{App, Arg, ArgMatches};
use rustpython_compiler::{compile, error::CompileError, error::CompileErrorType};
use rustpython_parser::error::ParseErrorType;
use rustpython_vm::{
frame::Scope,
import,
obj::objstr,
print_exception,
pyobject::{ItemProtocol, PyResult},
scope::Scope,
util, PySettings, VirtualMachine,
};
use std::convert::TryInto;
Expand Down
2 changes: 1 addition & 1 deletion vm/src/builtins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ use crate::obj::objtype::{self, PyClassRef};
use rustpython_compiler::compile;

use crate::eval::get_compile_mode;
use crate::frame::Scope;
use crate::function::{single_or_tuple_any, Args, KwArgs, OptionalArg, PyFuncArgs};
use crate::pyobject::{
Either, IdProtocol, IntoPyObject, ItemProtocol, PyIterable, PyObjectRef, PyResult, PyValue,
TryFromObject, TypeProtocol,
};
use crate::scope::Scope;
use crate::vm::VirtualMachine;

use crate::obj::objbyteinner::PyByteInner;
Expand Down
3 changes: 3 additions & 0 deletions vm/src/dictdatatype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ impl<T: Clone> Dict<T> {
}

/// Retrieve a key
#[cfg_attr(feature = "flame-it", flame("Dict"))]
pub fn get(&self, vm: &VirtualMachine, key: &PyObjectRef) -> PyResult<Option<T>> {
if let LookupResult::Existing(index) = self.lookup(vm, key)? {
Ok(Some(self.unchecked_get(index)))
Expand Down Expand Up @@ -197,6 +198,7 @@ impl<T: Clone> Dict<T> {
}

/// Lookup the index for the given key.
#[cfg_attr(feature = "flame-it", flame("Dict"))]
fn lookup(&self, vm: &VirtualMachine, key: &PyObjectRef) -> PyResult<LookupResult> {
let hash_value = collection_hash(vm, key)?;
let perturb = hash_value;
Expand Down Expand Up @@ -271,6 +273,7 @@ enum LookupResult {
Existing(EntryIndex), // Existing record, index into entries
}
Copy link
Member

Choose a reason for hiding this comment

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

The string passed to flame is a prefix, so this would appear in the output as collection_hash::collection_hash. I'd recommend changing it to dictdatatype or removing the prefix altogether.


#[cfg_attr(feature = "flame-it", flame())]
fn collection_hash(vm: &VirtualMachine, object: &PyObjectRef) -> PyResult<HashValue> {
let raw_hash = vm._hash(object)?;
let mut hasher = DefaultHasher::new();
Expand Down
2 changes: 1 addition & 1 deletion vm/src/eval.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::frame::Scope;
use crate::pyobject::PyResult;
use crate::scope::Scope;
use crate::vm::VirtualMachine;
use rustpython_compiler::compile;

Expand Down
Loading