{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/13842","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/13842/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/13842/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/13842/events","html_url":"https://github.com/rust-lang/rust/issues/13842","id":32447448,"number":13842,"title":"Static regexes are very slow to create","user":{"login":"huonw","id":1203825,"avatar_url":"https://avatars.githubusercontent.com/u/1203825?v=3","gravatar_id":"","url":"https://api.github.com/users/huonw","html_url":"https://github.com/huonw","followers_url":"https://api.github.com/users/huonw/followers","following_url":"https://api.github.com/users/huonw/following{/other_user}","gists_url":"https://api.github.com/users/huonw/gists{/gist_id}","starred_url":"https://api.github.com/users/huonw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/huonw/subscriptions","organizations_url":"https://api.github.com/users/huonw/orgs","repos_url":"https://api.github.com/users/huonw/repos","events_url":"https://api.github.com/users/huonw/events{/privacy}","received_events_url":"https://api.github.com/users/huonw/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rust-lang/rust/labels/I-compiletime","name":"I-compiletime","color":"e11d21"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2014-04-29T14:00:08Z","updated_at":"2015-06-19T19:13:46Z","closed_at":null,"body":"```rust\r\n#![feature(phase)]\r\n#![allow(dead_code)]\r\n\r\n#[phase(syntax)] extern crate regex_macros;\r\nextern crate regex;\r\n\r\n#[cfg(short)]\r\nfn short() {\r\n    regex!(\"a\");\r\n}\r\n\r\n#[cfg(medium)]\r\nfn medium() {\r\n    // 500\r\n    regex!(\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\");\r\n}\r\n\r\nfn main() {}\r\n```\r\n\r\n```\r\n$ for x in short medium long; do echo $x; time rustc regex.rs --cfg $x --no-trans; done\r\nshort\r\n\r\nreal    0m0.102s\r\nuser    0m0.092s\r\nsys     0m0.012s\r\nmedium\r\n\r\nreal    0m1.384s\r\nuser    0m1.332s\r\nsys     0m0.048s\r\nlong\r\n\r\nreal    0m3.612s\r\nuser    0m3.508s\r\nsys     0m0.104s\r\n```\r\n\r\nThey don't take nearly this long to just compile as dynamic ones, so I would guess it's the extra work that the generating macro is doing. (Note the `--no-trans` there, so it isn't just the extra code making LLVM slow.)\r\n\r\nA perf trace identifies `rustc  librustc-4283bb68-0.11-pre.so         [.] hashmap::HashMap$LT$K$C$$x20V$C$$x20H$GT$::search::h14555543045583792107::v0.11.pre` as taking a lot (10.18%) of time."},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/113610925","html_url":"https://github.com/rust-lang/rust/issues/13842#issuecomment-113610925","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/13842","id":113610925,"user":{"login":"BurntSushi","id":456674,"avatar_url":"https://avatars.githubusercontent.com/u/456674?v=3","gravatar_id":"","url":"https://api.github.com/users/BurntSushi","html_url":"https://github.com/BurntSushi","followers_url":"https://api.github.com/users/BurntSushi/followers","following_url":"https://api.github.com/users/BurntSushi/following{/other_user}","gists_url":"https://api.github.com/users/BurntSushi/gists{/gist_id}","starred_url":"https://api.github.com/users/BurntSushi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BurntSushi/subscriptions","organizations_url":"https://api.github.com/users/BurntSushi/orgs","repos_url":"https://api.github.com/users/BurntSushi/repos","events_url":"https://api.github.com/users/BurntSushi/events{/privacy}","received_events_url":"https://api.github.com/users/BurntSushi/received_events","type":"User","site_admin":false},"created_at":"2015-06-19T19:13:46Z","updated_at":"2015-06-19T19:13:46Z","body":"I'm re-opening this after it was moved to rust-lang/regex because I think it is predominantly related to compile times of lots of code.\r\n\r\nWith that said, I'm also leaving this issue open in rust-lang/regex because the macro should probably generate a lot less code than it does today."}}