like below fixes the issue That's unspecified; it's up to the implementation. As pointed out by Keith Thompson, it doesn't even have to tell you how it works. :) Some implementations will put all the arguments on the stack, some will use registers, and many use a mix (the first n arguments passed in registers, any more and they go on the stack).
add one each time function is called --- string + number
like below fixes the issue This happens due to the fact the string looks like a datetime to Ruby's default YAML loader. DelayedJob uses YAML for serialization, so this aspect manifests. If you want to keep the string as string, stuff some padding chars to the beginning of it, like x or something. Demo follows.
I wish this helpful for you You are misinterpreting the generated assembly. It's not that the vector's size is assumed unchanged, it's just that the call to v.size() is inlined. The vector's size is still computed anew every loop iteration and loaded into rax. The const qualifier only prevents the functions f and g from modifying the object they refer to. It does not mean they can assume the object is truly immutable and cannot change in size. The compiler has to assume that non-inline functions could be changing the vector, and that includes printf. So the function has to re-compute the vector's size in order to be correct.