monotone

monotone Mtn Source Tree

Root/constants.hh

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

Archive Download this file

Branches

Tags

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