monotone

monotone Mtn Source Tree

Root/src/constants.hh

1// Copyright (C) 2002 Graydon Hoare <graydon@pobox.com>
2//
3// This program is made available under the GNU GPL version 2.0 or
4// greater. See the accompanying file COPYING for details.
5//
6// This program is distributed WITHOUT ANY WARRANTY; without even the
7// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8// PURPOSE.
9
10#ifndef __CONSTANTS_HH__
11#define __CONSTANTS_HH__
12
13#include <cstddef>
14#include <ctime>
15#include "numeric_vocab.hh"
16
17namespace constants
18{
19 // this file contains magic constants which you could, in theory, tweak.
20 // probably best not to tweak them though.
21 // all scalar constants are defined in this file so their values are
22 // visible to the compiler; aggregate constants are defined in
23 // constants.cc, which also has some static assertions to make sure
24 // everything is consistent.
25
26 // number of bits in an RSA key we use
27 std::size_t const keylen = 1024;
28
29 // number of characters in a SHA1 id
30 std::size_t const idlen = 40;
31
32 // number of binary bytes, ditto
33 std::size_t const idlen_bytes = idlen / 2;
34
35 // number of characters in an encoded epoch
36 std::size_t const epochlen = idlen;
37
38 // number of characters in a raw epoch
39 std::size_t const epochlen_bytes = idlen_bytes;
40
41 // default packet size for 'automate stdio'
42 std::size_t const default_stdio_packet_size = 32768;
43
44 // number of seconds in window, in which to consider CVS commits equivalent
45 // if they have otherwise compatible contents (author, changelog)
46 std::time_t const cvs_window = 60 * 5;
47
48 // number of bytes in a password buffer. further bytes will be dropped.
49 std::size_t const maxpasswd = 0xfff;
50
51 // number of bytes to use in buffers, for buffered i/o operations
52 std::size_t const bufsz = 0x3ffff;
53
54 // size of a line of database traffic logging, beyond which lines will be
55 // truncated.
56 std::size_t const db_log_line_sz = 50;
57
58 // maximum size in bytes of the database xdelta version reconstruction
59 // cache. the value of 7 MB was determined as the optimal point after
60 // timing various values with a pull of the monotone repository - it could
61 // be tweaked further.
62 std::size_t const db_version_cache_sz = 7 * (1 << 20);
63
64 // maximum size in bytes of the write-back roster cache
65 // the value of 7 MB was determined by blindly copying the line above and
66 // not doing any testing at all - it could be tweaked further.
67 std::size_t const db_roster_cache_sz = 7 * (1 << 20);
68
69 // minimum number of items in the roster cache
70 // When receiving even a perfectly linear history, the cache needs
71 // to have at least 2 entries to be effective.
72 // Monotone, Pidgin, and Auroraux also all show *huge* drops in misses
73 // at 3 entries, monotone is the smallest drop with about a quarter as
74 // many misses at 3 entries as at 2 entries. (Not that this setting
75 // likely *matters* for monotone, since it's tree is rather small and
76 // a large number of entries fit in db_roster_cache_sz anyway.)
77 std::size_t const db_roster_cache_min_count = 3;
78
79 // estimated number of bytes taken for a node_t and its corresponding
80 // marking_t. used to estimate the current size of the write-back roster
81 // cache. the calculation is:
82 // -- 40 bytes content hash
83 // -- a path component, maybe 10 or 15 bytes
84 // -- 40 bytes birth revision
85 // -- 40 bytes name marking hash
86 // -- 40 bytes content marking hash
87 // -- plus internal pointers, etc., for strings, sets, shared_ptrs, heap
88 // overhead, ...
89 // -- plus any space taken for attrs
90 // so ~175 bytes for a file node, plus internal slop, plus attrs (another
91 // 60 bytes per attr, or so), minus 80 bytes for dir nodes. So this just
92 // picks a number that seems a reasonable amount over 175.
93 std::size_t const db_estimated_roster_node_sz = 210;
94
95 // maximum number of bytes to be consumed with the delayed write cache
96 unsigned long const db_max_delayed_file_bytes = 16 * (1 << 20);
97
98 // size of a line of text in the log buffer, beyond which log lines will be
99 // truncated.
100 std::size_t const log_line_sz = 0x300;
101
102 // assumed width of the terminal, when we can't query for it directly
103 std::size_t const default_terminal_width = 72;
104
105 // all the ASCII characters (bytes) which are legal in a base64 blob
106 extern char const legal_base64_bytes[];
107
108 // all the ASCII characters (bytes) which are legal in a SHA1 hex id
109 extern char const legal_id_bytes[];
110
111 // all the ASCII characters (bytes) which can occur in cert names
112 extern char const legal_cert_name_bytes[];
113
114 // all the ASCII characters (bytes) which can occur in key names
115 extern char const legal_key_name_bytes[];
116
117 // remaining constants are related to netsync protocol
118
119 // number of bytes in the hash used in netsync
120 std::size_t const merkle_hash_length_in_bytes = 20;
121
122 // number of bits of merkle prefix consumed by each level of tree
123 std::size_t const merkle_fanout_bits = 4;
124
125 // derived from hash_length_in_bytes
126 std::size_t const merkle_hash_length_in_bits
127 = merkle_hash_length_in_bytes * 8;
128
129 // derived from fanout_bits
130 std::size_t const merkle_num_tree_levels
131 = merkle_hash_length_in_bits / merkle_fanout_bits;
132
133 // derived from fanout_bits
134 std::size_t const merkle_num_slots = 1 << merkle_fanout_bits;
135
136 // derived from fanout_bits
137 std::size_t const merkle_bitmap_length_in_bits = merkle_num_slots * 2;
138
139 // derived from fanout_bits
140 std::size_t const merkle_bitmap_length_in_bytes
141 = merkle_bitmap_length_in_bits / 8;
142
143 // the current netcmd/netsync protocol version
144 u8 const netcmd_current_protocol_version = 8;
145
146 // the oldest netcmd/netsync protocol version that we're compatible with
147 u8 const netcmd_minimum_protocol_version = 6;
148
149 // minimum size of any netcmd on the wire
150 std::size_t const netcmd_minsz = (1 // version
151 + 1 // cmd code
152 + 1); // smallest uleb possible
153
154
155 // largest command *payload* allowed in a netcmd
156 // in practice, this sets the size of the largest compressed file
157 std::size_t const netcmd_payload_limit = 2 << 27;
158
159 // maximum size of any netcmd on the wire, including payload
160 std::size_t const netcmd_maxsz = netcmd_minsz + netcmd_payload_limit;
161
162 // netsync fragments larger than this are gzipped
163 std::size_t const netcmd_minimum_bytes_to_bother_with_gzip = 0xfff;
164
165 // TCP port to listen on / connect to when doing netsync
166 std::size_t const netsync_default_port = 4691;
167
168 // maximum number of simultaneous clients on a server
169 std::size_t const netsync_connection_limit = 1024;
170
171 // number of seconds a connection can be idle before it's dropped
172 std::size_t const netsync_timeout_seconds = 21600; // 6 hours
173
174 // netsync HMAC key length
175 std::size_t const netsync_session_key_length_in_bytes = 20;
176
177 // netsync HMAC value length
178 std::size_t const netsync_hmac_value_length_in_bytes = 20;
179
180 // how long a sha1 digest should be
181 std::size_t const sha1_digest_length = 20; // 160 bits
182
183 // netsync session key default initializer
184 extern char const netsync_key_initializer[];
185
186 // attributes
187 extern char const encoding_attribute[];
188 extern char const binary_encoding[];
189 extern char const default_encoding[];
190 extern char const manual_merge_attribute[];
191}
192
193#endif // __CONSTANTS_HH__
194
195// Local Variables:
196// mode: C++
197// fill-column: 76
198// c-file-style: "gnu"
199// indent-tabs-mode: nil
200// End:
201// vim: et:sw=2:sts=2:ts=2:cino=>2s,{s,\:s,+s,t0,g0,^-2,e-2,n-2,p2s,(0,=s:

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status