Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0007614OCamlmiddle end (typedtree to clambda)public2017-08-27 15:212017-09-04 15:53
ReporterAlex 
Assigned Tolpw25 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
PlatformOSOS Version
Product Version4.05.0 
Target VersionFixed in Version4.06.0 +dev/beta1/beta2/rc1 
Summary0007614: flambda optimizations depends on unrelated things
DescriptionOptimization decisions made by flambda are very fragile and sometimes depends on unrelated things.
I found the case where inline decisions can be due to source file renaming or even just adding some empty lines to the source, resulting in code size increase and suboptimal performance:

$ ls
fragile.ml
$ cp fragile.ml fragile2.ml
$ md5sum *
6a13d560736c81b3e5b5dfe7f13c2f56 fragile2.ml
6a13d560736c81b3e5b5dfe7f13c2f56 fragile.ml
$ ocamlopt -version
4.05.0
$ ocamlopt -O3 fragile.ml -dflambda 2>&1 | wc -l
1774
$ ocamlopt -O3 fragile2.ml -dflambda 2>&1 | wc -l
3835
TagsNo tags attached.
Attached Files? file icon fragile.ml [^] (1,720 bytes) 2017-08-27 15:21 [Show Content]

- Relationships

-  Notes
(0018197)
Alex (reporter)
2017-08-27 15:23

Is it possible that function size approximation somehow depends on string length of a source location?
(0018198)
chambart (developer)
2017-08-28 15:17

No, it does not affect size approximation.

The difference comes from the order in which expressions are examined. The file name is part of the identifiers which are used as key for an hashtable. While inlining, some quotas are consumed while traversing the expression. It seems that in your case, there is a threshold for a specific function that change a lot of things.

I don't know yet where the difference matter exactly.
(0018211)
xclerc (reporter)
2017-09-01 12:56

Pull request: https://github.com/ocaml/ocaml/pull/1313 [^]
(0018214)
lpw25 (developer)
2017-09-04 15:50

The PR was merged so marking as resolved.

- Issue History
Date Modified Username Field Change
2017-08-27 15:21 Alex New Issue
2017-08-27 15:21 Alex File Added: fragile.ml
2017-08-27 15:23 Alex Note Added: 0018197
2017-08-27 17:23 dra Assigned To => shinwell
2017-08-27 17:23 dra Status new => assigned
2017-08-28 15:17 chambart Note Added: 0018198
2017-09-01 12:56 xclerc Note Added: 0018211
2017-09-04 15:50 lpw25 Note Added: 0018214
2017-09-04 15:53 lpw25 Status assigned => resolved
2017-09-04 15:53 lpw25 Fixed in Version => 4.06.0 +dev/beta1/beta2/rc1
2017-09-04 15:53 lpw25 Resolution open => fixed
2017-09-04 15:53 lpw25 Assigned To shinwell => lpw25


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker