forked from heavyai/heavydb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCommandLineOptions.cpp
1176 lines (1100 loc) · 56 KB
/
CommandLineOptions.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright 2020 OmniSci, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <iostream>
#include "CommandLineOptions.h"
#include "LeafHostInfo.h"
#include "MapDRelease.h"
#include "QueryEngine/GroupByAndAggregate.h"
#include "Shared/Compressor.h"
#include "StringDictionary/StringDictionary.h"
#include "Utils/DdlUtils.h"
const std::string CommandLineOptions::nodeIds_token = {"node_id"};
extern std::string cluster_command_line_arg;
bool g_enable_thrift_logs{false};
extern bool g_use_table_device_offset;
extern float g_fraction_code_cache_to_evict;
extern bool g_cache_string_hash;
extern bool g_enable_idp_temporary_users;
extern bool g_enable_left_join_filter_hoisting;
extern int64_t g_large_ndv_threshold;
extern size_t g_large_ndv_multiplier;
extern int64_t g_bitmap_memory_limit;
extern bool g_enable_calcite_ddl_parser;
extern bool g_enable_seconds_refresh;
extern size_t g_approx_quantile_buffer;
extern size_t g_approx_quantile_centroids;
extern size_t g_parallel_top_min;
extern size_t g_parallel_top_max;
extern size_t g_estimator_failure_max_groupby_size;
namespace Catalog_Namespace {
extern bool g_log_user_id;
}
unsigned connect_timeout{20000};
unsigned recv_timeout{300000};
unsigned send_timeout{300000};
bool with_keepalive{false};
void CommandLineOptions::init_logging() {
if (verbose_logging && logger::Severity::DEBUG1 < log_options_.severity_) {
log_options_.severity_ = logger::Severity::DEBUG1;
}
validate_base_path();
log_options_.set_base_path(base_path);
logger::init(log_options_);
}
void CommandLineOptions::fillOptions() {
help_desc.add_options()("help,h", "Show available options.");
help_desc.add_options()(
"allow-cpu-retry",
po::value<bool>(&g_allow_cpu_retry)
->default_value(g_allow_cpu_retry)
->implicit_value(true),
R"(Allow the queries which failed on GPU to retry on CPU, even when watchdog is enabled.)");
help_desc.add_options()("allow-loop-joins",
po::value<bool>(&allow_loop_joins)
->default_value(allow_loop_joins)
->implicit_value(true),
"Enable loop joins.");
help_desc.add_options()("bigint-count",
po::value<bool>(&g_bigint_count)
->default_value(g_bigint_count)
->implicit_value(true),
"Use 64-bit count.");
help_desc.add_options()("calcite-max-mem",
po::value<size_t>(&system_parameters.calcite_max_mem)
->default_value(system_parameters.calcite_max_mem),
"Max memory available to calcite JVM.");
if (!dist_v5_) {
help_desc.add_options()("calcite-port",
po::value<int>(&system_parameters.calcite_port)
->default_value(system_parameters.calcite_port),
"Calcite port number.");
}
help_desc.add_options()("config",
po::value<std::string>(&system_parameters.config_file),
"Path to server configuration file.");
help_desc.add_options()("cpu-buffer-mem-bytes",
po::value<size_t>(&system_parameters.cpu_buffer_mem_bytes)
->default_value(system_parameters.cpu_buffer_mem_bytes),
"Size of memory reserved for CPU buffers, in bytes.");
help_desc.add_options()("cpu-only",
po::value<bool>(&system_parameters.cpu_only)
->default_value(system_parameters.cpu_only)
->implicit_value(true),
"Run on CPU only, even if GPUs are available.");
help_desc.add_options()("cuda-block-size",
po::value<size_t>(&system_parameters.cuda_block_size)
->default_value(system_parameters.cuda_block_size),
"Size of block to use on GPU.");
help_desc.add_options()("cuda-grid-size",
po::value<size_t>(&system_parameters.cuda_grid_size)
->default_value(system_parameters.cuda_grid_size),
"Size of grid to use on GPU.");
if (!dist_v5_) {
help_desc.add_options()(
"data",
po::value<std::string>(&base_path)->required()->default_value("data"),
"Directory path to OmniSci data storage (catalogs, raw data, log files, etc).");
positional_options.add("data", 1);
}
help_desc.add_options()("db-query-list",
po::value<std::string>(&db_query_file),
"Path to file containing OmniSci warmup queries.");
help_desc.add_options()(
"exit-after-warmup",
po::value<bool>(&exit_after_warmup)->default_value(false)->implicit_value(true),
"Exit after OmniSci warmup queries.");
help_desc.add_options()("dynamic-watchdog-time-limit",
po::value<unsigned>(&dynamic_watchdog_time_limit)
->default_value(dynamic_watchdog_time_limit)
->implicit_value(10000),
"Dynamic watchdog time limit, in milliseconds.");
help_desc.add_options()("enable-debug-timer",
po::value<bool>(&g_enable_debug_timer)
->default_value(g_enable_debug_timer)
->implicit_value(true),
"Enable debug timer logging.");
help_desc.add_options()("enable-dynamic-watchdog",
po::value<bool>(&enable_dynamic_watchdog)
->default_value(enable_dynamic_watchdog)
->implicit_value(true),
"Enable dynamic watchdog.");
help_desc.add_options()("enable-filter-push-down",
po::value<bool>(&g_enable_filter_push_down)
->default_value(g_enable_filter_push_down)
->implicit_value(true),
"Enable filter push down through joins.");
help_desc.add_options()("enable-overlaps-hashjoin",
po::value<bool>(&g_enable_overlaps_hashjoin)
->default_value(g_enable_overlaps_hashjoin)
->implicit_value(true),
"Enable the overlaps hash join framework allowing for range "
"join (e.g. spatial overlaps) computation using a hash table.");
help_desc.add_options()("enable-hashjoin-many-to-many",
po::value<bool>(&g_enable_hashjoin_many_to_many)
->default_value(g_enable_hashjoin_many_to_many)
->implicit_value(true),
"Enable the overlaps hash join framework allowing for range "
"join (e.g. spatial overlaps) computation using a hash table.");
help_desc.add_options()("enable-runtime-query-interrupt",
po::value<bool>(&enable_runtime_query_interrupt)
->default_value(enable_runtime_query_interrupt)
->implicit_value(true),
"Enable runtime query interrupt.");
help_desc.add_options()("enable-non-kernel-time-query-interrupt",
po::value<bool>(&enable_non_kernel_time_query_interrupt)
->default_value(enable_non_kernel_time_query_interrupt)
->implicit_value(true),
"Enable non-kernel time query interrupt.");
help_desc.add_options()("pending-query-interrupt-freq",
po::value<unsigned>(&pending_query_interrupt_freq)
->default_value(pending_query_interrupt_freq)
->implicit_value(1000),
"A frequency of checking the request of pending query "
"interrupt from user (in millisecond).");
help_desc.add_options()(
"running-query-interrupt-freq",
po::value<double>(&running_query_interrupt_freq)
->default_value(running_query_interrupt_freq)
->implicit_value(0.5),
"A frequency of checking the request of running query "
"interrupt from user (0.0 (less frequent) ~ (more frequent) 1.0).");
help_desc.add_options()("use-estimator-result-cache",
po::value<bool>(&use_estimator_result_cache)
->default_value(use_estimator_result_cache)
->implicit_value(true),
"Use estimator result cache.");
if (!dist_v5_) {
help_desc.add_options()(
"enable-string-dict-hash-cache",
po::value<bool>(&g_cache_string_hash)
->default_value(g_cache_string_hash)
->implicit_value(true),
"Cache string hash values in the string dictionary server during import.");
}
help_desc.add_options()(
"enable-thrift-logs",
po::value<bool>(&g_enable_thrift_logs)
->default_value(g_enable_thrift_logs)
->implicit_value(true),
"Enable writing messages directly from thrift to stdout/stderr.");
help_desc.add_options()("enable-watchdog",
po::value<bool>(&enable_watchdog)
->default_value(enable_watchdog)
->implicit_value(true),
"Enable watchdog.");
help_desc.add_options()(
"filter-push-down-low-frac",
po::value<float>(&g_filter_push_down_low_frac)
->default_value(g_filter_push_down_low_frac)
->implicit_value(g_filter_push_down_low_frac),
"Lower threshold for selectivity of filters that are pushed down.");
help_desc.add_options()(
"filter-push-down-high-frac",
po::value<float>(&g_filter_push_down_high_frac)
->default_value(g_filter_push_down_high_frac)
->implicit_value(g_filter_push_down_high_frac),
"Higher threshold for selectivity of filters that are pushed down.");
help_desc.add_options()("filter-push-down-passing-row-ubound",
po::value<size_t>(&g_filter_push_down_passing_row_ubound)
->default_value(g_filter_push_down_passing_row_ubound)
->implicit_value(g_filter_push_down_passing_row_ubound),
"Upperbound on the number of rows that should pass the filter "
"if the selectivity is less than "
"the high fraction threshold.");
help_desc.add_options()("from-table-reordering",
po::value<bool>(&g_from_table_reordering)
->default_value(g_from_table_reordering)
->implicit_value(true),
"Enable automatic table reordering in FROM clause.");
help_desc.add_options()("gpu-buffer-mem-bytes",
po::value<size_t>(&system_parameters.gpu_buffer_mem_bytes)
->default_value(system_parameters.gpu_buffer_mem_bytes),
"Size of memory reserved for GPU buffers, in bytes, per GPU.");
help_desc.add_options()("gpu-input-mem-limit",
po::value<double>(&system_parameters.gpu_input_mem_limit)
->default_value(system_parameters.gpu_input_mem_limit),
"Force query to CPU when input data memory usage exceeds this "
"percentage of available GPU memory.");
help_desc.add_options()(
"hll-precision-bits",
po::value<int>(&g_hll_precision_bits)
->default_value(g_hll_precision_bits)
->implicit_value(g_hll_precision_bits),
"Number of bits used from the hash value used to specify the bucket number.");
if (!dist_v5_) {
help_desc.add_options()("http-port",
po::value<int>(&http_port)->default_value(http_port),
"HTTP port number.");
}
help_desc.add_options()(
"idle-session-duration",
po::value<int>(&idle_session_duration)->default_value(idle_session_duration),
"Maximum duration of idle session.");
help_desc.add_options()("inner-join-fragment-skipping",
po::value<bool>(&g_inner_join_fragment_skipping)
->default_value(g_inner_join_fragment_skipping)
->implicit_value(true),
"Enable/disable inner join fragment skipping. This feature is "
"considered stable and is enabled by default. This "
"parameter will be removed in a future release.");
help_desc.add_options()(
"max-session-duration",
po::value<int>(&max_session_duration)->default_value(max_session_duration),
"Maximum duration of active session.");
help_desc.add_options()("num-sessions",
po::value<int>(&system_parameters.num_sessions)
->default_value(system_parameters.num_sessions),
"Maximum number of active session.");
help_desc.add_options()(
"null-div-by-zero",
po::value<bool>(&g_null_div_by_zero)
->default_value(g_null_div_by_zero)
->implicit_value(true),
"Return null on division by zero instead of throwing an exception.");
help_desc.add_options()(
"num-reader-threads",
po::value<size_t>(&num_reader_threads)->default_value(num_reader_threads),
"Number of reader threads to use.");
help_desc.add_options()(
"max-import-threads",
po::value<size_t>(&g_max_import_threads)->default_value(g_max_import_threads),
"Max number of default import threads to use (num hardware threads will be used "
"instead if lower). Can be overriden with copy statement threads option).");
help_desc.add_options()(
"overlaps-max-table-size-bytes",
po::value<size_t>(&g_overlaps_max_table_size_bytes)
->default_value(g_overlaps_max_table_size_bytes),
"The maximum size in bytes of the hash table for an overlaps hash join.");
help_desc.add_options()("overlaps-target-entries-per-bin",
po::value<double>(&g_overlaps_target_entries_per_bin)
->default_value(g_overlaps_target_entries_per_bin),
"The target number of hash entries per bin for overlaps join");
if (!dist_v5_) {
help_desc.add_options()("port,p",
po::value<int>(&system_parameters.omnisci_server_port)
->default_value(system_parameters.omnisci_server_port),
"TCP Port number.");
}
help_desc.add_options()("num-gpus",
po::value<int>(&system_parameters.num_gpus)
->default_value(system_parameters.num_gpus),
"Number of gpus to use.");
help_desc.add_options()(
"read-only",
po::value<bool>(&read_only)->default_value(read_only)->implicit_value(true),
"Enable read-only mode.");
help_desc.add_options()(
"res-gpu-mem",
po::value<size_t>(&reserved_gpu_mem)->default_value(reserved_gpu_mem),
"Reduces GPU memory available to the OmniSci allocator by this amount. Used for "
"compiled code cache and ancillary GPU functions and other processes that may also "
"be using the GPU concurrent with OmniSciDB.");
help_desc.add_options()("start-gpu",
po::value<int>(&system_parameters.start_gpu)
->default_value(system_parameters.start_gpu),
"First gpu to use.");
help_desc.add_options()("trivial-loop-join-threshold",
po::value<unsigned>(&g_trivial_loop_join_threshold)
->default_value(g_trivial_loop_join_threshold)
->implicit_value(1000),
"The maximum number of rows in the inner table of a loop join "
"considered to be trivially small.");
help_desc.add_options()("verbose",
po::value<bool>(&verbose_logging)
->default_value(verbose_logging)
->implicit_value(true),
"Write additional debug log messages to server logs.");
help_desc.add_options()(
"enable-runtime-udf",
po::value<bool>(&enable_runtime_udf)
->default_value(enable_runtime_udf)
->implicit_value(true),
"Enable runtime UDF registration by passing signatures and corresponding LLVM IR "
"to the `register_runtime_udf` endpoint. For use with the Python Remote Backend "
"Compiler server, packaged separately.");
help_desc.add_options()("version,v", "Print Version Number.");
help_desc.add_options()("enable-experimental-string-functions",
po::value<bool>(&g_enable_experimental_string_functions)
->default_value(g_enable_experimental_string_functions)
->implicit_value(true),
"Enable experimental string functions.");
help_desc.add_options()(
"enable-fsi",
po::value<bool>(&g_enable_fsi)->default_value(g_enable_fsi)->implicit_value(true),
"Enable foreign storage interface.");
help_desc.add_options()("disk-cache-path",
po::value<std::string>(&disk_cache_config.path),
"Specify the path for the disk cache.");
help_desc.add_options()(
"disk-cache-level",
po::value<std::string>(&(disk_cache_level))->default_value("foreign_tables"),
"Specify level of disk cache. Valid options are 'foreign_tables', "
"'local_tables', 'none', and 'all'.");
help_desc.add_options()("disk-cache-size",
po::value<size_t>(&(disk_cache_config.size_limit)),
"Specify a maximum size for the disk cache in bytes.");
#ifdef HAVE_AWS_S3
help_desc.add_options()(
"allow-s3-server-privileges",
po::value<bool>(&g_allow_s3_server_privileges)
->default_value(g_allow_s3_server_privileges)
->implicit_value(true),
"Allow S3 server privileges, if IAM user credentials are not provided. Credentials "
"may be specified with "
"environment variables (such as AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, etc), "
"an AWS credentials file, or when running on an EC2 instance, with an IAM role "
"that is attached to the instance.");
#endif // defined(HAVE_AWS_S3)
help_desc.add_options()(
"enable-interoperability",
po::value<bool>(&g_enable_interop)
->default_value(g_enable_interop)
->implicit_value(true),
"Enable offloading of query portions to an external execution engine.");
help_desc.add_options()("enable-union",
po::value<bool>(&g_enable_union)
->default_value(g_enable_union)
->implicit_value(true),
"Enable UNION ALL SQL clause.");
help_desc.add_options()(
"calcite-service-timeout",
po::value<size_t>(&system_parameters.calcite_timeout)
->default_value(system_parameters.calcite_timeout),
"Calcite server timeout (milliseconds). Increase this on systems with frequent "
"schema changes or when running large numbers of parallel queries.");
help_desc.add_options()("calcite-service-keepalive",
po::value<size_t>(&system_parameters.calcite_keepalive)
->default_value(system_parameters.calcite_keepalive)
->implicit_value(true),
"Enable keepalive on Calcite connections.");
help_desc.add_options()(
"stringdict-parallelizm",
po::value<bool>(&g_enable_stringdict_parallel)
->default_value(g_enable_stringdict_parallel)
->implicit_value(true),
"Allow StringDictionary to parallelize loads using multiple threads");
help_desc.add_options()(
"log-user-id",
po::value<bool>(&Catalog_Namespace::g_log_user_id)
->default_value(Catalog_Namespace::g_log_user_id)
->implicit_value(true),
"Log userId integer in place of the userName (when available).");
help_desc.add_options()("log-user-origin",
po::value<bool>(&log_user_origin)
->default_value(log_user_origin)
->implicit_value(true),
"Lookup the origin of inbound connections by IP address/DNS "
"name, and print this information as part of stdlog.");
help_desc.add_options()(
"allowed-import-paths",
po::value<std::string>(&allowed_import_paths),
"List of allowed root paths that can be used in import operations.");
help_desc.add_options()(
"allowed-export-paths",
po::value<std::string>(&allowed_export_paths),
"List of allowed root paths that can be used in export operations.");
help_desc.add(log_options_.get_options());
}
void CommandLineOptions::fillAdvancedOptions() {
developer_desc.add_options()("dev-options", "Print internal developer options.");
developer_desc.add_options()(
"enable-calcite-view-optimize",
po::value<bool>(&system_parameters.enable_calcite_view_optimize)
->default_value(system_parameters.enable_calcite_view_optimize)
->implicit_value(true),
"Enable additional calcite (query plan) optimizations when a view is part of the "
"query.");
developer_desc.add_options()(
"enable-columnar-output",
po::value<bool>(&g_enable_columnar_output)
->default_value(g_enable_columnar_output)
->implicit_value(true),
"Enable columnar output for intermediate/final query steps.");
developer_desc.add_options()(
"enable-left-join-filter-hoisting",
po::value<bool>(&g_enable_left_join_filter_hoisting)
->default_value(g_enable_left_join_filter_hoisting)
->implicit_value(true),
"Enable hoisting left hand side filters through left joins.");
developer_desc.add_options()("optimize-row-init",
po::value<bool>(&g_optimize_row_initialization)
->default_value(g_optimize_row_initialization)
->implicit_value(true),
"Optimize row initialization.");
developer_desc.add_options()("enable-legacy-syntax",
po::value<bool>(&enable_legacy_syntax)
->default_value(enable_legacy_syntax)
->implicit_value(true),
"Enable legacy syntax.");
developer_desc.add_options()(
"enable-multifrag",
po::value<bool>(&allow_multifrag)
->default_value(allow_multifrag)
->implicit_value(true),
"Enable execution over multiple fragments in a single round-trip to GPU.");
developer_desc.add_options()("enable-lazy-fetch",
po::value<bool>(&g_enable_lazy_fetch)
->default_value(g_enable_lazy_fetch)
->implicit_value(true),
"Enable lazy fetch columns in query results.");
developer_desc.add_options()(
"enable-shared-mem-group-by",
po::value<bool>(&g_enable_smem_group_by)
->default_value(g_enable_smem_group_by)
->implicit_value(true),
"Enable using GPU shared memory for some GROUP BY queries.");
developer_desc.add_options()("num-executors",
po::value<int>(&system_parameters.num_executors)
->default_value(system_parameters.num_executors),
"Number of executors to run in parallel.");
developer_desc.add_options()(
"gpu-shared-mem-threshold",
po::value<size_t>(&g_gpu_smem_threshold)->default_value(g_gpu_smem_threshold),
"GPU shared memory threshold (in bytes). If query requires larger buffers than "
"this threshold, we disable those optimizations. 0 (default) means no static cap.");
developer_desc.add_options()(
"enable-shared-mem-grouped-non-count-agg",
po::value<bool>(&g_enable_smem_grouped_non_count_agg)
->default_value(g_enable_smem_grouped_non_count_agg)
->implicit_value(true),
"Enable using GPU shared memory for grouped non-count aggregate queries.");
developer_desc.add_options()(
"enable-shared-mem-non-grouped-agg",
po::value<bool>(&g_enable_smem_non_grouped_agg)
->default_value(g_enable_smem_non_grouped_agg)
->implicit_value(true),
"Enable using GPU shared memory for non-grouped aggregate queries.");
developer_desc.add_options()("enable-direct-columnarization",
po::value<bool>(&g_enable_direct_columnarization)
->default_value(g_enable_direct_columnarization)
->implicit_value(true),
"Enables/disables a more optimized columnarization method "
"for intermediate steps in multi-step queries.");
developer_desc.add_options()(
"offset-device-by-table-id",
po::value<bool>(&g_use_table_device_offset)
->default_value(g_use_table_device_offset)
->implicit_value(true),
"Enables/disables offseting the chosen device ID by the table ID for a given "
"fragment. This improves balance of fragments across GPUs.");
developer_desc.add_options()("enable-window-functions",
po::value<bool>(&g_enable_window_functions)
->default_value(g_enable_window_functions)
->implicit_value(true),
"Enable experimental window function support.");
developer_desc.add_options()("enable-table-functions",
po::value<bool>(&g_enable_table_functions)
->default_value(g_enable_table_functions)
->implicit_value(true),
"Enable experimental table functions support.");
developer_desc.add_options()(
"jit-debug-ir",
po::value<bool>(&jit_debug)->default_value(jit_debug)->implicit_value(true),
"Enable runtime debugger support for the JIT. Note that this flag is "
"incompatible "
"with the `ENABLE_JIT_DEBUG` build flag. The generated code can be found at "
"`/tmp/mapdquery`.");
developer_desc.add_options()(
"intel-jit-profile",
po::value<bool>(&intel_jit_profile)
->default_value(intel_jit_profile)
->implicit_value(true),
"Enable runtime support for the JIT code profiling using Intel VTune.");
developer_desc.add_options()(
"enable-modern-thread-pool",
po::value<bool>(&g_use_tbb_pool)
->default_value(g_use_tbb_pool)
->implicit_value(true),
"Enable a new thread pool implementation for queuing kernels for execution.");
developer_desc.add_options()(
"enable-cpu-sub-tasks",
po::value<bool>(&g_enable_cpu_sub_tasks)
->default_value(g_enable_cpu_sub_tasks)
->implicit_value(true),
"Enable parallel processing of a single data fragment on CPU. This can improve CPU "
"load balance and decrease reduction overhead.");
developer_desc.add_options()(
"cpu-sub-task-size",
po::value<size_t>(&g_cpu_sub_task_size)->default_value(g_cpu_sub_task_size),
"Set CPU sub-task size in rows.");
developer_desc.add_options()(
"skip-intermediate-count",
po::value<bool>(&g_skip_intermediate_count)
->default_value(g_skip_intermediate_count)
->implicit_value(true),
"Skip pre-flight counts for intermediate projections with no filters.");
developer_desc.add_options()(
"strip-join-covered-quals",
po::value<bool>(&g_strip_join_covered_quals)
->default_value(g_strip_join_covered_quals)
->implicit_value(true),
"Remove quals from the filtered count if they are covered by a "
"join condition (currently only ST_Contains).");
developer_desc.add_options()(
"min-cpu-slab-size",
po::value<size_t>(&system_parameters.min_cpu_slab_size)
->default_value(system_parameters.min_cpu_slab_size),
"Min slab size (size of memory allocations) for CPU buffer pool.");
developer_desc.add_options()(
"max-cpu-slab-size",
po::value<size_t>(&system_parameters.max_cpu_slab_size)
->default_value(system_parameters.max_cpu_slab_size),
"Max CPU buffer pool slab size (size of memory allocations). Note if "
"there is not enough free memory to accomodate the target slab size, smaller "
"slabs will be allocated, down to the minimum size specified by "
"min-cpu-slab-size.");
developer_desc.add_options()(
"min-gpu-slab-size",
po::value<size_t>(&system_parameters.min_gpu_slab_size)
->default_value(system_parameters.min_gpu_slab_size),
"Min slab size (size of memory allocations) for GPU buffer pools.");
developer_desc.add_options()(
"max-gpu-slab-size",
po::value<size_t>(&system_parameters.max_gpu_slab_size)
->default_value(system_parameters.max_gpu_slab_size),
"Max GPU buffer pool slab size (size of memory allocations). Note if "
"there is not enough free memory to accomodate the target slab size, smaller "
"slabs will be allocated, down to the minimum size speified by "
"min-gpu-slab-size.");
developer_desc.add_options()(
"max-output-projection-allocation-bytes",
po::value<size_t>(&g_max_memory_allocation_size)
->default_value(g_max_memory_allocation_size),
"Maximum allocation size for a fixed output buffer allocation for projection "
"queries with no pre-flight count. Default is the maximum slab size (sizes "
"greater "
"than the maximum slab size have no affect). Requires bump allocator.");
developer_desc.add_options()(
"min-output-projection-allocation-bytes",
po::value<size_t>(&g_min_memory_allocation_size)
->default_value(g_min_memory_allocation_size),
"Minimum allocation size for a fixed output buffer allocation for projection "
"queries with no pre-flight count. If an allocation of this size cannot be "
"obtained, the query will be retried with different execution parameters and/or "
"on "
"CPU (if allow-cpu-retry is enabled). Requires bump allocator.");
developer_desc.add_options()("enable-bump-allocator",
po::value<bool>(&g_enable_bump_allocator)
->default_value(g_enable_bump_allocator)
->implicit_value(true),
"Enable the bump allocator for projection queries on "
"GPU. The bump allocator will "
"allocate a fixed size buffer for each query, track the "
"number of rows passing the "
"kernel during query execution, and copy back only the "
"rows that passed the kernel "
"to CPU after execution. When disabled, pre-flight "
"count queries are used to size "
"the output buffer for projection queries.");
developer_desc.add_options()(
"code-cache-eviction-percent",
po::value<float>(&g_fraction_code_cache_to_evict)
->default_value(g_fraction_code_cache_to_evict),
"Percentage of the GPU code cache to evict if an out of memory error is "
"encountered while attempting to place generated code on the GPU.");
developer_desc.add_options()("ssl-cert",
po::value<std::string>(&system_parameters.ssl_cert_file)
->default_value(std::string("")),
"SSL Validated public certficate.");
developer_desc.add_options()("ssl-private-key",
po::value<std::string>(&system_parameters.ssl_key_file)
->default_value(std::string("")),
"SSL private key file.");
// Note ssl_trust_store is passed through to Calcite via system_parameters
// todo(jack): add ensure ssl-trust-store exists if cert and private key in use
developer_desc.add_options()("ssl-trust-store",
po::value<std::string>(&system_parameters.ssl_trust_store)
->default_value(std::string("")),
"SSL public CA certifcates (java trust store) to validate "
"TLS connections (passed through to the Calcite server).");
developer_desc.add_options()(
"ssl-trust-password",
po::value<std::string>(&system_parameters.ssl_trust_password)
->default_value(std::string("")),
"SSL password for java trust store provided via --ssl-trust-store parameter.");
developer_desc.add_options()(
"ssl-trust-ca",
po::value<std::string>(&system_parameters.ssl_trust_ca_file)
->default_value(std::string("")),
"SSL public CA certificates to validate TLS connection(as a client).");
developer_desc.add_options()(
"ssl-trust-ca-server",
po::value<std::string>(&authMetadata.ca_file_name)->default_value(std::string("")),
"SSL public CA certificates to validate TLS connection(as a server).");
developer_desc.add_options()("ssl-keystore",
po::value<std::string>(&system_parameters.ssl_keystore)
->default_value(std::string("")),
"SSL server credentials as a java key store (passed "
"through to the Calcite server).");
developer_desc.add_options()(
"ssl-keystore-password",
po::value<std::string>(&system_parameters.ssl_keystore_password)
->default_value(std::string("")),
"SSL password for java keystore, provide by via --ssl-keystore.");
developer_desc.add_options()(
"udf",
po::value<std::string>(&udf_file_name),
"Load user defined extension functions from this file at startup. The file is "
"expected to be a C/C++ file with extension .cpp.");
developer_desc.add_options()(
"udf-compiler-path",
po::value<std::string>(&udf_compiler_path),
"Provide absolute path to clang++ used in udf compilation.");
developer_desc.add_options()("udf-compiler-options",
po::value<std::vector<std::string>>(&udf_compiler_options),
"Specify compiler options to tailor udf compilation.");
#ifdef ENABLE_GEOS
developer_desc.add_options()("libgeos-so-filename",
po::value<std::string>(&libgeos_so_filename),
"Specify libgeos shared object filename to be used for "
"geos-backed geo opertations.");
#endif
developer_desc.add_options()(
"large-ndv-threshold",
po::value<int64_t>(&g_large_ndv_threshold)->default_value(g_large_ndv_threshold));
developer_desc.add_options()(
"large-ndv-multiplier",
po::value<size_t>(&g_large_ndv_multiplier)->default_value(g_large_ndv_multiplier));
developer_desc.add_options()("approx_quantile_buffer",
po::value<size_t>(&g_approx_quantile_buffer)
->default_value(g_approx_quantile_buffer));
developer_desc.add_options()("approx_quantile_centroids",
po::value<size_t>(&g_approx_quantile_centroids)
->default_value(g_approx_quantile_centroids));
developer_desc.add_options()(
"bitmap-memory-limit",
po::value<int64_t>(&g_bitmap_memory_limit)->default_value(g_bitmap_memory_limit),
"Limit for count distinct bitmap memory use. The limit is computed by taking the "
"size of the group by buffer (entry count in Query Memory Descriptor) and "
"multiplying it by the number of count distinct expression and the size of bitmap "
"required for each. For approx_count_distinct this is typically 8192 bytes.");
developer_desc.add_options()(
"enable-filter-function",
po::value<bool>(&g_enable_filter_function)
->default_value(g_enable_filter_function)
->implicit_value(true),
"Enable the filter function protection feature for the SQL JIT compiler. "
"Normally should be on but techs might want to disable for troubleshooting.");
developer_desc.add_options()(
"enable-idp-temporary-users",
po::value<bool>(&g_enable_idp_temporary_users)
->default_value(g_enable_idp_temporary_users)
->implicit_value(true),
"Enable temporary users for SAML and LDAP logins on read-only servers. "
"Normally should be on but techs might want to disable for troubleshooting.");
developer_desc.add_options()(
"enable-calcite-ddl",
po::value<bool>(&g_enable_calcite_ddl_parser)
->default_value(g_enable_calcite_ddl_parser)
->implicit_value(true),
"Enable using Calcite for supported DDL parsing when available.");
developer_desc.add_options()(
"enable-seconds-refresh-interval",
po::value<bool>(&g_enable_seconds_refresh)
->default_value(g_enable_seconds_refresh)
->implicit_value(true),
"Enable foreign table seconds refresh interval for testing purposes.");
developer_desc.add_options()("enable-auto-metadata-update",
po::value<bool>(&g_enable_auto_metadata_update)
->default_value(g_enable_auto_metadata_update)
->implicit_value(true),
"Enable automatic metadata update.");
developer_desc.add_options()(
"parallel-top-min",
po::value<size_t>(&g_parallel_top_min)->default_value(g_parallel_top_min),
"For ResultSets requiring a heap sort, the number of rows necessary to trigger "
"parallelTop() to sort.");
developer_desc.add_options()(
"parallel-top-max",
po::value<size_t>(&g_parallel_top_max)->default_value(g_parallel_top_max),
"For ResultSets requiring a heap sort, the maximum number of rows allowed by "
"watchdog.");
developer_desc.add_options()("vacuum-min-selectivity",
po::value<float>(&g_vacuum_min_selectivity)
->default_value(g_vacuum_min_selectivity),
"Minimum selectivity for automatic vacuuming. "
"This specifies the percentage (with a value of 0 "
"implying 0% and a value of 1 implying 100%) of "
"deleted rows in a fragment at which to perform "
"automatic vacuuming. A number greater than 1 can "
"be used to disable automatic vacuuming.");
developer_desc.add_options()("enable-automatic-ir-metadata",
po::value<bool>(&g_enable_automatic_ir_metadata)
->default_value(g_enable_automatic_ir_metadata)
->implicit_value(true),
"Enable automatic IR metadata (debug builds only).");
developer_desc.add_options()(
"estimator-failure-max-groupby-size",
po::value<size_t>(&g_estimator_failure_max_groupby_size)
->default_value(g_estimator_failure_max_groupby_size),
"Maximum size of the groupby buffer if the estimator fails. By default we use the "
"number of tuples in the table up to this value.");
help_desc.add_options()(
"allow-query-step-cpu-retry",
po::value<bool>(&g_allow_query_step_cpu_retry)
->default_value(g_allow_query_step_cpu_retry)
->implicit_value(true),
R"(Allow certain query steps to retry on CPU, even when allow-cpu-retry is disabled)");
}
namespace {
std::stringstream sanitize_config_file(std::ifstream& in) {
// Strip the web section out of the config file so boost can validate program options
std::stringstream ss;
std::string line;
while (std::getline(in, line)) {
ss << line << "\n";
if (line == "[web]") {
break;
}
}
return ss;
}
bool trim_and_check_file_exists(std::string& filename, const std::string desc) {
if (!filename.empty()) {
boost::algorithm::trim_if(filename, boost::is_any_of("\"'"));
if (!boost::filesystem::exists(filename)) {
std::cerr << desc << " " << filename << " does not exist." << std::endl;
return false;
}
}
return true;
}
void addOptionalFileToBlacklist(std::string& filename) {
if (!filename.empty()) {
ddl_utils::FilePathBlacklist::addToBlacklist(filename);
}
}
} // namespace
void CommandLineOptions::validate_base_path() {
boost::algorithm::trim_if(base_path, boost::is_any_of("\"'"));
if (!boost::filesystem::exists(base_path)) {
throw std::runtime_error("OmniSci base directory does not exist at " + base_path);
}
}
void CommandLineOptions::validate() {
boost::algorithm::trim_if(base_path, boost::is_any_of("\"'"));
const auto data_path = boost::filesystem::path(base_path) / "mapd_data";
if (!boost::filesystem::exists(data_path)) {
throw std::runtime_error("OmniSci data directory does not exist at '" + base_path +
"'");
}
{
const auto lock_file = boost::filesystem::path(base_path) / "omnisci_server_pid.lck";
auto pid = std::to_string(getpid());
#ifdef _WIN32
int pid_fd = _open(lock_file.string().c_str(), O_RDWR | O_CREAT, 0644);
#else
int pid_fd = open(lock_file.string().c_str(), O_RDWR | O_CREAT, 0644);
#endif
if (pid_fd == -1) {
auto err = std::string("Failed to open PID file ") + lock_file.string().c_str() +
". " + strerror(errno) + ".";
throw std::runtime_error(err);
}
// TODO: support lock on Windows
#ifndef _WIN32
if (lockf(pid_fd, F_TLOCK, 0) == -1) {
::close(pid_fd);
auto err = std::string("Another OmniSci Server is using data directory ") +
base_path + ".";
throw std::runtime_error(err);
}
#endif
if (ftruncate(pid_fd, 0) == -1) {
::close(pid_fd);
auto err = std::string("Failed to truncate PID file ") +
lock_file.string().c_str() + ". " + strerror(errno) + ".";
throw std::runtime_error(err);
}
if (write(pid_fd, pid.c_str(), pid.length()) == -1) {
::close(pid_fd);
auto err = std::string("Failed to write PID file ") + lock_file.string().c_str() +
". " + strerror(errno) + ".";
throw std::runtime_error(err);
}
}
boost::algorithm::trim_if(db_query_file, boost::is_any_of("\"'"));
if (db_query_file.length() > 0 && !boost::filesystem::exists(db_query_file)) {
throw std::runtime_error("File containing DB queries " + db_query_file +
" does not exist.");
}
const auto db_file =
boost::filesystem::path(base_path) / "mapd_catalogs" / OMNISCI_SYSTEM_CATALOG;
if (!boost::filesystem::exists(db_file)) {
{ // check old system catalog existsense
const auto db_file = boost::filesystem::path(base_path) / "mapd_catalogs/mapd";
if (!boost::filesystem::exists(db_file)) {
throw std::runtime_error("OmniSci system catalog " + OMNISCI_SYSTEM_CATALOG +
" does not exist.");
}
}
}
if (license_path.length() == 0) {
license_path = base_path + "/omnisci.license";
}
// add all parameters to be displayed on startup
LOG(INFO) << "OmniSci started with data directory at '" << base_path << "'";
if (vm.count("license-path")) {
LOG(INFO) << "License key path set to '" << license_path << "'";
}
g_read_only = read_only;
LOG(INFO) << " Server read-only mode is " << read_only;
LOG(INFO) << " Watchdog is set to " << enable_watchdog;
LOG(INFO) << " Dynamic Watchdog is set to " << enable_dynamic_watchdog;
if (enable_dynamic_watchdog) {
LOG(INFO) << " Dynamic Watchdog timeout is set to " << dynamic_watchdog_time_limit;
}
LOG(INFO) << " Runtime query interrupt is set to " << enable_runtime_query_interrupt;
if (enable_runtime_query_interrupt) {
LOG(INFO) << " A frequency of checking pending query interrupt request is set to "
<< pending_query_interrupt_freq << " (in ms.)";
LOG(INFO) << " A frequency of checking running query interrupt request is set to "
<< running_query_interrupt_freq << " (0.0 ~ 1.0)";
}
LOG(INFO) << " Non-kernel time query interrupt is set to "
<< enable_non_kernel_time_query_interrupt;
LOG(INFO) << " Debug Timer is set to " << g_enable_debug_timer;
LOG(INFO) << " LogUserId is set to " << Catalog_Namespace::g_log_user_id;
LOG(INFO) << " Maximum idle session duration " << idle_session_duration;
LOG(INFO) << " Maximum active session duration " << max_session_duration;
LOG(INFO) << " Maximum number of sessions " << system_parameters.num_sessions;
LOG(INFO) << "Allowed import paths is set to " << allowed_import_paths;
LOG(INFO) << "Allowed export paths is set to " << allowed_export_paths;
ddl_utils::FilePathWhitelist::initialize(
base_path, allowed_import_paths, allowed_export_paths);
ddl_utils::FilePathBlacklist::addToBlacklist(base_path + "/mapd_catalogs");
ddl_utils::FilePathBlacklist::addToBlacklist(base_path + "/temporary/mapd_catalogs");
ddl_utils::FilePathBlacklist::addToBlacklist(base_path + "/mapd_data");
ddl_utils::FilePathBlacklist::addToBlacklist(base_path + "/mapd_log");
g_enable_s3_fsi = false;
if (disk_cache_level == "foreign_tables") {
if (g_enable_fsi) {
disk_cache_config.enabled_level = File_Namespace::DiskCacheLevel::fsi;
LOG(INFO) << "Disk cache enabled for foreign tables only";
} else {
LOG(INFO) << "Cannot enable disk cache for fsi when fsi is disabled. Defaulted to "
"disk cache disabled";
}
} else if (disk_cache_level == "all") {
disk_cache_config.enabled_level = File_Namespace::DiskCacheLevel::all;
LOG(INFO) << "Disk cache enabled for all tables";
} else if (disk_cache_level == "local_tables") {
disk_cache_config.enabled_level = File_Namespace::DiskCacheLevel::non_fsi;
LOG(INFO) << "Disk cache enabled for non-FSI tables";
} else if (disk_cache_level == "none") {
disk_cache_config.enabled_level = File_Namespace::DiskCacheLevel::none;
LOG(INFO) << "Disk cache disabled";
} else {
throw std::runtime_error{
"Unexpected \"disk-cache-level\" value: " + disk_cache_level +
". Valid options are 'foreign_tables', "
"'local_tables', 'none', and 'all'."};
}
if (disk_cache_config.size_limit < File_Namespace::CachingFileMgr::getMinimumSize()) {
throw std::runtime_error{"disk-cache-size must be at least " +
to_string(File_Namespace::CachingFileMgr::getMinimumSize())};
}
if (disk_cache_config.path.empty()) {
disk_cache_config.path = base_path + "/omnisci_disk_cache";
}
ddl_utils::FilePathBlacklist::addToBlacklist(disk_cache_config.path);
ddl_utils::FilePathBlacklist::addToBlacklist("/etc/passwd");
ddl_utils::FilePathBlacklist::addToBlacklist("/etc/shadow");
// If passed in, blacklist all security config files
addOptionalFileToBlacklist(license_path);
addOptionalFileToBlacklist(system_parameters.ssl_cert_file);
addOptionalFileToBlacklist(authMetadata.ca_file_name);
addOptionalFileToBlacklist(system_parameters.ssl_trust_store);
addOptionalFileToBlacklist(system_parameters.ssl_keystore);
addOptionalFileToBlacklist(system_parameters.ssl_key_file);
addOptionalFileToBlacklist(system_parameters.ssl_trust_ca_file);
addOptionalFileToBlacklist(cluster_file);
if (g_vacuum_min_selectivity < 0) {
throw std::runtime_error{"vacuum-min-selectivity cannot be less than 0."};
}
LOG(INFO) << "Vacuum Min Selectivity: " << g_vacuum_min_selectivity;
}
boost::optional<int> CommandLineOptions::parse_command_line(
int argc,
char const* const* argv,
const bool should_init_logging) {
po::options_description all_desc("All options");
all_desc.add(help_desc).add(developer_desc);
try {
po::store(po::command_line_parser(argc, argv)
.options(all_desc)
.positional(positional_options)
.run(),
vm);
po::notify(vm);
if (vm.count("help")) {
std::cerr << "Usage: omnisci_server <data directory path> [-p <port number>] "