Geode 最佳实践 系统测试配置

本文提供了详细的Linux系统配置参数及推荐值,涵盖文件句柄、内存管理、网络连接及TCP/IP协议栈调优,旨在提升系统性能和稳定性。

OS Configuration/Tuning

SettingRecommend ValueRationaleNote
fs.file-max2097152Maximum number of open files system-wide全系统最大打开文件数
vm.swappiness0turn off swappiness关闭交换
net.core.somaxconn1024maximum number of simul connection attempts同时尝试连接的最大次数
net.core.netdev_max_backlog30000Set maximum number of packets, queued on the INPUT side, when the interface receives packets faster than kernel can process them. Recommended setting is for 10GbE links. For 1GbE links use 8000.当接口接收数据包的速度快于内核处理数据包的速度时,设置在INPUT端排队的最大数据包数。推荐设置用于10GbE链接。对于1GbE链接,请使用8000。
net.core.wmem_max67108864Set max to 16MB (16777216) for 1GbE links and 64MB(67108864) for 10GbE links.对于1GbE链接,最大设置为16MB(16777216),对于10GbE链接,最大设置为64MB(67108864)。
net.core.rmem_max67108864Set max to 16MB (16777216) for 1GbE links and 64MB(67108864) for 10GbE links.对于1GbE链接,最大设置为16MB(16777216),对于10GbE链接,最大设置为64MB(67108864)。
net.ipv4.tcp_congestion_control


 
htcpThere seem to be bugs in both bic and cubic (the default) for a number of versions of the Linux kernel up to version 2.6.33. The kernel version for Redhat 5.x is 2.6.18-x and 2.6.32-x for Redhat 6.x 这个表示的一种TCP算法,包括htcp,bbr,cubic,bic直到版本2.6.33的许多Linux内核似乎在bic和cubic(默认)中均存在错误。Redhat 5.x的内核版本是2.6.18-x,而Redhat 6.x的内核版本是2.6.32-x。这个表示的是一种TCP算法,包括htcp,bbr,cubic,bic
net.ipv4.tcp_congestion_window10This is the default for Linux operating systems based on
Linux kernel 2.6.39 or later.
这是基于Linux内核2.6.39或更高版本的Linux操作系统的默认设置。
net.ipv4.tcp_fin_timeout10This setting determines the time that must elapse before TCP/IP can release a closed connection and reuse its resources. During this TIME_WAIT state, reopening the connection to the client costs less than establishing a new connection. By reducing the value of this entry, TCP/IP can release closed connections faster, making more resources available for new connections. The default value is 60. The
recommened setting lowers its to 10. You can lower this even further, but too low, and you can run into socket close errors in networks with lots of jitter.与TCP握手的状态相关,表示其中一个握手的间隔。
此设置确定TCP / IP可以释放关闭的连接并重新使用其资源之前必须经过的时间。在此TIME_WAIT状态下,重新建立与客户端的连接比建立新的连接花费少。通过减小此条目的值,TCP / IP可以更快地释放关闭的连接,从而为新连接提供更多资源。默认值是60。建议的设置将其降低到10。您甚至可以将其降低得更低,但又太低,并且在存在很多抖动的网络中可能会遇到套接字关闭错误。握手的间隔。
net.ipv4.tcp_keepalive_interval30This determines the wait time between isAlive interval probes. Default value is 75. Recommended value reduces this in keeping with the reduction of the overall keepalive time.这确定了“活动间隔”探测之间的等待时间。默认值是75。建议值会减少此值,以减少总的保持活动时间。
net.ipv4.tcp_keepalive_probes5How many keepalive probes to send out before the socket is timed out. Default value is 9. Recommended value reduces this to 5 so that retry attempts will take 2.5
minutes.
在套接字超时之前要发送多少个保持活动状态的探针。默认值为9。建议的值将该值减小为5,以便重试尝试将花费2.5分钟。
net.ipv4.tcp_keepalive_time600Set the TCP Socket timeout value to 10 minutes instead of 2 hour default. With an idle socket, the system will wait tcp_keepalive_time seconds, and after that try tcp_keepalive_probes times to send a TCP KEEPALIVE in intervals of tcp_keepalive_intvl seconds. If the retry
attempts fail, the socket times out.
将“ TCP套接字超时”值设置为10分钟,而不是默认的2小时。使用空闲套接字时,系统将等待tcp_keepalive_time秒,然后尝试tcp_keepalive_probes次以tcp_keepalive_intvl秒为间隔发送TCP KEEPALIVE。如果重试失败,则套接字超时。
net.ipv4.tcp_low_latency1Configure TCP for low latency, favorig low latency over throughput将TCP配置为低延迟,从而在吞吐量上实现低延迟
net.ipv4.tcp_max_orphans16384Limit number of orphans, each orphan can eat up to 16M (max wmem) of unswappable memory限制孤儿数量,每个孤儿最多可以吃掉16M(最大wmem)不可交换的内存
net.ipv4.tcp_max_tw_buckets

 
1440000Maximal number of time wait sockets held by system simultaneously. If this number is exceeded time-wait socket is immediately destroyed and warning is printed. This limit
exists to help prevent simple DoS attacks.
系统同时持有的最大等待套接字数。如果超过此数量,等待时间插座将立即销毁并打印警告。存在此限制有助于防止简单的DoS攻击。
net.ipv4.tcp_no_metrics_save1Disable caching TCP metrics on onnection close在连接关闭时禁用缓存TCP指标
net.ipv4.tcp_orphan_retries0Limit number of orphans, each orphan can eat up to 16M(max wmem) of unswappable memory限制孤儿数量,每个孤儿最多可以吃掉16M(最大wmem)的不可交换内存
net.ipv4.tcp_rfc1337 Enable a fix for RFC1337 - time-wait assassination hazardsin TCP启用RFC1337的修复-TCP中的时间等待暗杀危险
net.ipv4.tcp_rmem

