avatar
f*a
1
只有原来唱的,最近有娃没有空录音了
过节就得来个热闹喜庆的吧,王派的我学唱的都比较凄惨
悲剧的是我只能学着唱王派,这个范傅版本的太累了
尤其还得吼范派,我手忙脚乱了
http://frada.cnaudios.net/chorus/frada/YueOpera/mp3/frada-11shibaxiangsong.mp3
买一送一,大家都吼,我也吼,吼吼!!!!不要吓飞了!
http://frada.cnaudios.net/chorus/frada/PopSong/mp3/frada-Baibaili.mp3
avatar
g*g
2
I am working on an extremely high load server and trying to
optimize performance.
We have a class for caching which is like
HashMap map;
synchronized getEnry(String key) {
Entry value = map.get(key);
if(value == null) {
//create entry
map.put(key, entry);
}
}
synchronized removeEntry(String key) {
map.remove(key)
}
There's no update operation.
Obviously this is like using Collections.synchronizedMap(map) everything has
to
run on single thread and the performance sucks.
avatar
s*y
3
虽然我听过第一段,还是要说
实在是太赞了!
都很赞

【在 f***a 的大作中提到】
: 只有原来唱的,最近有娃没有空录音了
: 过节就得来个热闹喜庆的吧,王派的我学唱的都比较凄惨
: 悲剧的是我只能学着唱王派,这个范傅版本的太累了
: 尤其还得吼范派,我手忙脚乱了
: http://frada.cnaudios.net/chorus/frada/YueOpera/mp3/frada-11shibaxiangsong.mp3
: 买一送一,大家都吼,我也吼,吼吼!!!!不要吓飞了!
: http://frada.cnaudios.net/chorus/frada/PopSong/mp3/frada-Baibaili.mp3

avatar
F*n
4
A simple change will improve your performance a lot:
Entry getEntry(String key) {
Entry value = map.getKey(key);
if (value == null) {
synchronized(map) {
value = map.getKey(key);
if (value == null) {
//create entry here;
}
}
}
return value;
}
void removeEntry(String key) {
if (map.containsKey(key) {
synchronized(map) {
map.remove(key);
}
}
}
In your code everybody gets a

【在 g*****g 的大作中提到】
: I am working on an extremely high load server and trying to
: optimize performance.
: We have a class for caching which is like
: HashMap map;
: synchronized getEnry(String key) {
: Entry value = map.get(key);
: if(value == null) {
: //create entry
: map.put(key, entry);
: }

avatar
r*r
5
赞哪,还一人串几个角

【在 f***a 的大作中提到】
: 只有原来唱的,最近有娃没有空录音了
: 过节就得来个热闹喜庆的吧,王派的我学唱的都比较凄惨
: 悲剧的是我只能学着唱王派,这个范傅版本的太累了
: 尤其还得吼范派,我手忙脚乱了
: http://frada.cnaudios.net/chorus/frada/YueOpera/mp3/frada-11shibaxiangsong.mp3
: 买一送一,大家都吼,我也吼,吼吼!!!!不要吓飞了!
: http://frada.cnaudios.net/chorus/frada/PopSong/mp3/frada-Baibaili.mp3

avatar
g*g
6
You are using double check pattern, and while get is not
locking, add/update/remove does and isn't it better to use
ConcurrentHashMap where you can have multiple non-conflicting
update threads?

【在 F****n 的大作中提到】
: A simple change will improve your performance a lot:
: Entry getEntry(String key) {
: Entry value = map.getKey(key);
: if (value == null) {
: synchronized(map) {
: value = map.getKey(key);
: if (value == null) {
: //create entry here;
: }
: }

avatar
S*9
7
忘带耳机了 吼得很给力吗
avatar
F*n
8
First, you said you don't have update. If so, ConcurrentHashMap is not good
because the overhead of partitioning. Second, ConcurrentHashMap is not for
this purpose. It's for concurrent update. It does not check existing copy.
You still have to lock it otherwise you will have multiple concurrent
creations. Third, your double check pattern is not right.

【在 g*****g 的大作中提到】
: You are using double check pattern, and while get is not
: locking, add/update/remove does and isn't it better to use
: ConcurrentHashMap where you can have multiple non-conflicting
: update threads?

avatar
s*y
9
给力极了 我娘这样的越剧迷都会给包子的

【在 S****9 的大作中提到】
: 忘带耳机了 吼得很给力吗
avatar
g*g
10
I understand the ConcurrentHashMap overhead part, however,
you do want concurrent creations on different keys. Your implementation
blocks that, doesn't it?

good

【在 F****n 的大作中提到】
: First, you said you don't have update. If so, ConcurrentHashMap is not good
: because the overhead of partitioning. Second, ConcurrentHashMap is not for
: this purpose. It's for concurrent update. It does not check existing copy.
: You still have to lock it otherwise you will have multiple concurrent
: creations. Third, your double check pattern is not right.

avatar
S*9
11
一人分饰二角好听,戏曲都有那么个味道蛮勾人的。
avatar
F*n
12
Then double check on ConcurrentHashMap with key locks.

【在 g*****g 的大作中提到】
: I understand the ConcurrentHashMap overhead part, however,
: you do want concurrent creations on different keys. Your implementation
: blocks that, doesn't it?
:
: good

avatar
B*7
13
这版真是藏龙卧虎啊
avatar
m*t
14
Is Double Checked Lock no longer a broken pattern and
I somehow missed the news?

【在 g*****g 的大作中提到】
: You are using double check pattern, and while get is not
: locking, add/update/remove does and isn't it better to use
: ConcurrentHashMap where you can have multiple non-conflicting
: update threads?

avatar
S*9
15
有龙有虎不成席,还得来大鱼或小黄鸡,以及米饭馒头花卷

【在 B******7 的大作中提到】
: 这版真是藏龙卧虎啊
avatar
g*g
16
It's not since 1.5 and you put a volatile keyword on it,
that's what I've heard.

【在 m******t 的大作中提到】
: Is Double Checked Lock no longer a broken pattern and
: I somehow missed the news?

avatar
s*y
17
好吧,我配合地问一下,大家爱喝什么酒啊

【在 S****9 的大作中提到】
: 有龙有虎不成席,还得来大鱼或小黄鸡,以及米饭馒头花卷
avatar
F*n
18
It has been fixed. It's essentially a JVM problem not the pattern's.

【在 m******t 的大作中提到】
: Is Double Checked Lock no longer a broken pattern and
: I somehow missed the news?

avatar
w*0
19
赞,难怪经验值已是天籁之音了。

【在 f***a 的大作中提到】
: 只有原来唱的,最近有娃没有空录音了
: 过节就得来个热闹喜庆的吧,王派的我学唱的都比较凄惨
: 悲剧的是我只能学着唱王派,这个范傅版本的太累了
: 尤其还得吼范派,我手忙脚乱了
: http://frada.cnaudios.net/chorus/frada/YueOpera/mp3/frada-11shibaxiangsong.mp3
: 买一送一,大家都吼,我也吼,吼吼!!!!不要吓飞了!
: http://frada.cnaudios.net/chorus/frada/PopSong/mp3/frada-Baibaili.mp3

avatar
m*t
20

Oh I didn't miss _that_ news, but the fix only fixes (via a hack btw)
it when only the variable itself is involved in race conditions.
The case in discussion is different. The synchronization on
map access is to prevent race conditions on the internal
map data structure, not on the variable holding the lookup
result.

【在 F****n 的大作中提到】
: It has been fixed. It's essentially a JVM problem not the pattern's.
avatar
w*0
21
山东大馒头味道是好,几天不见刀老乡,估计是正挥汗如雨刻苦彩排中。俺也吼了几嗓
子,可是录了下来一听糁
得直起鸡皮疙瘩,真想捧场可实在上不了台面,就安心做个优秀的观众了,你下个节目
是啥,期待中。

【在 S****9 的大作中提到】
: 有龙有虎不成席,还得来大鱼或小黄鸡,以及米饭馒头花卷
avatar
F*n
22
I think in the discussed case double check will NEVER be a problem on ANY
JVM. The problem JVM used to have is at thread stack. The Map data is in the
heap.

【在 m******t 的大作中提到】
:
: Oh I didn't miss _that_ news, but the fix only fixes (via a hack btw)
: it when only the variable itself is involved in race conditions.
: The case in discussion is different. The synchronization on
: map access is to prevent race conditions on the internal
: map data structure, not on the variable holding the lookup
: result.

avatar
u*u
23
真好听,听得俺耳朵都软了
avatar
g*g
24
What will be the problem if I do double check with key locks
on HashMap instead?

【在 F****n 的大作中提到】
: Then double check on ConcurrentHashMap with key locks.
avatar
S*9
25
桑心了
你就录这一句:我关键时刻掉链子对不起革命对不起大家 我愿意奔别的才艺以弥补大
家心灵上蒙受的损失
另外FYI:你的刀老乡很守信 我已经收到她的DEMO 这是什么精神 混江湖靠的就是一个
字:义气

【在 w****0 的大作中提到】
: 山东大馒头味道是好,几天不见刀老乡,估计是正挥汗如雨刻苦彩排中。俺也吼了几嗓
: 子,可是录了下来一听糁
: 得直起鸡皮疙瘩,真想捧场可实在上不了台面,就安心做个优秀的观众了,你下个节目
: 是啥,期待中。

avatar
m*t
26

the
I wouldn't be so sure. IIUC, the problem arises from a reference being
used before the object it points to is completely initialized. I don't see
how that has to do with where the data is.
I was also just reading the HashTable code from jdk 1.6. Looking
at get() and removeEntryForKey(), which span about 12 and 25 lines of code,
including a while loop, there is no way this doesn't require a strict
synchronization.

【在 F****n 的大作中提到】
: I think in the discussed case double check will NEVER be a problem on ANY
: JVM. The problem JVM used to have is at thread stack. The Map data is in the
: heap.

avatar
w*0
27
你一伤心我就慌心了,不是还有时间么,那我再练练,行不。先听
听刀妹妹的。
我又糊涂了,义气是俩字还是一个,或者藏着啥东西只有智商140
的才能看出来的。

奔别的才艺以弥补大
混江湖靠的就是一个

【在 S****9 的大作中提到】
: 桑心了
: 你就录这一句:我关键时刻掉链子对不起革命对不起大家 我愿意奔别的才艺以弥补大
: 家心灵上蒙受的损失
: 另外FYI:你的刀老乡很守信 我已经收到她的DEMO 这是什么精神 混江湖靠的就是一个
: 字:义气

avatar
g*g
28
ConcurrentHashMap has internal lock to do it, HashMap seems
to need an external lock in my opinion.

【在 m******t 的大作中提到】
:
: the
: I wouldn't be so sure. IIUC, the problem arises from a reference being
: used before the object it points to is completely initialized. I don't see
: how that has to do with where the data is.
: I was also just reading the HashTable code from jdk 1.6. Looking
: at get() and removeEntryForKey(), which span about 12 and 25 lines of code,
: including a while loop, there is no way this doesn't require a strict
: synchronization.

avatar
s*y
29
不论多少个字,表达气概都可以说一个字的
哎,这是我在这个bbs上第一次这么那爱死

【在 w****0 的大作中提到】
: 你一伤心我就慌心了,不是还有时间么,那我再练练,行不。先听
: 听刀妹妹的。
: 我又糊涂了,义气是俩字还是一个,或者藏着啥东西只有智商140
: 的才能看出来的。
:
: 奔别的才艺以弥补大
: 混江湖靠的就是一个

avatar
m*t
30

If it's for caching and you are not worried about updating, then
the objects cached can be considered immutable, then two objects
loaded by the same key would be logically equivalent and would stay
that way.
If that's the case, why not just skip synchronization all together.
Worse comes to worst two threads get two equivalent objects, right?

【在 g*****g 的大作中提到】
: I am working on an extremely high load server and trying to
: optimize performance.
: We have a class for caching which is like
: HashMap map;
: synchronized getEnry(String key) {
: Entry value = map.get(key);
: if(value == null) {
: //create entry
: map.put(key, entry);
: }

avatar
S*9
31
助教:强教授的意思是nice,就是奈斯

【在 s******y 的大作中提到】
: 不论多少个字,表达气概都可以说一个字的
: 哎,这是我在这个bbs上第一次这么那爱死

avatar
F*n
32
The core of the double check pattern problem, is that when you assign a
newly created object to a field (which is on stack), the content of that
field on the stack may be out of synch. The volatile keyword fix it because
by declaring a field volatile, the content of that field will never be
cached on the stack.
If the variable is on the heap, there should be no problem.

【在 m******t 的大作中提到】
:
: If it's for caching and you are not worried about updating, then
: the objects cached can be considered immutable, then two objects
: loaded by the same key would be logically equivalent and would stay
: that way.
: If that's the case, why not just skip synchronization all together.
: Worse comes to worst two threads get two equivalent objects, right?

avatar
s*y
33
老子的房顶又要不够了

【在 S****9 的大作中提到】
: 助教:强教授的意思是nice,就是奈斯
avatar
g*g
34
Can't do that. It's not a simple class, it has references to other
classes. And while I am new on this system, I am afraid that might
lead to double creation of some other informations.

【在 m******t 的大作中提到】
:
: If it's for caching and you are not worried about updating, then
: the objects cached can be considered immutable, then two objects
: loaded by the same key would be logically equivalent and would stay
: that way.
: If that's the case, why not just skip synchronization all together.
: Worse comes to worst two threads get two equivalent objects, right?

avatar
r*r
35
这句话助教怎么不注释了?

【在 s******y 的大作中提到】
: 老子的房顶又要不够了
avatar
F*n
36
That equals to ConcurrentHashMap without double check.

【在 m******t 的大作中提到】
:
: If it's for caching and you are not worried about updating, then
: the objects cached can be considered immutable, then two objects
: loaded by the same key would be logically equivalent and would stay
: that way.
: If that's the case, why not just skip synchronization all together.
: Worse comes to worst two threads get two equivalent objects, right?

avatar
S*9
37
助教查文献没查到
“老子的房顶又不够了”
1. 老子是思想家?爹?自称?
2. 房顶是实指?象征?玻璃天花板?
3. 又:上次不够是什么时候?
4. 不够:房顶要几个才够

【在 r****r 的大作中提到】
: 这句话助教怎么不注释了?
avatar
F*n
38
What about if two keys have same hash code?

【在 g*****g 的大作中提到】
: What will be the problem if I do double check with key locks
: on HashMap instead?

avatar
L*y
39
古人云,三天不打,上房揭瓦。
教授格外如此。

【在 S****9 的大作中提到】
: 助教查文献没查到
: “老子的房顶又不够了”
: 1. 老子是思想家?爹?自称?
: 2. 房顶是实指?象征?玻璃天花板?
: 3. 又:上次不够是什么时候?
: 4. 不够:房顶要几个才够

avatar
g*g
40
How is that related? When I lock on key.intern(),
don't you have to get the monitor on that key in the string pool
before you can access them? 2 different keys can have the same
hash code but how can they have the same monitor?
And two strings can't have the same hashcode right, otherwise
how can string be used as key?

【在 F****n 的大作中提到】
: What about if two keys have same hash code?
avatar
s*y
41
你这话里,只有 人 字跟我有点关系

【在 L**********y 的大作中提到】
: 古人云,三天不打,上房揭瓦。
: 教授格外如此。

avatar
F*n
42
I was not accurate. Same hash codes may not happen but it is possible
that two different hash codes are treated same in a hashmap. If you
look at the implementation of HashMap, it just & the the lower bits of
the hash code.
BTW, off course two strings can have the same hash code. The Hashtable
will use hash code as internal index, and they will do a Object.equals
to check if the key is the same.
For object that qualifies as keys, the only thing that must be assured
is that if two objects pass eq

【在 g*****g 的大作中提到】
: How is that related? When I lock on key.intern(),
: don't you have to get the monitor on that key in the string pool
: before you can access them? 2 different keys can have the same
: hash code but how can they have the same monitor?
: And two strings can't have the same hashcode right, otherwise
: how can string be used as key?

avatar
L*y
43
那爱死也不用这么谦虚吗 //我强词夺理可都是你逼出来的阿

【在 s******y 的大作中提到】
: 你这话里,只有 人 字跟我有点关系
avatar
m*t
44

because
OK, one of us is losing it. 8-)
In the basic test case demonstrating how the DCL is broken:
http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html
The variable 'helper' is a member variable, which has to
be on the heap.

【在 F****n 的大作中提到】
: The core of the double check pattern problem, is that when you assign a
: newly created object to a field (which is on stack), the content of that
: field on the stack may be out of synch. The volatile keyword fix it because
: by declaring a field volatile, the content of that field will never be
: cached on the stack.
: If the variable is on the heap, there should be no problem.

avatar
s*y
45
行行行,都怪我nice。。。搞得我都不知道正确的翻译到底是啥了

【在 L**********y 的大作中提到】
: 那爱死也不用这么谦虚吗 //我强词夺理可都是你逼出来的阿
avatar
g*g
46
OK, I get what you are saying, but you still doesn't explain
how could a monitor on key.intern() fail for sync purpose.

【在 F****n 的大作中提到】
: I was not accurate. Same hash codes may not happen but it is possible
: that two different hash codes are treated same in a hashmap. If you
: look at the implementation of HashMap, it just & the the lower bits of
: the hash code.
: BTW, off course two strings can have the same hash code. The Hashtable
: will use hash code as internal index, and they will do a Object.equals
: to check if the key is the same.
: For object that qualifies as keys, the only thing that must be assured
: is that if two objects pass eq

avatar
f*a
47
难道你要上房揭瓦来砸我???
不会难听到连你家房顶揭光了你还没砸消气???

【在 s******y 的大作中提到】
: 老子的房顶又要不够了
avatar
F*n
48
I think a member variable is on the thread's stack, not heap. The JVM's
memory model is like this: The common heap contains block memory and non-
field objects, and a stack per thread that contains member variables (fields
). The problem is that when you initialize a field in an unsynchronized
block, other threads may "see it" before the field is completely initialized
. You don't have that problem in the heap.

【在 m******t 的大作中提到】
:
: because
: OK, one of us is losing it. 8-)
: In the basic test case demonstrating how the DCL is broken:
: http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html
: The variable 'helper' is a member variable, which has to
: be on the heap.

avatar
s*y
49
师妹,大过节的我,我,我干什么了惹得你这么生气

【在 f***a 的大作中提到】
: 难道你要上房揭瓦来砸我???
: 不会难听到连你家房顶揭光了你还没砸消气???

avatar
g*g
50
It's not a heap or stack thing. It's that the object construction
may not have finished in one thread and it's seen existing already
for another thread.

【在 m******t 的大作中提到】
:
: because
: OK, one of us is losing it. 8-)
: In the basic test case demonstrating how the DCL is broken:
: http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html
: The variable 'helper' is a member variable, which has to
: be on the heap.

avatar
i*i
51
小艾狂点头ing

【在 S****9 的大作中提到】
: 桑心了
: 你就录这一句:我关键时刻掉链子对不起革命对不起大家 我愿意奔别的才艺以弥补大
: 家心灵上蒙受的损失
: 另外FYI:你的刀老乡很守信 我已经收到她的DEMO 这是什么精神 混江湖靠的就是一个
: 字:义气

avatar
m*t
52

Yeah, I think there is an implementation of Map with an external lock.
And it's called HashTable. ;-)

【在 g*****g 的大作中提到】
: ConcurrentHashMap has internal lock to do it, HashMap seems
: to need an external lock in my opinion.

avatar
S*9
53
你再给刀刀示范一下义气吧 来段评书五的

【在 i*i 的大作中提到】
: 小艾狂点头ing
avatar
F*n
54
If you have two keys with same hash codes or same internal codes they are
basically unsynchronized, right?

【在 g*****g 的大作中提到】
: OK, I get what you are saying, but you still doesn't explain
: how could a monitor on key.intern() fail for sync purpose.

avatar
w*0
55
Lol, frada妹妹不知道强教授道行太深,说话艰涩到连智商二百的小酒助教都哭着辞职
不干了。那句话绝不是冲着
你来滴,你的歌喉的美丽,用言语难以表达,尤其是唱越剧的时候。

【在 f***a 的大作中提到】
: 难道你要上房揭瓦来砸我???
: 不会难听到连你家房顶揭光了你还没砸消气???

avatar
F*n
56
When you say "initialize" in one thread you are referring to the private
stack that thread holds.

【在 g*****g 的大作中提到】
: It's not a heap or stack thing. It's that the object construction
: may not have finished in one thread and it's seen existing already
: for another thread.

avatar
w*0
57
要不小艾唱个歌,她嗓子柔柔甜甜的,唱个情歌啥的肯定好听。

【在 S****9 的大作中提到】
: 你再给刀刀示范一下义气吧 来段评书五的
avatar
g*g
58
Not if the performance matters. Just saying. HashTable is thread-safe
but nothing is really CONCURRENT.

【在 m******t 的大作中提到】
:
: Yeah, I think there is an implementation of Map with an external lock.
: And it's called HashTable. ;-)

avatar
S*9
59
看明白了 你暗示小强IQ比200高50。

【在 w****0 的大作中提到】
: Lol, frada妹妹不知道强教授道行太深,说话艰涩到连智商二百的小酒助教都哭着辞职
: 不干了。那句话绝不是冲着
: 你来滴,你的歌喉的美丽,用言语难以表达,尤其是唱越剧的时候。

avatar
m*t
60

fields
Could you give me a link on details about this so I can make sure I
really understand what you are saying, because as of now I'm taking it
as you are saying that member variables are the same as thread locals?
initialized

【在 F****n 的大作中提到】
: I think a member variable is on the thread's stack, not heap. The JVM's
: memory model is like this: The common heap contains block memory and non-
: field objects, and a stack per thread that contains member variables (fields
: ). The problem is that when you initialize a field in an unsynchronized
: block, other threads may "see it" before the field is completely initialized
: . You don't have that problem in the heap.

avatar
S*9
61
严重支持 哦也

【在 w****0 的大作中提到】
: 要不小艾唱个歌,她嗓子柔柔甜甜的,唱个情歌啥的肯定好听。
avatar
g*g
62
What does object monitor synchronization uses have to do with hashcode?
The problem with key.intern() I would think is causing racing in different
places of system if multiple places are using it, but it's certainly
thread-safe.

【在 F****n 的大作中提到】
: If you have two keys with same hash codes or same internal codes they are
: basically unsynchronized, right?

avatar
i*i
63
我端着板凳等着你们大家呢

【在 w****0 的大作中提到】
: 要不小艾唱个歌,她嗓子柔柔甜甜的,唱个情歌啥的肯定好听。
avatar
m*t
64

That's how I understand it too, but Foxman is saying that it wouldn't
be a problem in this case because of stack vs. heap. That's how this
has become "a head or stack thing" now. 8-)

【在 g*****g 的大作中提到】
: It's not a heap or stack thing. It's that the object construction
: may not have finished in one thread and it's seen existing already
: for another thread.

avatar
s*y
65
给你们透露一个隐私,我被人喊“250的小强”喊了四年,真事。

【在 S****9 的大作中提到】
: 看明白了 你暗示小强IQ比200高50。
avatar
F*n
66
No, I said if a field is not declared volatile it will be cached in local.
Basically thread locals are caches of the common heap.

【在 m******t 的大作中提到】
:
: That's how I understand it too, but Foxman is saying that it wouldn't
: be a problem in this case because of stack vs. heap. That's how this
: has become "a head or stack thing" now. 8-)

