Julia : 如何进一步改进操作Redis的效率?

来源:互联网 发布:b神淘宝店 编辑:程序博客网 时间:2024/04/27 18:16
最近在用Julia脚本操作Redis内存数据库,但是感觉Julia的脚本效率比较低。还没有找到相关办法。
julia> using Redis;julia>  conn = RedisConnection( host="127.0.0.1", port=6379, db=0);julia> trans = open_transaction(conn);julia> mydat= Dict{Any,Any}();julia> @time for i =1:10000 setindex!(mydat,"abcdefghijklmn",i) end;  0.011981 seconds (47.48 k allocations: 1.079 MB)julia> length(mydat)10000julia> mydat2 = mydat;julia> @time hmset(trans,"mydat_1",mydat)  1.958942 seconds (382.23 k allocations: 2.892 GB, 29.62% gc time)"QUEUED"julia> @time for i =10001:1000000 setindex!(mydat,"abcdefghijklmn",i) end;  5.918395 seconds (10.73 M allocations: 228.507 MB, 59.50% gc time)julia> @time hmset(trans,"mydat_2",mydat)ERROR: InterruptException: in string at ascii.jl:44 in pack_command at C:\Users\Administrator\.julia\v0.4\Redis\src\parser.jl:74 in execute_command at C:\Users\Administrator\.julia\v0.4\Redis\src\parser.jl:83 in hmset at C:\Users\Administrator\.julia\v0.4\Redis\src\client.jl:76julia> @time hmset(conn,"mydat_conn",mydat2)  1.901253 seconds (379.91 k allocations: 2.892 GB, 28.90% gc time)truejulia> @time reData_conn= hgetall(conn,"mydat_conn");  0.346850 seconds (343.77 k allocations: 18.921 MB, 6.67% gc time)julia> typeof(reData_conn)Dict{AbstractString,AbstractString}julia> length(reData_conn)10000

问题:当KEY-VALUE在1万量级时,基本运行正常;但达到100万量级时,效率极其低下,只有中断执行。这个问题,不管是否使用事务,基本一样。
事务的效率并不明显,不知为什么?使用不正确?

0 0