10240

131072

33554432

Setting is min/default/max. Recommend increasing theLinux autotuning TCP buffer limit to 32MB设置为最小/默认/最大。建议将Linux自动调整TCP缓冲区限制增加到32MB
net.ipv4.tcp_sack1Enable select acknowledgmen启用选择确认
net.ipv4.tcp_slow_start_after_idle0By default, TCP starts with a single small segment, gradually increasing it by one each time. This results in unnecessary
slowness that impacts the start of every request.
默认情况下,TCP从一个小段开始,然后每次逐渐增加一个。这会导致不必要的延迟,从而影响每个请求的开始。
net.ipv4.tcp_syncookies0Many default Linux installations use SYN cookies to protect the system against malicious attacks that flood TCP SYN
packets. The use of SYN cookies dramatically reduces network bandwidth, and can be triggered by a running Geode cluster. If your Geode cluster is otherwise protected against such attacks, disable SYN cookies to ensure that Geode network throughput is not affected.
NOTE: if SYN floods are an issue and SYN cookies can’t be disabled, try the following:
net.ipv4.tcp_max_syn_backlog="16384"
net.ipv4.tcp_synack_retries="1"
net.ipv4.tcp_max_orphans="400000"
许多默认的Linux安装使用SYN cookie来保护系统免受淹没TCP SYN数据包的恶意攻击。使用SYN cookie可以大大减少网络带宽,并且可以由正在运行的Geode集群触发。如果您的Geode群集受到其他保护,可免受此类攻击,请禁用SYN cookie以确保Geode网络吞吐量不受影响。注意:如果出现SYN泛滥且无法禁用SYN cookie的情况,请尝试以下操作:net.ipv4.tcp_max_syn_backlog =“ 16384” net.ipv4.tcp_synack_retries =“ 1” net.ipv4.tcp_max_orphans =“ 400000”
net.ipv4.tcp_timestamps1Enable timestamps as defined in RFC1323:启用RFC1323中定义的时间戳记:
net.ipv4.tcp_tw_recycle11 This enables fast recycling of TIME_WAIT sockets. The default value is 0 (disabled). Should be used with caution with load balancers.这样可以快速回收TIME_WAIT套接字。默认值为0(禁用)。应谨慎使用负载平衡器。
net.ipv4.tcp_tw_reuse 1This allows reusing sockets in TIME_WAIT state for new connections when it is safe from protocol viewpoint. Default value is 0 (disabled). It is generally a safer alternative to tcp_tw_recycle. The tcp_tw_reuse setting is
particularly useful in environments where numerous short connections are open and left in TIME_WAIT state, such as web servers and load balancers.
从协议的角度来看,这可以在安全的情况下将TIME_WAIT状态的套接字重新用于新连接。默认值为0(禁用)。通常,它是tcp_tw_recycle的更安全的替代方法。tcp_tw_reuse设置在Web服务器和负载均衡器等许多短连接处于打开状态并处于TIME_WAIT状态的环境中特别有用。
net.ipv4.tcp_window_scaling1Turn on window scaling which can be an option to enlarge the transfer window:打开窗口缩放,可以选择放大传输窗口:
    
    
    

 

