{"action":"created","issue":{"url":"https://api.github.com/repos/travisdowns/bimodal-performance/issues/4","repository_url":"https://api.github.com/repos/travisdowns/bimodal-performance","labels_url":"https://api.github.com/repos/travisdowns/bimodal-performance/issues/4/labels{/name}","comments_url":"https://api.github.com/repos/travisdowns/bimodal-performance/issues/4/comments","events_url":"https://api.github.com/repos/travisdowns/bimodal-performance/issues/4/events","html_url":"https://github.com/travisdowns/bimodal-performance/issues/4","id":389396419,"node_id":"MDU6SXNzdWUzODkzOTY0MTk=","number":4,"title":"Interesting related issue","user":{"login":"amonakov","id":1997391,"node_id":"MDQ6VXNlcjE5OTczOTE=","avatar_url":"https://avatars2.githubusercontent.com/u/1997391?v=4","gravatar_id":"","url":"https://api.github.com/users/amonakov","html_url":"https://github.com/amonakov","followers_url":"https://api.github.com/users/amonakov/followers","following_url":"https://api.github.com/users/amonakov/following{/other_user}","gists_url":"https://api.github.com/users/amonakov/gists{/gist_id}","starred_url":"https://api.github.com/users/amonakov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amonakov/subscriptions","organizations_url":"https://api.github.com/users/amonakov/orgs","repos_url":"https://api.github.com/users/amonakov/repos","events_url":"https://api.github.com/users/amonakov/events{/privacy}","received_events_url":"https://api.github.com/users/amonakov/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":9,"created_at":"2018-12-10T17:02:17Z","updated_at":"2018-12-11T18:08:30Z","closed_at":null,"author_association":"NONE","body":"I found a fascinating issue while running this test on Sandy Bridge. I've noticed that c++ and asm variants had different performance, while being different only in how a register is zeroed (`xor eax, eax` in hand-written asm vs. `mov eax, 0` in -O1 gcc output).\r\n\r\nLowering buffer size to fit in L1 makes the two variants differ exactly 1.5x in performance, 2 cycles/iter for the asm loop (as it should be), vs. 3 cycles/iteration for the `mov eax, 0` variant, which is clearly an anomaly.\r\n\r\nThis also happens on Ivy Bridge. I'm unsure of what exactly is causing this, my best \"theory\" so far is that without the zero idiom something happens in the beginning of the loop that makes LSD latch to some sort of  a \"slow pattern\" (suppressing LSD with stack pushes makes it fast). Not sure what the extra cycles are, I see an increase in the `resource_stalls.sb` perf counter implying that store buffer is not accepting stores, but that doesn't make sense to me...\r\n\r\nHere's a minimal standalone asm repro this boils down to:\r\n\r\n```asm\r\nglobal _start:function\r\n_start:\r\n        mov rbp, rsp\r\n        mov eax, 3700000\r\n.oloop:\r\n        mov ecx, 1000\r\n        xor edi, edi ; try swapping these for\r\n        mov edi, 0   ; a 1.5x perf difference\r\nalign 16\r\n.iloop:\r\n        mov [rbp], edi\r\n        mov [rsp], edi\r\n        sub rsp, 4\r\n        dec ecx\r\n        jnz .iloop\r\n        mov rsp, rbp\r\n        dec eax\r\n        jnz .oloop\r\n        mov eax, 60\r\n        syscall\r\n```"},"comment":{"url":"https://api.github.com/repos/travisdowns/bimodal-performance/issues/comments/446302647","html_url":"https://github.com/travisdowns/bimodal-performance/issues/4#issuecomment-446302647","issue_url":"https://api.github.com/repos/travisdowns/bimodal-performance/issues/4","id":446302647,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0NjMwMjY0Nw==","user":{"login":"travisdowns","id":2403521,"node_id":"MDQ6VXNlcjI0MDM1MjE=","avatar_url":"https://avatars3.githubusercontent.com/u/2403521?v=4","gravatar_id":"","url":"https://api.github.com/users/travisdowns","html_url":"https://github.com/travisdowns","followers_url":"https://api.github.com/users/travisdowns/followers","following_url":"https://api.github.com/users/travisdowns/following{/other_user}","gists_url":"https://api.github.com/users/travisdowns/gists{/gist_id}","starred_url":"https://api.github.com/users/travisdowns/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/travisdowns/subscriptions","organizations_url":"https://api.github.com/users/travisdowns/orgs","repos_url":"https://api.github.com/users/travisdowns/repos","events_url":"https://api.github.com/users/travisdowns/events{/privacy}","received_events_url":"https://api.github.com/users/travisdowns/received_events","type":"User","site_admin":false},"created_at":"2018-12-11T18:08:30Z","updated_at":"2018-12-11T18:08:30Z","author_association":"OWNER","body":"@karlisolte - interesting finding.\r\n\r\nThe whole thing is weird because those types of things where the offset matters is usually something to do with the front-end decoding, yet this happens both when the loop is in the DSB and when it is in the LSD, and they usually wouldn't both have the same decoding bottleneck/quirk, and also the total number of instructions per cycle is low. So while that part of it smells like a front-end thing, the rest of it does not smell that way."}}
{"actor":{"display_login":"travisdowns"}}