Possible overhead question
Summary
In testing out the library, I am trying to figure out how to make it run efficiently, but in some benchmarks I noticed a possible overhead (perhaps due to pybind, not sure). As an example, I saw that the performance of the label()
function - which should just return a property of the tensor, as far as I can see - seems to be dependent on the size / number of sectors of the tensor. This seems strange to me, and it might indicate a possible performance issue in other situations as well, so I would like to hear what you think of this.
Thank you in advance!
Steps to reproduce
Here is a small example:
n_sectors = 6
block_D = 10
s_p = uni10.Qnum(1)
s_0 = uni10.Qnum(0)
s_m = uni10.Qnum(-1)
nlist = [block_D*[uni10.Qnum(i)] for i in range(-n_sectors,n_sectors+1)]
nlist = [i for subl in nlist for i in subl]
Bl = uni10.Bond(uni10.BD_IN, nlist)
Br = uni10.Bond(uni10.BD_OUT, nlist)
Bphys = uni10.Bond(uni10.BD_IN, [s_0, s_p, s_m, s_0])
S = uni10.UniTensorR([Bphys,Bl,Bl,Br,Br])
S.Randomize()
S.PrintDiagram()
And then time the label()
function, like so:
for i in range(0,20): print S.label()
What is the current bug behavior?
cProfile shows the following result:
ncalls tottime percall cumtime percall filename:lineno(function) 20 5.984 0.299 5.984 0.299 {built-in method label}
And this scales up when the size of the blocks is increased, or more legs are added to the tensor, or more symmetry sectors, etc.
What is the expected correct behavior?
I would expect a simple function like this to be quick, and not to scale up with the size of the tensor.
Relevant logs and/or screenshots
Possible fixes
I am not sure where this could be attributed to (or perhaps it is in fact expected behaviour).