Hello,
There seem to be many places where static buffers are used for building strings. It is clear they are used just for usage inside some functions, with no need to keep the value for usage somewhere else.
Would defining a global static buffer to be used for such cases make sense? The access to the pointer and size can be given via functions.
There could be couple of such buffers to be used in the cases one function need concurrent access to more than one ... opinions? It will reduce memory space reserved and used...
Cheers, Daniel
On Thursday 27 November 2008, Daniel-Constantin Mierla wrote:
There seem to be many places where static buffers are used for building strings. It is clear they are used just for usage inside some functions, with no need to keep the value for usage somewhere else.
Would defining a global static buffer to be used for such cases make sense? The access to the pointer and size can be given via functions.
There could be couple of such buffers to be used in the cases one function need concurrent access to more than one ... opinions? It will reduce memory space reserved and used...
Hi Daniel,
what about getting rid of this static buffers completely? If we want to go multi-threaded sometimes, we need to lock every access. And i doubt it really makes a difference from the performance POV nowadays. The only issue i could think of is eventual memory fragementation..
Cheers,
Henning
On Nov 27, 2008 at 16:22, Henning Westerholt henning.westerholt@1und1.de wrote:
On Thursday 27 November 2008, Daniel-Constantin Mierla wrote:
There seem to be many places where static buffers are used for building strings. It is clear they are used just for usage inside some functions, with no need to keep the value for usage somewhere else.
Would defining a global static buffer to be used for such cases make sense? The access to the pointer and size can be given via functions.
There could be couple of such buffers to be used in the cases one function need concurrent access to more than one ... opinions? It will reduce memory space reserved and used...
Hi Daniel,
what about getting rid of this static buffers completely? If we want to go multi-threaded sometimes, we need to lock every access. And i doubt it really makes a difference from the performance POV nowadays. The only issue i could think of is eventual memory fragementation..
We could use buffers on the stack as much as possible (we don't need to pkg_malloc all the buffers).
Andrei
On 11/27/08 17:51, Andrei Pelinescu-Onciul wrote:
On Nov 27, 2008 at 16:22, Henning Westerholt henning.westerholt@1und1.de wrote:
On Thursday 27 November 2008, Daniel-Constantin Mierla wrote:
There seem to be many places where static buffers are used for building strings. It is clear they are used just for usage inside some functions, with no need to keep the value for usage somewhere else.
Would defining a global static buffer to be used for such cases make sense? The access to the pointer and size can be given via functions.
There could be couple of such buffers to be used in the cases one function need concurrent access to more than one ... opinions? It will reduce memory space reserved and used...
Hi Daniel,
what about getting rid of this static buffers completely? If we want to go multi-threaded sometimes,
he, he ... let's look closer in the future ... and from management perspective looks easier if they are collected in one place.
we need to lock every access. And i doubt it really makes a difference from the performance POV nowadays. The only issue i could think of is eventual memory fragementation..
We could use buffers on the stack as much as possible (we don't need to pkg_malloc all the buffers).
yes, but is it advisable to do it with big buffers ... ?
Cheers, Daniel
On Nov 27, 2008 at 18:27, Daniel-Constantin Mierla miconda@gmail.com wrote:
On 11/27/08 17:51, Andrei Pelinescu-Onciul wrote:
On Nov 27, 2008 at 16:22, Henning Westerholt henning.westerholt@1und1.de wrote:
On Thursday 27 November 2008, Daniel-Constantin Mierla wrote:
There seem to be many places where static buffers are used for building strings. It is clear they are used just for usage inside some functions, with no need to keep the value for usage somewhere else.
Would defining a global static buffer to be used for such cases make sense? The access to the pointer and size can be given via functions.
There could be couple of such buffers to be used in the cases one function need concurrent access to more than one ... opinions? It will reduce memory space reserved and used...
Hi Daniel,
what about getting rid of this static buffers completely? If we want to go multi-threaded sometimes,
he, he ... let's look closer in the future ... and from management perspective looks easier if they are collected in one place.
we need to lock every access. And i doubt it really makes a difference from the performance POV nowadays. The only issue i could think of is eventual memory fragementation..
We could use buffers on the stack as much as possible (we don't need to pkg_malloc all the buffers).
yes, but is it advisable to do it with big buffers ... ?
It depends, but in general yes, unless you have something very big. A few k shouldn't be any problem, The performance overhead is only 1 cycle when entering the function, when using the stack (sp-=sizeof(buffer)) and from the cache point of view there is no difference since you write to it anyway.
Andrei
On Nov 27, 2008 at 17:15, Daniel-Constantin Mierla miconda@gmail.com wrote:
Hello,
There seem to be many places where static buffers are used for building strings. It is clear they are used just for usage inside some functions, with no need to keep the value for usage somewhere else.
Would defining a global static buffer to be used for such cases make sense? The access to the pointer and size can be given via functions.
In general I think we should move away from static buffers (we will need to get rid of a lot of them for the async. stuff so most of this work will have to be redone anyway).
There could be couple of such buffers to be used in the cases one function need concurrent access to more than one ... opinions? It will reduce memory space reserved and used...
I'm afraid it would introduce a lot of new bugs (you must make sure your functions that call each other do not use the same static buffer and that you do not call function using the same buffer in a row). As far as the memory space is concerned, it depends on how many of them are used. At least in sip-router core less then 1Mb is used in static vars of all kinds:
objdump -j .bss -j .data -t ser|perl -ne 'END { print "\nTotal: $s bytes\n" }; @l=split; $s+= hex $l[4]; print hex($l[4]), "\t-\t$l[5]\t$l[1]\t$l[2]\t$l[3]\n" ' => Total: 4604741 bytes in staitic vars, but 4M is the pkg mem pool => 410437 bytes from which 2*139276 are tcp local timers and 65k udp recv buffers => 66349 in other static vars and buffers.
So I guess it doesn't make sense to try to go beyond 66k...
Andrei
On 11/27/08 17:48, Andrei Pelinescu-Onciul wrote:
On Nov 27, 2008 at 17:15, Daniel-Constantin Mierla miconda@gmail.com wrote:
Hello,
There seem to be many places where static buffers are used for building strings. It is clear they are used just for usage inside some functions, with no need to keep the value for usage somewhere else.
Would defining a global static buffer to be used for such cases make sense? The access to the pointer and size can be given via functions.
In general I think we should move away from static buffers (we will need to get rid of a lot of them for the async. stuff so most of this work will have to be redone anyway).
these are one time usage, without any concurrency. They are basically used inside functions to avoid alloc/free for each function. I think this is not affected by async stuff.
There could be couple of such buffers to be used in the cases one function need concurrent access to more than one ... opinions? It will reduce memory space reserved and used...
I'm afraid it would introduce a lot of new bugs (you must make sure your functions that call each other do not use the same static buffer and that you do not call function using the same buffer in a row). As far as the memory space is concerned, it depends on how many of them are used. At least in sip-router core less then 1Mb is used in static vars of all kinds:
in the modules might be bigger... I think with 5 buffers, each of 1k, we can satisfy all needs.
Cheers, Daniel
objdump -j .bss -j .data -t ser|perl -ne 'END { print "\nTotal: $s bytes\n" }; @l=split; $s+= hex $l[4]; print hex($l[4]), "\t-\t$l[5]\t$l[1]\t$l[2]\t$l[3]\n" ' => Total: 4604741 bytes in staitic vars, but 4M is the pkg mem pool => 410437 bytes from which 2*139276 are tcp local timers and 65k udp recv buffers => 66349 in other static vars and buffers.
So I guess it doesn't make sense to try to go beyond 66k...
Andrei
sr-dev mailing list sr-dev@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev