Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

perf: eliminate scala.util.Sorting from native binary#917

Merged
stephenamar-db merged 1 commit into
databricks:masterfrom
He-Pin:perf/eliminate-scala-util-sorting
Jun 15, 2026
Merged

perf: eliminate scala.util.Sorting from native binary#917
stephenamar-db merged 1 commit into
databricks:masterfrom
He-Pin:perf/eliminate-scala-util-sorting

Conversation

@He-Pin

@He-Pin He-Pin commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Summary

Removes scala.util.Sorting from the native binary by replacing two calls in Profiler.scala with java.util.Arrays.sort.

The Profiler was the only code path pulling in scala.util.Sorting — this saves 96KB from the native binary (88KB __text + 8KB __eh_frame), code that is never exercised during normal Jsonnet evaluation.

Changes

Before After
aggregated.toSeq.sortBy(-_.selfTimeNs) java.util.Arrays.sort(arr, comparator)
samples.sorted.apply(median) java.util.Arrays.sort(samples); samples(median)

Test plan

  • JVM test suite passes (only pre-existing cyclic test failures from untracked files)
  • No behavioral change — Profiler output is identical

Motivation:
The Profiler was the only code path using scala.util.Sorting
(via .sortBy and .sorted), pulling in 96KB of dead code into
the native binary (88KB __text + 8KB __eh_frame) that is never
exercised during normal evaluation.

Modification:
- Replace aggregated.toSeq.sortBy(-_.selfTimeNs) with
  java.util.Arrays.sort using a Comparator
- Replace samples.sorted.apply(median) with in-place
  java.util.Arrays.sort followed by direct index access

Result:
Native binary __text reduced by 88KB, __eh_frame by 8KB.
No behavioral change — Profiler output is identical.
@stephenamar-db stephenamar-db merged commit 694c613 into databricks:master Jun 15, 2026
5 checks passed
@He-Pin He-Pin deleted the perf/eliminate-scala-util-sorting branch June 15, 2026 18:26
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.

2 participants