avatar
r*r
67
没雕刻个什么作为纪念么

【在 s******y 的大作中提到】
: 给你们透露一个隐私,我被人喊“250的小强”喊了四年,真事。
avatar
m*t
68

Well, I'm going to take a big step back and ask you the obvious here:
have you done profiling and made sure that the old school, straightforward,
thread-safe synchronized block is the root cause of your performance
problem?
If you are new to the project, probably a good idea to stay with a safe
but maybe less performant solution.

【在 g*****g 的大作中提到】
: Not if the performance matters. Just saying. HashTable is thread-safe
: but nothing is really CONCURRENT.

avatar
s*y
69
你的意思是刻个门牌号?

【在 r****r 的大作中提到】
: 没雕刻个什么作为纪念么
avatar
g*g
70
Yes, we take a snapshot on JVM every 30 minutes. And we see
threads are getting blocked
Id:595
Name:J-379
State:BLOCKED on [email protected] owned by J-382
Stack trace:
......
Of course this may not be the biggest bottleneck for performance per se.
But it's obviously I need to do something about it. If not for real
performance gain, getting it out of picture will prove I am actually
doing something.

【在 m******t 的大作中提到】
:
: Well, I'm going to take a big step back and ask you the obvious here:
: have you done profiling and made sure that the old school, straightforward,
: thread-safe synchronized block is the root cause of your performance
: problem?
: If you are new to the project, probably a good idea to stay with a safe
: but maybe less performant solution.

