{"action":"created","issue":{"url":"https://api.github.com/repos/cms-sw/cmssw/issues/9066","labels_url":"https://api.github.com/repos/cms-sw/cmssw/issues/9066/labels{/name}","comments_url":"https://api.github.com/repos/cms-sw/cmssw/issues/9066/comments","events_url":"https://api.github.com/repos/cms-sw/cmssw/issues/9066/events","html_url":"https://github.com/cms-sw/cmssw/pull/9066","id":75817869,"number":9066,"title":"Do less cloning of TH1 objects in the DQMStore.","user":{"login":"dmitrijus","id":151853,"avatar_url":"https://avatars.githubusercontent.com/u/151853?v=3","gravatar_id":"","url":"https://api.github.com/users/dmitrijus","html_url":"https://github.com/dmitrijus","followers_url":"https://api.github.com/users/dmitrijus/followers","following_url":"https://api.github.com/users/dmitrijus/following{/other_user}","gists_url":"https://api.github.com/users/dmitrijus/gists{/gist_id}","starred_url":"https://api.github.com/users/dmitrijus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmitrijus/subscriptions","organizations_url":"https://api.github.com/users/dmitrijus/orgs","repos_url":"https://api.github.com/users/dmitrijus/repos","events_url":"https://api.github.com/users/dmitrijus/events{/privacy}","received_events_url":"https://api.github.com/users/dmitrijus/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/cms-sw/cmssw/labels/comparison-available","name":"comparison-available","color":"009800"},{"url":"https://api.github.com/repos/cms-sw/cmssw/labels/dqm-approved","name":"dqm-approved","color":"009800"},{"url":"https://api.github.com/repos/cms-sw/cmssw/labels/fully-signed","name":"fully-signed","color":"009800"},{"url":"https://api.github.com/repos/cms-sw/cmssw/labels/orp-pending","name":"orp-pending","color":"fbca04"},{"url":"https://api.github.com/repos/cms-sw/cmssw/labels/tests-approved","name":"tests-approved","color":"009800"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/cms-sw/cmssw/milestones/51","html_url":"https://github.com/cms-sw/cmssw/milestones/Next%20CMSSW_7_5_X","labels_url":"https://api.github.com/repos/cms-sw/cmssw/milestones/51/labels","id":982516,"number":51,"title":"Next CMSSW_7_5_X","description":"","creator":{"login":"nclopezo","id":1944922,"avatar_url":"https://avatars.githubusercontent.com/u/1944922?v=3","gravatar_id":"","url":"https://api.github.com/users/nclopezo","html_url":"https://github.com/nclopezo","followers_url":"https://api.github.com/users/nclopezo/followers","following_url":"https://api.github.com/users/nclopezo/following{/other_user}","gists_url":"https://api.github.com/users/nclopezo/gists{/gist_id}","starred_url":"https://api.github.com/users/nclopezo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nclopezo/subscriptions","organizations_url":"https://api.github.com/users/nclopezo/orgs","repos_url":"https://api.github.com/users/nclopezo/repos","events_url":"https://api.github.com/users/nclopezo/events{/privacy}","received_events_url":"https://api.github.com/users/nclopezo/received_events","type":"User","site_admin":false},"open_issues":76,"closed_issues":601,"state":"open","created_at":"2015-02-17T08:21:25Z","updated_at":"2015-05-19T13:38:44Z","due_on":"2015-03-02T23:00:00Z","closed_at":null},"comments":10,"created_at":"2015-05-13T02:40:29Z","updated_at":"2015-05-19T13:47:32Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/cms-sw/cmssw/pulls/9066","html_url":"https://github.com/cms-sw/cmssw/pull/9066","diff_url":"https://github.com/cms-sw/cmssw/pull/9066.diff","patch_url":"https://github.com/cms-sw/cmssw/pull/9066.patch"},"body":"Previously, DQMStore would implicitly create a number of TH1 copies:\r\n```\r\n  func DQMStore::mergeAndResetMEsRunSummaryCache:\r\n    ...\r\n    MonitorElement global_me(*i); <- constructor makes an internal copy of th1 (fixed: 1)\r\n    global_me.globalize()\r\n    ...\r\n    gme = data_.insert(global_me) <- insert calls the same copy constructor (fixed: 2)\r\n```\r\n  global_me is used as a key (in a set) to find an actual object to work on.\r\n  It is not used outside that and once the actual object is found,\r\n  global_me is just left to be destroyed at the end of the loop.\r\n\r\n  This is not a leak, but the TH1::Clone is just useless,\r\n  since the key comparison does not depend on it.\r\n\r\nSo I've implemented:\r\n\r\n1. Special tagged constructor which does not clone the internal th1 object,\r\nand just sets it to nullptr (perfect for searching in a set).\r\n\r\n2. Special move constructor which will move the TH1 object.\r\nThe old object will have TH1 unset.\r\nThis makes std::set::insert not to make a clone of TH1 internally\r\nwhen inserting a transient (on the stack) object.\r\n\r\n3. Disabled the assignment operator to avoid confusion/complexity.\r\nIt was never actually used and move-constructor is complex enough already.\r\n\r\nResult: running 25.0 (with 1000 events) on 8 threads:\r\n - ~300mb less memory (peak rss)\r\n - 60s faster (5%)\r\n\r\nThe code runs at end of the job, so in theory, the number of events does not matter.\r\nOnly the number of streams used (it shouldn't improve anything on a single stream job).\r\n\r\nPlease test before accepting, I am not that familiar with all the newest c++ stuff.\r\nI will also ask someone to review the code today.\r\n\r\nDmitrijus"},"comment":{"url":"https://api.github.com/repos/cms-sw/cmssw/issues/comments/103501050","html_url":"https://github.com/cms-sw/cmssw/pull/9066#issuecomment-103501050","issue_url":"https://api.github.com/repos/cms-sw/cmssw/issues/9066","id":103501050,"user":{"login":"cmsbuild","id":4170616,"avatar_url":"https://avatars.githubusercontent.com/u/4170616?v=3","gravatar_id":"","url":"https://api.github.com/users/cmsbuild","html_url":"https://github.com/cmsbuild","followers_url":"https://api.github.com/users/cmsbuild/followers","following_url":"https://api.github.com/users/cmsbuild/following{/other_user}","gists_url":"https://api.github.com/users/cmsbuild/gists{/gist_id}","starred_url":"https://api.github.com/users/cmsbuild/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cmsbuild/subscriptions","organizations_url":"https://api.github.com/users/cmsbuild/orgs","repos_url":"https://api.github.com/users/cmsbuild/repos","events_url":"https://api.github.com/users/cmsbuild/events{/privacy}","received_events_url":"https://api.github.com/users/cmsbuild/received_events","type":"User","site_admin":false},"created_at":"2015-05-19T13:47:32Z","updated_at":"2015-05-19T13:47:32Z","body":"This pull request is fully signed and it will be integrated in one of the next CMSSW_7_5_X IBs unless changes (tests are also fine). This pull request requires discussion in the ORP meeting before it's merged. @davidlange6, @nclopezo, @smuzaffar"}}