Package availability: JaviMapper is an unpublished beta and JaviPerf is experimental. Neither has a public PyPI release or public wheel, and the source repository is private. Visitors cannot obtain or build these packages from this site. The Fabric installation steps below require an already-authorized wheel supplied privately; without that access, the exercises cannot be run.

JaviPerf 0.2.1 (experimental)

JaviPerf helps answer one question carefully: did this change make this workload faster, and what in the Spark plan might explain it? It is an Apache-2.0 library developed alongside Javi Builds, and it is experimental: validated locally, not validated on production workloads, and not published to PyPI. A Fabric lab ran the previous version, 0.2.0, once; that run did not exercise the duration-only reporting added in 0.2.1. See the complete Fabric walkthrough for the exact evidence and limits.

  • Measured
    1. Repeated runsWarm-up, measured runs, failures kept
    2. Before and afterInterleaved, equivalence checked
  • Observed in the plan
    1. explain() onlyNo Spark job, no data collected
    2. FindingsEvidence, explanation, limitations
  • To validate
    1. InvestigationsWhere to look next
    2. Measure againOnly a new comparison confirms a change
Three kinds of evidence, kept apart. JaviPerf reports measurements, plan observations and next steps in separate sections. A plan finding is never presented as a measured problem, and an investigation is a hypothesis, not a fix.

Problem and motivation

Performance claims in data engineering are often based on a single run, on a DataFrame that was never executed, or on two versions that don’t produce the same output. JaviPerf makes the careful version the easy one:

It complements Fabric’s Spark advisor and monitoring pages, which show what actually ran. It doesn’t replace them.

Startup versus execution (0.2)

A notebook’s elapsed time is several different measurements: waiting for a Spark session, the first Spark job, the work itself, and gaps between cells. JaviPerf 0.2 records them as separate phases, each with its source, clock and precision, and never adds up phases that overlap, nest or come from different clocks.

Measured automatically, inside the notebook Needs Fabric monitoring or timestamps you record
The first Spark action (javiperf.spark.first_action) When compute was requested, and when the session was ready
Defining versus materializing, with Spark job counts Queueing and Environment library installation
Read, transform and write phases (Timeline.phase) The session source and delay reason (Session Start Insights)
Before/after comparisons and plan observations Capacity contention from other workloads

Session startup can’t be timed from inside the notebook: no cell runs until the session is ready. JaviPerf records it from a worksheet, Session Start Insights, or a Livy session JSON you download yourself (labelled as a documented proxy). A reused session has no startup in that run: it is not applicable, never zero. The hands-on lab walks through a first live measurement.

Install JaviPerf in Microsoft Fabric

You need a prebuilt JaviPerf .whl file. Fabric installs it through an Environment; a local pip install or wheel build does not install it in Fabric.

1. Obtain the wheel

Use a prebuilt .whl supplied by your library maintainer or internal package process. To follow the historical walkthrough in this private development preview, the local-only link serves the exact 0.2.0 wheel used in the captured run:

This is not a public download. The current locally built version is 0.2.1 and has not been tested in Fabric. The screenshots below show 0.2.0, not 0.2.1.

2. Upload it to an Environment

  1. Open an existing Fabric Environment or create one for your workspace.
  2. Select Libraries → Custom libraries, then choose Full mode.
  3. Select Upload and choose the JaviPerf .whl file. Compatible libraries already in the Environment can stay installed.

The screenshot shows the historical JaviPerf 0.2.0 wheel pending beside JaviMapper 0.6.0b1 in env_javimapper_lab. The existing library was kept in the Environment.

3. Publish the changes

Save pending changes if Fabric asks, select Publish all, and wait for publication to finish. Confirm that JaviPerf shows Success in Custom libraries.

Both libraries showed Success in the historical run. That confirms publication completed; it does not prove that every future combination of library versions is compatible.

4. Attach the published Environment

Open or import your Fabric notebook. From its toolbar, select the Environment you just published. The screenshot shows the historical lab notebook attached to env_javimapper_lab.

5. Verify the package and use it in a notebook

In a notebook cell, check which version the attached Environment provides:

