{"action":"created","comment":{"url":"https://api.github.com/repos/apache/incubator-trafodion/pulls/comments/138498166","pull_request_review_id":62301636,"id":138498166,"diff_hunk":"@@ -307,18 +307,38 @@ class ExExeStmtGlobals : public ex_globals\n \n   inline NABoolean grabMemoryQuotaIfAvailable(ULng32 size)\n   { \n+    CliGlobals *cli_globals = GetCliGlobals();\n+    if (cli_globals->isEspProcess())\n+       return cli_globals->grabMemoryQuotaIfAvailable(size);\n     if ( unusedBMOsMemoryQuota_ < size ) return FALSE;\n     unusedBMOsMemoryQuota_ -= size ;\n     return TRUE;\n   }\n \n-  inline void resetMemoryQuota() { unusedBMOsMemoryQuota_ = 0 ; }\n+  inline void resetMemoryQuota() \n+  {\n+    CliGlobals *cli_globals = GetCliGlobals();\n+    if (cli_globals->isEspProcess())\n+       return cli_globals->resetMemoryQuota();\n+    unusedBMOsMemoryQuota_ = 0 ; \n+  }","path":"core/sql/executor/ex_exe_stmt_globals.h","position":19,"original_position":19,"commit_id":"fd3275c8ca90c5ce99690103b4711cbe1164b291","original_commit_id":"fd3275c8ca90c5ce99690103b4711cbe1164b291","user":{"login":"selvaganesang","id":8702996,"avatar_url":"https://avatars1.githubusercontent.com/u/8702996?v=4","gravatar_id":"","url":"https://api.github.com/users/selvaganesang","html_url":"https://github.com/selvaganesang","followers_url":"https://api.github.com/users/selvaganesang/followers","following_url":"https://api.github.com/users/selvaganesang/following{/other_user}","gists_url":"https://api.github.com/users/selvaganesang/gists{/gist_id}","starred_url":"https://api.github.com/users/selvaganesang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/selvaganesang/subscriptions","organizations_url":"https://api.github.com/users/selvaganesang/orgs","repos_url":"https://api.github.com/users/selvaganesang/repos","events_url":"https://api.github.com/users/selvaganesang/events{/privacy}","received_events_url":"https://api.github.com/users/selvaganesang/received_events","type":"User","site_admin":false},"body":"In case of master process the unused memory quota is yielded to others operators within the statement and hence it is stored in statement globals. In case of ESP, the unused memory quota to yielded to operators in other fragments within the process and hence it is stored in the default context.  The part of the code deals with the unused memory quota.\r\n\r\n I am assuming that you want details about the quota assignment itself.  Based on this assumption:\r\n\r\n Each open statement in the master would get its own quota.   If it is non-ESP plan, each BMO operator will be capped to max BMO limit of 1200 MB as opposed to 10240 MB per node. If there are more than one BMO operator in such a plan,  each BMO operator memory quota will be assigned proportionally as per item 14 subjected to min and max limits.\r\n\r\nit is a ESP plan, the memory quota will be assigned as per item 14 subjected to min and max limit. \r\nCurrently,  Trafodion won't assign the instances from a same fragment to a process. It also won't assign the ESP to two different queries either from the same context or different contexts.  Because TDB contains the memory quota assignment per instance, different instances within the same process should work irrespective how the instances are assigned.\r\n\r\nYielding the unused memory quota will work fine as long as the ESP is not shared for different ESPs at the same time.  Currently the ESP is released only when the statement is deallocated.  The   current plan is not to share ESPs when it is multi-threaded. It is just that all the fragments and all the instances within the same fragment  from a query will be hosted in the same process via different threads.\r\n\r\nHence,\r\n1) Yes. Each open statement would get its own quota assignment\r\n2) All ESPs and BMO operator instances memory consumption from a query will be limited by BMO_MEMORY_LIMIT_PER_NODE. However, memory consumption won't be exact amount as specified by this CQD because the memory quota assignment is subjected to min and max limits.\r\n3) ESPs are not shared currently.  There is no plan to share in the multi-threaded ESP environment also.\r\n4) . Each statement will have its own quota irrespective of the context to which its belongs","created_at":"2017-09-13T00:14:06Z","updated_at":"2017-09-13T00:14:06Z","html_url":"https://github.com/apache/incubator-trafodion/pull/1228#discussion_r138498166","pull_request_url":"https://api.github.com/repos/apache/incubator-trafodion/pulls/1228","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-trafodion/pulls/comments/138498166"},"html":{"href":"https://github.com/apache/incubator-trafodion/pull/1228#discussion_r138498166"},"pull_request":{"href":"https://api.github.com/repos/apache/incubator-trafodion/pulls/1228"}},"in_reply_to_id":138429018},"pull_request":{"url":"https://api.github.com/repos/apache/incubator-trafodion/pulls/1228","id":140151168,"html_url":"https://github.com/apache/incubator-trafodion/pull/1228","diff_url":"https://github.com/apache/incubator-trafodion/pull/1228.diff","patch_url":"https://github.com/apache/incubator-trafodion/pull/1228.patch","issue_url":"https://api.github.com/repos/apache/incubator-trafodion/issues/1228","number":1228,"state":"open","locked":false,"title":"[TRAFODION-2733]  Provide an improved memory quota assignment for big memory operators (BMO)","user":{"login":"selvaganesang","id":8702996,"avatar_url":"https://avatars1.githubusercontent.com/u/8702996?v=4","gravatar_id":"","url":"https://api.github.com/users/selvaganesang","html_url":"https://github.com/selvaganesang","followers_url":"https://api.github.com/users/selvaganesang/followers","following_url":"https://api.github.com/users/selvaganesang/following{/other_user}","gists_url":"https://api.github.com/users/selvaganesang/gists{/gist_id}","starred_url":"https://api.github.com/users/selvaganesang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/selvaganesang/subscriptions","organizations_url":"https://api.github.com/users/selvaganesang/orgs","repos_url":"https://api.github.com/users/selvaganesang/repos","events_url":"https://api.github.com/users/selvaganesang/events{/privacy}","received_events_url":"https://api.github.com/users/selvaganesang/received_events","type":"User","site_admin":false},"body":"1) Enabled memory quota per node. The CQD BMO_MEMORY_LIMIT_PER_NODE\r\n(renamed from EXE_MEMORY_LIMIT_PER_CPU) is set to 10240 MB by default.\r\n\r\nOld attribute | Old value | Renamed Attribute | New value\r\n-- | -- | -- | --\r\nEXE_MEMORY_LIMIT_PER_CPU | 0 | BMO_MEMORY_LIMIT_PER_NODE | 10240\r\nEXE_MEMORY_LIMIT_LOWER_BOUND_HASHGROUPBY | 10 | BMO_MEMORY_LIMIT_LOWER_BOUND_HASHGROUPBY | 25\r\nEXE_MEMORY_LIMIT_LOWER_BOUND_HASHJOIN | 10 | BMO_MEMORY_LIMIT_LOWER_BOUND_HASHJOIN | 25\r\nEXE_MEMORY_LIMIT_LOWER_BOUND_PROBE_CACHE | 10 | BMO_MEMORY_LIMIT_LOWER_BOUND_PROBE_CACHE | 25\r\nEXE_MEMORY_LIMIT_LOWER_BOUND_SORT | 10 | BMO_MEMORY_LIMIT_LOWER_BOU\r\n\r\n\r\n2) Changes in EXPLAIN\r\nEstimated memory per node for all BMOs at ROOT operator\r\nEstimated memory per instance for every BMO operator\r\nMemory quota per instance for every BMO operator\r\n3) BMO TDB contains the memory quota per esp instance now.\r\n4) Root TDB now contains the limit per node and estimated memory per node.\r\nThis can be used by WMS to change the memory allocation during\r\nruntime without compilation. - Not yet implemented.\r\n5) Added a CQD BMO_MEMORY_LIMIT_UPPER_BOUND to cap the memory\r\nconsumed by BMO by the same queries with less number of\r\nbmos.\r\n6) The unused memory quota is yielded to other fragments in the process\r\nalso.\r\n7) Removed the code to limit the ESPs from being assigned to a fragment\r\nbased on the BMO memory quota.\r\n8) Added a new CQD BMO_MEMORY_ESTIMATE_RATIO_CAP to cap the memory\r\nestimate skew by any one BMO operator to 0.7.\r\n9) To disable the memory quota per node, set BMO_MEMORY_LIMIT_PER_NODE to 0.\r\n10) This memory quota is distributed proportionally based on the estimated memory\r\ntaking into consideration the number of bmo instances per operator and\r\nthe number of nodes available in the cluster to host these instances.\r\nHence, this memory quota should be valid in multi-fragments independent of the\r\nnumber of fragments in an ESP.\r\n10) Removed the CQD EXE_MEMORY_LIMIT_NONBMOS_PERCENT and EXE_MEMORY_RESERVED_FOR_MXOSRVR_IN_MB\r\n11) Fixed BMO stats WM to be at least the allocated memory.\r\n12) Changed the sort operator to account the bmo memory correctly.\r\n13)  Introduced a new CQD BMO_MEMORY_EQUAL_QUOTA_SHARE_RATIO\r\nto determine how much of BMO_MEMORY_LIMITE_PER_NODE is divided equally between\r\nBMO operators and the rest would depend upon the memory estimate. This ratio is set\r\nto 0.5 by default. Changing it to 0 will divide the memory quota proportional to the memory estimate of the BMO operator. This change is needed to get better BMO quota allocation when the memory estimate goes awry for certain types of query.\r\n","created_at":"2017-09-09T01:46:19Z","updated_at":"2017-09-13T00:14:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a7a433e633b7c3b7717e771c7f13ab3dd3285fa6","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/incubator-trafodion/pulls/1228/commits","review_comments_url":"https://api.github.com/repos/apache/incubator-trafodion/pulls/1228/comments","review_comment_url":"https://api.github.com/repos/apache/incubator-trafodion/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/incubator-trafodion/issues/1228/comments","statuses_url":"https://api.github.com/repos/apache/incubator-trafodion/statuses/fd3275c8ca90c5ce99690103b4711cbe1164b291","head":{"label":"selvaganesang:bmo_memory_quota","ref":"bmo_memory_quota","sha":"fd3275c8ca90c5ce99690103b4711cbe1164b291","user":{"login":"selvaganesang","id":8702996,"avatar_url":"https://avatars1.githubusercontent.com/u/8702996?v=4","gravatar_id":"","url":"https://api.github.com/users/selvaganesang","html_url":"https://github.com/selvaganesang","followers_url":"https://api.github.com/users/selvaganesang/followers","following_url":"https://api.github.com/users/selvaganesang/following{/other_user}","gists_url":"https://api.github.com/users/selvaganesang/gists{/gist_id}","starred_url":"https://api.github.com/users/selvaganesang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/selvaganesang/subscriptions","organizations_url":"https://api.github.com/users/selvaganesang/orgs","repos_url":"https://api.github.com/users/selvaganesang/repos","events_url":"https://api.github.com/users/selvaganesang/events{/privacy}","received_events_url":"https://api.github.com/users/selvaganesang/received_events","type":"User","site_admin":false},"repo":{"id":37948798,"name":"incubator-trafodion","full_name":"selvaganesang/incubator-trafodion","owner":{"login":"selvaganesang","id":8702996,"avatar_url":"https://avatars1.githubusercontent.com/u/8702996?v=4","gravatar_id":"","url":"https://api.github.com/users/selvaganesang","html_url":"https://github.com/selvaganesang","followers_url":"https://api.github.com/users/selvaganesang/followers","following_url":"https://api.github.com/users/selvaganesang/following{/other_user}","gists_url":"https://api.github.com/users/selvaganesang/gists{/gist_id}","starred_url":"https://api.github.com/users/selvaganesang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/selvaganesang/subscriptions","organizations_url":"https://api.github.com/users/selvaganesang/orgs","repos_url":"https://api.github.com/users/selvaganesang/repos","events_url":"https://api.github.com/users/selvaganesang/events{/privacy}","received_events_url":"https://api.github.com/users/selvaganesang/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/selvaganesang/incubator-trafodion","description":"Mirror of Apache Trafodion (Incubating)","fork":true,"url":"https://api.github.com/repos/selvaganesang/incubator-trafodion","forks_url":"https://api.github.com/repos/selvaganesang/incubator-trafodion/forks","keys_url":"https://api.github.com/repos/selvaganesang/incubator-trafodion/keys{/key_id}","collaborators_url":"https://api.github.com/repos/selvaganesang/incubator-trafodion/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/selvaganesang/incubator-trafodion/teams","hooks_url":"https://api.github.com/repos/selvaganesang/incubator-trafodion/hooks","issue_events_url":"https://api.github.com/repos/selvaganesang/incubator-trafodion/issues/events{/number}","events_url":"https://api.github.com/repos/selvaganesang/incubator-trafodion/events","assignees_url":"https://api.github.com/repos/selvaganesang/incubator-trafodion/assignees{/user}","branches_url":"https://api.github.com/repos/selvaganesang/incubator-trafodion/branches{/branch}","tags_url":"https://api.github.com/repos/selvaganesang/incubator-trafodion/tags","blobs_url":"https://api.github.com/repos/selvaganesang/incubator-trafodion/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/selvaganesang/incubator-trafodion/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/selvaganesang/incubator-trafodion/git/refs{/sha}","trees_url":"https://api.github.com/repos/selvaganesang/incubator-trafodion/git/trees{/sha}","statuses_url":"https://api.github.com/repos/selvaganesang/incubator-trafodion/statuses/{sha}","languages_url":"https://api.github.com/repos/selvaganesang/incubator-trafodion/languages","stargazers_url":"https://api.github.com/repos/selvaganesang/incubator-trafodion/stargazers","contributors_url":"https://api.github.com/repos/selvaganesang/incubator-trafodion/contributors","subscribers_url":"https://api.github.com/repos/selvaganesang/incubator-trafodion/subscribers","subscription_url":"https://api.github.com/repos/selvaganesang/incubator-trafodion/subscription","commits_url":"https://api.github.com/repos/selvaganesang/incubator-trafodion/commits{/sha}","git_commits_url":"https://api.github.com/repos/selvaganesang/incubator-trafodion/git/commits{/sha}","comments_url":"https://api.github.com/repos/selvaganesang/incubator-trafodion/comments{/number}","issue_comment_url":"https://api.github.com/repos/selvaganesang/incubator-trafodion/issues/comments{/number}","contents_url":"https://api.github.com/repos/selvaganesang/incubator-trafodion/contents/{+path}","compare_url":"https://api.github.com/repos/selvaganesang/incubator-trafodion/compare/{base}...{head}","merges_url":"https://api.github.com/repos/selvaganesang/incubator-trafodion/merges","archive_url":"https://api.github.com/repos/selvaganesang/incubator-trafodion/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/selvaganesang/incubator-trafodion/downloads","issues_url":"https://api.github.com/repos/selvaganesang/incubator-trafodion/issues{/number}","pulls_url":"https://api.github.com/repos/selvaganesang/incubator-trafodion/pulls{/number}","milestones_url":"https://api.github.com/repos/selvaganesang/incubator-trafodion/milestones{/number}","notifications_url":"https://api.github.com/repos/selvaganesang/incubator-trafodion/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/selvaganesang/incubator-trafodion/labels{/name}","releases_url":"https://api.github.com/repos/selvaganesang/incubator-trafodion/releases{/id}","deployments_url":"https://api.github.com/repos/selvaganesang/incubator-trafodion/deployments","created_at":"2015-06-23T22:34:16Z","updated_at":"2016-04-04T17:45:10Z","pushed_at":"2017-09-09T04:31:51Z","git_url":"git://github.com/selvaganesang/incubator-trafodion.git","ssh_url":"git@github.com:selvaganesang/incubator-trafodion.git","clone_url":"https://github.com/selvaganesang/incubator-trafodion.git","svn_url":"https://github.com/selvaganesang/incubator-trafodion","homepage":null,"size":82196,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"b62e577019cba518eb7416b56814eecbb602ed16","user":{"login":"apache","id":47359,"avatar_url":"https://avatars0.githubusercontent.com/u/47359?v=4","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":36349344,"name":"incubator-trafodion","full_name":"apache/incubator-trafodion","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars0.githubusercontent.com/u/47359?v=4","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/incubator-trafodion","description":"Mirror of Apache Trafodion (Incubating)","fork":false,"url":"https://api.github.com/repos/apache/incubator-trafodion","forks_url":"https://api.github.com/repos/apache/incubator-trafodion/forks","keys_url":"https://api.github.com/repos/apache/incubator-trafodion/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/incubator-trafodion/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/incubator-trafodion/teams","hooks_url":"https://api.github.com/repos/apache/incubator-trafodion/hooks","issue_events_url":"https://api.github.com/repos/apache/incubator-trafodion/issues/events{/number}","events_url":"https://api.github.com/repos/apache/incubator-trafodion/events","assignees_url":"https://api.github.com/repos/apache/incubator-trafodion/assignees{/user}","branches_url":"https://api.github.com/repos/apache/incubator-trafodion/branches{/branch}","tags_url":"https://api.github.com/repos/apache/incubator-trafodion/tags","blobs_url":"https://api.github.com/repos/apache/incubator-trafodion/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/incubator-trafodion/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/incubator-trafodion/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/incubator-trafodion/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/incubator-trafodion/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/incubator-trafodion/languages","stargazers_url":"https://api.github.com/repos/apache/incubator-trafodion/stargazers","contributors_url":"https://api.github.com/repos/apache/incubator-trafodion/contributors","subscribers_url":"https://api.github.com/repos/apache/incubator-trafodion/subscribers","subscription_url":"https://api.github.com/repos/apache/incubator-trafodion/subscription","commits_url":"https://api.github.com/repos/apache/incubator-trafodion/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/incubator-trafodion/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/incubator-trafodion/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/incubator-trafodion/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/incubator-trafodion/contents/{+path}","compare_url":"https://api.github.com/repos/apache/incubator-trafodion/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/incubator-trafodion/merges","archive_url":"https://api.github.com/repos/apache/incubator-trafodion/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/incubator-trafodion/downloads","issues_url":"https://api.github.com/repos/apache/incubator-trafodion/issues{/number}","pulls_url":"https://api.github.com/repos/apache/incubator-trafodion/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/incubator-trafodion/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/incubator-trafodion/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/incubator-trafodion/labels{/name}","releases_url":"https://api.github.com/repos/apache/incubator-trafodion/releases{/id}","deployments_url":"https://api.github.com/repos/apache/incubator-trafodion/deployments","created_at":"2015-05-27T07:00:05Z","updated_at":"2017-08-31T15:41:57Z","pushed_at":"2017-09-12T17:52:34Z","git_url":"git://github.com/apache/incubator-trafodion.git","ssh_url":"git@github.com:apache/incubator-trafodion.git","clone_url":"https://github.com/apache/incubator-trafodion.git","svn_url":"https://github.com/apache/incubator-trafodion","homepage":null,"size":82130,"stargazers_count":113,"watchers_count":113,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":96,"mirror_url":"git://git.apache.org/incubator-trafodion.git","open_issues_count":6,"forks":96,"open_issues":6,"watchers":113,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-trafodion/pulls/1228"},"html":{"href":"https://github.com/apache/incubator-trafodion/pull/1228"},"issue":{"href":"https://api.github.com/repos/apache/incubator-trafodion/issues/1228"},"comments":{"href":"https://api.github.com/repos/apache/incubator-trafodion/issues/1228/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/incubator-trafodion/pulls/1228/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/incubator-trafodion/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/incubator-trafodion/pulls/1228/commits"},"statuses":{"href":"https://api.github.com/repos/apache/incubator-trafodion/statuses/fd3275c8ca90c5ce99690103b4711cbe1164b291"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"selvaganesang"}}