[2001-7-18 5:07:19] A:
hi, something about adstorge server....
in adstoragesvr.cpp, the .Get() function of adcache, and the lock of the cache has some problems i think.....
[2001-7-18 5:08:59] B:
ok, please give more info.
[2001-7-18 5:11:58] A:
I think u can lock the cache between get and store the cache...so
the sequence is lock the cache->Get()-> Fetchtemplate->Store->release lock, otherwise it may cause multi-thread problem...
and the process above should be put in Cache.Get() function....
[2001-7-18 5:13:41] A:
the reason that puting the process to Get() function is that it is better that the lock is used just in the cache class...
[2001-7-18 5:14:48] B:
It's Rayman who advice me to separate database access from
ADCache......
[2001-7-18 5:19:26] A:
yes, separate the db access is better , but then the interal level acess of adcache will appear ...
[2001-7-18 5:22:07] A:
maybe we can give an function to lock the cache in some hashbask, it is not good but better....
[2001-7-18 5:22:46] B:
do you think that the OnRequest function at now would cause
a deadlock in multithread case?
[2001-7-18 5:24:36] A:
no, it maynot...
but the efficency is not good...
and a more serious problem...it is possible that many thread can't get the mid content at the same time, and they get it from db just for one mail content....
[2001-7-18 5:27:25] A:
if we don't consider about the structure of this program, at least
the lock code of adcache should be placed before u invoke Cache's Get() function...
[2001-7-18 5:31:37] B:
按你这么说其实PORTAL Server的ipaecache也有此问题....
[2001-7-18 5:32:52] A:
yes, I do all the process in IPAECache's Get() function, and the lock is between those process as I wrote to you before...
[2001-7-18 5:37:27] B:
我觉得其实区别不大, 不同点就是我现在的写法在Cache中没有letter的时候要多加锁和释放锁一次, 性能可能下降一些.
不过其实我原来是参照ipaecache的把数据库访问,Store等全封装在同一个Get()函数里, 后来Rayman说把数据库访问和Cache分开来, 才改成了现在这样的,
[2001-7-18 5:45:08] A:
HEHE..
由程序结构來说, 兩种做法都是差不多的.只是在兩种风格上取舍那种好而已.
不过你看看, 在你的程序中, 调用GET时从CACHE中取出信內容, 如沒有則就从DB中取, 存入CACHE, 你可以设想有很多thread一起去到GET这行取某一MID的內容. 但是它们取得的都是null, 即很多thread都不能从CACHE中取到同一个MID的內容. 它们到走过了ad.isnull这行, 但都未过Store那行, 此时它们都会从DB中取, 都重复地存入CACHE了.
[2001-7-18 5:48:47] A:
情況可能比较复杂...这样写可能不太清楚...
[2001-7-18 5:49:53] B:
我已经明白你的意思了.
[2001-7-18 5:51:54] A:
你应为呢?
我忘了cache中遇到已有內容时的处理方式...如果它是采用原來的指針进行內容替換的话, 你现有的那段程序可能还有其它一些多線程问题...
[2001-7-18 5:57:44] A:
現在回想起來, 其实当时的PAECACHE设计得很差...如果你覺得有不好的地方, 你不一定要跟它一样的...
[2001-7-18 5:58:29] B:
其实统一写到Get()函数里, 能够避免你这次说的很多thread并发取Cache中没有的信件的问题, 但对于很多thread并发取同一在Cache里有的信件的问题, 统一写到Get()里并加锁的效率一样是不高的, 亦即ipaecache的做法的效率也不会高......
:) 谢谢你的提醒, 我会考虑更好的实现方法.
[2001-7-18 6:03:51] A:
是的, 但是按PAECACHE这种做法是把一个HASH桶鎖上, 它每次都只鎖上CACHE中的一部分而已, 但是它鎖的时间间隔是较長的...所以如果按PAECACHE这种做法, 代价只是在某一个HASH桶上的結點存取时间長一点, 但是与多个thread从数据库中取出并重复执行STORE操作相比, 效率始终高出很多...最少数据库那边已不是一个小的开銷了....
[2001-7-18 6:12:51] A:
好像adcache中的settimetolive和setnodesize等函数沒有存在的必要吧?
当时我只是因为PAE那边较特殊才写的...那兩个函数不太好....
[2001-7-18 6:34:26] B:
IHashCache中的Fetch()函数都是先LockNodeByKey()加锁, 这意味着一个时间只能有一个thread调用Fetch读取Cache中的Node,
看来ihashcache.cpp也得动手改..... 改成读写锁.....
[2001-7-18 6:35:59] A:
这些鎖的粒度都是按HASH桶, 就是說在同一时间, 只要結點位于不同的桶, 就能同时存取...
[2001-7-18 6:38:32] A:
至于读写锁, 我们当时都有考慮, 但是因为好像用到读锁的地方不太多, 所以就干脆省掉了...
[2001-7-18 6:39:12] B:
但无论如何把X锁改成RW锁会more efficient, 况且广告信的数量不会很多, 可能就几封而已....
分享到:
相关推荐
api服务器 用于构建Kubernetes聚合API服务器的通用库。 目的 该库包含用于创建Kubernetes聚合... apiserver是从同步的。 在该位置进行代码更改,合并到k8s.io/kubernetes ,然后在此处同步。 事情你不应该这样做 直
Advertise and monetize your applications ☆ 出版信息:☆ [作者信息] Sanjay Shah Khirulnizam Abd Rahman [出版机构] Packt Publishing [出版日期] 2013年07月26日 [图书页数] 144页 [图书语言] 英语 ...
tmate-ssh-server是的服务器端部分。 用法 参见 。 Docker镜像 提供了一个映像: 以下环境变量用于配置服务器: SSH_KEYS_PATH (强制性):ssh密钥所在的路径。 HAS_WEBSOCKET :如果存在tmate-websocket服务器...
[ZC-HX-RT01-MSR3610]dis cur # version 7.1.064, Release 0615P13 # sysname ZC-HX-RT01-MSR3610 # telnet server enable telnet server acl 2002 # ospf 1 router-id 192.168.120.1 default-route-advertise area...
前端获取广告进行展示接口:/api/getAdvertiseForView/v1参数:返回值:
Advertisement for Callers
BT-LE广告 通过低功耗蓝牙广告服务的示例项目。 该项目对应于同一主题。
Advertise Opportunities是一个在线营销网站,将各种机会体现在一个强大的信息网络中 广告机会是一个在线营销网络,它将各种商业机会整合到一个信息平台中。 我们为寻求开始或扩展家庭业务的人们提供培训,指导和...
智能机器人操作系统IROS V1.7.0 ros1 SDK 安装包 X64 gz格式,基本兼容ROS,性能比ROS高百倍。 demo: ros::init (argc, argv, (char *) "talker"); ros::NodeHandle n; ros::Publisher chatter_pub = n....
2、Access Right访问(存取)权 3、Accounts 网络账号 4、Accounting Services 记账服务 5、Acknowledgment 确认 6、Address Resolution Protocol(ARP)网址解决协议 7、Addresses of Electronic Mail电子邮件地址 ...
大多数课程侧重于Web和移动开发,而另一些课程则涉及数据科学,游戏开发等。 数据 由于进行调查的成本可能很高,因此我们正在使用另一家电子学习公司的调查数据。 该项目的数据集包含有关freeCodeCamp自2017年以来...
目录页;...Speaker:发送BGP报文的设备称为BGP发言者(Speaker),它接收或产生新的报文信息,并发布(Advertise)给其它BGP?Speaker。 Peer:相互交换报文的Speaker之间互称对等体(Peer)。若干相关
通过分析源代码,分析Ralink WIFI driver中的QBSS_LoadAlarm自动切换channel实现机制。
Linux限制某一网卡速度
使用Django REST framework开发Web APIs。 安装步骤 使用Docker安装本服务 docker pull [Repository URL] docker pull mysql:5.7 复制docker-compose.yml到/home/share/vod目录中 复制MySQL配置文件到/home/share/...
17-2-2 Advertise信息生成和发送 17-2-3 Reply消息生成和发送 第18章 DHCP客户端-发起的配置交换 18-1 客户端行为 18-1-1 Request消息生成和发送 18-1-2 Confirm消息生成和发送 18-1-3 Renew消息生成和发送 18...
// advertise an HTTP server on port 3000 bonjour . publish ( { name : 'My Web Server' , type : 'http' , port : 3000 } ) // browse for all http services bonjour . find ( { type : 'http' } , function ( ...
广告机会是一个在线营销网站,它将各种机会...我们为寻求开始或扩展家庭业务的人们提供培训,指导和营销信息。 我们希望您能找到有价值的东西,以帮助指导您完成开始或扩展自己的家庭式业务的过程。 支持语言:English
--apiserver-advertise-address=x.x.x.x 安装包内容: $ tree -L 1 kubernetes-ubuntu-1.10.5 kubernetes-ubuntu-1.10.5 ├── ebtables_2.0.10.4-3.5ubuntu2.18.04.1_amd64.deb ├── kubeadm_1.10.5-00_amd64....
rtmp-平衡器-码头工人cine.io 容器,用于平衡不同 rtmp-endpoints 上的 rtmp-...p 8600:53/udp -h LOAD_BALANCER_SERVER progrium/consul -ui-dir /ui -server -advertise 192.168.59.103 -bootstrap 您必须在