Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SQL] add note of use synchronizedMap in SQLConf #1996

Closed
wants to merge 4 commits into from

Conversation

scwf
Copy link
Contributor

@scwf scwf commented Aug 17, 2014

Refer to:
http://stackoverflow.com/questions/510632/whats-the-difference-between-concurrenthashmap-and-collections-synchronizedmap
Collections.synchronizedMap(map) creates a blocking Map which will degrade performance, albeit ensure consistency. So use ConcurrentHashMap(a more effective thread-safe hashmap) instead.

also update HiveQuerySuite to fix test error when changed to ConcurrentHashMap.

@AmplabJenkins
Copy link

Can one of the admins verify this patch?

@rxin
Copy link
Contributor

rxin commented Aug 18, 2014

That winning answer on SO has no clue about performance. In most cases with low degree of contention, ConcurrentHashMap is both slower and uses more memory.

i.e. we should close this PR. Thanks.

@rxin
Copy link
Contributor

rxin commented Aug 18, 2014

Actually to prevent this from happening in the future, do you mind change the PR to add a line above the declaration to state "Only low degree of contention is expected for conf, thus NOT using ConcurrentHashMap" ?

@aarondav
Copy link
Contributor

The only way you argued me out of this last time @rxin was that you said we'd have one of these per thread. Is that still happening?

@rxin
Copy link
Contributor

rxin commented Aug 18, 2014

It happens for the main use case which is the server. And for non-server, users have to explicitly create multiple threads to access conf to make contention happen. Either way, this code path is not some highly contended thing that you'd want a ConcurrentHashMap for.

@scwf scwf changed the title [SQL] use ConcurrentHashMap in SQLConf [SQL] add note of use synchronizedMap in SQLConf Aug 19, 2014
@scwf
Copy link
Contributor Author

scwf commented Aug 19, 2014

@rxin , thanks, updated.

@rxin
Copy link
Contributor

rxin commented Aug 19, 2014

Jenkins, test this please.

@SparkQA
Copy link

SparkQA commented Aug 19, 2014

QA tests have started for PR 1996 at commit 93bc0c5.

  • This patch merges cleanly.

@SparkQA
Copy link

SparkQA commented Aug 19, 2014

QA tests have finished for PR 1996 at commit 93bc0c5.

  • This patch fails unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@rxin
Copy link
Contributor

rxin commented Aug 19, 2014

Jenkins, retest this please.

@SparkQA
Copy link

SparkQA commented Aug 19, 2014

QA tests have started for PR 1996 at commit 93bc0c5.

  • This patch merges cleanly.

@SparkQA
Copy link

SparkQA commented Aug 19, 2014

QA tests have finished for PR 1996 at commit 93bc0c5.

  • This patch fails unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@rxin
Copy link
Contributor

rxin commented Aug 19, 2014

Jenkins, retest this please.

@SparkQA
Copy link

SparkQA commented Aug 19, 2014

QA tests have started for PR 1996 at commit 93bc0c5.

  • This patch merges cleanly.

@SparkQA
Copy link

SparkQA commented Aug 19, 2014

QA tests have finished for PR 1996 at commit 93bc0c5.

  • This patch fails unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@scwf
Copy link
Contributor Author

scwf commented Aug 20, 2014

There are something wrong with CliSuite and HiveThriftServer2Suite, the master branch can not pass this two tests. refer to #2036

@rxin
Copy link
Contributor

rxin commented Aug 20, 2014

I'm going to merge this since the test failures are expected.

asfgit pushed a commit that referenced this pull request Aug 20, 2014
Refer to:
http://stackoverflow.com/questions/510632/whats-the-difference-between-concurrenthashmap-and-collections-synchronizedmap
Collections.synchronizedMap(map) creates a blocking Map which will degrade performance, albeit ensure consistency. So use ConcurrentHashMap(a more effective thread-safe hashmap) instead.

also update HiveQuerySuite to fix test error when changed to ConcurrentHashMap.

Author: wangfei <[email protected]>
Author: scwf <[email protected]>

Closes #1996 from scwf/sqlconf and squashes the following commits:

93bc0c5 [wangfei] revert change of HiveQuerySuite
0cc05dd [wangfei] add note for use synchronizedMap
3c224d3 [scwf] fix formate
a7bcb98 [scwf] use ConcurrentHashMap in sql conf, intead synchronizedMap

(cherry picked from commit 0e3ab94)
Signed-off-by: Reynold Xin <[email protected]>
@asfgit asfgit closed this in 0e3ab94 Aug 20, 2014
@scwf scwf deleted the sqlconf branch August 22, 2014 15:16
xiliu82 pushed a commit to xiliu82/spark that referenced this pull request Sep 4, 2014
Refer to:
http://stackoverflow.com/questions/510632/whats-the-difference-between-concurrenthashmap-and-collections-synchronizedmap
Collections.synchronizedMap(map) creates a blocking Map which will degrade performance, albeit ensure consistency. So use ConcurrentHashMap(a more effective thread-safe hashmap) instead.

also update HiveQuerySuite to fix test error when changed to ConcurrentHashMap.

Author: wangfei <[email protected]>
Author: scwf <[email protected]>

Closes apache#1996 from scwf/sqlconf and squashes the following commits:

93bc0c5 [wangfei] revert change of HiveQuerySuite
0cc05dd [wangfei] add note for use synchronizedMap
3c224d3 [scwf] fix formate
a7bcb98 [scwf] use ConcurrentHashMap in sql conf, intead synchronizedMap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants