Skip to content

perf(profiler): optimize hot paths from async-profiler - #10

Open
szhatchenko wants to merge 1 commit into
mainfrom
profiler-optimize/sde-simulation-allocation-reduction
Open

szhatchenko wants to merge 1 commit into
mainfrom
profiler-optimize/sde-simulation-allocation-reduction

Conversation

@szhatchenko

Copy link
Copy Markdown
Contributor

Optimizations based on async-profiler analysis from https://uni.sirius-web.org:58443.

Profiles Analyzed

  • Number of reports: 5 (most recent from last 24h)
  • Time range: 2026-08-03 ~07:35-07:38 UTC
  • Total samples across all profiles: 91,173
  • Simulation: AgentModeling with Euler-Maruyama SDE solver (Neuronal_activity_modular_model_plain)

Top Hot Functions

  1. SimpleEventDetector.detectEvent - 21,750 samples (24%) - per-step array cloning
  2. EulerStochastic.doStep / integrationStep - 39,169 samples (43%) - simulation loop
  3. SdeModel.dy_dt_deterministic / JavaBaseModel.dy_dt - 10,211 samples (11%) - derivative calculations
  4. JavaBaseModel.firstPart / delay - 8,206 samples - linear search through sorted time list
  5. updateStochasticValuesArrays - per-step HashMap copy

Changes

  • SimpleEventDetector.detectEvent: Replace xNew.clone() with reusable scratch array (xEventScratch), eliminating per-step double[] allocation
  • EulerStochastic.integrationStep: Pre-allocate scratch arrays for stochastic and deterministic derivatives, eliminating per-step double[] allocations
  • SdeModel: Add allocation-free dy_dt_stochastic(time, x, output) and dy_dt_deterministic(time, x, output) overloads for solver usage
  • EulerStochastic.updateStochasticValuesArrays: Swap HashMap references instead of copying, eliminating per-step HashMap allocation
  • JavaBaseModel.firstPart(): Replace O(n) linear search with O(log n) binary search for delay lookups; add cache invalidation on history clear

Verification

  • Maven build passes (mvn package -DskipTests)
  • Ant build passes (cd src && ant compile)
  • All tests pass (mvn -pl src test) - 697 tests, 1 pre-existing failure (WorkflowTest.testViewBuilderAnalysis, unrelated to these changes)

Co-Authored-By: Claude noreply@anthropic.com

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant