mirror of
				https://github.com/TeaOSLab/EdgeAdmin.git
				synced 2025-11-04 13:10:26 +08:00 
			
		
		
		
	使用MMAP提升缓存读取性能
This commit is contained in:
		@@ -41,6 +41,7 @@ func (this *CreatePopupAction) RunPost(params struct {
 | 
				
			|||||||
	MaxSizeJSON          []byte
 | 
						MaxSizeJSON          []byte
 | 
				
			||||||
	FetchTimeoutJSON     []byte
 | 
						FetchTimeoutJSON     []byte
 | 
				
			||||||
	SyncCompressionCache bool
 | 
						SyncCompressionCache bool
 | 
				
			||||||
 | 
						EnableMMAP           bool
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	Description string
 | 
						Description string
 | 
				
			||||||
	IsOn        bool
 | 
						IsOn        bool
 | 
				
			||||||
@@ -97,6 +98,7 @@ func (this *CreatePopupAction) RunPost(params struct {
 | 
				
			|||||||
			OpenFileCache:  openFileCacheConfig,
 | 
								OpenFileCache:  openFileCacheConfig,
 | 
				
			||||||
			EnableSendfile: params.FileEnableSendfile,
 | 
								EnableSendfile: params.FileEnableSendfile,
 | 
				
			||||||
			MinFreeSize:    minFreeSize,
 | 
								MinFreeSize:    minFreeSize,
 | 
				
			||||||
 | 
								EnableMMAP:     params.EnableMMAP,
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	case serverconfigs.CachePolicyStorageMemory:
 | 
						case serverconfigs.CachePolicyStorageMemory:
 | 
				
			||||||
		options = &serverconfigs.HTTPMemoryCacheStorage{}
 | 
							options = &serverconfigs.HTTPMemoryCacheStorage{}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -40,8 +40,9 @@ func (this *UpdateAction) RunGet(params struct {
 | 
				
			|||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// fix min free size
 | 
					 | 
				
			||||||
	if cachePolicy.Type == serverconfigs.CachePolicyStorageFile && cachePolicy.Options != nil {
 | 
						if cachePolicy.Type == serverconfigs.CachePolicyStorageFile && cachePolicy.Options != nil {
 | 
				
			||||||
 | 
							// fix min free size
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
			_, ok := cachePolicy.Options["minFreeSize"]
 | 
								_, ok := cachePolicy.Options["minFreeSize"]
 | 
				
			||||||
			if !ok {
 | 
								if !ok {
 | 
				
			||||||
				cachePolicy.Options["minFreeSize"] = &shared.SizeCapacity{
 | 
									cachePolicy.Options["minFreeSize"] = &shared.SizeCapacity{
 | 
				
			||||||
@@ -51,6 +52,15 @@ func (this *UpdateAction) RunGet(params struct {
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							// fix enableMMAP
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								_, ok := cachePolicy.Options["enableMMAP"]
 | 
				
			||||||
 | 
								if !ok {
 | 
				
			||||||
 | 
									cachePolicy.Options["enableMMAP"] = true
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	this.Data["cachePolicy"] = cachePolicy
 | 
						this.Data["cachePolicy"] = cachePolicy
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// 其他选项
 | 
						// 其他选项
 | 
				
			||||||
@@ -77,6 +87,8 @@ func (this *UpdateAction) RunPost(params struct {
 | 
				
			|||||||
	SyncCompressionCache bool
 | 
						SyncCompressionCache bool
 | 
				
			||||||
	FetchTimeoutJSON     []byte
 | 
						FetchTimeoutJSON     []byte
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						EnableMMAP bool
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	Description string
 | 
						Description string
 | 
				
			||||||
	IsOn        bool
 | 
						IsOn        bool
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -137,6 +149,7 @@ func (this *UpdateAction) RunPost(params struct {
 | 
				
			|||||||
			OpenFileCache:  openFileCacheConfig,
 | 
								OpenFileCache:  openFileCacheConfig,
 | 
				
			||||||
			EnableSendfile: params.FileEnableSendfile,
 | 
								EnableSendfile: params.FileEnableSendfile,
 | 
				
			||||||
			MinFreeSize:    minFreeSize,
 | 
								MinFreeSize:    minFreeSize,
 | 
				
			||||||
 | 
								EnableMMAP:     params.EnableMMAP,
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	case serverconfigs.CachePolicyStorageMemory:
 | 
						case serverconfigs.CachePolicyStorageMemory:
 | 
				
			||||||
		options = &serverconfigs.HTTPMemoryCacheStorage{}
 | 
							options = &serverconfigs.HTTPMemoryCacheStorage{}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -70,6 +70,13 @@
 | 
				
			|||||||
                    <p class="comment">缓存磁盘保留的最小空余空间,如果为0表示自动限制(目前默认保留5GiB)。</p>
 | 
					                    <p class="comment">缓存磁盘保留的最小空余空间,如果为0表示自动限制(目前默认保留5GiB)。</p>
 | 
				
			||||||
                </td>
 | 
					                </td>
 | 
				
			||||||
            </tr>
 | 
					            </tr>
 | 
				
			||||||
 | 
					            <tr v-show="moreOptionsVisible && policyType == 'file' && teaIsPlus">
 | 
				
			||||||
 | 
					                <td class="color-border">启用MMAP</td>
 | 
				
			||||||
 | 
					                <td>
 | 
				
			||||||
 | 
					                    <checkbox name="enableMMAP" checked="checked"></checkbox>
 | 
				
			||||||
 | 
					                    <p class="comment">选中后,表示允许系统自动利用MMAP提升缓存读取性能。</p>
 | 
				
			||||||
 | 
					                </td>
 | 
				
			||||||
 | 
					            </tr>
 | 
				
			||||||
            <tr>
 | 
					            <tr>
 | 
				
			||||||
                <td class="color-border">缓存文件句柄缓存</td>
 | 
					                <td class="color-border">缓存文件句柄缓存</td>
 | 
				
			||||||
                <td>
 | 
					                <td>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -46,6 +46,13 @@
 | 
				
			|||||||
                <a :href="Tea.url('.update', {cachePolicyId:cachePolicy.id})"><span class="red">请设置一个内存容量作为缓冲区,以提升缓存写入性能。</span></a>
 | 
					                <a :href="Tea.url('.update', {cachePolicyId:cachePolicy.id})"><span class="red">请设置一个内存容量作为缓冲区,以提升缓存写入性能。</span></a>
 | 
				
			||||||
            </td>
 | 
					            </td>
 | 
				
			||||||
        </tr>
 | 
					        </tr>
 | 
				
			||||||
 | 
					        <tr v-if="cachePolicy.options != null && teaIsPlus">
 | 
				
			||||||
 | 
					            <td class="color-border">启用MMAP</td>
 | 
				
			||||||
 | 
					            <td>
 | 
				
			||||||
 | 
					                <span class="green" v-if="cachePolicy.options.enableMMAP || cachePolicy.options.enableMMAP == null">Y</span>
 | 
				
			||||||
 | 
					                <span class="disabled" v-else>N</span>
 | 
				
			||||||
 | 
					            </td>
 | 
				
			||||||
 | 
					        </tr>
 | 
				
			||||||
        <tr v-if="cachePolicy.options.openFileCache != null && cachePolicy.options.openFileCache.isOn && cachePolicy.options.openFileCache.max > 0">
 | 
					        <tr v-if="cachePolicy.options.openFileCache != null && cachePolicy.options.openFileCache.isOn && cachePolicy.options.openFileCache.max > 0">
 | 
				
			||||||
            <td class="color-border">缓存文件句柄缓存</td>
 | 
					            <td class="color-border">缓存文件句柄缓存</td>
 | 
				
			||||||
            <td>{{cachePolicy.options.openFileCache.max}}</td>
 | 
					            <td>{{cachePolicy.options.openFileCache.max}}</td>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -77,6 +77,13 @@
 | 
				
			|||||||
                        <p class="comment">缓存磁盘保留的最小空余空间,如果为0表示使用默认(目前默认保留5GiB)。</p>
 | 
					                        <p class="comment">缓存磁盘保留的最小空余空间,如果为0表示使用默认(目前默认保留5GiB)。</p>
 | 
				
			||||||
                    </td>
 | 
					                    </td>
 | 
				
			||||||
                </tr>
 | 
					                </tr>
 | 
				
			||||||
 | 
					                <tr v-show="teaIsPlus">
 | 
				
			||||||
 | 
					                    <td class="color-border">启用MMAP</td>
 | 
				
			||||||
 | 
					                    <td>
 | 
				
			||||||
 | 
					                        <checkbox name="enableMMAP" v-model="cachePolicy.options.enableMMAP"></checkbox>
 | 
				
			||||||
 | 
					                        <p class="comment">选中后,表示允许系统自动利用MMAP提升缓存读取性能。</p>
 | 
				
			||||||
 | 
					                    </td>
 | 
				
			||||||
 | 
					                </tr>
 | 
				
			||||||
                <tr>
 | 
					                <tr>
 | 
				
			||||||
                    <td class="color-border">缓存文件句柄缓存</td>
 | 
					                    <td class="color-border">缓存文件句柄缓存</td>
 | 
				
			||||||
                    <td>
 | 
					                    <td>
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user