pax_global_header 0000666 0000000 0000000 00000000064 14311351254 0014511 g ustar 00root root 0000000 0000000 52 comment=3fda26b05d97498f9b7d2caa6ec83de0b0545a56
mycard-deploy-master/ 0000775 0000000 0000000 00000000000 14311351254 0015117 5 ustar 00root root 0000000 0000000 mycard-deploy-master/.gitignore 0000664 0000000 0000000 00000000034 14311351254 0017104 0 ustar 00root root 0000000 0000000 /inventory.yaml
__pycache__
mycard-deploy-master/.gitmodules 0000664 0000000 0000000 00000000266 14311351254 0017300 0 ustar 00root root 0000000 0000000 [submodule "roles/init"]
path = roles/init
url = git@git.mycard.moe:mycard/init
[submodule "nextgen-router"]
path = nextgen-router
url = git@git.mycard.moe:mycard/nextgen-router
mycard-deploy-master/LICENSE 0000664 0000000 0000000 00000002047 14311351254 0016127 0 ustar 00root root 0000000 0000000 MIT License
Copyright (c) 2021 MyCard
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
mycard-deploy-master/README.md 0000664 0000000 0000000 00000001542 14311351254 0016400 0 ustar 00root root 0000000 0000000 # mycard-deploy
MyCard 服务器初始化工具合集
## 如何使用
1. `git submodule update --init && git submodule foreach git pull origin master && cd nextgen-router && ./prepare.sh`
1. 复制 `inventory.example.yaml` 到 `inventory.yaml`,修改配置。
1. `./init.sh --limit <主机名>`
1. `ansible <主机名> -m shell -b -a reboot`
1. **可选。** 如果主机作为路由器,那么 `./nextgen-router-install.sh --limit <主机名>`
## nextgen-router
在方便的位置完成上面的步骤之后,如果需要配置路由器,则继续下面的步骤。
1. 配置好 `router-nextgen` 里面的变量。
1. `ansible-playbook nextgen-router/network.yaml --limit <主机名>`
1. 把主机关机,移动到路由器应该在的地方,开机,确认有无网络。
1. `ansible-playbook nextgen-router/services.yaml --limit <主机名>`
mycard-deploy-master/ansible.cfg 0000775 0000000 0000000 00000000234 14311351254 0017217 0 ustar 00root root 0000000 0000000 [defaults]
inventory = inventory.yaml
host_key_checking = False
strategy_plugins = mitogen-0.2.9/ansible_mitogen/plugins/strategy
strategy = mitogen_linear
mycard-deploy-master/init.sh 0000775 0000000 0000000 00000000054 14311351254 0016420 0 ustar 00root root 0000000 0000000 #!/bin/bash
ansible-playbook init.yaml "$@"
mycard-deploy-master/init.yaml 0000664 0000000 0000000 00000000074 14311351254 0016747 0 ustar 00root root 0000000 0000000 ---
- hosts: mycard
remote_user: root
roles:
- init
mycard-deploy-master/inventory.example.yaml 0000664 0000000 0000000 00000016127 14311351254 0021501 0 ustar 00root root 0000000 0000000 mycard:
hosts:
example.com:
children:
router_nextgen:
rcloud:
vars: # 一般可以什么都不改,想改的话改什么抄什么
ansible_ssh_user: root
ansible_python_interpreter: python3
authorized_keys: |
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCf7d3z1zJ3+AekdFlF+7BTL8k1X5YrC/Mu23aBBETYxl7N37XM/Ts1u15Xu9l0rgKOe2YphAzexsTmvnBW+3ZJUaJ4gIelw2FWYSHmPkcTtLRrqmSqqCVqyxLrlkvDV1mJmRTQh9rFT3OM2jge4HkN2PSnxuT4AuRwblHcGj2LWD/4XijmHf/BK6GaKownt702ARX18D7d2hYZwO7TgVtJsZclIg3g9SjLgtx6sx+Khlx2/p3HdMo7lYmbucnk1Px11Z0Uq6H7gdUyZhRMWgHnqpnzTy02onhsDhPotUbJdEHJKMZW+eg3X1KiPH143jDHPW/EQjhnPfMBBqaPof1l nanahira@nanahira-another
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAtRix6NrCSXMNpL9WuD6DA198aGirvb8cYIcx5fS98/EWqA8n8yjBEjfLkWZviSh8J6hDw5x4rlZWa777eP+qFfwZO5MjQp/n3cgpZgnbJFRUROuNEyaGQvv09uO05cgRKemVDysqte6xjH6YOts/+oX6dC/JK+Cwi7K0kUETQ2WLLTghyQfLkwKoXkP30v/j18yfyswyWsM1E70stmezMRYswsAeOP6j5/dZiSY9vPCPHJ0w3cGhV+YZcWVE3687cQyf++Iv4AGBzRWlGStGHfb3UB8fkeIClChkQDjjzrxfbrmeS3kC5w6hkbZFsreM8ZvWhDvB1eBxjU9KKbV0iQ== zh99998@gmail.com
allow_password: false
hypervisor: false
mirror_debian: http://deb.debian.org
mirror_debian_security: http://security.debian.org
mirror_ubuntu: http://archive.ubuntu.com
mirror_ubuntu_security: http://security.ubuntu.com
mirror_docker: https://download.docker.com
china_mirror: false
install_docker: true
upgrade: true
reboot: true
pip_executable_install: pip
registry: https://registry.mycard.moe
china_mirror_docker: false
china_mirror_pip: false
china_mirror_omf: false
cpufreq_policy: none
vm_agents_status: present
customization: true
nvidia_driver_version: null
cloud_kernel: auto # or enabled / disabled
xanmod: false
railgun:
destination: oversea
remoteGatewayId: 20001
laptop: false
extra_params: []
nfs: false
docker_root: /var/lib/docker
rcloud:
hosts:
example-1.com:
vars:
ansible_ssh_user: root
ansible_python_interpreter: python3
smartdns:
https_dns:
- 9.9.9.9
- 149.112.112.112
china_dns:
- 114.114.114.114
- 223.5.5.5
router_nextgen:
hosts:
example-2.com: # 在这里的基本上都是需要改的
links:
- name: eno2 # 物理网卡,如果有 bond 就不要设置在这里。
bonds: # 没有可以删
- name: bond0 # bond,一般用 mode 4 来LACP
links:
- eno1
mode: 4
vlans: # 没有可以删
- link: bond0 # vlan,只需要写 link和 tag,最后网卡名字会变成 link.tag
tag: 2
- link: bond0
tag: 3
- link: bond0
tag: 41
- link: bond0
tag: 46
bridges: # bridge,IP只能在这里配。
- name: brlan # 名称,必须填写
links:
- bond0 # 上行链路,必须填写
type: static # dhcp还是 static,manual 理论上也可以,必须填写
address: 10.0.0.1/24 # 首选地址
moreAddresses:
- 10.0.0.2/24 # 备选地址
gateways: null # 网关,看下面
masq: false # 是否 MASQ
stp: false # 是否开启 STP,默认 false
macvlan: false # 是不是 macvlan,有时候复用网卡有用
linkUp: echo 'link up' # 链路启动脚本,用于奇怪的特殊链路或者 netns
up: echo "up" # 启动脚本和关闭脚本
down: echo "down"
linkDown: echo 'link down'
mac: null # 自定 mac 地址,否则 bridge 随机,注意 dhcp 会以原始 mac 请求 dhcp,因此不建议 dhcp 模式使用
dhcpv6Client: false # 是否进行 dhcpv6 请求
dhcpv6Receive: true # DHCPv6 得到的地址的落脚点,只能有 1 个 LAN 获得
mtu: 1500
dhcp: # 是否开启dhcp,不是的话直接没有这一栏
start: 10.0.0.100
end: 10.0.0.240
time: 48h
domain: lan # 该段的缺省域名,默认为 br 的名称,删掉即可
pxe: # 为该段指定特别的PXE服务器,不指定的话删掉这个
file: somefile.txt
address: 10.0.0.4
- name: brwan
links:
- bond0.2
type: dhcp
address: null
moreAddresses: null
masq: true
gateways: # 网关定义,DHCP 关闭自动获取网关,需要手写地址。
- id: 0 # 网关ID,关乎 mark 和table。该网关的 table 计算方法为 1100+id
address: 10.198.21.1 # 网关地址,填写 _use_first 使用可用地址第一个,填写 _use_last 使用可用地址最后一个
mac: null # 网关 mac 地址,为 null 则自动 ping 获取,但是 bridge 有启动坑容易获取失败
noOrigin: false # 是否关闭源进源出,对于专门 peer 的网关,这个可能很有用。
up: null
down: null
mac: null
dhcpv6Client: false
dhcpv6Receive: false
dhcp: null
ppps: # 没有可以删
- id: 0 # ppp id,例如 0 代表 ppp0,该网关的 table 计算方法为 1000+id
link: bond0.41 # 上行链路
username: user # 拨号用户名,密码在 pppoeUsers 给出
mac: null # 给 ISP 看的 mac 地址,null 为随机
dhcpv6Client: false # 使用这里的 DHCPv6,所有 ppp 只能有1个
restartCron: '0 4 * * *' # 重启 crontab
pppoeUsers: # PPPoE帐号,没有可以删
- username: user
password: pass
services: # 必须有
address: 10.0.0.1 # 各内网服务主要监听的地址,必须填写
ddns: # 没有可以删
- name: test-ddns
email: name@example.com # cf 邮箱
apiKey: qweqwe # api 密钥
zone: mycard.moe # ddns 主域名
subdomain: test # ddns 子域名
ipv6: false # 是否解析 ipv6
interface: brwan # 网卡名,可以是 null,null 则用公网解析结果
vars: # 这里的都是默认设置,没什么事情可以不改,改的话需要整段抄上去
ansible_ssh_user: root
ansible_python_interpreter: python3
localnets:
- '10.198.0.0/16' # 主网段
- '192.168.1.0/24' # myacg
- '192.168.5.0/24' # gzzchh
- '192.168.123.0/24' # ayane 公司
smartdns:
external: null # 完全不使用 smartdns
# - 114.114.114.114#53
disable_ipv6: false # 是否禁用 IPv6 解析
tls_dns:
- 8.8.8.8
- 1.1.1.1
https_dns:
- cloudflare-dns.com
- dns.quad9.net
china_dns:
- 114.114.114.114
- 223.5.5.5
dnsmasq:
extraInterfaces: [] # 额外监听的网卡
kms: localhost # kms 服务器的地址,localhost 为自己搭建
aptCacher: null # apt-cacher-ng 的地址
pxe: localhost # pxe 服务器的地址,localhost 为自己搭建,也可以是 address/file 对象的格式
ntp: localhost # ntp 服务器的地址,localhost 为自己搭建
#gdut: # 校园网特化使用
# remote: 10.0.3.6
# flag: 2f
mycard-deploy-master/inventory.localhost.yaml 0000664 0000000 0000000 00000002547 14311351254 0022037 0 ustar 00root root 0000000 0000000 mycard:
hosts:
nanahira-another:
ansible_connection: local
vars:
authorized_keys: |
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCf7d3z1zJ3+AekdFlF+7BTL8k1X5YrC/Mu23aBBETYxl7N37XM/Ts1u15Xu9l0rgKOe2YphAzexsTmvnBW+3ZJUaJ4gIelw2FWYSHmPkcTtLRrqmSqqCVqyxLrlkvDV1mJmRTQh9rFT3OM2jge4HkN2PSnxuT4AuRwblHcGj2LWD/4XijmHf/BK6GaKownt702ARX18D7d2hYZwO7TgVtJsZclIg3g9SjLgtx6sx+Khlx2/p3HdMo7lYmbucnk1Px11Z0Uq6H7gdUyZhRMWgHnqpnzTy02onhsDhPotUbJdEHJKMZW+eg3X1KiPH143jDHPW/EQjhnPfMBBqaPof1l nanahira@nanahira-another
allow_password: false
hypervisor: false
mirror_debian: http://deb.debian.org
mirror_debian_security: http://security.debian.org
mirror_ubuntu: http://archive.ubuntu.com
mirror_ubuntu_security: http://security.ubuntu.com
mirror_docker: https://download.docker.com
china_mirror: false
install_docker: true
upgrade: true
reboot: true
pip_executable_install: pip
registry: https://registry.mycard.moe
china_mirror_docker: false
china_mirror_pip: false
china_mirror_omf: false
cpufreq_policy: none
vm_agents_status: present
customization: true
nvidia_driver_version: null
cloud_kernel: auto # or enabled / disabled
xanmod: false
railgun:
destination: oversea
remoteGatewayId: 20001
laptop: false
extra_params: []
nfs: false
docker_root: /var/lib/docker
mycard-deploy-master/mitogen-0.2.9/ 0000775 0000000 0000000 00000000000 14311351254 0017225 5 ustar 00root root 0000000 0000000 mycard-deploy-master/mitogen-0.2.9/LICENSE 0000664 0000000 0000000 00000002662 14311351254 0020240 0 ustar 00root root 0000000 0000000 Copyright 2019, David Wilson
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mycard-deploy-master/mitogen-0.2.9/MANIFEST.in 0000664 0000000 0000000 00000000020 14311351254 0020753 0 ustar 00root root 0000000 0000000 include LICENSE
mycard-deploy-master/mitogen-0.2.9/PKG-INFO 0000664 0000000 0000000 00000001617 14311351254 0020327 0 ustar 00root root 0000000 0000000 Metadata-Version: 1.1
Name: mitogen
Version: 0.2.9
Summary: Library for writing distributed self-replicating programs.
Home-page: https://github.com/dw/mitogen/
Author: David Wilson
Author-email: UNKNOWN
License: New BSD
Description: UNKNOWN
Platform: UNKNOWN
Classifier: Environment :: Console
Classifier: Intended Audience :: System Administrators
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: POSIX
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2.4
Classifier: Programming Language :: Python :: 2.5
Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Topic :: System :: Distributed Computing
Classifier: Topic :: System :: Systems Administration
mycard-deploy-master/mitogen-0.2.9/README.md 0000664 0000000 0000000 00000001267 14311351254 0020512 0 ustar 00root root 0000000 0000000
# Mitogen
Please see the documentation.
![](https://i.imgur.com/eBM6LhJ.gif)
[![Total alerts](https://img.shields.io/lgtm/alerts/g/dw/mitogen.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/dw/mitogen/alerts/)
[![Build Status](https://travis-ci.org/dw/mitogen.svg?branch=master)](https://travis-ci.org/dw/mitogen)
[![Pipelines Status](https://dev.azure.com/dw-mitogen/Mitogen/_apis/build/status/dw.mitogen?branchName=master)](https://dev.azure.com/dw-mitogen/Mitogen/_build/latest?definitionId=1?branchName=master)
mycard-deploy-master/mitogen-0.2.9/ansible_mitogen/ 0000775 0000000 0000000 00000000000 14311351254 0022364 5 ustar 00root root 0000000 0000000 mycard-deploy-master/mitogen-0.2.9/ansible_mitogen/__init__.py 0000664 0000000 0000000 00000000000 14311351254 0024463 0 ustar 00root root 0000000 0000000 mycard-deploy-master/mitogen-0.2.9/ansible_mitogen/__init__.pyc 0000664 0000000 0000000 00000000227 14311351254 0024641 0 ustar 00root root 0000000 0000000
TJB^c @ s d S( N( ( ( ( s@ /home/nanahira/ansible/mitogen-0.2.9/ansible_mitogen/__init__.pyt t mycard-deploy-master/mitogen-0.2.9/ansible_mitogen/__pycache__/ 0000775 0000000 0000000 00000000000 14311351254 0024574 5 ustar 00root root 0000000 0000000 mycard-deploy-master/mitogen-0.2.9/ansible_mitogen/__pycache__/__init__.cpython-36.pyc 0000664 0000000 0000000 00000000223 14311351254 0030756 0 ustar 00root root 0000000 0000000 3
TJB^ @ s d S )N r r r @/home/nanahira/ansible/mitogen-0.2.9/ansible_mitogen/__init__.py s mycard-deploy-master/mitogen-0.2.9/ansible_mitogen/__pycache__/__init__.cpython-37.pyc 0000664 0000000 0000000 00000000255 14311351254 0030764 0 ustar 00root root 0000000 0000000 B
ý] @ s d S )N r r r V/Users/zh99998/gateways/gateways-api/ansible/mitogen-0.2.9/ansible_mitogen/__init__.py mycard-deploy-master/mitogen-0.2.9/ansible_mitogen/__pycache__/affinity.cpython-36.pyc 0000664 0000000 0000000 00000023317 14311351254 0031041 0 ustar 00root root 0000000 0000000 3
TJB^' @ s4 d Z ddlmZ ddlZddlZddlZddlZddlZddlZddl Z
ddlZ
eje
Zy8ejdddZejZeje_ejZejZejZejZW n0 eefk
r dZdZdZdZdZdZY nX G dd dejZ G dd d ejZ!G d
d de"Z#G dd
d
e#Z$G dd de$Z%edk r*e% Z&ne# Z&dS )a
As Mitogen separates asynchronous IO out to a broker thread, communication
necessarily involves context switching and waking that thread. When application
threads and the broker share a CPU, this can be almost invisibly fast - around
25 microseconds for a full A->B->A round-trip.
However when threads are scheduled on different CPUs, round-trip delays
regularly vary wildly, and easily into milliseconds. Many contributing factors
exist, not least scenarios like:
1. A is preempted immediately after waking B, but before releasing the GIL.
2. B wakes from IO wait only to immediately enter futex wait.
3. A may wait 10ms or more for another timeslice, as the scheduler on its CPU
runs threads unrelated to its transaction (i.e. not B), wake only to release
its GIL, before entering IO sleep waiting for a reply from B, which cannot
exist yet.
4. B wakes, acquires GIL, performs work, and sends reply to A, causing it to
wake. B is preempted before releasing GIL.
5. A wakes from IO wait only to immediately enter futex wait.
6. B may wait 10ms or more for another timeslice, wake only to release its GIL,
before sleeping again.
7. A wakes, acquires GIL, finally receives reply.
Per above if we are unlucky, on an even moderately busy machine it is possible
to lose milliseconds just in scheduling delay, and the effect is compounded
when pairs of threads in process A are communicating with pairs of threads in
process B using the same scheme, such as when Ansible WorkerProcess is
communicating with ContextService in the connection multiplexer. In the worst
case it could involve 4 threads working in lockstep spread across 4 busy CPUs.
Since multithreading in Python is essentially useless except for waiting on IO
due to the presence of the GIL, at least in Ansible there is no good reason for
threads in the same process to run on distinct CPUs - they always operate in
lockstep due to the GIL, and are thus vulnerable to issues like above.
Linux lacks any natural API to describe what we want, it only permits
individual threads to be constrained to run on specific CPUs, and for that
constraint to be inherited by new threads and forks of the constrained thread.
This module therefore implements a CPU pinning policy for Ansible processes,
providing methods that should be called early in any new process, either to
rebalance which CPU it is pinned to, or in the case of subprocesses, to remove
the pinning entirely. It is likely to require ongoing tweaking, since pinning
necessarily involves preventing the scheduler from making load balancing
decisions.
)absolute_importNT) use_errnoc @ s8 e Zd ZdZdejd fgZdd Zdd Zdd Z d
S )sem_tz>
Wrap sem_t to allow storing a lock in shared memory.
data c C s" t | jddrtttj d S )N ) _sem_initr Exception _strerrorctypes get_errno)self r @/home/nanahira/ansible/mitogen-0.2.9/ansible_mitogen/affinity.pyinitt s z
sem_t.initc C s t | jrtttj d S )N) _sem_waitr r r
r r )r
r r r acquirex s
z
sem_t.acquirec C s t | jrtttj d S )N) _sem_postr r r
r r )r
r r r release| s
z
sem_t.releaseN)
__name__
__module____qualname____doc__r c_uint8_fields_r r r r r r r r l s
r c @ s" e Zd ZdZdefdejfgZdS )Statez
Contents of shared memory segment. This allows :meth:`Manager.assign` to be
called from any child, since affinity assignment must happen from within
the context of the new child process.
lockcounterN)r r r r r r r r r r r r r s r c @ s0 e Zd ZdZdd Zdd Zdd Zdd Zd
S )Policyz"
Process affinity policy.
c C s dS )zF
Assign the Ansible top-level policy to this process.
Nr )r
r r r assign_controller s zPolicy.assign_controllerc C s dS )z?
Assign the MuxProcess policy to this process.
Nr )r
indexr r r assign_muxprocess s zPolicy.assign_muxprocessc C s dS )zB
Assign the WorkerProcess policy to this process.
Nr )r
r r r
assign_worker s zPolicy.assign_workerc C s dS )zF
Assign the helper subprocess policy to this process.
Nr )r
r r r assign_subprocess s zPolicy.assign_subprocessN)r r r r r r! r" r# r r r r r s
r c @ sZ e Zd ZdZdddZdd Zdd Zd d
Zdd Zd
d Z dd Z
dd Zdd ZdS )FixedPolicya
:class:`Policy` for machines where the only control method available is
fixed CPU placement. The scheme here was tested on an otherwise idle 16
thread machine.
- The connection multiplexer is pinned to CPU 0.
- The Ansible top-level (strategy) is pinned to CPU 1.
- WorkerProcesses are pinned sequentually to 2..N, wrapping around when no
more CPUs exist.
- Children such as SSH may be scheduled on any CPU except 0/1.
If the machine has less than 4 cores available, the top-level and workers
are pinned between CPU 2..N, i.e. no CPU is reserved for the top-level
process.
This could at least be improved by having workers pinned to independent
cores, before reusing the second hyperthread of an existing core.
A hook is installed that causes :meth:`reset` to run in the child of any
process created with :func:`mitogen.parent.popen`, ensuring CPU-intensive
children like SSH are not forced to share the same core as the (otherwise
potentially very busy) parent.
Nc C s |p
t j | _tjd d| _tj| j| _| jjj | jdk rZd| _ d| _
d| _d| _n<| jdk r~d| _ d| _
d| _d| _nd| _ d| _
d| _d| _d S )
Nr i Fr T )
multiprocessing cpu_countmmapZmemr from_bufferstater r Z_reserve_mux_reserve_controller
_reserve_mask_reserve_shift)r
r* r r r __init__ s$
zFixedPolicy.__init__c C s* |rt jd|| | jtj_| j| d S )NzCPU mask for %s: %#08x)LOGdebug_clearmitogenparentZ
_preexec_hook
_set_cpu_mask)r
descrmaskr r r
_set_affinity s
zFixedPolicy._set_affinityc C sZ | j jj z| j j}| j jd7 _W d | j jj X | j|| j|| j| j d S )Nr )r- r r r r _set_cpur0 r* )r
r8 nr r r _balance s
zFixedPolicy._balancec C s | j |d|| j > d S )Nr )r: r* )r
r8 cpur r r r; s zFixedPolicy._set_cpuc C s&