avatar
r*r
71
门牌号不够坚强。刻个坚强的代表么,比如金刚钻

【在 s******y 的大作中提到】
: 你的意思是刻个门牌号?
avatar
m*t
72

I think we have some confusion in terminology. When you say
"cached in thread local", you mean the cache of the _processor
core_ that happens to be executing the thread, which, allow
me for insisting with my terminology, is yet another heap,
only smaller.
I took you to mean "thread local" as in:
http://java.sun.com/javase/6/docs/api/java/lang/ThreadLocal.html
Well, back to our original point, I do still believe that the same
situation applies to HashTable, as the internal data structure of
Hash

【在 F****n 的大作中提到】
: No, I said if a field is not declared volatile it will be cached in local.
: Basically thread locals are caches of the common heap.

avatar
s*y
73
你别说,我还真抛过钻石,就是cut出多面体的形状。经过我手的大约共计有10 carats
的小钻

【在 r****r 的大作中提到】
: 门牌号不够坚强。刻个坚强的代表么,比如金刚钻
avatar
m*t
74
But what about throughput and average response time _per thread_?
We constantly see a couple of synchronization spots in our
thread dumps as well, but every time it's a different thread holding it.
And because it's on the typical code path, with around 50 user threads
in the vm all the time, there is almost always some thread holding it.
But then from each individual thread's stand point, they almost never
spend a lot of time waiting on the lock, so I don't really consider it
a truly serialized

