禁止后台刷写注册表以提高机器性能

现在常常用到的多是基于hive的注册表,如果你的产品使用的是基于hive的注册表,你可以通过禁止后台刷写动作以提高产品性能。一旦此动作被禁止,我们改动了注册表后就只能调用RegFlushKey来写入到文件系统中。我们知道当我们使用RegFlushKey这个API时会对我们的系统性能产生一些影响,它会降低系统表现,所以我们一般在一些特殊的场合才使用它。

要禁止后台刷写注册表可通过配置下面的动作来完成:

[HKEY_LOCAL_MACHINE\init\BootVars]
"RegistryFlags"=dword:2

我们知道,基于hive的注册表是使用内存映射文件(memory-mapped files)来保存注册表值的。上面提到的key(RegistryFlags)就是用来决定当注册表有改动时如何去把改动后的注册表值提交到永久存储器中。同时要注意的是,此操作只是针对于基于hive的注册表有效,若对于对象存储注册表(object store registry)则没有一点影响。

[HKEY_LOCAL_MACHINE\init\BootVars]
 "DefaultUser"=$(_TGTHWNAME)
 
IF BSP_USE_HIVE
; @CESYSGEN IF FILESYS_FSREGHIVE
"Start DevMgr"=dword:1
"RegistryFlags"=dword:0
"Flags"=dword:F
IF BSP_HIVE_IN_OBJECT_STORE
!
"SystemHive"="\\HIVEREG\\save\\system.hv"
"ProfileDir"="\\HIVEREG\\save\\"
ENDIF
; @CESYSGEN ENDIF FILESYS_FSREGHIVE

[HKEY_LOCAL_MACHINE\System\ObjectStore\RegFlush]
; To monitor the flushing from an external process add
"ActivityName" registry value.
; The activity name
is a global named event that filesystem will signal on Registry Activity.
;
"ActivityName"=""
; Create an thread
in filesys to perform flushing
"SpawnThread"=dword:1
; Make the thread IDLE priority
"FlushPriority256"=dword:FF
; ActivityThreshold specifies the # of reg activity before we force a flush
"ActivityThreshold"=dword:1000
; Timeout period
in ms for a flush (flush occurs if there have been some changes during this period).
"FlushPeriod"=dword:3E8
ENDIF

ActivityName表示一个事件名,若增加此注册表键值,一个外部进程可通过此事件来监视注册表的刷写(flushing);

接下来的三个注册表键SpawnThread、FlushPriority256、FlushPeriod,只有当设置PRJ环境变量(PRJ_ENABLE_REGFLUSH_THREAD为1)时,表示按照SpawnThread创建一个优先级为FlushPriority256的线程,以 FlushPeriod (默认为0x3E8即1000ms=1s)为周期检查是否有注册表改变,并将改变Flushing到永久存储器中。

ActivityThreshold表示‘行为极限’,即注册表变动的上限值;

 

参考:http://lwlw146.blog.163.com/blog/static/3130165020085189452392/

posted on 2011-09-13 16:50  EmbeddedBoy_jsu_xtw  阅读(1108)  评论(0编辑  收藏  举报

导航