Skip to main content.

DOWNLOAD

PTB-1.0 here

Page Table Buffer ABSTRACT

PTB is a very small but powerful library that handles very small and frequent allocations and de-allocation by caching the memory in fixed-size pages. Page size is configurable while making the library (with defines), and cannot be changed at runtime.

PTB was developed under the hood of the CABAL project, a system that caches and optimizes network traffic; the problem there was to store data to be sent on the network, pre-organized in network sized packets (up to 1500 bytes), in a transient space. Having to minimize memory copy times, it had been necessary to develop some sort of memory management. A soltuion would have been that of using reference counted memory where to store packets data (destination, sender etc.) along with their payoff (generated by the final application), but allocation and deallocation times, for how much malloc was optimized for small memory blocks, would have just been a bottleneck.

Another solution may have been that one to use a growable buffer from which to get free blocks and send them to the application requesting for space where to store the data. But the reallocation time caused by the growth of this buffer under peak times was still unacceptables, not counting the high cost of maintainance of this buffer: to minimize fragmentation and to reduce memory usage, a search for a free memory block should have been done at each request; even using indexing technique, that was a little too much time.

PTB algorithm higly optimizes allocation and deallocation time, relies on system memory pages (and so it doesn't need the memory pool support provied by malloc), grants high throughput of memory and, under certains condition a relatively low frammentation.

On the other hand, PTB may be less efficient during "warm up" time, and can use more memory than needed in the case of the allocated block are meant to be allocated for an undefinitely long time period. Finally, it cannot allocate an item larger than the memory page it uses; but this concerns were not in our schedule, as PTB was specifically meant to temporarily hold small memory blocks that are going to be deleted in a very short (and even pre-determinable) time lapse.

PTB works on unices (tested on Linux and BSD) and on MS-Windows. It's actually fully portable; the target application can directly call PTB functions without any difference between Unix and Windows.

An essential documentation is shipped with the tgz.

LICENSE

This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.

Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:

      The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
      Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
      This notice may not be removed or altered from any source distribution.

PTB can be found at http://www.niccolai.cc