Exemplo n.º 1
0
def _custom(trace: ProcessedTrace) -> None:
    gen2_gcs = [gc for gc in trace.gcs if gc.IsGen2]
    datas: List[_GCData] = []
    for gc in gen2_gcs:
        bytes_since_last_same_gen_gc = (unwrap(
            get_bytes_allocated_since_last_gc(trace.gcs, trace.gcs.index(gc),
                                              Gens.GenLargeObj))
                                        if gc.IsGen2 else None)

        datas.append(
            _GCData(
                Number=gc.Number,
                MBSOHSinceLastGen2=bytes_to_mb(
                    unwrap(
                        get_bytes_allocated_since_last_gc(
                            trace.gcs, trace.gcs.index(gc), Gens.Gen2)))
                if gc.IsGen2 else None,
                MBLOHSinceLastGen2=bytes_to_mb(
                    non_null(bytes_since_last_same_gen_gc))
                if gc.IsGen2 else None,
                Gen2BudgetMB=gc.Gen2BudgetMB if gc.IsGen2 else None,
                LOHBudgetMB=gc.LOHBudgetMB if gc.IsGen2 else None,
            ))

    rows = []
    for data in datas:
        rows.append([
            Cell(str(int(x))) if x is not None else Cell() for x in (
                data.Number,
                data.MBSOHSinceLastGen2,
                data.MBLOHSinceLastGen2,
                data.Gen2BudgetMB,
                data.LOHBudgetMB,
            )
        ])

    g2_numbers = ", ".join(str(gc.Number) for gc in gen2_gcs)
    gens = f"Gen2 numbers are: {g2_numbers}"

    doc = single_table_document(
        Table(
            text=gens,
            headers=(
                "number",
                "MB on SOH since last gen2",
                "MB on LOH since last gen2",
                "gen2 budget MB",
                "loh budget MB",
            ),
            rows=rows,
        ))
    handle_doc(doc)
Exemplo n.º 2
0
def _custom_chart_heaps_2(trace: ProcessedTrace) -> None:
    # A different chart for each heap
    heaps: Sequence[List[_HeapData]] = [[] for _ in range(trace.HeapCount)]
    prev_non_free_size_after: List[int] = [0 for _ in range(trace.HeapCount)]
    for gc in trace.gcs:
        if gc.Generation != Gens.Gen2:
            continue

        budget_per_heap = gc.LOHBudgetMB / len(heaps)

        for hp_i, hp in enumerate(gc.heaps):
            # Want the difference in size before -- get prev gen2 gc
            prev_size_after = prev_non_free_size_after[hp_i]
            gen = hp.gen(Gens.GenLargeObj)
            size_before_now = gen.non_free_size_before
            size_after_now = gen.non_free_size_after
            allocated_bytes = size_before_now - prev_size_after
            prev_non_free_size_after[hp_i] = size_after_now
            # gen.budget is before equalizing
            heaps[hp_i].append(
                _HeapData(
                    gc_number=gc.Number,
                    budget_mb=budget_per_heap,
                    allocated_mb=bytes_to_mb(allocated_bytes),
                )
            )

    # Chart each hp
    lines = []
    for i, hp_data in enumerate(heaps):
        xs = [d.gc_number for d in hp_data]
        line0 = BasicLine(name="budget (MB)", xs=xs, ys=[d.budget_mb for d in hp_data])
        line1 = BasicLine(name="allocated (MB)", xs=xs, ys=[d.allocated_mb for d in hp_data])
        lines.append(BasicLineChart(name=f"hp{i}", lines=(line0, line1)))
    basic_chart(lines)