<think>好的,用户问的是在OSG中设置Geode的深度测试取消为什么不起作用。首先,我需要回忆一下OSG中渲染状态的相关知识。OSG中,渲染属性比如深度测试是通过StateSet来控制的。Geode继承自Node,可以有自己的StateSet。 用户可能是在Geode的StateSet中设置了关闭深度测试,但实际运行时发现没有效果。这时候可能有几个原因。首先,渲染状态的继承问题,可能父节点的StateSet覆盖了Geode的设置。比如,如果父节点或者更高层的节点(比如Group或者Camera)启用了深度测试,并且设置了覆盖模式(OVERRIDE),那么子节点的设置可能被忽略。 其次,渲染顺序的问题。OSG中的渲染是分前后顺序的,透明物体通常会在后面渲染,并且可能会修改深度测试的状态。如果用户的Geode所在的节点在渲染时被其他节点的状态覆盖,比如后渲染的物体重新启用了深度测试,那么可能会影响结果。 另外,状态应用的模式是否正确。在设置渲染属性时,需要使用setMode并指定正确的StateAttribute值,比如PROTECTED或者OVERRIDE。如果用户只是关闭了深度测试,但没有正确设置覆盖模式,可能其他地方的设置会覆盖这个状态。 还有,可能用户没有正确关联StateSet到Geode。需要确认是否调用了geode->setStateSet(stateSet)来应用状态。如果只是创建了StateSet但没有设置到节点上,自然不会生效。 还要考虑其他渲染状态的影响,比如深度写入(DepthWrite)。有时候关闭深度测试的同时可能需要关闭深度写入,否则残留的深度缓冲数据可能影响后续渲染。 另外,OSG的版本差异也可能导致问题。不同版本的OSG在状态管理上可能有细微差别,需要确认用户使用的版本是否存在已知的问题。 最后,可能需要通过调试手段,比如查看OSG的渲染状态树,或者使用osgviewer的统计信息来确认当前节点的状态是否被正确应用。比如在运行osgviewer时加上--stats参数,可以查看各个节点的状态设置情况。 总结下来,需要逐步排查渲染状态的继承关系、覆盖模式、是否正确应用、其他相关状态设置以及可能的渲染顺序问题。建议用户检查父节点的状态,确认覆盖模式,关闭深度写入,并验证状态是否正确应用。如果问题依旧,可能需要提供更详细的代码或场景结构进一步分析。</think>在OSG中,使用`Geode`设置取消深度测试未生效的问题,通常与渲染状态继承、渲染顺序或状态覆盖机制有关。以下是逐步排查和解决方案: --- ### **1. 确认状态继承关系** OSG的渲染状态具有**继承性**,父节点的`StateSet`可能覆盖子节点的设置: - **检查父节点**:确保父节点(如`Group`或`Camera`)未强制启用深度测试。 - **设置覆盖模式**:显式声明状态覆盖权限: ```cpp osg::StateSet* state = geode->getOrCreateStateSet(); state->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF | osg::StateAttribute::OVERRIDE); ``` `OVERRIDE`标记会强制覆盖父节点状态。 --- ### **2. 渲染顺序与透明物体** - **透明物体渲染**:透明物体默认在最后渲染,可能重新启用深度测试。 - **解决方案**:为透明物体单独设置渲染顺序: ```cpp state->setRenderBinDetails(0, "RenderBin"); // 提前渲染顺序 ``` --- ### **3. 关闭深度写入** 仅关闭深度测试可能不够,需同时关闭深度写入: ```cpp state->setAttributeAndModes(new osg::Depth(osg::Depth::ALWAYS), osg::StateAttribute::ON); ``` --- ### **4. 检查其他状态覆盖** - **材质/着色器影响**:某些材质或着色器可能隐式修改深度测试状态。 - **后处理阶段**:后期渲染的屏幕四边形可能覆盖状态。 --- ### **5. 调试方法** - **查看状态树**:通过`osg::StateSet::getParent`检查状态继承链。 - **命令行工具**:使用`osgviewer --stats`查看实际生效的渲染状态。 --- ### **代码示例** ```cpp osg::Geode* geode = new osg::Geode(); osg::StateSet* state = geode->getOrCreateStateSet(); // 关闭深度测试并覆盖父状态 state->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF | osg::StateAttribute::OVERRIDE); // 关闭深度写入 osg::Depth* depth = new osg::Depth(osg::Depth::ALWAYS, 0, 1, false); state->setAttributeAndModes(depth, osg::StateAttribute::ON); // 调整渲染顺序 state->setRenderBinDetails(0, "RenderBin"); ``` --- ### **常见原因总结** | 原因 | 解决方案 | |---------------------|-----------------------------------| | 父节点状态覆盖 | 使用`OVERRIDE`标记强制覆盖 | | 透明物体渲染顺序 | 调整`RenderBin`优先级 | | 深度写入未关闭 | 设置`osg::Depth::ALWAYS` | | 着色器隐式修改状态 | 检查着色器代码或材质属性 | 通过上述步骤,应能解决深度测试未正确关闭的问题。如果仍无效,建议提供完整场景结构和代码片段进一步分析。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值