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

profila occasionally fails with message that is none #13

Merged
merged 6 commits into from
Dec 16, 2024
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
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ for i in range(100):
```

### Command-line profiling

If you usually run your script like this:

```bash
Expand All @@ -101,6 +102,18 @@ Instead run it like this:
$ python -m profila annotate -- yourscript.py --arg1=200
```

If you usually run your script like this, with `-m`:

```bash
$ python -m yourpackage --arg1=200
```

Instead run it like this:

```bash
$ python -m profila annotate -- -m yourpackage --arg1=200
```

**Sampling is done every 10 milliseconds, so you need to make sure your Numba code runs for a sufficiently long time.**
For example, you can run your function in a loop until a number of seconds has passed:

Expand Down Expand Up @@ -148,6 +161,7 @@ Instruction-level parallelism, branch mispredictions, SIMD, and the CPU memory c
Bug fixes:

* Work on newer versions of Linux, like Ubuntu 24.04 and RHEL 9, in the face of issues with newer gdb.
* Fixed occasional error `TypeError: argument of type 'NoneType' is not iterable`.

### v0.2.1

Expand Down
4 changes: 2 additions & 2 deletions scripts_for_tests/simple.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import numpy as np
from numba import njit
from numba import jit

DATA = np.random.random((1_000_000,))


@njit
@jit
def simple(timeseries):
result = np.empty_like(timeseries)
for i in range(len(timeseries)):
Expand Down
2 changes: 1 addition & 1 deletion src/profila/_gdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ async def _sample(process: Process) -> AsyncIterable[Optional[list[Frame]]]:

process.stdin.write(b"-stack-list-frames --no-frame-filters 0 10\n")
message = await _read_until_done(process)
if "stack" not in message["payload"]: # type: ignore
if message["payload"] is None or "stack" not in message["payload"]: # type: ignore
# Bad read of some sort:
yield None
else:
Expand Down
Loading