| Anonymous | Login | Signup for a new account | 2013-05-18 15:32 CEST | ![]() |
| Main | My View | View Issues | Change Log | Roadmap |
| View Issue Details [ Jump to Notes ] | [ Issue History ] [ Print ] | ||||||||||
| ID | Project | Category | View Status | Date Submitted | Last Update | ||||||
| 0005133 | OCaml | OCaml backend (code generation) | public | 2010-08-23 15:40 | 2012-06-21 20:10 | ||||||
| Reporter | Christophe Troestler | ||||||||||
| Assigned To | |||||||||||
| Priority | normal | Severity | feature | Reproducibility | always | ||||||
| Status | acknowledged | Resolution | open | ||||||||
| Platform | OS | OS Version | |||||||||
| Product Version | 3.13.0+dev | ||||||||||
| Target Version | Fixed in Version | ||||||||||
| Summary | 0005133: Improve float allocation | ||||||||||
| Description | There have been a number of significant improvements in float handling in 3.12 but the following example shows on could go further: Program 1 ------------------------------ let r = ref 0.0 in for i = 0 to 1000_000_000 do r := float i done; Printf.printf "%f\n" !r; Printf.printf "words: %f\n" (Gc.stat ()).Gc.minor_words 1000000000.000000 words: 2000000363.000000 2.79user 0.00system 0:02.79elapsed 99%CPU (0avgtext+0avgdata 4208maxresident)k 0inputs+0outputs (0major+313minor)pagefaults 0swaps Program 2 ------------------------------ let r = ref 0.0 in for i = 0 to 1000_000_000 do r := float i done; Printf.printf "%f\n" (!r +. 0.); Printf.printf "words: %f\n" (Gc.stat ()).Gc.minor_words 1000000000.000000 words: 363.000000 1.20user 0.00system 0:01.20elapsed 99%CPU (0avgtext+0avgdata 3152maxresident)k 0inputs+0outputs (0major+247minor)pagefaults 0swaps ---------------------------------------- The second version allocates much less and is way faster on my machine (Linux poincare 2.6.35 #1 SMP Fri Aug 20 14:34:25 CEST 2010 x86_64 GNU/Linux). Both programs were compiled to native code. It would be nice not to have to resort to such tricks to improve performance! Couldn't the compiler figure out this optimization? | ||||||||||
| Tags | No tags attached. | ||||||||||
| Attached Files | |||||||||||
Relationships |
||||||
|
||||||
Notes |
|
|
(0007344) Christophe Troestler (reporter) 2012-04-12 19:27 |
See also bug 0005204. |
|
(0007345) frisch (developer) 2012-04-12 19:49 |
Indeed, this is a typical case where the boxing/unboxing strategy proposed in 0005204 works nicely and avoids having to force manually the unboxing by adding an ad hoc "+. 0.". |
Issue History |
|||
| Date Modified | Username | Field | Change |
| 2010-08-23 15:40 | Christophe Troestler | New Issue | |
| 2011-05-20 17:56 | doligez | Status | new => acknowledged |
| 2012-04-12 19:27 | Christophe Troestler | Note Added: 0007344 | |
| 2012-04-12 19:47 | frisch | Relationship added | child of 0005204 |
| 2012-04-12 19:49 | frisch | Note Added: 0007345 | |
| 2012-06-21 20:10 | frisch | Category | OCaml general => OCaml backend (code generation) |
| Copyright © 2000 - 2011 MantisBT Group |