PythonVerify JaviPerf in the notebook2 lines
Python
import javiperf
print(javiperf.__version__)
Python2 linesRead-only example cell. Nothing on this page runs code.
Illustrative cell; no output is recorded here. The historical Fabric notebook reported 0.2.0.

The output should match the wheel you installed. The short cells below illustrate the APIs; they have no recorded output. For a complete executed example, use the genuine quickstart notebook.

Use JaviPerf in a notebook

Python API

PythonCompare Python implementations11 lines
Python
from javiperf import compare, measure, run_benchmark

with measure("transform_sales") as m:
    transformed = transform_sales(data)

result = run_benchmark("transform_sales", lambda: transform_sales(data), warmup=2, repeat=10)
print(result.summary.median_s, result.summary.cv)

comparison = compare(lambda: old_transform(data), lambda: new_transform(data),
                     warmup=2, repeat=10, equivalent=lambda a, b: a == b)
print(comparison.verdict, comparison.verdict_reason)
Python11 linesRead-only example cell. Nothing on this page runs code.
Illustrative API cell; no output is recorded.

PySpark API

PySparkInspect a Spark plan and compare DataFrames8 lines
PySpark
from javiperf.spark import analyze_dataframe, compare_dataframes, materialize_noop

analysis = analyze_dataframe(orders.join(customers, "customer_id").groupBy("country").count())
for finding in analysis.findings:            # no Spark job has run
    print(finding.code, finding.level, finding.evidence)

comparison = compare_dataframes("UDF vs built-in", with_udf, with_builtin,
                                action=materialize_noop, spark=spark, repeat=5)
PySpark8 linesRead-only example cell. Nothing on this page runs code.
Illustrative API cell; no output is recorded. Supply your DataFrames and Spark session.

action is required: without one, Spark only builds a plan, and the timing would be meaningless.

Report example

build_report and write_report produce a JSON document and one standalone HTML file. The HTML has no scripts and no external resources, works on a phone and in dark mode, and has four parts: the environment, measured runtime behaviour, static plan observations, and investigations to validate, followed by the limitations. An excerpt from the JSON of the recorded local benchmark (PySpark 4.1.4, Python 3.13, synthetic data):

{
  "name": "Python UDF vs built-in function (Spark)",
  "verdict": "candidate_faster",
  "verdict_reason": "Every successful candidate run was faster than every successful baseline run in this session.",
  "median_ratio": 0.024,
  "equivalence": "equivalent",
  "baseline_median_s": 6.697,
  "candidate_median_s": 0.161
}

The ratio describes that local run only. In the same benchmark, the UDF version took about as long with 50,000 rows as with 500,000, so fixed local overhead dominated it. The executed quickstart notebook:

Notebook: javiperf-quickstart.ipynb

PySpark notebook12 cells

