GitHub PullRequestReviewCommentEvent at 2014-08-27 06:36:09
Repository: akka
Actor: patriknw
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/akka/akka/pulls/comments/16759628","id":16759628,"diff_hunk":"@@ -104,33 +178,67 @@ object MaterializerSettings {\n  *\n  * This will likely be replaced in the future by auto-tuning these values at runtime.\n  */\n-case class MaterializerSettings(\n-  initialFanOutBufferSize: Int = 4,\n-  maxFanOutBufferSize: Int = 16,\n-  initialInputBufferSize: Int = 4,\n-  maximumInputBufferSize: Int = 16,\n-  dispatcher: String = Deploy.NoDispatcherGiven) {\n+class MaterializerSettings(cfg: Config) {\n+\n+  private final val MaterializerSettingsConfigPrefix = \"akka.stream.materializer-settings\"\n+\n+  private val config: Config = {\n+    val reference = ConfigFactory.defaultReference\n+    val config = cfg.withFallback(reference)\n+    config.checkValid(reference, MaterializerSettingsConfigPrefix)\n+    config.getConfig(MaterializerSettingsConfigPrefix)\n+  }\n+\n+  final val initialInputBufferSize: Int = try {\n+    config.getInt(\"initial-input-buffer-size\")\n+  } catch {\n+    case ex: Exception ⇒\n+      import collection.JavaConversions._\n+      println(\"config.entrySet().map(_.getKey) = \" + config.entrySet().map(_.getKey))\n+      throw ex\n+  }\n+  final val maxInputBufferSize: Int = config.getInt(\"maximum-input-buffer-size\")\n+\n+  final val initialFanOutBufferSize: Int = config.getInt(\"initial-fan-out-buffer-size\")\n+  final val maxFanOutBufferSize: Int = config.getInt(\"max-fan-out-buffer-size\")\n+\n+  final val dispatcher: String = config.getString(\"dispatcher\")\n \n-  private def isPowerOfTwo(n: Integer): Boolean = (n & (n - 1)) == 0\n   require(initialFanOutBufferSize > 0, \"initialFanOutBufferSize must be > 0\")\n   require(maxFanOutBufferSize > 0, \"maxFanOutBufferSize must be > 0\")\n+\n   require(initialFanOutBufferSize <= maxFanOutBufferSize,\n     s\"initialFanOutBufferSize($initialFanOutBufferSize) must be <= maxFanOutBufferSize($maxFanOutBufferSize)\")\n \n   require(initialInputBufferSize > 0, \"initialInputBufferSize must be > 0\")\n   require(isPowerOfTwo(initialInputBufferSize), \"initialInputBufferSize must be a power of two\")\n-  require(maximumInputBufferSize > 0, \"maximumInputBufferSize must be > 0\")\n-  require(isPowerOfTwo(maximumInputBufferSize), \"initialInputBufferSize must be a power of two\")\n-  require(initialInputBufferSize <= maximumInputBufferSize,\n-    s\"initialInputBufferSize($initialInputBufferSize) must be <= maximumInputBufferSize($maximumInputBufferSize)\")\n \n-  def withBuffer(initialInputBufferSize: Int, maximumInputBufferSize: Int): MaterializerSettings =\n-    copy(initialInputBufferSize = initialInputBufferSize, maximumInputBufferSize = maximumInputBufferSize)\n+  require(maxInputBufferSize > 0, \"maximumInputBufferSize must be > 0\")\n+  require(isPowerOfTwo(maxInputBufferSize), \"initialInputBufferSize must be a power of two\")\n \n-  def withFanOut(initialFanOutBufferSize: Int, maxFanOutBufferSize: Int): MaterializerSettings =\n-    copy(initialFanOutBufferSize = initialFanOutBufferSize, maxFanOutBufferSize = maxFanOutBufferSize)\n+  require(initialInputBufferSize <= maxInputBufferSize,\n+    s\"initialInputBufferSize($initialInputBufferSize) must be <= maximumInputBufferSize($maxInputBufferSize)\")\n \n-  def withDispatcher(dispatcher: String): MaterializerSettings = copy(dispatcher = dispatcher)\n+  def withInputBuffer(initialInputBufferSize: Int, maximumInputBufferSize: Int): MaterializerSettings = {\n+    val overrides = new ju.HashMap[String, Any](2)\n+    overrides.put(s\"$MaterializerSettingsConfigPrefix.initial-input-buffer-size\", initialInputBufferSize)\n+    overrides.put(s\"$MaterializerSettingsConfigPrefix.maximum-input-buffer-size\", maximumInputBufferSize)\n+    new MaterializerSettings(ConfigFactory.parseMap(overrides.asInstanceOf[ju.Map[String, AnyRef]], \"withBuffer\").withFallback(cfg))","path":"akka-stream/src/main/scala/akka/stream/FlowMaterializer.scala","position":219,"original_position":219,"commit_id":"7c1eec0af1d4dae7aa747800ee34e533ef6d2e01","original_commit_id":"7c1eec0af1d4dae7aa747800ee34e533ef6d2e01","user":{"login":"patriknw","id":336161,"avatar_url":"https://avatars.githubusercontent.com/u/336161?v=2","gravatar_id":"a036dbdf494ae4c9d46e1d24b53fd5da","url":"https://api.github.com/users/patriknw","html_url":"https://github.com/patriknw","followers_url":"https://api.github.com/users/patriknw/followers","following_url":"https://api.github.com/users/patriknw/following{/other_user}","gists_url":"https://api.github.com/users/patriknw/gists{/gist_id}","starred_url":"https://api.github.com/users/patriknw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/patriknw/subscriptions","organizations_url":"https://api.github.com/users/patriknw/orgs","repos_url":"https://api.github.com/users/patriknw/repos","events_url":"https://api.github.com/users/patriknw/events{/privacy}","received_events_url":"https://api.github.com/users/patriknw/received_events","type":"User","site_admin":false},"body":"I don't interpret his comment as that. We can talk about it.\r\nThis approach of building new setting instance by creating new config feels backwards (and is very performance costly).","created_at":"2014-08-27T06:36:09Z","updated_at":"2014-08-27T06:36:09Z","html_url":"https://github.com/akka/akka/pull/15759#discussion_r16759628","pull_request_url":"https://api.github.com/repos/akka/akka/pulls/15759","_links":{"self":{"href":"https://api.github.com/repos/akka/akka/pulls/comments/16759628"},"html":{"href":"https://github.com/akka/akka/pull/15759#discussion_r16759628"},"pull_request":{"href":"https://api.github.com/repos/akka/akka/pulls/15759"}}},"pull_request":{"url":"https://api.github.com/repos/akka/akka/pulls/15759","id":20303147,"html_url":"https://github.com/akka/akka/pull/15759","diff_url":"https://github.com/akka/akka/pull/15759.diff","patch_url":"https://github.com/akka/akka/pull/15759.patch","issue_url":"https://api.github.com/repos/akka/akka/issues/15759","number":15759,"state":"open","locked":false,"title":"!str #15121 MaterializerSettings now uses a config object","user":{"login":"ktoso","id":120979,"avatar_url":"https://avatars.githubusercontent.com/u/120979?v=2","gravatar_id":"03cb20b97f6a14701c24c4e088b6af87","url":"https://api.github.com/users/ktoso","html_url":"https://github.com/ktoso","followers_url":"https://api.github.com/users/ktoso/followers","following_url":"https://api.github.com/users/ktoso/following{/other_user}","gists_url":"https://api.github.com/users/ktoso/gists{/gist_id}","starred_url":"https://api.github.com/users/ktoso/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ktoso/subscriptions","organizations_url":"https://api.github.com/users/ktoso/orgs","repos_url":"https://api.github.com/users/ktoso/repos","events_url":"https://api.github.com/users/ktoso/events{/privacy}","received_events_url":"https://api.github.com/users/ktoso/received_events","type":"User","site_admin":false},"body":"* it's now easier to create a FlowMaterializer(), which will use the default (see akka-streams/.../reference.conf) configuration\r\n* kept methods to easily overload some values of the settings (used to be done via copy())\r\n* made some apply() duplication trade-offs in FlowMaterializer companion for nicer API\r\n* made it possible to set namePrefix from Java API\r\n\r\nResolves #15121","created_at":"2014-08-26T11:46:30Z","updated_at":"2014-08-27T06:36:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c2130802bf5a2eadd22ba2e94acfaa3848eaec47","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/akka/akka/pulls/15759/commits","review_comments_url":"https://api.github.com/repos/akka/akka/pulls/15759/comments","review_comment_url":"https://api.github.com/repos/akka/akka/pulls/comments/{number}","comments_url":"https://api.github.com/repos/akka/akka/issues/15759/comments","statuses_url":"https://api.github.com/repos/akka/akka/statuses/7c1eec0af1d4dae7aa747800ee34e533ef6d2e01","head":{"label":"ktoso:wip-reduce-weight-flow-materializer-ktoso","ref":"wip-reduce-weight-flow-materializer-ktoso","sha":"7c1eec0af1d4dae7aa747800ee34e533ef6d2e01","user":{"login":"ktoso","id":120979,"avatar_url":"https://avatars.githubusercontent.com/u/120979?v=2","gravatar_id":"03cb20b97f6a14701c24c4e088b6af87","url":"https://api.github.com/users/ktoso","html_url":"https://github.com/ktoso","followers_url":"https://api.github.com/users/ktoso/followers","following_url":"https://api.github.com/users/ktoso/following{/other_user}","gists_url":"https://api.github.com/users/ktoso/gists{/gist_id}","starred_url":"https://api.github.com/users/ktoso/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ktoso/subscriptions","organizations_url":"https://api.github.com/users/ktoso/orgs","repos_url":"https://api.github.com/users/ktoso/repos","events_url":"https://api.github.com/users/ktoso/events{/privacy}","received_events_url":"https://api.github.com/users/ktoso/received_events","type":"User","site_admin":false},"repo":{"id":4462204,"name":"akka","full_name":"ktoso/akka","owner":{"login":"ktoso","id":120979,"avatar_url":"https://avatars.githubusercontent.com/u/120979?v=2","gravatar_id":"03cb20b97f6a14701c24c4e088b6af87","url":"https://api.github.com/users/ktoso","html_url":"https://github.com/ktoso","followers_url":"https://api.github.com/users/ktoso/followers","following_url":"https://api.github.com/users/ktoso/following{/other_user}","gists_url":"https://api.github.com/users/ktoso/gists{/gist_id}","starred_url":"https://api.github.com/users/ktoso/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ktoso/subscriptions","organizations_url":"https://api.github.com/users/ktoso/orgs","repos_url":"https://api.github.com/users/ktoso/repos","events_url":"https://api.github.com/users/ktoso/events{/privacy}","received_events_url":"https://api.github.com/users/ktoso/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ktoso/akka","description":"Akka Project","fork":true,"url":"https://api.github.com/repos/ktoso/akka","forks_url":"https://api.github.com/repos/ktoso/akka/forks","keys_url":"https://api.github.com/repos/ktoso/akka/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ktoso/akka/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ktoso/akka/teams","hooks_url":"https://api.github.com/repos/ktoso/akka/hooks","issue_events_url":"https://api.github.com/repos/ktoso/akka/issues/events{/number}","events_url":"https://api.github.com/repos/ktoso/akka/events","assignees_url":"https://api.github.com/repos/ktoso/akka/assignees{/user}","branches_url":"https://api.github.com/repos/ktoso/akka/branches{/branch}","tags_url":"https://api.github.com/repos/ktoso/akka/tags","blobs_url":"https://api.github.com/repos/ktoso/akka/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ktoso/akka/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ktoso/akka/git/refs{/sha}","trees_url":"https://api.github.com/repos/ktoso/akka/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ktoso/akka/statuses/{sha}","languages_url":"https://api.github.com/repos/ktoso/akka/languages","stargazers_url":"https://api.github.com/repos/ktoso/akka/stargazers","contributors_url":"https://api.github.com/repos/ktoso/akka/contributors","subscribers_url":"https://api.github.com/repos/ktoso/akka/subscribers","subscription_url":"https://api.github.com/repos/ktoso/akka/subscription","commits_url":"https://api.github.com/repos/ktoso/akka/commits{/sha}","git_commits_url":"https://api.github.com/repos/ktoso/akka/git/commits{/sha}","comments_url":"https://api.github.com/repos/ktoso/akka/comments{/number}","issue_comment_url":"https://api.github.com/repos/ktoso/akka/issues/comments/{number}","contents_url":"https://api.github.com/repos/ktoso/akka/contents/{+path}","compare_url":"https://api.github.com/repos/ktoso/akka/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ktoso/akka/merges","archive_url":"https://api.github.com/repos/ktoso/akka/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ktoso/akka/downloads","issues_url":"https://api.github.com/repos/ktoso/akka/issues{/number}","pulls_url":"https://api.github.com/repos/ktoso/akka/pulls{/number}","milestones_url":"https://api.github.com/repos/ktoso/akka/milestones{/number}","notifications_url":"https://api.github.com/repos/ktoso/akka/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ktoso/akka/labels{/name}","releases_url":"https://api.github.com/repos/ktoso/akka/releases{/id}","created_at":"2012-05-27T14:05:17Z","updated_at":"2014-07-01T22:22:04Z","pushed_at":"2014-08-26T14:15:38Z","git_url":"git://github.com/ktoso/akka.git","ssh_url":"git@github.com:ktoso/akka.git","clone_url":"https://github.com/ktoso/akka.git","svn_url":"https://github.com/ktoso/akka","homepage":"http://akka.io","size":155318,"stargazers_count":1,"watchers_count":1,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"akka:release-2.3-dev","ref":"release-2.3-dev","sha":"892279e47a94451d961dc92b1928b302ee1b2adc","user":{"login":"akka","id":1496237,"avatar_url":"https://avatars.githubusercontent.com/u/1496237?v=2","gravatar_id":"0ff72320fb1bc5db35ba4fae61614eb0","url":"https://api.github.com/users/akka","html_url":"https://github.com/akka","followers_url":"https://api.github.com/users/akka/followers","following_url":"https://api.github.com/users/akka/following{/other_user}","gists_url":"https://api.github.com/users/akka/gists{/gist_id}","starred_url":"https://api.github.com/users/akka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akka/subscriptions","organizations_url":"https://api.github.com/users/akka/orgs","repos_url":"https://api.github.com/users/akka/repos","events_url":"https://api.github.com/users/akka/events{/privacy}","received_events_url":"https://api.github.com/users/akka/received_events","type":"Organization","site_admin":false},"repo":{"id":130013,"name":"akka","full_name":"akka/akka","owner":{"login":"akka","id":1496237,"avatar_url":"https://avatars.githubusercontent.com/u/1496237?v=2","gravatar_id":"0ff72320fb1bc5db35ba4fae61614eb0","url":"https://api.github.com/users/akka","html_url":"https://github.com/akka","followers_url":"https://api.github.com/users/akka/followers","following_url":"https://api.github.com/users/akka/following{/other_user}","gists_url":"https://api.github.com/users/akka/gists{/gist_id}","starred_url":"https://api.github.com/users/akka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akka/subscriptions","organizations_url":"https://api.github.com/users/akka/orgs","repos_url":"https://api.github.com/users/akka/repos","events_url":"https://api.github.com/users/akka/events{/privacy}","received_events_url":"https://api.github.com/users/akka/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/akka/akka","description":"Akka Project","fork":false,"url":"https://api.github.com/repos/akka/akka","forks_url":"https://api.github.com/repos/akka/akka/forks","keys_url":"https://api.github.com/repos/akka/akka/keys{/key_id}","collaborators_url":"https://api.github.com/repos/akka/akka/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/akka/akka/teams","hooks_url":"https://api.github.com/repos/akka/akka/hooks","issue_events_url":"https://api.github.com/repos/akka/akka/issues/events{/number}","events_url":"https://api.github.com/repos/akka/akka/events","assignees_url":"https://api.github.com/repos/akka/akka/assignees{/user}","branches_url":"https://api.github.com/repos/akka/akka/branches{/branch}","tags_url":"https://api.github.com/repos/akka/akka/tags","blobs_url":"https://api.github.com/repos/akka/akka/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/akka/akka/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/akka/akka/git/refs{/sha}","trees_url":"https://api.github.com/repos/akka/akka/git/trees{/sha}","statuses_url":"https://api.github.com/repos/akka/akka/statuses/{sha}","languages_url":"https://api.github.com/repos/akka/akka/languages","stargazers_url":"https://api.github.com/repos/akka/akka/stargazers","contributors_url":"https://api.github.com/repos/akka/akka/contributors","subscribers_url":"https://api.github.com/repos/akka/akka/subscribers","subscription_url":"https://api.github.com/repos/akka/akka/subscription","commits_url":"https://api.github.com/repos/akka/akka/commits{/sha}","git_commits_url":"https://api.github.com/repos/akka/akka/git/commits{/sha}","comments_url":"https://api.github.com/repos/akka/akka/comments{/number}","issue_comment_url":"https://api.github.com/repos/akka/akka/issues/comments/{number}","contents_url":"https://api.github.com/repos/akka/akka/contents/{+path}","compare_url":"https://api.github.com/repos/akka/akka/compare/{base}...{head}","merges_url":"https://api.github.com/repos/akka/akka/merges","archive_url":"https://api.github.com/repos/akka/akka/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/akka/akka/downloads","issues_url":"https://api.github.com/repos/akka/akka/issues{/number}","pulls_url":"https://api.github.com/repos/akka/akka/pulls{/number}","milestones_url":"https://api.github.com/repos/akka/akka/milestones{/number}","notifications_url":"https://api.github.com/repos/akka/akka/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/akka/akka/labels{/name}","releases_url":"https://api.github.com/repos/akka/akka/releases{/id}","created_at":"2009-02-16T12:51:54Z","updated_at":"2014-08-27T03:24:30Z","pushed_at":"2014-08-26T14:15:36Z","git_url":"git://github.com/akka/akka.git","ssh_url":"git@github.com:akka/akka.git","clone_url":"https://github.com/akka/akka.git","svn_url":"https://github.com/akka/akka","homepage":"http://akka.io","size":227162,"stargazers_count":2897,"watchers_count":2897,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":false,"forks_count":786,"mirror_url":null,"open_issues_count":400,"forks":786,"open_issues":400,"watchers":2897,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/akka/akka/pulls/15759"},"html":{"href":"https://github.com/akka/akka/pull/15759"},"issue":{"href":"https://api.github.com/repos/akka/akka/issues/15759"},"comments":{"href":"https://api.github.com/repos/akka/akka/issues/15759/comments"},"review_comments":{"href":"https://api.github.com/repos/akka/akka/pulls/15759/comments"},"review_comment":{"href":"https://api.github.com/repos/akka/akka/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/akka/akka/pulls/15759/commits"},"statuses":{"href":"https://api.github.com/repos/akka/akka/statuses/7c1eec0af1d4dae7aa747800ee34e533ef6d2e01"}}}}