{"action":"opened","issue":{"url":"https://api.github.com/repos/NumberFour/n4js/issues/171","repository_url":"https://api.github.com/repos/NumberFour/n4js","labels_url":"https://api.github.com/repos/NumberFour/n4js/issues/171/labels{/name}","comments_url":"https://api.github.com/repos/NumberFour/n4js/issues/171/comments","events_url":"https://api.github.com/repos/NumberFour/n4js/issues/171/events","html_url":"https://github.com/NumberFour/n4js/issues/171","id":150416172,"number":171,"title":"Performance: review subtype rule for nominal typing","user":{"login":"JensN4","id":1913837,"avatar_url":"https://avatars.githubusercontent.com/u/1913837?v=3","gravatar_id":"","url":"https://api.github.com/users/JensN4","html_url":"https://github.com/JensN4","followers_url":"https://api.github.com/users/JensN4/followers","following_url":"https://api.github.com/users/JensN4/following{/other_user}","gists_url":"https://api.github.com/users/JensN4/gists{/gist_id}","starred_url":"https://api.github.com/users/JensN4/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JensN4/subscriptions","organizations_url":"https://api.github.com/users/JensN4/orgs","repos_url":"https://api.github.com/users/JensN4/repos","events_url":"https://api.github.com/users/JensN4/events{/privacy}","received_events_url":"https://api.github.com/users/JensN4/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/NumberFour/n4js/labels/enhancement","name":"enhancement","color":"84b6eb"},{"url":"https://api.github.com/repos/NumberFour/n4js/labels/prio-high","name":"prio-high","color":"e11d21"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-04-22T16:35:05Z","updated_at":"2016-04-22T16:35:05Z","closed_at":null,"body":"The Xsemantics rule for nominal typing (and parameterized type refs) seems pretty slow.\r\n\r\nA test with 3000 sub-type checks requires approx. 10 second ( = 10000 ms). The same test with raw-subtype checks requires <20 ms, that is 500 times faster!\r\n\r\nThere are 3 things missing in the raw type check: (cf. n4js.xsemantics, lines 1348-1351)\r\n- substitutions\r\n- implicit super types\r\n- assignment compatible types\r\n\r\nIgnoring implicit super types ans assignment compatible types speeds up the rule about 5 times (2000 ms). There are only three implicit super types: Object, N4Object, and Function.\r\nAll three super types are non-generic! Also assignment-compatible types are non-generic.\r\n\r\nI would suggest to\r\n- handle implicit super types and assignment-compatible types differently -- and before we do any other subtype checks\r\n\r\nthen\r\n\r\n- do a raw subtype check (TypeUtils.rawSuperType) first before we do expensive substitution\r\n- if the raw subtype check fails, we do not need anymore substitutions; if it succeeds and right is non-generic, we can also return true immediately.\r\n\r\n\r\n"}}