Read-only view of the notebook file. Nothing on this page runs code.

  1. Cell 1MarkdownJaviPerf quickstart: measure, compare, and read a Spark plan

    JaviPerf quickstart: measure, compare, and read a Spark plan

    JaviPerf 0.1 is experimental. This notebook uses synthetic data only. The saved outputs were captured on a local machine (PySpark with a local master), not in Microsoft Fabric. Your numbers will differ: the point is the method.

    It runs unchanged in a Fabric notebook attached to an Environment that has the JaviPerf wheel as a custom library, because it uses the spark session the notebook provides when there is one.

  2. Cell 2PySparkCode14 lines
    PySpark
    import sys
    import javiperf
    from javiperf import build_report, compare, measure, render_html, run_benchmark
    from javiperf.spark import analyze_dataframe, benchmark_dataframe, compare_dataframes, materialize_noop
    
    try:
        spark  # provided by Microsoft Fabric and other Spark notebook hosts
        where = "notebook session"
    except NameError:
        from pyspark.sql import SparkSession
        spark = SparkSession.builder.master("local[2]").config("spark.ui.enabled", "false").getOrCreate()
        where = "local session"
    
    print(f"JaviPerf {javiperf.__version__} | Python {sys.version.split()[0]} | Spark {spark.version} ({where})")

    Output

    JaviPerf 0.1.0 | Python 3.13.17 | Spark 4.1.4 (local session)
  3. Cell 3Markdown1. Measure, then repeat
    1. Measure, then repeat

    One timing is one observation. run_benchmark adds warm-up runs (recorded, not summarized) and repeated runs.

  4. Cell 4PySparkCode13 lines
    PySpark
    rows = [{"order_id": i, "country": " ca " if i % 3 else "us"} for i in range(100_000)]
    
    def clean(data):
        return [(r["order_id"], r["country"].strip().upper()) for r in data]
    
    with measure("clean once") as m:
        clean(rows)
    print(f"single run: {m.status}")
    
    result = run_benchmark("clean", lambda: clean(rows), warmup=2, repeat=7)
    s = result.summary
    print(f"{s.count} measured runs, {len(result.failed_runs)} failed")
    print(f"spread: CV {s.cv:.1%}, max/min {s.max_s / s.min_s:.2f}")

    Output

    single run: ok
    7 measured runs, 0 failed
    spread: CV 5.7%, max/min 1.17
  5. Cell 5Markdown2. When an abstraction costs more than it saves
    2. When an abstraction costs more than it saves

    A generic "pipeline of steps" that copies each row at every step, against a direct comprehension. equivalent= checks that both produce the same rows, outside the timed region.

  6. Cell 6PySparkCode25 lines
    PySpark
    class Step:
        def apply(self, row):
            raise NotImplementedError
    
    class Strip(Step):
        def apply(self, row):
            out = dict(row); out["country"] = out["country"].strip(); return out
    
    class Upper(Step):
        def apply(self, row):
            out = dict(row); out["country"] = out["country"].upper(); return out
    
    def run_steps(data, steps):
        result = []
        for row in data:
            for step in steps:
                row = step.apply(row)
            result.append((row["order_id"], row["country"]))
        return result
    
    comparison = compare(lambda: run_steps(rows, [Strip(), Upper()]), lambda: clean(rows),
                         name="generic steps vs direct", warmup=2, repeat=7, equivalent=lambda a, b: a == b)
    print("equivalence:", comparison.equivalence)
    print("verdict:    ", comparison.verdict, "-", comparison.verdict_reason)
    print(f"observed median ratio (direct / steps): {comparison.median_ratio:.2f}")

    Output

    equivalence: equivalent
    verdict:     candidate_faster - Every successful candidate run was faster than every successful baseline run in this session.
    observed median ratio (direct / steps): 0.26
  7. Cell 7Markdown3. Read a Spark plan without running it
    3. Read a Spark plan without running it

    analyze_dataframe reads explain(mode="simple"). It launches no Spark job and collects nothing.

  8. Cell 8PySparkCode17 lines
    PySpark
    from pyspark.sql import functions as F
    from pyspark.sql.types import StringType
    
    source = spark.range(0, 200_000).select("id", F.concat(F.lit(" c"), (F.col("id") % 100).cast("string")).alias("code"))
    normalize = F.udf(lambda s: s.strip().upper(), StringType())
    
    def with_udf():
        return source.select("id", normalize("code").alias("code"))
    
    def with_builtin():
        return source.select("id", F.upper(F.trim("code")).alias("code"))
    
    for label, build in (("Python UDF", with_udf), ("built-in functions", with_builtin)):
        analysis = analyze_dataframe(build(), label=label)
        print(f"{label}: {', '.join(analysis.codes) or 'no findings'}")
        for f in analysis.findings:
            print(f"  {f.code} [{f.level}] {'; '.join(f.evidence)}")

    Output

    Python UDF: PYTHON_UDF
      PYTHON_UDF [review] Python execution operators: BatchEvalPython × 1; BatchEvalPython evaluates a row-at-a-time Python UDF (pickled rows, not Arrow batches)
    built-in functions: no findings
  9. Cell 9Markdown4. Time Spark with an explicit action
    4. Time Spark with an explicit action

    Building a DataFrame does no work. Timing it without an action is the classic mistake: JaviPerf counts the Spark jobs each run started and warns when there were none.

  10. Cell 10PySparkCode9 lines
    PySpark
    lazy = benchmark_dataframe("no action", with_builtin, action=lambda df: df, spark=spark, warmup=1, repeat=3)
    print("no action, Spark jobs per run:", [r.observations["spark_jobs"] for r in lazy.measured_runs])
    print("warning:", any("No Spark job was observed" in n for n in lazy.notes))
    
    spark_comparison = compare_dataframes("UDF vs built-in", with_udf, with_builtin, action=materialize_noop,
                                          spark=spark, warmup=1, repeat=3)
    print("noop write, Spark jobs per run:", [r.observations["spark_jobs"] for r in spark_comparison.candidate.measured_runs])
    print("equivalence:", spark_comparison.equivalence)
    print("verdict:    ", spark_comparison.verdict)

    Output

    no action, Spark jobs per run: [0, 0, 0]
    warning: True
    noop write, Spark jobs per run: [1, 1, 1]
    equivalence: equivalent
    verdict:     candidate_faster
  11. Cell 11Markdown5. Report
    5. Report

    One self-contained HTML file: measured behaviour, static plan observations, investigations to validate, and the limitations. In Fabric, displayHTML shows it inline.

  12. Cell 12PySparkCode10 lines
    PySpark
    report = build_report(title="JaviPerf quickstart", benchmarks=[result],
                          comparisons=[comparison, spark_comparison],
                          plan_analyses=[analyze_dataframe(with_udf(), label="Python UDF")])
    html = render_html(report)
    try:
        displayHTML(html)  # Fabric and Synapse notebooks
    except NameError:
        from pathlib import Path
        Path("javiperf-report.html").write_text(html, encoding="utf-8")
        print(f"report written: javiperf-report.html ({len(html) // 1024} KB, no scripts, no external resources)")

    Output

    report written: javiperf-report.html (20 KB, no scripts, no external resources)

Supported execution environments

The current 0.2.1 version was validated locally on Windows 11, Python 3.13.17, PySpark 4.3.0 and OpenJDK 21 (258 tests passed, with Spark required). Earlier compatibility runs below were for 0.2.0 and are historical results. “Spark required” means a Spark test that can’t run fails instead of skipping.

Python PySpark Closest Fabric runtime Result
3.13 4.1.4 Runtime 2.0 (Spark 4.1, Python 3.13, Java 21) 217 tests passed on 0.2.0, Spark required
3.11 3.5.5 Runtime 1.3 (Spark 3.5.5, Python 3.11) 217 tests passed on 0.2.0, Spark required
3.12 4.3.0 none (latest PySpark) 217 tests passed on 0.2.0, Spark required
3.10 and 3.14 none none core tests passed (Spark tests deselected)

The 0.2.0 Fabric run used Runtime 2.0 and JaviMapper 0.6.0b1. Version 0.2.1, including its duration-only reporting, has not been run in Fabric. Linux and macOS, Java 17, Spark Connect, and Fabric’s Native Execution Engine are also untested; JaviPerf normalizes operator names for the latter but has not seen them in a real plan.

Initial diagnostic capabilities

Static plan findings, read from DataFrame.explain(mode="simple"):

Code Level What the plan contains
SHUFFLE_EXCHANGE info Exchanges, with partitioning kinds and planned partition counts
SINGLE_PARTITION_EXCHANGE info All rows moved into one partition
SORT info Global or per-partition sorts
PYTHON_UDF review Python UDF execution (BatchEvalPython, ArrowEvalPython, MapInPandas…)
BROADCAST_JOIN info Broadcast joins, with join type and build side
CARTESIAN_OR_NESTED_LOOP_JOIN review Cartesian products and nested-loop joins
WINDOW_WITHOUT_PARTITION review Window functions without partitionBy
CACHED_DATA info Reads from cached data
REPEATED_SCAN info The same source scanned more than once

Each finding carries its evidence, why it might matter, what to investigate, and its false-positive risks. None of them is a problem by itself. Findings never quote plan text, which can contain table names, paths and filter values.

For library developers: build JaviPerf from source

Show the local development and packaging workflow

These commands are for maintainers and developers with access to this source repository. From the repository root:

python -m pip install -e "./libraries/javiperf[dev,spark]"
python -m build --wheel --outdir .codex-artifacts/private-wheels ./libraries/javiperf

Editable pip installation affects only the local Python environment. Building creates the versioned artifact javiperf-0.2.1-py3-none-any.whl; neither step installs JaviPerf into a Fabric Environment. Uploading and publishing the wheel in Fabric is a separate operation described above.

Known limitations