【在 g*****g 的大作中提到】
: Yes, we take a snapshot on JVM every 30 minutes. And we see
: threads are getting blocked
: Id:595
: Name:J-379
: State:BLOCKED on [email protected] owned by J-382
: Stack trace:
: ......
: Of course this may not be the biggest bottleneck for performance per se.
: But it's obviously I need to do something about it. If not for real
: performance gain, getting it out of picture will prove I am actually

avatar
f*a
75
没pp没真相!!!
btw,本站还有比我老的???!
我觉得总数应该很少,难道都进这个贴子了???

【在 s******y 的大作中提到】
: 你别说,我还真抛过钻石,就是cut出多面体的形状。经过我手的大约共计有10 carats
: 的小钻

avatar
F*n
76
Sorry for the terminology. It should the thread's local stack. ThreadLocal
is actually a class to access that stack.

【在 m******t 的大作中提到】
: But what about throughput and average response time _per thread_?
: We constantly see a couple of synchronization spots in our
: thread dumps as well, but every time it's a different thread holding it.
: And because it's on the typical code path, with around 50 user threads
: in the vm all the time, there is almost always some thread holding it.
: But then from each individual thread's stand point, they almost never
: spend a lot of time waiting on the lock, so I don't really consider it
: a truly serialized

avatar
s*y
77
师妹,你今天标点符号喝多了来这里散散?
我是1998年上这个站的。当然,那个时候我可以在上幼稚园

