[Varnish] #665: should provide function for aligned allocations on the workspace
Varnish
varnish-bugs at projects.linpro.no
Fri Mar 12 16:57:07 CET 2010
#665: should provide function for aligned allocations on the workspace
-------------------------+--------------------------------------------------
Reporter: slink | Owner: phk
Type: enhancement | Status: new
Priority: normal | Milestone:
Component: varnishd | Version: trunk
Severity: normal | Keywords: ws_alloc workspace allocation alignment
-------------------------+--------------------------------------------------
When WS_Malloc was implemented, it was probably designed for the purpose
of allocating memory for strings only, but it is now being used for
allocation of space for arbitrary data structures. In general, such
allocations may have alignment requirements.
While alignment is enforced only on some harware platforms (many of which
have become less popular (such as SPARC (unfortunetely) or MIPS)), also
AMD makes a clear recommendation for the popular AMD64 platform:
http://www.amd.com/us-
en/assets/content_type/DownloadableAssets/dwamd_AMD64_Porting_FAQ.pdf
What are the memory alignment requirements for code and data in
each of these operating systems?
There are no alignment requirements. x86 architecture has never had any
alignment requirements and the 64-bit extensions have not added any.
However, the ABI for 64-bit software has been designed to improve
performance by striving for natural alignment of most memory operands.
Natural alignment means that 2-byte objects are stored on 2-byte
boundaries, 4-byte objects on 4-byte boundaries, etc. The performance
side-effects of poorly aligned operands can be large.
or here: http://developer.amd.com/pages/11112003167.aspx
[...] a misaligned memory access can require more bus cycles than an
aligned access. For maximum performance, avoid misaligned memory accesses.
Therefor I am suggesting to introduce WS_Malloc for generic pointer-size
aligned allocations (and WS_Calloc as a convenience function while I was
at it already).
--
Ticket URL: <http://www.varnish-cache.org/ticket/665>
Varnish <http://varnish.projects.linpro.no/>
The Varnish HTTP Accelerator
More information about the varnish-bugs
mailing list