Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

145 lines
5.3 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. params.cpp
  5. Abstract:
  6. SIS Groveler parameter support & defaults
  7. Authors:
  8. John Douceur, 1998
  9. Environment:
  10. User Mode
  11. Revision History:
  12. --*/
  13. #include "all.hxx"
  14. static const _TCHAR registry_parameter_path[] =
  15. _T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Groveler\\Parameters");
  16. ReadParameters::ReadParameters()
  17. {
  18. ASSERT(this != 0);
  19. static EntrySpec registry_entries[registry_entry_count] =
  20. {
  21. {_T("parameter backup interval"), entry_int, _T("600000"), &parameter_backup_interval},
  22. {_T("target entries per log extraction"), entry_int, _T("100"), &target_entries_per_extraction},
  23. {_T("max extraction interval"), entry_int, _T("10000"), &max_extraction_interval},
  24. {_T("base grovel interval"), entry_int, _T("5000"), &base_grovel_interval},
  25. {_T("max grovel interval"), entry_int, _T("600000"), &max_grovel_interval},
  26. {_T("max response lag"), entry_int, _T("10000"), &max_response_lag},
  27. {_T("low-confidence grovel interval"), entry_int, _T("15000"), &low_confidence_grovel_interval},
  28. {_T("low-disk-space grovel interval"), entry_int, _T("500"), &low_disk_space_grovel_interval},
  29. {_T("working grovel interval"), entry_int, _T("500"), &working_grovel_interval},
  30. {_T("grovel duration"), entry_int, _T("400"), &grovel_duration},
  31. {_T("partition info update interval"), entry_int, _T("60000"), &partition_info_update_interval},
  32. {_T("base restart extraction interval"), entry_int, _T("10000"), &base_restart_extraction_interval},
  33. {_T("max restart extraction interval"), entry_int, _T("3600000"), &max_restart_extraction_interval},
  34. {_T("base restart groveling interval"), entry_int, _T("30000"), &base_restart_groveling_interval},
  35. {_T("max restart groveling interval"), entry_int, _T("86400000"), &max_restart_groveling_interval},
  36. {_T("base regrovel interval"), entry_int, _T("60000"), &base_regrovel_interval},
  37. {_T("max regrovel interval"), entry_int, _T("86400000"), &max_regrovel_interval},
  38. {_T("volscan regrovel threshold"), entry_int, _T("120000"), &volscan_regrovel_threshold},
  39. {_T("partition balance time constant"), entry_int, _T("1800000"), &partition_balance_time_constant},
  40. {_T("read time increase history size"), entry_int, _T("5"), &read_time_increase_history_size},
  41. {_T("read time decrease history size"), entry_int, _T("2"), &read_time_decrease_history_size},
  42. {_T("SIS efficacy history size"), entry_int, _T("1000"), &sis_efficacy_history_size},
  43. {_T("log winnow history size"), entry_int, _T("1000"), &log_winnow_history_size},
  44. {_T("file size history size"), entry_int, _T("1000"), &file_size_history_size},
  45. {_T("sample group size"), entry_int, _T("10"), &sample_group_size},
  46. {_T("acceptance P-value"), entry_double, _T("0.2"), &acceptance_p_value},
  47. {_T("rejection P-value"), entry_double, _T("0.05"), &rejection_p_value},
  48. {_T("base use multiplier"), entry_double, _T("1.0"), &base_use_multiplier},
  49. {_T("max use multiplier"), entry_double, _T("2.0"), &max_use_multiplier},
  50. {_T("peak finder accuracy"), entry_double, _T("0.05"), &peak_finder_accuracy},
  51. {_T("peak finder range"), entry_double, _T("20.0"), &peak_finder_range},
  52. {_T("base CPU load threshold"), entry_double, _T("0.50"), &base_cpu_load_threshold},
  53. {_T("max CPU load threshold"), entry_double, _T("1.0"), &max_cpu_load_threshold},
  54. {_T("read report discard threshold"), entry_double, _T("0.75"), &read_report_discard_threshold}
  55. };
  56. Registry::read(HKEY_LOCAL_MACHINE, registry_parameter_path,
  57. registry_entry_count, registry_entries);
  58. #if WRITE_ALL_PARAMETERS
  59. bool registry_write_ok =
  60. Registry::write(HKEY_LOCAL_MACHINE, registry_parameter_path,
  61. registry_entry_count, registry_entries);
  62. if (!registry_write_ok)
  63. {
  64. PRINT_DEBUG_MSG((_T("GROVELER: Registry::write() to %s failed\n"),
  65. registry_parameter_path));
  66. }
  67. #endif // WRITE_ALL_PARAMETERS
  68. }
  69. WriteParameters::WriteParameters(
  70. int backup_interval)
  71. {
  72. ASSERT(this != 0);
  73. ASSERT(backup_interval >= 0);
  74. this->backup_interval = backup_interval;
  75. static EntrySpec registry_entries[registry_entry_count] =
  76. {
  77. {_T("hash match ratio"), entry_double, _T("0.01"), &hash_match_ratio},
  78. {_T("compare match ratio"), entry_double, _T("1.0"), &compare_match_ratio},
  79. {_T("dequeue hash ratio"), entry_double, _T("1.0"), &dequeue_hash_ratio}
  80. };
  81. for (int index = 0; index < registry_entry_count; index++)
  82. {
  83. this->registry_entries[index] = registry_entries[index];
  84. }
  85. Registry::read(HKEY_LOCAL_MACHINE, registry_parameter_path,
  86. registry_entry_count, registry_entries);
  87. if (backup_interval > 0)
  88. {
  89. backup((void *)this);
  90. }
  91. }
  92. WriteParameters::~WriteParameters()
  93. {
  94. ASSERT(this != 0);
  95. ASSERT(backup_interval >= 0);
  96. backup((void *)this);
  97. }
  98. void
  99. WriteParameters::backup(
  100. void *context)
  101. {
  102. ASSERT(context != 0);
  103. unsigned int invokation_time = GET_TICK_COUNT();
  104. WriteParameters *me = (WriteParameters *)context;
  105. ASSERT(me->backup_interval >= 0);
  106. bool registry_overwrite_ok =
  107. Registry::overwrite(HKEY_LOCAL_MACHINE, registry_parameter_path,
  108. registry_entry_count, me->registry_entries);
  109. if (!registry_overwrite_ok)
  110. {
  111. PRINT_DEBUG_MSG((_T("GROVELER: Registry::overwrite() to %s failed\n"),
  112. registry_parameter_path));
  113. }
  114. event_timer.schedule(invokation_time + me->backup_interval,
  115. context, backup);
  116. }