~akopytov/percona-xtrabackup/bug1166888-2.0

« back to all changes in this revision

Viewing changes to src/libarchive/build/cmake/AddTest28.cmake

  • Committer: Alexey Kopytov
  • Date: 2012-02-10 20:05:56 UTC
  • mto: This revision was merged to the branch mainline in revision 390.
  • Revision ID: akopytov@gmail.com-20120210200556-6kx41z8wwrqfucro
Rebase of the parallel compression patch on new trunk + post-review
fixes.

Implementation of parallel compression and streaming for XtraBackup.

This revision implements the following changes:

* InnoDB files are now streamed by the xtrabackup binary rather than
innobackupex. As a result, integrity is now verified by xtrabackup and
thus tar4ibd is no longer needed, so it was removed.

* xtrabackup binary now accepts the new '--stream' option which has
exactly the same semantics as the '--stream' option in
innobackupex: it tells xtrabackup to stream all files to the standard
output in the specified format rather than storing them locally.

* The xtrabackup binary can now do parallel compression using the
quicklz library. Two new options were added to xtrabackup to support
this feature:

- '--compress' tells xtrabackup to compress all output data, including
the transaction log file and meta data files, using the specified
compression algorithm. The only currently supported algorithm is
'quicklz'. The resulting files have the qpress archive format,
i.e. every *.qp file produced by xtrabackup is essentially a one-file
qpress archive and can be extracted and uncompressed by the qpress
file archiver (http://www.quicklz.com/).

- '--compress-threads' specifies the number of worker threads used by
xtrabackup for parallel data compression. This option defaults to 1.

Parallel compression ('--compress-threads') can be used together with
parallel file copying ('--parallel'). For example, '--parallel=4
--compress --compress-threads=2' will create 4 IO threads that will
read the data and pipe it to 2 compression threads.

* To support simultaneous compression and streaming, a new custom
streaming format called 'xbstream' was introduced to XtraBackup in
addition to the 'tar' format. That was required to overcome some
limitations of traditional archive formats such as 'tar', 'cpio' and
others that do not allow streaming dynamically generated files, for
example dynamically compressed files.  Other advantages of xbstream over
traditional streaming/archive formats include ability to stream multiple
files concurrently (so it is possible to use streaming in the xbstream
format together with the --parallel option) and more compact data
storage.

* To allow streaming and extracting files to/from the xbstream format
produced by xtrabackup, a new utility aptly called 'xbstream' was
added to the XtraBackup distribution. This utility has a tar-like
interface:

- with the '-x' option it extracts files from the stream read from its
standard input to the current directory unless specified otherwise
with the '-C' option.

- with the '-c' option it streams files specified on the command line
to its standard output.

The utility also tries to minimize its impact on the OS page cache by
using the appropriate posix_fadvise() calls when available.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# - Macro approximating the CMake 2.8 ADD_TEST(NAME) signature.
 
2
# ADD_TEST_28(NAME <name> COMMAND <command> [arg1 [arg2 ...]])
 
3
#  <name>    - The name of the test
 
4
#  <command> - The test executable
 
5
#  [argN...] - Arguments to the test executable
 
6
# This macro approximates the ADD_TEST(NAME) signature provided in
 
7
# CMake 2.8 but works with CMake 2.6 too.  See CMake 2.8 documentation
 
8
# of ADD_TEST()for details.
 
9
#
 
10
# This macro automatically replaces a <command> that names an
 
11
# executable target with the target location.  A generator expression
 
12
# of the form "$<TARGET_FILE:tgt>" is supported in both the command
 
13
# and arguments of the test.  Howerver, this macro only works for
 
14
# targets without per-config output name properties set.
 
15
#
 
16
# Example usage:
 
17
#   add_test(NAME mytest COMMAND testDriver --exe $<TARGET_FILE:myexe>)
 
18
# This creates a test "mytest" whose command runs a testDriver tool
 
19
# passing the full path to the executable file produced by target
 
20
# "myexe".
 
21
 
 
22
#=============================================================================
 
23
# Copyright 2009 Kitware, Inc.
 
24
# All rights reserved.
 
25
#
 
26
# Redistribution and use in source and binary forms, with or without
 
27
# modification, are permitted provided that the following conditions
 
28
# are met:
 
29
# 1. Redistributions of source code must retain the above copyright
 
30
#    notice, this list of conditions and the following disclaimer
 
31
#    in this position and unchanged.
 
32
# 2. Redistributions in binary form must reproduce the above copyright
 
33
#    notice, this list of conditions and the following disclaimer in the
 
34
#    documentation and/or other materials provided with the distribution.
 
35
#
 
36
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
 
37
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 
38
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 
39
# IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
 
40
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 
41
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 
42
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 
43
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 
44
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 
45
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
46
#=============================================================================
 
47
 
 
48
CMAKE_MINIMUM_REQUIRED(VERSION 2.6.3)
 
49
 
 
50
# CMake 2.8 supports ADD_TEST(NAME) natively.
 
51
IF(NOT "${CMAKE_VERSION}" VERSION_LESS "2.8")
 
52
  MACRO(ADD_TEST_28)
 
53
    ADD_TEST(${ARGV})
 
54
  ENDMACRO()
 
55
  RETURN()
 
56
ENDIF()
 
57
 
 
58
# Simulate ADD_TEST(NAME) signature from CMake 2.8.
 
59
MACRO(ADD_TEST_28 NAME name COMMAND command)
 
60
  # Enforce the signature.
 
61
  IF(NOT "x${NAME}" STREQUAL "xNAME")
 
62
    MESSAGE(FATAL_ERROR "First ADD_TEST_28 argument must be \"NAME\"")
 
63
  ENDIF()
 
64
  IF(NOT "x${COMMAND}" STREQUAL "xCOMMAND")
 
65
    MESSAGE(FATAL_ERROR "Third ADD_TEST_28 argument must be \"COMMAND\"")
 
66
  ENDIF()
 
67
 
 
68
  # Perform "COMMAND myexe ..." substitution.
 
69
  SET(cmd "${command}")
 
70
  IF(TARGET "${cmd}")
 
71
    _ADD_TEST_28_GET_EXE(${cmd} cmd)
 
72
  ENDIF()
 
73
 
 
74
  # Perform "COMMAND ... $<TARGET_FILE:myexe> ..." substitution.
 
75
  SET(target_file "\\$<TARGET_FILE:(.+)>")
 
76
  SET(args)
 
77
  FOREACH(ARG ${cmd} ${ARGN})
 
78
    SET(arg "${ARG}")
 
79
    IF("${arg}" MATCHES "${target_file}")
 
80
      STRING(REGEX REPLACE "${target_file}" "\\1" tgt "${arg}")
 
81
      IF(TARGET "${tgt}")
 
82
        _ADD_TEST_28_GET_EXE(${tgt} exe)
 
83
        STRING(REGEX REPLACE "${target_file}" "${exe}" arg "${arg}")
 
84
      ENDIF()
 
85
    ENDIF()
 
86
    LIST(APPEND args "${arg}")
 
87
  ENDFOREACH()
 
88
 
 
89
  # Invoke old ADD_TEST() signature with transformed arguments.
 
90
  ADD_TEST(${name} ${args})
 
91
ENDMACRO()
 
92
 
 
93
# Get the test-time location of an executable target.
 
94
MACRO(_ADD_TEST_28_GET_EXE tgt exe_var)
 
95
  # The LOCATION property gives a build-time location.
 
96
  GET_TARGET_PROPERTY(${exe_var} ${tgt} LOCATION)
 
97
 
 
98
  # In single-configuration generatrs the build-time and test-time
 
99
  # locations are the same because there is no per-config variable
 
100
  # reference.  In multi-configuration generators the following
 
101
  # substitution converts the build-time configuration variable
 
102
  # reference to a test-time configuration variable reference.
 
103
  IF(CMAKE_CONFIGURATION_TYPES)
 
104
    STRING(REPLACE "${CMAKE_CFG_INTDIR}" "\${CTEST_CONFIGURATION_TYPE}"
 
105
      ${exe_var} "${${exe_var}}")
 
106
  ENDIF(CMAKE_CONFIGURATION_TYPES)
 
107
ENDMACRO()