erlang ets heir read_concurrency

2024-03-11 09:58
文章标签 read concurrency erlang ets heir

本文主要是介绍erlang ets heir read_concurrency,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

ets  在创建的时候有这个一个选项  read_concurrency 

官方文档解释如下


{read_concurrency,boolean()} Performance tuning. 
Default is false. When set to true, the table is optimized for concurrent read operations. 
When this option is enabled on a runtime system with SMP support, read operations become much cheaper; 
especially on systems with multiple physical processors.However, switching between read and write operations becomes more expensive. You typically want to enable this option when concurrent read operations are much more frequent than write operations, or when concurrent 
reads and writes comes in large read and write bursts (i.e., lots of reads not interrupted by writes,and lots of writes not interrupted by reads). 
You typically do not want to enable this option when the common access pattern is a few read operations interleaved with a few write operations repeatedly. 
In this case you will get a performance degradation by enabling this option. The read_concurrency option can be combined with the write_concurrency option. 
You typically want to combine these when large concurrent read bursts and large concurrent write bursts are common.


大致意思是,开启这个属性后 并发读效率提升,但是读/写之间切换效率会降低。

当有连续读需求,并且中间不穿插写操作时,可以试一下开启这个功能


做了一个小测试


%%首先启动三个ets log_time用于记录每个查询操作消耗的时间
ets:new(open_concurrency, [set, public, named_table, {keypos, 1}, {read_concurrency,true}].
ets:new(close_concurrency, [set, public, named_table, {keypos, 1}, {read_concurrency,false}].
ets:new(log_time, [set, public, named_table, {keypos, 1}, {read_concurrency,true}].read(EtsName) ->%%选择一个ets表先写入数据用于被查询FunUpdate = fun(Nth) ->cache:update(EtsName, Nth, Nth)end,
lists:foreach(FunUpdate, lists:sql(1, 10000)),ets:delete_all_objects(log_time),FunGetTime = fun(Nth) -> spawn(fun() ->SelectNth = utils:rand(1, 10000),{SelectTime, _} = timer:tc(fun() ->cache:get_value(EtsName, SelectNth)end),%%由于在子进程内,只能将时间数据储存在ets中cache:update(log_time, Nth, SelectTime)end)end,lists:froeach(FunPrint, lists:seq(1, 1000000)).%%随后再从log_time中将时间相加

 
 

对开启并发读/不开启并发读的ets分别 做了100万次的读取,

在windows上测试了下结果,发现不开启并发读的时间竟然每次都少。。。

尴尬有时间了再去linux环境下看看。。


ets  heir 当前ets 进程销毁后,会将数据发送至设定的heir进程


这篇关于erlang ets heir read_concurrency的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/797477

相关文章

SOMEIP_ETS_095: SD_Check_subscribe_eventgroup_ttl_expired

测试目的: 验证DUT(Device Under Test)能够检测到测试器(Tester)的订阅已过期(ttl = 3秒),并且在TTL过期后不响应测试器触发的事件。 描述 本测试用例旨在确保DUT能够识别测试器的订阅已过期,并在订阅过期后不响应测试器通过TriggerEventUint8方法触发的事件。 测试拓扑: 具体步骤: TESTER:发送订阅事件组消息,用于事件组0x0

vue 父组件调用子组件的方法报错,“TypeError: Cannot read property ‘subDialogRef‘ of undefined“

vue 父组件调用子组件的方法报错,“TypeError: Cannot read property ‘subDialogRef’ of undefined” 最近用vue做的一个界面,引入了一个子组件,在父组件中调用子组件的方法时,报错提示: [Vue warn]: Error in v-on handler: “TypeError: Cannot read property ‘methods

[轻笔记] pip install : Read timed out. (closed)

添加超时参数(单位秒) pip --default-timeout=10000 install ${package_name}

Cannot read property ‘length‘ of null while opening vscode terminal

同一问题地址:Cannot read property ‘length’ of null while opening vscode terminal 问题描述 One day, 我在ubuntu 18.04下用vscode打开一个项目,并想和往常一样在vscode使用终端,发现报错Cannot read property 'length' of null。 解决 打开setting.jso

王立平--Failed to push selection: Read-only file system

往android模拟器导入资源,失败。提示:只读文件、 mnt是只读文件。应点击sdcard,,在导入

erlang学习:用ETS和DETS存储数据3,保存元组到磁盘

学习内容 ETS表把元组保存在内存里,而DETS提供了把Erlang元组保存到磁盘上的方法。DETS的最大文件大小是2GB。DETS文件必须先打开才能使用,用完后还应该正确关闭。如果没有正确关闭,它们就会在下次打开时自动进行修复。因为修复可能会花很长一段时间,所以先正确关闭它们再结束程序是很重要的。 DETS表有着和ETS表不同的共享属性。DETS表在打开时必须赋予一个全局名称。如果两个或更多

uniapp微信小程序开发踩坑日记:Pinia持久化报错Cannot read property ‘localStorage‘ of undefined

插件默认使用 localStorage 实现持久化,小程序端不兼容,需要替换持久化 API import { defineStore } from 'pinia'   export const useCommonStore = defineStore('pack-store', {state: (): State => ({wwInfo: {},globalData: {},timerLoc

SOMEIP_ETS_089: SD_Calling_same_ports_before_and_after_suspendInterface

测试目的: 验证设备(DUT)是否能够在一个请求完成后,对相同的SOME/IP端口恢复监听和分派请求。 描述 本测试用例旨在检查DUT在执行了SuspendInterface操作后,是否仍然能够使用与之前相同的源端口和SOME/IP端口来响应方法调用。 测试拓扑: 具体步骤: TESTER:第一个TestFieldUINT8 Getter和SetterDUT:正常响应TESTER:

macos 系统文件操作时提示 Read-only file system 解决方法

这个情况是因为文件系统为只读, 需要我们执行一下命令重新将系统文件挂载为读写模式, 命令如下: sudo mount -uw / 这里的 mount 就是硬盘挂载命令, 后面的 -uw选项说明如下, 最后的 / 表示的是跟目录, 可以指定要修改的挂载路径,也可以默认. -u     -u标志表示应更改已装载文件系统的状态。上述任何选项(-o选项)都可以更改;文件系统也可以从只读更改为读写,

redis被攻击redis READONLY You can‘t write against a read only slave.

redis 日志路径 /var/log/redis 拿下来后发现有这种错误 Operation now in progress 可能是网络断开导致, 查找redis whereis redis 修改 vim /etc/redis.conf 大概在300行 下面代码yes改no slave-read-only no 重启redis sudo systemctl restart