Skip to content

uses_property_allowance works out every benefit on both routes since #2066, so microsimulations run several times slower #2694

Closed

Description

@juaristi22

Since 2.157.0 (#2066), a Microcosm UK microsimulation runs several times slower. Building it from microcosm_uk_2024_25.h5 and calculating 2026 household_net_income, on one Mac with policyengine-core 3.33.12 throughout:

  • 2.156.2: 17 s
  • 2.157.0: 111 s
  • 2.162.10: 124 s (50 s to build, 74 s for 2026)

Enhanced FRS 2024-25 barely moves (15.0 s to 17.5 s for 2025 to 2029): it has no property_finance_costs input, so no landlord weighs the property allowance against the finance-cost reduction.

#2066 adds winter_fuel_payment_charge to income_tax, and the charge depends on Pension Credit, Universal Credit, Income Support, income-based JSA and income-related ESA (ITEPA 2003 s.681I(4)). uses_property_allowance compares each landlord's income_tax with and without the allowance in two branches of the whole simulation. Each branch now works out every benefit for the whole population, then drops it. Comparing on income tax including the charge is right: the charge is income tax, and a route can move total income across £35,000 or change Pension Credit, and with it the exemption. The cost comes from how often the comparison runs:

  • one step for each rank and round of decisions within households, each with its own pair of branches;
  • Pension Credit's tax-on-earnings counterfactual (income_tax_with_inputs_zeroed) calls drop_computed_arrays(), so at the top level it chooses everyone's election again for a year without earnings and runs the comparison again, with its own branches. Inside a comparison branch the election is an input and stays as made;
  • building a microsimulation calculates uc_LCWRA_element for 2026 to 2032, which reaches income tax through the ESA permitted-work test (esa_exempt_work_earnings, reg. 96(3)), so the comparison runs once for each of those years before anything is requested.

Profiling on a 20% household sample of Microcosm, most of the time in the comparison's branches goes to variables that do not depend on the election (LHA rates, UC child elements, carer conditions, capital), worked out again in each branch.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions