Skip to content

Conversation

@nsajko
Copy link
Contributor

@nsajko nsajko commented Sep 9, 2025

As documented in the doc string of each of these three functions, these functions are not intended to get any new methods from packages.

Preventing the definition of these unnecessary methods also prevents most of the sysimage invalidation that happens when loading this package. On nightly Julia, commit JuliaLang/julia@3681bb37ec7, the unique invalidation count upon using DynamicQuantities goes from $1381$ to $261$.

As documented in the doc string of each of these three functions, these
functions are not intended to get any new methods from packages.

Preventing the definition of these unnecessary methods also prevents
most of the sysimage invalidation that happens when loading this
package. On nightly Julia, commit JuliaLang/julia@3681bb37ec7, the
unique invalidation count upon `using DynamicQuantities` goes from 1381
to 261.
@nsajko
Copy link
Contributor Author

nsajko commented Sep 9, 2025

Data on each invalidation:

@github-actions
Copy link
Contributor

github-actions bot commented Sep 9, 2025

Benchmark Results (Julia v1.10)

Time benchmarks
main 210b98b... main / 210b98b...
Quantity/creation/Quantity(x) 3.11 ± 0.001 ns 2.79 ± 0.01 ns 1.11 ± 0.004
Quantity/creation/Quantity(x, length=y) 3.11 ± 0.001 ns 3.42 ± 0.001 ns 0.909 ± 0.0004
Quantity/with_numbers/*real 3.11 ± 0.001 ns 3.12 ± 0.01 ns 0.997 ± 0.0032
Quantity/with_numbers/^int 8.67 ± 2.5 ns 8.06 ± 2.2 ns 1.07 ± 0.42
Quantity/with_numbers/^int * real 8.37 ± 2.2 ns 8.38 ± 1.9 ns 0.999 ± 0.34
Quantity/with_quantity/+y 4.04 ± 0.001 ns 4.06 ± 0.02 ns 0.995 ± 0.0049
Quantity/with_quantity//y 3.42 ± 0.01 ns 3.12 ± 0.001 ns 1.1 ± 0.0032
Quantity/with_self/dimension 3.11 ± 0.01 ns 3.11 ± 0 ns 1 ± 0.0032
Quantity/with_self/inv 3.41 ± 0.01 ns 3.11 ± 0.01 ns 1.1 ± 0.0048
Quantity/with_self/ustrip 3.1 ± 0.01 ns 2.79 ± 0.01 ns 1.11 ± 0.0053
QuantityArray/broadcasting/multi_array_of_quantities 0.143 ± 0.0013 ms 0.142 ± 0.0021 ms 1.01 ± 0.017
QuantityArray/broadcasting/multi_normal_array 0.0559 ± 0.0031 ms 0.0529 ± 0.003 ms 1.06 ± 0.084
QuantityArray/broadcasting/multi_quantity_array 0.157 ± 0.001 ms 0.157 ± 0.00094 ms 1 ± 0.009
QuantityArray/broadcasting/x^2_array_of_quantities 24.9 ± 2.5 μs 23.1 ± 2 μs 1.08 ± 0.14
QuantityArray/broadcasting/x^2_normal_array 5.77 ± 0.44 μs 4.27 ± 1 μs 1.35 ± 0.35
QuantityArray/broadcasting/x^2_quantity_array 7.04 ± 0.38 μs 6.97 ± 0.29 μs 1.01 ± 0.069
QuantityArray/broadcasting/x^4_array_of_quantities 0.0817 ± 0.00059 ms 0.0815 ± 0.0005 ms 1 ± 0.0095
QuantityArray/broadcasting/x^4_normal_array 0.0499 ± 0.00021 ms 0.0499 ± 0.00021 ms 1 ± 0.006
QuantityArray/broadcasting/x^4_quantity_array 0.05 ± 0.00022 ms 0.0529 ± 0.003 ms 0.945 ± 0.054
time_to_load 0.188 ± 0.00082 s 0.188 ± 0.0033 s 1 ± 0.018
Memory benchmarks
main 210b98b... main / 210b98b...
Quantity/creation/Quantity(x) 0 allocs: 0 B 0 allocs: 0 B
Quantity/creation/Quantity(x, length=y) 0 allocs: 0 B 0 allocs: 0 B
Quantity/with_numbers/*real 0 allocs: 0 B 0 allocs: 0 B
Quantity/with_numbers/^int 0 allocs: 0 B 0 allocs: 0 B
Quantity/with_numbers/^int * real 0 allocs: 0 B 0 allocs: 0 B
Quantity/with_quantity/+y 0 allocs: 0 B 0 allocs: 0 B
Quantity/with_quantity//y 0 allocs: 0 B 0 allocs: 0 B
Quantity/with_self/dimension 0 allocs: 0 B 0 allocs: 0 B
Quantity/with_self/inv 0 allocs: 0 B 0 allocs: 0 B
Quantity/with_self/ustrip 0 allocs: 0 B 0 allocs: 0 B
QuantityArray/broadcasting/multi_array_of_quantities 2 allocs: 0.382 MB 2 allocs: 0.382 MB 1
QuantityArray/broadcasting/multi_normal_array 2 allocs: 0.0763 MB 2 allocs: 0.0763 MB 1
QuantityArray/broadcasting/multi_quantity_array 2 allocs: 0.0763 MB 2 allocs: 0.0763 MB 1
QuantityArray/broadcasting/x^2_array_of_quantities 2 allocs: 0.382 MB 2 allocs: 0.382 MB 1
QuantityArray/broadcasting/x^2_normal_array 2 allocs: 0.0763 MB 2 allocs: 0.0763 MB 1
QuantityArray/broadcasting/x^2_quantity_array 2 allocs: 0.0763 MB 2 allocs: 0.0763 MB 1
QuantityArray/broadcasting/x^4_array_of_quantities 2 allocs: 0.382 MB 2 allocs: 0.382 MB 1
QuantityArray/broadcasting/x^4_normal_array 2 allocs: 0.0763 MB 2 allocs: 0.0763 MB 1
QuantityArray/broadcasting/x^4_quantity_array 2 allocs: 0.0763 MB 2 allocs: 0.0763 MB 1
time_to_load 0.153 k allocs: 14.5 kB 0.153 k allocs: 14.5 kB 1

@github-actions
Copy link
Contributor

github-actions bot commented Sep 9, 2025

Benchmark Results (Julia v1)

Time benchmarks
main 210b98b... main / 210b98b...
Quantity/creation/Quantity(x) 3.1 ± 0.01 ns 4.02 ± 0.01 ns 0.773 ± 0.0031
Quantity/creation/Quantity(x, length=y) 3.73 ± 0.01 ns 3.73 ± 0 ns 1 ± 0.0027
Quantity/with_numbers/*real 3.1 ± 0.01 ns 2.79 ± 0.001 ns 1.11 ± 0.0036
Quantity/with_numbers/^int 8.98 ± 2.2 ns 8.67 ± 2.2 ns 1.04 ± 0.36
Quantity/with_numbers/^int * real 9.29 ± 2.2 ns 9.29 ± 2.2 ns 1 ± 0.33
Quantity/with_quantity/+y 4.35 ± 0.009 ns 4.35 ± 0 ns 1 ± 0.0021
Quantity/with_quantity//y 3.41 ± 0.01 ns 3.41 ± 0.01 ns 1 ± 0.0042
Quantity/with_self/dimension 2.79 ± 0 ns 3.1 ± 0.01 ns 0.9 ± 0.0029
Quantity/with_self/inv 3.11 ± 0.01 ns 3.11 ± 0.001 ns 1 ± 0.0032
Quantity/with_self/ustrip 2.79 ± 0 ns 3.1 ± 0.01 ns 0.903 ± 0.0029
QuantityArray/broadcasting/multi_array_of_quantities 0.0907 ± 0.00066 ms 0.0908 ± 0.0045 ms 0.999 ± 0.05
QuantityArray/broadcasting/multi_normal_array 0.0498 ± 0.00027 ms 0.0498 ± 0.00026 ms 1 ± 0.0075
QuantityArray/broadcasting/multi_quantity_array 0.0592 ± 0.00028 ms 0.0622 ± 0.00019 ms 0.951 ± 0.0054
QuantityArray/broadcasting/x^2_array_of_quantities 20.2 ± 4.5 μs 18.7 ± 4.7 μs 1.08 ± 0.36
QuantityArray/broadcasting/x^2_normal_array 3.12 ± 2.4 μs 2.89 ± 2.5 μs 1.08 ± 1.3
QuantityArray/broadcasting/x^2_quantity_array 3.75 ± 0.46 μs 4.04 ± 1.2 μs 0.928 ± 0.3
QuantityArray/broadcasting/x^4_array_of_quantities 0.0846 ± 0.00079 ms 0.0847 ± 0.00099 ms 0.999 ± 0.015
QuantityArray/broadcasting/x^4_normal_array 0.0466 ± 0.00019 ms 0.0497 ± 0.00016 ms 0.939 ± 0.0049
QuantityArray/broadcasting/x^4_quantity_array 0.05 ± 0.0092 ms 0.0468 ± 0.00023 ms 1.07 ± 0.2
time_to_load 0.205 ± 0.0029 s 0.209 ± 0.0026 s 0.982 ± 0.018
Memory benchmarks
main 210b98b... main / 210b98b...
Quantity/creation/Quantity(x) 0 allocs: 0 B 0 allocs: 0 B
Quantity/creation/Quantity(x, length=y) 0 allocs: 0 B 0 allocs: 0 B
Quantity/with_numbers/*real 0 allocs: 0 B 0 allocs: 0 B
Quantity/with_numbers/^int 0 allocs: 0 B 0 allocs: 0 B
Quantity/with_numbers/^int * real 0 allocs: 0 B 0 allocs: 0 B
Quantity/with_quantity/+y 0 allocs: 0 B 0 allocs: 0 B
Quantity/with_quantity//y 0 allocs: 0 B 0 allocs: 0 B
Quantity/with_self/dimension 0 allocs: 0 B 0 allocs: 0 B
Quantity/with_self/inv 0 allocs: 0 B 0 allocs: 0 B
Quantity/with_self/ustrip 0 allocs: 0 B 0 allocs: 0 B
QuantityArray/broadcasting/multi_array_of_quantities 3 allocs: 0.382 MB 3 allocs: 0.382 MB 1
QuantityArray/broadcasting/multi_normal_array 3 allocs: 0.0764 MB 3 allocs: 0.0764 MB 1
QuantityArray/broadcasting/multi_quantity_array 3 allocs: 0.0764 MB 3 allocs: 0.0764 MB 1
QuantityArray/broadcasting/x^2_array_of_quantities 3 allocs: 0.382 MB 3 allocs: 0.382 MB 1
QuantityArray/broadcasting/x^2_normal_array 3 allocs: 0.0764 MB 3 allocs: 0.0764 MB 1
QuantityArray/broadcasting/x^2_quantity_array 3 allocs: 0.0764 MB 3 allocs: 0.0764 MB 1
QuantityArray/broadcasting/x^4_array_of_quantities 3 allocs: 0.382 MB 3 allocs: 0.382 MB 1
QuantityArray/broadcasting/x^4_normal_array 3 allocs: 0.0764 MB 3 allocs: 0.0764 MB 1
QuantityArray/broadcasting/x^4_quantity_array 3 allocs: 0.0764 MB 3 allocs: 0.0764 MB 1
time_to_load 0.159 k allocs: 11.2 kB 0.159 k allocs: 11.2 kB 1

@codecov
Copy link

codecov bot commented Sep 9, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@d262170). Learn more about missing BASE report.
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #189   +/-   ##
=======================================
  Coverage        ?   99.21%           
=======================================
  Files           ?       21           
  Lines           ?     1273           
  Branches        ?        0           
=======================================
  Hits            ?     1263           
  Misses          ?       10           
  Partials        ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@MilesCranmer
Copy link
Member

Thanks!

@MilesCranmer MilesCranmer merged commit 9896c8a into JuliaPhysics:main Sep 10, 2025
7 checks passed
@nsajko nsajko deleted the prevent_adding_methods_fix branch September 10, 2025 07:13
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