【在 f***a 的大作中提到】
: 没pp没真相!!!
: btw,本站还有比我老的???!
: 我觉得总数应该很少,难道都进这个贴子了???

avatar
F*n
78
No it's not. Imagine two key with same hashcodes (or internal address codes
). They are not synchronized. So when you remove one from the bucket the
other one may be appended after the removed one.

【在 g*****g 的大作中提到】
: What does object monitor synchronization uses have to do with hashcode?
: The problem with key.intern() I would think is causing racing in different
: places of system if multiple places are using it, but it's certainly
: thread-safe.

avatar
L*y
79
你的手有没有被钻石硌疼?那得是多么复杂的心情啊

carats

【在 s******y 的大作中提到】
: 你别说,我还真抛过钻石,就是cut出多面体的形状。经过我手的大约共计有10 carats
: 的小钻

avatar
g*g
80
I believe for this piece of code we usually configure 200
worker threads thread pool, so while blocking is not always
a performance issue for the overall system, we do want to
minimize the synchronized scope and sync on a function is
almost never the right thing to do.

【在 m******t 的大作中提到】
: But what about throughput and average response time _per thread_?
: We constantly see a couple of synchronization spots in our
: thread dumps as well, but every time it's a different thread holding it.
: And because it's on the typical code path, with around 50 user threads
: in the vm all the time, there is almost always some thread holding it.
: But then from each individual thread's stand point, they almost never
: spend a lot of time waiting on the lock, so I don't really consider it
: a truly serialized

