> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sifr.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# SIFR-ASYNC-0004: CPU-heavy function called directly from async context.

> CPU-heavy function called directly from async context.

`SIFR-ASYNC-0004` belongs to the **Async effect and awaitability** diagnostic family. It means: cPU-heavy function called directly from async context.

## Why It Happens

Sifr tracks suspension and blocking effects statically. This diagnostic fires when async code either does not really suspend, awaits work that cannot suspend, or calls blocking/CPU-heavy work without an explicit offload boundary.

<Info>
  Use `sifr --explain SIFR-ASYNC-0004` locally to see the renderer's exact message template and any machine-applicable suggestions for the compiler version you are running.
</Info>

## Erroneous Code

```python theme={null}
def crunch(values: list[int]) -> int:
    total: int = 0
    for value in values:
        total = total + value
    return total

async def main(values: list[int]) -> int:
    return crunch(values)
```

## How To Fix It

Keep CPU-heavy work out of the async executor. Use the parallel/offload surface intended for owned CPU work.

## Fixed Code

```python theme={null}
from sifr.parallel import map as par_map

def crunch(value: int) -> int:
    return value * value

async def main(values: list[int]) -> list[int]:
    return par_map(values, crunch)
```

## Details

| Field                  | Value                                                                     |
| ---------------------- | ------------------------------------------------------------------------- |
| Code                   | `SIFR-ASYNC-0004`                                                         |
| Family                 | `ASYNC`                                                                   |
| Severity               | Error                                                                     |
| Stability              | stable                                                                    |
| Owner                  | `sifr_lowering::lower::workload_annotations`                              |
| Representative fixture | `crates/sifr/tests/e2e/fail/cpu_heavy_direct_call_in_async_rejected.sifr` |

See the [Error Codes index](/diagnostics/error-codes) for the complete catalog.
