Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sparkle some #[inline] #55

Merged
merged 1 commit into from
Jul 27, 2024
Merged

sparkle some #[inline] #55

merged 1 commit into from
Jul 27, 2024

Conversation

GrigorenkoPV
Copy link
Contributor

No description provided.

Copy link
Owner

@droundy droundy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you happen to check if this affected the benchmarks at all?

@droundy
Copy link
Owner

droundy commented Jul 19, 2024

Actually I see the tests are failing, since there were some inlines applied to types which don't make sense, so this needs to be fixed.

@GrigorenkoPV
Copy link
Contributor Author

Fixed the typo and rebased on top of master (also I think CI does not check formatting, because there's currently an extra newline that rustfmt does not like on master).

I will provide benchmarks later.

@GrigorenkoPV GrigorenkoPV marked this pull request as draft July 19, 2024 20:42
@droundy
Copy link
Owner

droundy commented Jul 21, 2024

It may not be obvious that you can run the existing benchmark with cargo bench --features=bench.

@GrigorenkoPV
Copy link
Contributor Author

Ok, here we go

benches/bench.rs

Before

  Contended &'static str Intern 3.470053539s (R²=0.921, 10 iterations in 4 samples)
Uncontended &'static str Intern 119.988105ms (R²=1.000, 6 iterations in 3 samples)
  Contended &'stati.. NewIntern 2.715266643s (R²=0.000, 4 iterations in 3 samples)
Uncontended &'stati.. NewIntern 125.482971ms (R²=0.999, 6 iterations in 3 samples)
  Contended &'stat... ArcIntern 887.985919ms (R²=1.000, 6 iterations in 3 samples)
Uncontended &'stat... ArcIntern 380.820361ms (R²=1.000, 6 iterations in 3 samples)
Uncontended &'st... ArenaIntern 164.269351ms (R²=1.000, 6 iterations in 3 samples)


  Contended few Strings Intern 2.582528797s (R²=0.000, 4 iterations in 3 samples)
Uncontended few Strings Intern 186.651849ms (R²=1.000, 6 iterations in 3 samples)
  Contended few S... NewIntern  2.9345888s (R²=0.000, 4 iterations in 3 samples)
Uncontended few S... NewIntern 186.575032ms (R²=1.000, 6 iterations in 3 samples)
  Contended few S... ArcIntern 868.53773ms (R²=0.999, 6 iterations in 3 samples)
Uncontended few S... ArcIntern 216.561047ms (R²=1.000, 6 iterations in 3 samples)
Uncontended few S..ArenaIntern 158.027995ms (R²=1.000, 6 iterations in 3 samples)
  Contended few Strings Intern::from 2.008508227s (R²=1.000, 6 iterations in 3 samples)
Uncontended few Strings Intern::from  93.49282ms (R²=1.000, 6 iterations in 3 samples)
  Contended few S... ArcIntern::from 844.27767ms (R²=1.000, 6 iterations in 3 samples)
Uncontended few S... ArcIntern::from 211.63708ms (R²=1.000, 6 iterations in 3 samples)
  Contended few str. Intern::from 2.327903806s (R²=1.000, 6 iterations in 3 samples)
Uncontended few str. Intern::from 100.563083ms (R²=1.000, 6 iterations in 3 samples)
  Contended few str. NewIntern::from 2.155720709s (R²=1.000, 6 iterations in 3 samples)
Uncontended few str. NewIntern::from 89.760435ms (R²=0.999, 6 iterations in 3 samples)


  Contended unique Strings Intern 7.086988004s (R²=0.000, 2 iterations in 2 samples)
Uncontended unique Strings Intern 882.737256ms (R²=1.000, 6 iterations in 3 samples)
  Contended unique S... NewIntern 7.071832727s (R²=0.000, 2 iterations in 2 samples)
Uncontended unique S... NewIntern 869.983007ms (R²=1.000, 6 iterations in 3 samples)
  Contended unique S... ArcIntern 1.280252649s (R²=1.000, 6 iterations in 3 samples)
Uncontended unique S... ArcIntern 2.451821053s (R²=1.000, 6 iterations in 3 samples)
Uncontended unique S..ArenaIntern 1.039732958s (R²=0.998, 6 iterations in 3 samples)


  Contended four types Intern 1.890321792s (R²=1.000, 6 iterations in 3 samples)
Uncontended four types Intern 657.014643ms (R²=1.000, 6 iterations in 3 samples)
  Contended four ...NewIntern 1.736759376s (R²=1.000, 6 iterations in 3 samples)
Uncontended four ...NewIntern 650.628263ms (R²=1.000, 6 iterations in 3 samples)
  Contended four ...ArcIntern 1.245849742s (R²=1.000, 6 iterations in 3 samples)
Uncontended four ...ArcIntern 1.887004673s (R²=1.000, 6 iterations in 3 samples)


Contended arrays Intern 926.45528ms (R²=1.000, 6 iterations in 3 samples)
Uncontended  ... Intern 286.146342ms (R²=1.000, 6 iterations in 3 samples)
Contended ... NewIntern 806.958797ms (R²=1.000, 6 iterations in 3 samples)
Uncontended . NewIntern 301.572902ms (R²=1.000, 6 iterations in 3 samples)
Contended ... ArcIntern 9.467367368s (R²=0.000, 2 iterations in 2 samples)
Uncontended . ArcIntern 1.503260484s (R²=0.970, 6 iterations in 3 samples)


Contended different arrays Intern 2.29115075s (R²=1.000, 6 iterations in 3 samples)
Contended different arrays Intern 1.243822669s (R²=1.000, 6 iterations in 3 samples)
Contended different ... NewIntern 1.931904743s (R²=0.998, 6 iterations in 3 samples)
Contended different ... NewIntern 1.212583633s (R²=1.000, 6 iterations in 3 samples)
Contended different ... ArcIntern 838.574041ms (R²=1.000, 6 iterations in 3 samples)
Contended different ... ArcIntern 1.667524733s (R²=1.000, 6 iterations in 3 samples)


String::new short   206.641µs (R²=1.000, 6 iterations in 3 samples)
String::new   960.385µs (R²=0.991, 276 iterations in 23 samples)
String::compare/hash   127.172µs (R²=1.000, 6 iterations in 3 samples)
String sort   591.873µs (R²=1.000, 6 iterations in 3 samples)
Box<String> sort    632.36µs (R²=0.999, 6 iterations in 3 samples)
String any eq     1.633µs (R²=0.992, 6 iterations in 3 samples)
Box<String> any eq     4.623µs (R²=0.999, 6 iterations in 3 samples)

Intern<i64>::new       215ns (R²=0.538, 58922891 iterations in 151 samples)
Intern<u8>::new        14ns (R²=1.000, 60881 iterations in 79 samples)
Intern<String>::new short    211.78µs (R²=0.992, 21 iterations in 6 samples)
Intern<String>::new short   226.222µs (R²=1.000, 6 iterations in 3 samples)
Intern<String>::from short   237.447µs (R²=1.000, 6 iterations in 3 samples)
Intern<String>::new   364.987µs (R²=0.998, 6 iterations in 3 samples)
Intern<String>::from   326.538µs (R²=0.997, 6 iterations in 3 samples)
Intern<String>::compare/hash     9.478µs (R²=0.999, 91 iterations in 13 samples)
Intern<str>::compare/hash    13.507µs (R²=0.998, 66 iterations in 11 samples)
Intern<String> sort   674.743µs (R²=1.000, 6 iterations in 3 samples)
Intern<str> sort   509.163µs (R²=1.000, 6 iterations in 3 samples)
Intern<String> any eq str      1.31µs (R²=1.000, 276 iterations in 23 samples)
Intern<String> any eq       743ns (R²=1.000, 325 iterations in 25 samples)
Intern<i64>::clone         0ns (R²=0.996, 7877635 iterations in 130 samples)

ArcIntern<i64>::new       131ns (R²=1.000, 7235 iterations in 57 samples)
ArcIntern<u8>::new       124ns (R²=0.991, 8645 iterations in 59 samples)
ArcIntern<String>::new short   908.337µs (R²=1.000, 6 iterations in 3 samples)
ArcIntern<String>::new  2.143663ms (R²=1.000, 6 iterations in 3 samples)
ArcIntern<String>::from   1.86587ms (R²=0.991, 190 iterations in 19 samples)
ArcIntern<String>::compare/hash     9.716µs (R²=1.000, 21 iterations in 6 samples)
ArcIntern<String> sort    784.47µs (R²=0.999, 6 iterations in 3 samples)
ArcIntern<String> any eq       779ns (R²=1.000, 36 iterations in 8 samples)
ArcIntern<i64>::clone        12ns (R²=1.000, 80887 iterations in 82 samples)

arc_interner::ArcIntern<i64>::new       100ns (R²=1.000, 9465 iterations in 60 samples)
arc_interner::ArcIntern<u8>::new        99ns (R²=1.000, 10376 iterations in 61 samples)
arc_interner::ArcIntern<String>::new short   986.312µs (R²=1.000, 6 iterations in 3 samples)
arc_interner::ArcIntern<String>::new  2.182568ms (R²=1.000, 6 iterations in 3 samples)
arc_interner::ArcIntern<String>::compare/hash   130.061µs (R²=1.000, 6 iterations in 3 samples)
arc_interner::ArcIntern<String> sort   793.701µs (R²=1.000, 6 iterations in 3 samples)
arc_interner::ArcIntern<i64>::clone        37ns (R²=1.000, 27626 iterations in 71 samples)

After

  Contended &'static str Intern 2.543669473s (R²=1.000, 6 iterations in 3 samples)
Uncontended &'static str Intern 129.238952ms (R²=1.000, 6 iterations in 3 samples)
  Contended &'stati.. NewIntern 2.876520802s (R²=0.000, 4 iterations in 3 samples)
Uncontended &'stati.. NewIntern 123.095285ms (R²=1.000, 6 iterations in 3 samples)
  Contended &'stat... ArcIntern 978.716627ms (R²=1.000, 6 iterations in 3 samples)
Uncontended &'stat... ArcIntern 335.857887ms (R²=1.000, 6 iterations in 3 samples)
Uncontended &'st... ArenaIntern  170.1385ms (R²=1.000, 6 iterations in 3 samples)


  Contended few Strings Intern 2.537284238s (R²=0.000, 4 iterations in 3 samples)
Uncontended few Strings Intern 211.154104ms (R²=0.993, 6 iterations in 3 samples)
  Contended few S... NewIntern 2.880762934s (R²=0.000, 4 iterations in 3 samples)
Uncontended few S... NewIntern 180.160525ms (R²=1.000, 6 iterations in 3 samples)
  Contended few S... ArcIntern 857.621069ms (R²=1.000, 6 iterations in 3 samples)
Uncontended few S... ArcIntern 319.532064ms (R²=0.950, 36 iterations in 8 samples)
Uncontended few S..ArenaIntern 153.498924ms (R²=1.000, 6 iterations in 3 samples)
  Contended few Strings Intern::from 2.089621205s (R²=1.000, 6 iterations in 3 samples)
Uncontended few Strings Intern::from 88.866164ms (R²=0.999, 6 iterations in 3 samples)
  Contended few S... ArcIntern::from 876.690047ms (R²=0.995, 6 iterations in 3 samples)
Uncontended few S... ArcIntern::from 214.015566ms (R²=0.999, 6 iterations in 3 samples)
  Contended few str. Intern::from 2.079382502s (R²=1.000, 6 iterations in 3 samples)
Uncontended few str. Intern::from 95.668417ms (R²=0.997, 6 iterations in 3 samples)
  Contended few str. NewIntern::from 2.039205345s (R²=1.000, 6 iterations in 3 samples)
Uncontended few str. NewIntern::from 82.750759ms (R²=1.000, 6 iterations in 3 samples)


  Contended unique Strings Intern 6.952386744s (R²=0.000, 2 iterations in 2 samples)
Uncontended unique Strings Intern 971.452688ms (R²=0.997, 6 iterations in 3 samples)
  Contended unique S... NewIntern 7.615081847s (R²=0.000, 2 iterations in 2 samples)
Uncontended unique S... NewIntern 918.167722ms (R²=1.000, 6 iterations in 3 samples)
  Contended unique S... ArcIntern 1.192980505s (R²=1.000, 6 iterations in 3 samples)
Uncontended unique S... ArcIntern 2.264558945s (R²=0.999, 6 iterations in 3 samples)
Uncontended unique S..ArenaIntern 961.309716ms (R²=1.000, 6 iterations in 3 samples)


  Contended four types Intern 1.793752064s (R²=1.000, 6 iterations in 3 samples)
Uncontended four types Intern 661.168236ms (R²=1.000, 6 iterations in 3 samples)
  Contended four ...NewIntern 1.899652978s (R²=1.000, 6 iterations in 3 samples)
Uncontended four ...NewIntern 653.447642ms (R²=1.000, 6 iterations in 3 samples)
  Contended four ...ArcIntern 1.218470161s (R²=0.999, 6 iterations in 3 samples)
Uncontended four ...ArcIntern 2.10128296s (R²=0.989, 6 iterations in 3 samples)


Contended arrays Intern 949.927147ms (R²=0.999, 6 iterations in 3 samples)
Uncontended  ... Intern 293.969547ms (R²=1.000, 6 iterations in 3 samples)
Contended ... NewIntern 936.479941ms (R²=1.000, 6 iterations in 3 samples)
Uncontended . NewIntern 310.670937ms (R²=1.000, 6 iterations in 3 samples)
Contended ... ArcIntern 9.904778654s (R²=0.000, 2 iterations in 2 samples)
Uncontended . ArcIntern 1.622988501s (R²=1.000, 6 iterations in 3 samples)


Contended different arrays Intern 2.164186328s (R²=1.000, 6 iterations in 3 samples)
Contended different arrays Intern 1.243485186s (R²=1.000, 6 iterations in 3 samples)
Contended different ... NewIntern 1.817633227s (R²=1.000, 6 iterations in 3 samples)
Contended different ... NewIntern 1.258292825s (R²=1.000, 6 iterations in 3 samples)
Contended different ... ArcIntern 796.176939ms (R²=1.000, 6 iterations in 3 samples)
Contended different ... ArcIntern 1.662553458s (R²=1.000, 6 iterations in 3 samples)


String::new short   206.734µs (R²=1.000, 6 iterations in 3 samples)
String::new  1.213898ms (R²=0.995, 10 iterations in 4 samples)
String::compare/hash   122.871µs (R²=1.000, 6 iterations in 3 samples)
String sort   606.355µs (R²=1.000, 6 iterations in 3 samples)
Box<String> sort    716.02µs (R²=0.990, 6 iterations in 3 samples)
String any eq     3.894µs (R²=0.990, 1105 iterations in 38 samples)
Box<String> any eq    13.255µs (R²=0.992, 715 iterations in 34 samples)

Intern<i64>::new       167ns (R²=0.616, 64825439 iterations in 152 samples)
Intern<u8>::new        13ns (R²=0.999, 60881 iterations in 79 samples)
Intern<String>::new short   177.474µs (R²=1.000, 6 iterations in 3 samples)
Intern<String>::new short   216.208µs (R²=0.999, 6 iterations in 3 samples)
Intern<String>::from short    214.07µs (R²=1.000, 6 iterations in 3 samples)
Intern<String>::new   326.975µs (R²=0.998, 6 iterations in 3 samples)
Intern<String>::from   282.821µs (R²=1.000, 6 iterations in 3 samples)
Intern<String>::compare/hash     9.247µs (R²=0.998, 91 iterations in 13 samples)
Intern<str>::compare/hash    11.776µs (R²=0.999, 78 iterations in 12 samples)
Intern<String> sort   597.205µs (R²=1.000, 6 iterations in 3 samples)
Intern<str> sort   518.671µs (R²=1.000, 6 iterations in 3 samples)
Intern<String> any eq str     1.216µs (R²=0.995, 300 iterations in 24 samples)
Intern<String> any eq       687ns (R²=0.997, 379 iterations in 27 samples)
Intern<i64>::clone         0ns (R²=0.999, 7154295 iterations in 129 samples)

ArcIntern<i64>::new       123ns (R²=0.997, 7905 iterations in 58 samples)
ArcIntern<u8>::new       117ns (R²=0.999, 8645 iterations in 59 samples)
ArcIntern<String>::new short   750.697µs (R²=0.999, 6 iterations in 3 samples)
ArcIntern<String>::new  2.488695ms (R²=0.994, 6 iterations in 3 samples)
ArcIntern<String>::from  1.347961ms (R²=0.999, 6 iterations in 3 samples)
ArcIntern<String>::compare/hash     9.393µs (R²=0.999, 21 iterations in 6 samples)
ArcIntern<String> sort    750.57µs (R²=1.000, 6 iterations in 3 samples)
ArcIntern<String> any eq       762ns (R²=1.000, 36 iterations in 8 samples)
ArcIntern<i64>::clone        11ns (R²=0.999, 88817 iterations in 83 samples)

arc_interner::ArcIntern<i64>::new        97ns (R²=1.000, 10376 iterations in 61 samples)
arc_interner::ArcIntern<u8>::new        96ns (R²=0.994, 10376 iterations in 61 samples)
arc_interner::ArcIntern<String>::new short  1.027959ms (R²=1.000, 6 iterations in 3 samples)
arc_interner::ArcIntern<String>::new  2.332802ms (R²=0.992, 6 iterations in 3 samples)
arc_interner::ArcIntern<String>::compare/hash   120.573µs (R²=1.000, 6 iterations in 3 samples)
arc_interner::ArcIntern<String> sort   662.147µs (R²=1.000, 6 iterations in 3 samples)
arc_interner::ArcIntern<i64>::clone        34ns (R²=0.998, 30550 iterations in 72 samples)

benches/get_container.rs

Before

cached/String/short     time:   [19.687 ms 20.152 ms 20.667 ms]
Found 10 outliers among 100 measurements (10.00%)
  4 (4.00%) high mild
  6 (6.00%) high severe

uncached/NewType<String>/short
                        time:   [22.437 ms 22.584 ms 22.737 ms]
Found 1 outliers among 100 measurements (1.00%)
  1 (1.00%) high mild
uncached/usize/short    time:   [10.634 ms 10.709 ms 10.787 ms]
Found 3 outliers among 100 measurements (3.00%)
  3 (3.00%) high mild
uncached/NewType<usize>/short
                        time:   [10.175 ms 10.426 ms 10.702 ms]
Found 20 outliers among 100 measurements (20.00%)
  2 (2.00%) high mild
  18 (18.00%) high severe

After

cached/String/short     time:   [16.735 ms 16.768 ms 16.798 ms]
                        change: [-18.880% -16.792% -14.798%] (p = 0.00 < 0.05)
                        Performance has improved.

uncached/NewType<String>/short
                        time:   [19.924 ms 20.347 ms 20.863 ms]
                        change: [-11.996% -9.9070% -7.5905%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 15 outliers among 100 measurements (15.00%)
  1 (1.00%) high mild
  14 (14.00%) high severe
uncached/usize/short    time:   [9.6531 ms 9.6627 ms 9.6734 ms]
                        change: [-10.434% -9.7664% -9.1308%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 14 outliers among 100 measurements (14.00%)
  5 (5.00%) high mild
  9 (9.00%) high severe
uncached/NewType<usize>/short
                        time:   [9.6703 ms 9.6990 ms 9.7295 ms]
                        change: [-9.4234% -6.9690% -4.6938%] (p = 0.00 < 0.05)
                        Performance has improved.

@GrigorenkoPV GrigorenkoPV marked this pull request as ready for review July 23, 2024 15:38
@droundy droundy merged commit 8a5feb3 into droundy:master Jul 27, 2024
8 of 9 checks passed
@GrigorenkoPV GrigorenkoPV deleted the inline branch July 27, 2024 21:28
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