avatar
f*a
81
我一直标点符号多
手写输入写字太累,逮个机会大把撒标点
98年我也上bbs,不过是水木。

【在 s******y 的大作中提到】
: 师妹,你今天标点符号喝多了来这里散散?
: 我是1998年上这个站的。当然,那个时候我可以在上幼稚园

avatar
m*t
82

I wouldn't make a technically subtle fix unless I'm sure
what it fixes is going to be worth the risk.

【在 g*****g 的大作中提到】
: I believe for this piece of code we usually configure 200
: worker threads thread pool, so while blocking is not always
: a performance issue for the overall system, we do want to
: minimize the synchronized scope and sync on a function is
: almost never the right thing to do.

avatar
s*y
83
不是很复杂。心思主要是集中在检查钻石有没有气泡和裂痕中

【在 L**********y 的大作中提到】
: 你的手有没有被钻石硌疼?那得是多么复杂的心情啊
:
: carats

avatar
m*t
84

codes
Right, not to mention also the bucket itself could be changed
and synch'ing on the hash value itself mostly certainly won't
cover that.

【在 F****n 的大作中提到】
: No it's not. Imagine two key with same hashcodes (or internal address codes
: ). They are not synchronized. So when you remove one from the bucket the
: other one may be appended after the removed one.

avatar
s*y
85
湖心亭上那些咿咿呀呀唱昆曲的孩子们中有你没?

【在 f***a 的大作中提到】
: 我一直标点符号多
: 手写输入写字太累,逮个机会大把撒标点
: 98年我也上bbs,不过是水木。

avatar
g*g
86
OK, I get that, thanks. I wasn't thinking inside of HashMap
implementation.

【在 m******t 的大作中提到】
:
: codes
: Right, not to mention also the bucket itself could be changed
: and synch'ing on the hash value itself mostly certainly won't
: cover that.

avatar
S*9
87
好有诗意啊

【在 s******y 的大作中提到】
: 湖心亭上那些咿咿呀呀唱昆曲的孩子们中有你没?
avatar
k*r
88
There are other problems. The conclusion so far is it's
still broken, and pretty much unfixable.

【在 g*****g 的大作中提到】
: It's not since 1.5 and you put a volatile keyword on it,
: that's what I've heard.

avatar
f*a
89
我连票友都算不上呢,水平太差
不过我也看过两次他们排练
厚脸皮说也同台演出过,当然是龙套。

【在 s******y 的大作中提到】
: 湖心亭上那些咿咿呀呀唱昆曲的孩子们中有你没?
avatar
F*n
90
I don't understand why they say double check is algorithmically incorrect.

【在 k***r 的大作中提到】
: There are other problems. The conclusion so far is it's
: still broken, and pretty much unfixable.

avatar
s*y
91
当我没听过 两边我都听过啦
你就不要谦虚了

【在 f***a 的大作中提到】
: 我连票友都算不上呢,水平太差
: 不过我也看过两次他们排练
: 厚脸皮说也同台演出过,当然是龙套。

avatar
r*r
92
小强我忘了问你了,你抛光钻石用什么工具?

【在 s******y 的大作中提到】
: 当我没听过 两边我都听过啦
: 你就不要谦虚了

avatar
s*y
93
抛钻石啊鹿鹿 当然是用钻石啦

【在 r****r 的大作中提到】
: 小强我忘了问你了,你抛光钻石用什么工具?
avatar
r*r
94
努力想象中。。。那你怎么有把握要抛的对象被削掉而不是工具被磨掉

【在 s******y 的大作中提到】
: 抛钻石啊鹿鹿 当然是用钻石啦
avatar
f*a
95
京昆社高人很多
我们同台演出那次就很惊艳他们。

【在 s******y 的大作中提到】
: 当我没听过 两边我都听过啦
: 你就不要谦虚了

avatar
f*a
96
抛钻石干嘛?手工艺爱好者?

【在 s******y 的大作中提到】
: 抛钻石啊鹿鹿 当然是用钻石啦
avatar
s*y
97
还行。我也是从小听戏听到大的。
几年前听你唱王派就很惊艳

【在 f***a 的大作中提到】
: 京昆社高人很多
: 我们同台演出那次就很惊艳他们。

avatar
s*y
98
工作需要。不过我是手工艺爱好者,人生最大理想是做一个木匠

【在 f***a 的大作中提到】
: 抛钻石干嘛?手工艺爱好者?
avatar
L*y
99
网上小说说木匠得会捉鬼避邪,你敢吗?

【在 s******y 的大作中提到】
: 工作需要。不过我是手工艺爱好者,人生最大理想是做一个木匠
avatar
s*y
100
网上小说说不长记性就会被当鬼捉,你能改么?

【在 L**********y 的大作中提到】
: 网上小说说木匠得会捉鬼避邪,你敢吗?
avatar
L*y
101
蒙谁啊,根本没这么一说。你先创作一篇这样的网上小说来

【在 s******y 的大作中提到】
: 网上小说说不长记性就会被当鬼捉,你能改么?
avatar
s*y
102
你也知道可以创作啊 所以网络小说当不得真,而我想当木匠的心愿是很真切的
可惜

【在 L**********y 的大作中提到】
: 蒙谁啊,根本没这么一说。你先创作一篇这样的网上小说来
avatar
S*9
103
你奔个小说我放你一马

【在 s******y 的大作中提到】
: 你也知道可以创作啊 所以网络小说当不得真,而我想当木匠的心愿是很真切的
: 可惜

avatar
s*y
104
我不奔小说你送我一马?

【在 S****9 的大作中提到】
: 你奔个小说我放你一马
avatar
s*y
105
用来磨钻石的工具的表面是人工生长的钻石。工具可以旋转,通过调节压力和旋转的速度来把握抛钻石的快慢。如果钻石没有明显的气泡和裂痕的话,一个上午我大概可以把一个0.5克拉的钻石抛出一个介于“old single cut”和“round brilliant cut”之间的类型出来。
不过这里我又忽悠了。我需要抛的是钻石的小头,就是尖的那一端:工作需要。如果是正常的大头,抛的时间会大大延长。

【在 r****r 的大作中提到】
: 努力想象中。。。那你怎么有把握要抛的对象被削掉而不是工具被磨掉
avatar
r*r
106
GRE逻辑:从以上一段话我们可得出以下结论:人工生长的钻石(PS:这是什么东西?
)的硬度>被抛的钻石(天然生长的?)。可以得分么?
小强你可以看出钻石里的气泡?牛啊,是用那种贴在眼睛上的放大镜看的么?

速度来把握抛钻石的快慢。如果钻石没有明显的气泡和裂痕的话,一个上午我大概可以
把一个0.5克拉的钻石抛出一个介于“old single cut”和“round brilliant cut”之
间的类型出来。
是正常的大头,抛的时间会大大延长。

【在 s******y 的大作中提到】
: 用来磨钻石的工具的表面是人工生长的钻石。工具可以旋转,通过调节压力和旋转的速度来把握抛钻石的快慢。如果钻石没有明显的气泡和裂痕的话,一个上午我大概可以把一个0.5克拉的钻石抛出一个介于“old single cut”和“round brilliant cut”之间的类型出来。
: 不过这里我又忽悠了。我需要抛的是钻石的小头,就是尖的那一端:工作需要。如果是正常的大头,抛的时间会大大延长。

avatar
s*y
107
其实是互相磨,都有损耗。钻石里的气泡很容易看见,一般的放大倍数不高的光学显微
镜就可以。
你去珠宝店,很多晶体都分天然生长的和人工生长的,区别么,就是前者价钱比后者高
,后者品质比前者高。不过买这些东西的,都是买个难得罢了。

【在 r****r 的大作中提到】
: GRE逻辑:从以上一段话我们可得出以下结论:人工生长的钻石(PS:这是什么东西?
: )的硬度>被抛的钻石(天然生长的?)。可以得分么?
: 小强你可以看出钻石里的气泡?牛啊,是用那种贴在眼睛上的放大镜看的么?
:
: 速度来把握抛钻石的快慢。如果钻石没有明显的气泡和裂痕的话,一个上午我大概可以
: 把一个0.5克拉的钻石抛出一个介于“old single cut”和“round brilliant cut”之
: 间的类型出来。
: 是正常的大头,抛的时间会大大延长。

avatar
b*n
108
你那个香皂菜花雕刻的很强啊,要是当木匠也会是个手艺很好的木匠,不过就是太屈才
了。

【在 s******y 的大作中提到】
: 工作需要。不过我是手工艺爱好者,人生最大理想是做一个木匠
avatar
S*9
109
第一句话挺哲的

【在 s******y 的大作中提到】
: 其实是互相磨,都有损耗。钻石里的气泡很容易看见,一般的放大倍数不高的光学显微
: 镜就可以。
: 你去珠宝店,很多晶体都分天然生长的和人工生长的,区别么,就是前者价钱比后者高
: ,后者品质比前者高。不过买这些东西的,都是买个难得罢了。

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。