{"id":62073,"date":"2026-01-19T09:34:03","date_gmt":"2026-01-19T01:34:03","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/62073.html"},"modified":"2026-01-19T09:34:03","modified_gmt":"2026-01-19T01:34:03","slug":"%e7%bc%93%e5%ad%98%e8%b0%83%e5%ba%a6%e4%bc%98%e5%8c%96%e7%b3%bb%e7%bb%9f%e5%8a%9f%e8%83%bd%e3%80%81%e6%95%b0%e6%8d%ae%e7%bb%93%e6%9e%84%e4%b8%8e%e7%ae%97%e6%b3%95%e8%af%a6%e8%a7%a3","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/62073.html","title":{"rendered":"\u7f13\u5b58\u8c03\u5ea6\u4f18\u5316\u7cfb\u7edf\u529f\u80fd\u3001\u6570\u636e\u7ed3\u6784\u4e0e\u7b97\u6cd5\u8be6\u89e3"},"content":{"rendered":"<h2>\u4e00\u3001\u7a0b\u5e8f\u6982\u8ff0\u4e0e\u529f\u80fd\u5206\u6790<\/h2>\n<h4>1.1 \u7a0b\u5e8f\u80cc\u666f\u4e0e\u5b9a\u4f4d<\/h4>\n<p>\u8be5\u7a0b\u5e8f\u662f\u4e00\u4e2a\u7f13\u5b58\u8c03\u5ea6\u4f18\u5316\u7cfb\u7edf&#xff0c;\u4e13\u95e8\u7528\u4e8e\u89e3\u51b3\u8ba1\u7b97\u56fe\u4e2d\u4efb\u52a1\u6267\u884c\u7684\u7f13\u5b58\u5206\u914d\u95ee\u9898\u3002\u5728\u8ba1\u7b97\u5bc6\u96c6\u578b\u5e94\u7528\u4e2d&#xff0c;\u5f53\u4efb\u52a1\u4e4b\u95f4\u5b58\u5728\u4f9d\u8d56\u5173\u7cfb\u4e14\u9700\u8981\u5171\u4eab\u6709\u9650\u7684\u7f13\u5b58\u8d44\u6e90\u65f6&#xff0c;\u5982\u4f55\u9ad8\u6548\u7ba1\u7406\u7f13\u5b58\u5206\u914d\u6210\u4e3a\u5173\u952e\u6027\u80fd\u74f6\u9888\u3002\u672c\u7a0b\u5e8f\u901a\u8fc7\u667a\u80fd\u7684\u7f13\u5b58\u8c03\u5ea6\u7b97\u6cd5&#xff0c;\u5728\u4fdd\u8bc1\u4efb\u52a1\u6b63\u786e\u6267\u884c\u7684\u524d\u63d0\u4e0b&#xff0c;\u6700\u5c0f\u5316\u56e0\u7f13\u5b58\u4e0d\u8db3\u5bfc\u81f4\u7684\u989d\u5916\u6570\u636e\u642c\u8fd0\u6210\u672c\u3002<\/p>\n<h4>1.2 \u6838\u5fc3\u529f\u80fd\u6a21\u5757<\/h4>\n<p>\u7a0b\u5e8f\u4e3b\u8981\u5305\u542b\u4e09\u5927\u529f\u80fd\u6a21\u5757&#xff1a;<\/p>\n<p>1. \u7f13\u5b58\u7ba1\u7406\u6a21\u5757<\/p>\n<ul>\n<li>\n<p>\u52a8\u6001\u5206\u914d\u548c\u91ca\u653eL1\u7f13\u5b58\u7a7a\u95f4<\/p>\n<\/li>\n<li>\n<p>\u5904\u7406\u7f13\u5b58\u7a7a\u95f4\u4e0d\u8db3\u65f6\u7684spill&#xff08;\u6362\u51fa&#xff09;\u64cd\u4f5c<\/p>\n<\/li>\n<li>\n<p>\u8bb0\u5f55\u7f13\u5b58\u4f7f\u7528\u60c5\u51b5\u548cspill\u5386\u53f2<\/p>\n<\/li>\n<\/ul>\n<p>2. \u4efb\u52a1\u8c03\u5ea6\u6a21\u5757<\/p>\n<ul>\n<li>\n<p>\u57fa\u4e8e\u4efb\u52a1\u4f9d\u8d56\u5173\u7cfb\u7684\u62d3\u6251\u6392\u5e8f\u8c03\u5ea6<\/p>\n<\/li>\n<li>\n<p>\u5c31\u7eea\u961f\u5217\u7ba1\u7406\u548c\u4efb\u52a1\u6267\u884c\u987a\u5e8f\u4f18\u5316<\/p>\n<\/li>\n<li>\n<p>\u5904\u7406\u4efb\u52a1\u56e0\u7f13\u5b58\u4e0d\u8db3\u800c\u63a8\u8fdf\u6267\u884c\u7684\u60c5\u51b5<\/p>\n<\/li>\n<\/ul>\n<p>3. \u6570\u636e\u52a0\u8f7d\u4e0e\u7ed3\u679c\u5206\u6790\u6a21\u5757<\/p>\n<ul>\n<li>\n<p>\u4eceJSON\u6587\u4ef6\u52a0\u8f7d\u8ba1\u7b97\u56fe\u6570\u636e<\/p>\n<\/li>\n<li>\n<p>\u6267\u884c\u5b8c\u6574\u7684\u8c03\u5ea6\u6d41\u7a0b<\/p>\n<\/li>\n<li>\n<p>\u751f\u6210\u8be6\u7ec6\u7684\u6027\u80fd\u5206\u6790\u62a5\u544a<\/p>\n<\/li>\n<\/ul>\n<h3>\u4e8c\u3001\u6570\u636e\u7ed3\u6784\u8be6\u7ec6\u89e3\u6790<\/h3>\n<h4>2.1 \u6838\u5fc3\u7c7b\u6570\u636e\u7ed3\u6784<\/h4>\n<h5>SchedulingSolution\u7c7b<\/h5>\n<p>class SchedulingSolution:<br \/>\n    def __init__(self, l1_capacity&#061;65536):<br \/>\n        self.l1_capacity &#061; l1_capacity      # \u7f13\u5b58\u603b\u5bb9\u91cf(64KB)<br \/>\n        self.l1_used &#061; {}                   # \u5f53\u524d\u5df2\u5206\u914d\u7f13\u51b2\u533a{\u7f13\u51b2\u533aID: \u5927\u5c0f}<br \/>\n        self.extra_movement &#061; 0             # \u603b\u989d\u5916\u6570\u636e\u642c\u8fd0\u91cf<br \/>\n        self.spill_log &#061; []                 # Spill\u64cd\u4f5c\u8bb0\u5f55\u5217\u8868<br \/>\n        self.finished &#061; set()               # \u5df2\u5b8c\u6210\u4efb\u52a1\u96c6\u5408<\/p>\n<p>\u6570\u636e\u7ed3\u6784\u8bbe\u8ba1\u7279\u70b9&#xff1a;<\/p>\n<ul>\n<li>\n<p>l1_used\u5b57\u5178&#xff1a;\u91c7\u7528\u54c8\u5e0c\u8868\u5b58\u50a8\u5f53\u524d\u7f13\u5b58\u5206\u914d\u72b6\u6001&#xff0c;\u5b9e\u73b0O(1)\u65f6\u95f4\u590d\u6742\u5ea6\u7684\u67e5\u627e\u548c\u63d2\u5165\u64cd\u4f5c<\/p>\n<\/li>\n<li>\n<p>spill_log\u5217\u8868&#xff1a;\u987a\u5e8f\u8bb0\u5f55\u6240\u6709spill\u64cd\u4f5c&#xff0c;\u4fbf\u4e8e\u540e\u7eed\u5206\u6790\u548c\u8c03\u8bd5<\/p>\n<\/li>\n<li>\n<p>finished\u96c6\u5408&#xff1a;\u5229\u7528\u96c6\u5408\u7684\u552f\u4e00\u6027\u7279\u6027&#xff0c;\u5feb\u901f\u5224\u65ad\u4efb\u52a1\u5b8c\u6210\u72b6\u6001<\/p>\n<\/li>\n<\/ul>\n<h4>2.2 \u8ba1\u7b97\u56fe\u6570\u636e\u7ed3\u6784<\/h4>\n<h5>\u8282\u70b9\u6570\u636e\u7ed3\u6784<\/h5>\n<p>{<br \/>\n    &#034;Id&#034;: &#034;\u4efb\u52a1\u552f\u4e00\u6807\u8bc6\u7b26&#034;,<br \/>\n    &#034;BufId&#034;: &#034;\u5173\u8054\u7684\u7f13\u51b2\u533aID&#034;,<br \/>\n    &#034;Size&#034;: &#034;\u6240\u9700\u7f13\u5b58\u5927\u5c0f&#034;,<br \/>\n    &#034;Op&#034;: &#034;\u64cd\u4f5c\u7c7b\u578b(\u5982COPY_IN)&#034;<br \/>\n}<\/p>\n<h5>\u8fb9\u6570\u636e\u7ed3\u6784<\/h5>\n<p>[&#034;\u6e90\u4efb\u52a1ID&#034;, &#034;\u76ee\u6807\u4efb\u52a1ID&#034;]  # \u8868\u793a\u4efb\u52a1\u95f4\u7684\u4f9d\u8d56\u5173\u7cfb<\/p>\n<h4>2.3 \u4f9d\u8d56\u5173\u7cfb\u7ba1\u7406\u6570\u636e\u7ed3\u6784<\/h4>\n<p>\u7a0b\u5e8f\u4f7f\u7528\u4e09\u79cd\u6838\u5fc3\u6570\u636e\u7ed3\u6784\u7ba1\u7406\u4efb\u52a1\u4f9d\u8d56&#xff1a;<\/p>\n<p>\u5165\u5ea6\u8868(indeg)<\/p>\n<ul>\n<li>\n<p>\u7c7b\u578b&#xff1a;\u5b57\u5178{\u4efb\u52a1ID: \u5165\u5ea6\u503c}<\/p>\n<\/li>\n<li>\n<p>\u529f\u80fd&#xff1a;\u8bb0\u5f55\u6bcf\u4e2a\u4efb\u52a1\u5c1a\u672a\u5b8c\u6210\u7684\u76f4\u63a5\u524d\u9a71\u4efb\u52a1\u6570\u91cf<\/p>\n<\/li>\n<li>\n<p>\u4f5c\u7528&#xff1a;\u5feb\u901f\u5224\u65ad\u4efb\u52a1\u662f\u5426\u5c31\u7eea&#xff08;\u5165\u5ea6\u4e3a0&#xff09;<\/p>\n<\/li>\n<\/ul>\n<p>\u5b50\u8282\u70b9\u5173\u7cfb\u8868(children)<\/p>\n<ul>\n<li>\n<p>\u7c7b\u578b&#xff1a;\u5b57\u5178{\u4efb\u52a1ID: [\u76f4\u63a5\u540e\u7ee7\u4efb\u52a1\u5217\u8868]}<\/p>\n<\/li>\n<li>\n<p>\u529f\u80fd&#xff1a;\u5efa\u7acb\u4efb\u52a1\u5230\u5176\u540e\u7ee7\u4efb\u52a1\u7684\u6620\u5c04<\/p>\n<\/li>\n<li>\n<p>\u4f5c\u7528&#xff1a;\u5f53\u524d\u4efb\u52a1\u5b8c\u6210\u540e\u5feb\u901f\u66f4\u65b0\u540e\u7ee7\u4efb\u52a1\u72b6\u6001<\/p>\n<\/li>\n<\/ul>\n<p>\u5c31\u7eea\u961f\u5217(ready)<\/p>\n<ul>\n<li>\n<p>\u7c7b\u578b&#xff1a;collections.deque\u53cc\u7aef\u961f\u5217<\/p>\n<\/li>\n<li>\n<p>\u529f\u80fd&#xff1a;\u5b58\u50a8\u5f53\u524d\u53ef\u7acb\u5373\u6267\u884c\u7684\u4efb\u52a1<\/p>\n<\/li>\n<li>\n<p>\u7279\u70b9&#xff1a;\u652f\u6301\u9ad8\u6548\u7684\u961f\u9996\u5f39\u51fa\u548c\u961f\u5c3e\u8ffd\u52a0\u64cd\u4f5c<\/p>\n<\/li>\n<\/ul>\n<h3>\u4e09\u3001\u7b97\u6cd5\u8bbe\u8ba1\u4e0e\u5b9e\u73b0\u6df1\u5ea6\u89e3\u6790<\/h3>\n<h4>3.1 \u4e3b\u8c03\u5ea6\u7b97\u6cd5\u6846\u67b6<\/h4>\n<h5>\u7b97\u6cd53.1&#xff1a;\u57fa\u4e8e\u62d3\u6251\u6392\u5e8f\u7684\u8c03\u5ea6\u4e3b\u5faa\u73af<\/h5>\n<p>def schedule_case(case_name, case_json, l1_capacity&#061;65536):<br \/>\n    # 1. \u521d\u59cb\u5316\u4f9d\u8d56\u5173\u7cfb\u6570\u636e\u7ed3\u6784<br \/>\n    indeg &#061; {}      # \u5165\u5ea6\u8868<br \/>\n    children &#061; {}   # \u5b50\u8282\u70b9\u5173\u7cfb<\/p>\n<p>    # 2. \u6784\u5efa\u8ba1\u7b97\u56fe<br \/>\n    for n in nodes:<br \/>\n        indeg[n[&#034;Id&#034;]] &#061; 0<br \/>\n        children[n[&#034;Id&#034;]] &#061; []<\/p>\n<p>    for u, v in edges:<br \/>\n        indeg[v] &#043;&#061; 1<br \/>\n        children[u].append(v)<\/p>\n<p>    # 3. \u521d\u59cb\u5316\u5c31\u7eea\u961f\u5217<br \/>\n    ready &#061; deque([n for n in nodes if indeg[n[&#034;Id&#034;]] &#061;&#061; 0])<br \/>\n    solution &#061; SchedulingSolution(l1_capacity)<\/p>\n<p>    # 4. \u4e3b\u8c03\u5ea6\u5faa\u73af<br \/>\n    while ready:<br \/>\n        task &#061; ready.popleft()  # \u53d6\u51fa\u961f\u9996\u4efb\u52a1<br \/>\n        tid &#061; task[&#034;Id&#034;]<\/p>\n<p>        # \u5c1d\u8bd5\u5206\u914d\u7f13\u5b58<br \/>\n        if not solution.allocate_buffer(&#8230;):<br \/>\n            # \u7f13\u5b58\u4e0d\u8db3&#xff0c;\u63a8\u8fdf\u6267\u884c<br \/>\n            solution._postpone_allocation(task, ready)<br \/>\n            continue<\/p>\n<p>        # \u6267\u884c\u4efb\u52a1\u5e76\u66f4\u65b0\u72b6\u6001<br \/>\n        solution.finished.add(tid)<br \/>\n        solution.release_buffer(&#8230;)<\/p>\n<p>        # \u66f4\u65b0\u540e\u7ee7\u4efb\u52a1\u72b6\u6001<br \/>\n        for v in children[tid]:<br \/>\n            indeg[v] -&#061; 1<br \/>\n            if indeg[v] &#061;&#061; 0:<br \/>\n                next_node &#061; next(n for n in nodes if n[&#034;Id&#034;] &#061;&#061; v)<br \/>\n                ready.append(next_node)<\/p>\n<p>    return solution.summary()<\/p>\n<p>\u7b97\u6cd5\u590d\u6742\u5ea6\u5206\u6790&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u65f6\u95f4\u590d\u6742\u5ea6&#xff1a;O(V &#043; E)&#xff0c;\u5176\u4e2dV\u4e3a\u8282\u70b9\u6570&#xff0c;E\u4e3a\u8fb9\u6570<\/p>\n<\/li>\n<li>\n<p>\u7a7a\u95f4\u590d\u6742\u5ea6&#xff1a;O(V &#043; E)&#xff0c;\u7528\u4e8e\u5b58\u50a8\u56fe\u7ed3\u6784\u548c\u5404\u79cd\u8f85\u52a9\u6570\u636e\u7ed3\u6784<\/p>\n<\/li>\n<\/ul>\n<h4>3.2 \u7f13\u5b58\u5206\u914d\u7b97\u6cd5\u8be6\u89e3<\/h4>\n<h5>\u7b97\u6cd53.2&#xff1a;\u667a\u80fd\u7f13\u5b58\u5206\u914d\u7b56\u7565<\/h5>\n<p>def allocate_buffer(self, buf_id, size, is_copyin&#061;False):<br \/>\n    # \u68c0\u67e5\u662f\u5426\u5df2\u5206\u914d<br \/>\n    if buf_id in self.l1_used:<br \/>\n        return True<\/p>\n<p>    # \u68c0\u67e5\u76f4\u63a5\u5206\u914d\u53ef\u80fd\u6027<br \/>\n    current_usage &#061; self._current_usage()<br \/>\n    if current_usage &#043; size &lt;&#061; self.l1_capacity:<br \/>\n        self.l1_used[buf_id] &#061; size<br \/>\n        return True<\/p>\n<p>    # \u9700\u8981spill\u64cd\u4f5c<br \/>\n    if self._try_spill(size):<br \/>\n        self.l1_used[buf_id] &#061; size<br \/>\n        return True<\/p>\n<p>    return False  # \u5206\u914d\u5931\u8d25<\/p>\n<p>\u7f13\u5b58\u5206\u914d\u7b56\u7565\u7279\u70b9&#xff1a;<\/p>\n<li>\n<p>\u60f0\u6027\u5206\u914d&#xff1a;\u53ea\u6709\u5728\u771f\u6b63\u9700\u8981\u65f6\u624d\u5206\u914d\u7f13\u5b58<\/p>\n<\/li>\n<li>\n<p>\u907f\u514d\u91cd\u590d\u5206\u914d&#xff1a;\u901a\u8fc7\u68c0\u67e5l1_used\u5b57\u5178\u9632\u6b62\u540c\u4e00\u7f13\u51b2\u533a\u7684\u91cd\u590d\u5206\u914d<\/p>\n<\/li>\n<li>\n<p>\u6e10\u8fdb\u5f0fspill&#xff1a;\u5f53\u76f4\u63a5\u5206\u914d\u5931\u8d25\u65f6&#xff0c;\u5c1d\u8bd5\u901a\u8fc7spill\u817e\u51fa\u7a7a\u95f4<\/p>\n<\/li>\n<h4>3.3 Spill\u7b97\u6cd5\u8bbe\u8ba1\u4e0e\u5b9e\u73b0<\/h4>\n<h5>\u7b97\u6cd53.3&#xff1a;\u57fa\u4e8e\u6700\u5927\u5c3a\u5bf8\u4f18\u5148\u7684Spill\u7b56\u7565<\/h5>\n<p>def _try_spill(self, required_size):<br \/>\n    freed &#061; 0<br \/>\n    # \u5faa\u73af\u76f4\u5230\u6ee1\u8db3\u7a7a\u95f4\u9700\u6c42\u6216\u65e0\u53efspill\u7684\u7f13\u51b2\u533a<br \/>\n    while (self._current_usage() &#043; required_size &gt; self.l1_capacity<br \/>\n           and self.l1_used):<br \/>\n        # \u9009\u62e9\u6700\u5927\u7684\u7f13\u51b2\u533a\u4f5c\u4e3a\u727a\u7272\u8005<br \/>\n        victim &#061; max(self.l1_used.items(), key&#061;lambda x: x[1])<br \/>\n        buf_id, sz &#061; victim<\/p>\n<p>        # \u8bb0\u5f55spill\u64cd\u4f5c<br \/>\n        self.spill_log.append((buf_id, sz))<br \/>\n        self.extra_movement &#043;&#061; 2 * sz  # \u8ba1\u7b97\u989d\u5916\u5f00\u9500<\/p>\n<p>        # \u6267\u884cspill<br \/>\n        del self.l1_used[buf_id]<br \/>\n        freed &#043;&#061; sz<\/p>\n<p>    return self._current_usage() &#043; required_size &lt;&#061; self.l1_capacity<\/p>\n<p>Spill\u7b56\u7565\u5206\u6790&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u8d2a\u5fc3\u9009\u62e9\u7b56\u7565&#xff1a;\u6bcf\u6b21\u9009\u62e9\u5c3a\u5bf8\u6700\u5927\u7684\u7f13\u51b2\u533a\u8fdb\u884cspill<\/p>\n<\/li>\n<li>\n<p>\u6210\u672c\u8ba1\u7b97\u6a21\u578b&#xff1a;\u6bcf\u6b21spill\u4ea7\u751f2\u500d\u5927\u5c0f\u7684\u6570\u636e\u642c\u8fd0\u6210\u672c&#xff08;\u5199\u51fa&#043;\u8bfb\u56de&#xff09;<\/p>\n<\/li>\n<li>\n<p>\u7ec8\u6b62\u6761\u4ef6&#xff1a;\u6ee1\u8db3\u7a7a\u95f4\u9700\u6c42\u6216\u65e0\u53efspill\u7684\u7f13\u51b2\u533a<\/p>\n<\/li>\n<\/ul>\n<h4>3.4 \u4efb\u52a1\u63a8\u8fdf\u6267\u884c\u7b56\u7565<\/h4>\n<h5>\u7b97\u6cd53.4&#xff1a;\u81ea\u9002\u5e94\u4efb\u52a1\u63a8\u8fdf\u673a\u5236<\/h5>\n<p>def _postpone_allocation(self, task, ready_queue):<br \/>\n    ready_queue.append(task)  # \u7b80\u5355\u5730\u5c06\u4efb\u52a1\u653e\u56de\u961f\u5217\u672b\u5c3e<\/p>\n<p>\u63a8\u8fdf\u7b56\u7565\u5206\u6790&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u5b9e\u73b0\u7b80\u5355&#xff1a;\u4ec5\u5c06\u4efb\u52a1\u91cd\u65b0\u653e\u5165\u5c31\u7eea\u961f\u5217<\/p>\n<\/li>\n<li>\n<p>\u6f5c\u5728\u95ee\u9898&#xff1a;\u53ef\u80fd\u4ea7\u751f\u9965\u997f\u73b0\u8c61&#xff0c;\u9700\u8981\u7ed3\u5408\u5b9e\u9645\u573a\u666f\u4f18\u5316<\/p>\n<\/li>\n<li>\n<p>\u6539\u8fdb\u7a7a\u95f4&#xff1a;\u53ef\u5f15\u5165\u4f18\u5148\u7ea7\u673a\u5236\u6216\u65f6\u95f4\u6233\u907f\u514d\u65e0\u9650\u63a8\u8fdf<\/p>\n<\/li>\n<\/ul>\n<h3>\u56db\u3001\u7b97\u6cd5\u4f18\u5316\u4e0e\u6027\u80fd\u5206\u6790<\/h3>\n<h4>4.1 \u7f13\u5b58\u5229\u7528\u7387\u4f18\u5316<\/h4>\n<p>\u7a0b\u5e8f\u901a\u8fc7\u4ee5\u4e0b\u7b56\u7565\u4f18\u5316\u7f13\u5b58\u4f7f\u7528&#xff1a;<\/p>\n<p>1. \u52a8\u6001\u7a7a\u95f4\u7ba1\u7406<\/p>\n<ul>\n<li>\n<p>\u5b9e\u65f6\u76d1\u63a7\u7f13\u5b58\u4f7f\u7528\u7387&#xff1a;_current_usage()\u65b9\u6cd5<\/p>\n<\/li>\n<li>\n<p>\u6309\u9700\u5206\u914d\u548c\u91ca\u653e&#xff0c;\u907f\u514d\u9759\u6001\u5206\u914d\u7684\u7a7a\u95f4\u6d6a\u8d39<\/p>\n<\/li>\n<\/ul>\n<p>2. \u667a\u80fdspill\u89e6\u53d1\u673a\u5236<\/p>\n<ul>\n<li>\n<p>\u4ec5\u5728\u5fc5\u8981\u65f6\u89e6\u53d1spill\u64cd\u4f5c<\/p>\n<\/li>\n<li>\n<p>\u901a\u8fc7\u7cbe\u786e\u7684\u7a7a\u95f4\u8ba1\u7b97\u907f\u514d\u4e0d\u5fc5\u8981\u7684spill<\/p>\n<\/li>\n<\/ul>\n<h4>4.2 \u65f6\u95f4\u590d\u6742\u5ea6\u4f18\u5316<\/h4>\n<p>\u6570\u636e\u7ed3\u6784\u9009\u62e9\u4f18\u5316&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u4f7f\u7528\u5b57\u5178\u5b58\u50a8\u7f13\u5b58\u5206\u914d\u72b6\u6001&#xff1a;O(1)\u7684\u67e5\u627e\u548c\u63d2\u5165<\/p>\n<\/li>\n<li>\n<p>\u4f7f\u7528\u53cc\u7aef\u961f\u5217\u7ba1\u7406\u5c31\u7eea\u4efb\u52a1&#xff1a;O(1)\u7684\u5165\u961f\u548c\u51fa\u961f\u64cd\u4f5c<\/p>\n<\/li>\n<li>\n<p>\u4f7f\u7528\u96c6\u5408\u8bb0\u5f55\u5b8c\u6210\u72b6\u6001&#xff1a;O(1)\u7684\u6210\u5458\u68c0\u67e5<\/p>\n<\/li>\n<\/ul>\n<p>\u7b97\u6cd5\u6d41\u7a0b\u4f18\u5316&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u62d3\u6251\u6392\u5e8f\u907f\u514d\u91cd\u590d\u8ba1\u7b97\u4f9d\u8d56\u5173\u7cfb<\/p>\n<\/li>\n<li>\n<p>\u589e\u91cf\u5f0f\u66f4\u65b0\u540e\u7ee7\u4efb\u52a1\u72b6\u6001<\/p>\n<\/li>\n<li>\n<p>\u5c40\u90e8\u6027\u4f18\u5316\u7684\u4efb\u52a1\u8c03\u5ea6\u987a\u5e8f<\/p>\n<\/li>\n<\/ul>\n<h4>4.3 \u7a7a\u95f4\u590d\u6742\u5ea6\u5206\u6790<\/h4>\n<p>\u4e3b\u8981\u7a7a\u95f4\u5f00\u9500\u6765\u6e90&#xff1a;<\/p>\n<li>\n<p>\u8ba1\u7b97\u56fe\u5b58\u50a8&#xff1a;O(V &#043; E)<\/p>\n<\/li>\n<li>\n<p>\u4f9d\u8d56\u5173\u7cfb\u6570\u636e\u7ed3\u6784&#xff1a;O(V &#043; E)<\/p>\n<\/li>\n<li>\n<p>\u7f13\u5b58\u72b6\u6001\u8ddf\u8e2a&#xff1a;O(V)\u6700\u574f\u60c5\u51b5<\/p>\n<\/li>\n<li>\n<p>\u8f85\u52a9\u8bb0\u5f55\u7ed3\u6784&#xff1a;O(V)\u91cf\u7ea7<\/p>\n<\/li>\n<p>\u603b\u7a7a\u95f4\u590d\u6742\u5ea6&#xff1a;\u200b O(V &#043; E)&#xff0c;\u4e0e\u95ee\u9898\u89c4\u6a21\u7ebf\u6027\u76f8\u5173<\/p>\n<h3>\u4e94\u3001\u5e94\u7528\u573a\u666f\u4e0e\u6269\u5c55\u6027\u5206\u6790<\/h3>\n<h4>5.1 \u5178\u578b\u5e94\u7528\u573a\u666f<\/h4>\n<p>1. \u795e\u7ecf\u7f51\u7edc\u63a8\u7406\u4f18\u5316<\/p>\n<ul>\n<li>\n<p>\u9002\u7528\u4e8e\u8ba1\u7b97\u56fe\u5f62\u5f0f\u7684\u795e\u7ecf\u7f51\u7edc\u6a21\u578b<\/p>\n<\/li>\n<li>\n<p>\u4f18\u5316\u4e2d\u95f4\u7279\u5f81\u56fe\u7684\u7f13\u5b58\u4f7f\u7528<\/p>\n<\/li>\n<li>\n<p>\u51cf\u5c11GPU\/TPU\u7b49\u52a0\u901f\u5668\u7684\u5185\u5b58\u4ea4\u6362\u5f00\u9500<\/p>\n<\/li>\n<\/ul>\n<p>2. \u6d41\u5f0f\u8ba1\u7b97\u7cfb\u7edf<\/p>\n<ul>\n<li>\n<p>\u6570\u636e\u5904\u7406\u6d41\u6c34\u7ebf\u7684\u8d44\u6e90\u4f18\u5316<\/p>\n<\/li>\n<li>\n<p>\u6709\u9650\u5185\u5b58\u6761\u4ef6\u4e0b\u7684\u4efb\u52a1\u8c03\u5ea6<\/p>\n<\/li>\n<li>\n<p>\u5b9e\u65f6\u7cfb\u7edf\u7684\u6027\u80fd\u4fdd\u969c<\/p>\n<\/li>\n<\/ul>\n<p>3. \u7f16\u8bd1\u5668\u4f18\u5316<\/p>\n<ul>\n<li>\n<p>\u9759\u6001\u5185\u5b58\u5206\u914d\u4f18\u5316<\/p>\n<\/li>\n<li>\n<p>\u5faa\u73af\u5d4c\u5957\u7684\u6570\u636e\u5c40\u90e8\u6027\u4f18\u5316<\/p>\n<\/li>\n<li>\n<p>\u81ea\u52a8\u5185\u5b58\u7ba1\u7406\u7b56\u7565\u751f\u6210<\/p>\n<\/li>\n<\/ul>\n<h4>5.2 \u7b97\u6cd5\u6269\u5c55\u6027\u5206\u6790<\/h4>\n<p>\u53ef\u6269\u5c55\u7684\u6539\u8fdb\u65b9\u5411&#xff1a;<\/p>\n<p>1. \u9ad8\u7ea7spill\u7b56\u7565<\/p>\n<p># \u66ff\u4ee3\u73b0\u6709\u7684\u6700\u5927\u5c3a\u5bf8\u4f18\u5148\u7b56\u7565<br \/>\ndef _advanced_spill_strategy(self, required_size):<br \/>\n    # \u57fa\u4e8e\u8bbf\u95ee\u9891\u7387\u7684spill<br \/>\n    # \u57fa\u4e8e\u672a\u6765\u4f7f\u7528\u9884\u6d4b\u7684spill<br \/>\n    # \u591a\u76ee\u6807\u4f18\u5316\u7684spill\u51b3\u7b56<br \/>\n    pass<\/p>\n<p>2. \u4f18\u5148\u7ea7\u8c03\u5ea6\u673a\u5236<\/p>\n<p>def prioritize_tasks(self, ready_queue):<br \/>\n    # \u57fa\u4e8e\u4efb\u52a1\u5173\u952e\u8def\u5f84\u7684\u4f18\u5148\u7ea7<br \/>\n    # \u57fa\u4e8e\u7f13\u5b58\u9700\u6c42\u7684\u7d27\u8feb\u6027\u4f18\u5148\u7ea7<br \/>\n    # \u52a8\u6001\u8c03\u6574\u7684\u4f18\u5148\u7ea7\u7b56\u7565<br \/>\n    pass<\/p>\n<p>3. \u5206\u5e03\u5f0f\u7f13\u5b58\u652f\u6301<\/p>\n<p>class DistributedSchedulingSolution(SchedulingSolution):<br \/>\n    def __init__(self, l1_capacities, network_cost_model):<br \/>\n        # \u591a\u7ea7\u7f13\u5b58\u5c42\u6b21\u652f\u6301<br \/>\n        # \u7f51\u7edc\u4f20\u8f93\u6210\u672c\u5efa\u6a21<br \/>\n        # \u534f\u540c\u7f13\u5b58\u7ba1\u7406<br \/>\n        pass<\/p>\n<h3>\u516d\u3001\u6027\u80fd\u8bc4\u4f30\u4e0e\u5b9e\u9a8c\u7ed3\u679c\u5206\u6790<\/h3>\n<h4>6.1 \u6027\u80fd\u5ea6\u91cf\u6307\u6807<\/h4>\n<p>\u7a0b\u5e8f\u4e3b\u8981\u5173\u6ce8\u4ee5\u4e0b\u6027\u80fd\u6307\u6807&#xff1a;<\/p>\n<p>1. \u989d\u5916\u6570\u636e\u642c\u8fd0\u91cf(extra_movement)<\/p>\n<ul>\n<li>\n<p>\u76f4\u63a5\u53cd\u6620\u7b97\u6cd5\u4f18\u5316\u6548\u679c<\/p>\n<\/li>\n<li>\n<p>\u4e0e\u7cfb\u7edf\u80fd\u8017\u548c\u5ef6\u8fdf\u6b63\u76f8\u5173<\/p>\n<\/li>\n<li>\n<p>\u4e3b\u8981\u4f18\u5316\u76ee\u6807<\/p>\n<\/li>\n<\/ul>\n<p>2. Spill\u64cd\u4f5c\u6b21\u6570\u548c\u89c4\u6a21<\/p>\n<ul>\n<li>\n<p>\u53cd\u6620\u7f13\u5b58\u51b2\u7a81\u7684\u4e25\u91cd\u7a0b\u5ea6<\/p>\n<\/li>\n<li>\n<p>\u6307\u5bfc\u7f13\u5b58\u5bb9\u91cf\u89c4\u5212<\/p>\n<\/li>\n<li>\n<p>\u7b97\u6cd5\u8c03\u4f18\u7684\u91cd\u8981\u53c2\u8003<\/p>\n<\/li>\n<\/ul>\n<h4>6.2 \u9884\u671f\u4f18\u5316\u6548\u679c<\/h4>\n<p>\u57fa\u4e8e\u7b97\u6cd5\u8bbe\u8ba1&#xff0c;\u9884\u671f\u5728\u4ee5\u4e0b\u65b9\u9762\u4ea7\u751f\u4f18\u5316\u6548\u679c&#xff1a;<\/p>\n<p>1. \u7f13\u5b58\u547d\u4e2d\u7387\u63d0\u5347<\/p>\n<ul>\n<li>\n<p>\u901a\u8fc7\u667a\u80fdspill\u51cf\u5c11\u4e0d\u5fc5\u8981\u7684\u7f13\u5b58\u4ea4\u6362<\/p>\n<\/li>\n<li>\n<p>\u5229\u7528\u4efb\u52a1\u4f9d\u8d56\u5173\u7cfb\u4f18\u5316\u6570\u636e\u5c40\u90e8\u6027<\/p>\n<\/li>\n<\/ul>\n<p>2. \u7cfb\u7edf\u541e\u5410\u91cf\u6539\u5584<\/p>\n<ul>\n<li>\n<p>\u51cf\u5c11\u6570\u636e\u642c\u8fd0\u7b49\u5f85\u65f6\u95f4<\/p>\n<\/li>\n<li>\n<p>\u63d0\u9ad8\u8ba1\u7b97\u8d44\u6e90\u5229\u7528\u7387<\/p>\n<\/li>\n<\/ul>\n<p>3. \u80fd\u8017\u4f18\u5316<\/p>\n<ul>\n<li>\n<p>\u964d\u4f4e\u5185\u5b58\u8bbf\u95ee\u9891\u6b21<\/p>\n<\/li>\n<li>\n<p>\u51cf\u5c11\u6570\u636e\u4f20\u8f93\u80fd\u8017<\/p>\n<\/li>\n<\/ul>\n<h3>\u4e03\u3001\u603b\u7ed3\u4e0e\u5c55\u671b<\/h3>\n<p>\u672c\u7a0b\u5e8f\u5b9e\u73b0\u4e86\u4e00\u4e2a\u5b8c\u6574\u7684\u7f13\u5b58\u8c03\u5ea6\u4f18\u5316\u7cfb\u7edf&#xff0c;\u901a\u8fc7\u7cbe\u5999\u7684\u6570\u636e\u7ed3\u6784\u8bbe\u8ba1\u548c\u9ad8\u6548\u7684\u7b97\u6cd5\u5b9e\u73b0&#xff0c;\u89e3\u51b3\u4e86\u6709\u9650\u7f13\u5b58\u6761\u4ef6\u4e0b\u7684\u4efb\u52a1\u8c03\u5ea6\u95ee\u9898\u3002\u7a0b\u5e8f\u7684\u6838\u5fc3\u4ef7\u503c\u5728\u4e8e&#xff1a;<\/p>\n<h4>7.1 \u6280\u672f\u8d21\u732e<\/h4>\n<li>\n<p>\u5b9e\u7528\u7684\u7f13\u5b58\u7ba1\u7406\u6846\u67b6&#xff1a;\u4e3a\u7c7b\u4f3c\u95ee\u9898\u63d0\u4f9b\u4e86\u53ef\u590d\u7528\u7684\u89e3\u51b3\u65b9\u6848\u6a21\u677f<\/p>\n<\/li>\n<li>\n<p>\u9ad8\u6548\u7684\u56fe\u7b97\u6cd5\u5e94\u7528&#xff1a;\u5c06\u62d3\u6251\u6392\u5e8f\u4e0e\u8d44\u6e90\u7ea6\u675f\u8c03\u5ea6\u6709\u673a\u7ed3\u5408<\/p>\n<\/li>\n<li>\n<p>\u53ef\u6269\u5c55\u7684\u67b6\u6784\u8bbe\u8ba1&#xff1a;\u4e3a\u540e\u7eed\u7b97\u6cd5\u6539\u8fdb\u7559\u6709\u5145\u5206\u63a5\u53e3<\/p>\n<\/li>\n<h4>7.2 \u5b9e\u9645\u5e94\u7528\u4ef7\u503c<\/h4>\n<p>\u8be5\u7a0b\u5e8f\u4e0d\u4ec5\u5177\u6709\u7406\u8bba\u610f\u4e49&#xff0c;\u5728\u5b9e\u9645\u5de5\u7a0b\u5e94\u7528\u4e2d\u4e5f\u6709\u91cd\u8981\u4ef7\u503c\u3002\u7279\u522b\u662f\u5728\u8fb9\u7f18\u8ba1\u7b97\u3001\u79fb\u52a8\u8bbe\u5907\u7b49\u8d44\u6e90\u53d7\u9650\u73af\u5883\u4e2d&#xff0c;\u7c7b\u4f3c\u7684\u7f13\u5b58\u4f18\u5316\u6280\u672f\u80fd\u591f\u663e\u8457\u63d0\u5347\u7cfb\u7edf\u6027\u80fd\u3002<\/p>\n<h4>7.3 \u672a\u6765\u53d1\u5c55\u65b9\u5411<\/h4>\n<p>\u672a\u6765\u53ef\u4ee5\u4ece\u591a\u4e2a\u7ef4\u5ea6\u7ee7\u7eed\u6df1\u5316\u8be5\u7814\u7a76&#xff1a;<\/p>\n<li>\n<p>\u673a\u5668\u5b66\u4e60\u589e\u5f3a&#xff1a;\u5229\u7528\u5f3a\u5316\u5b66\u4e60\u4f18\u5316spill\u51b3\u7b56<\/p>\n<\/li>\n<li>\n<p>\u591a\u76ee\u6807\u4f18\u5316&#xff1a;\u540c\u65f6\u8003\u8651\u6027\u80fd\u3001\u80fd\u8017\u3001\u6e29\u5ea6\u7b49\u591a\u4e2a\u4f18\u5316\u76ee\u6807<\/p>\n<\/li>\n<li>\n<p>\u81ea\u9002\u5e94\u53c2\u6570\u8c03\u6574&#xff1a;\u6839\u636e\u5de5\u4f5c\u8d1f\u8f7d\u7279\u5f81\u52a8\u6001\u8c03\u6574\u7b97\u6cd5\u53c2\u6570<\/p>\n<\/li>\n<p>\u672c\u7a0b\u5e8f\u4f5c\u4e3a\u4e00\u4e2a\u57fa\u7840\u6846\u67b6&#xff0c;\u4e3a\u540e\u7eed\u66f4\u590d\u6742\u7684\u7f13\u5b58\u4f18\u5316\u7814\u7a76\u5960\u5b9a\u4e86\u575a\u5b9e\u7684\u6280\u672f\u57fa\u7840\u3002<\/p>\n<h2>\u6e90\u4ee3\u7801<\/h2>\n<p>#!\/usr\/bin\/env python3<br \/>\n# -*- coding: utf-8 -*-<\/p>\n<p>import os<br \/>\nimport json<br \/>\nfrom collections import deque<\/p>\n<p>class SchedulingSolution:<br \/>\n    def __init__(self, l1_capacity&#061;65536):<br \/>\n        # \u7f13\u5b58\u5bb9\u91cf<br \/>\n        self.l1_capacity &#061; l1_capacity<br \/>\n        # \u5f53\u524d\u5df2\u5206\u914d\u7684\u7f13\u51b2\u533a {buf_id: size}<br \/>\n        self.l1_used &#061; {}<br \/>\n        # \u603b\u642c\u8fd0\u91cf<br \/>\n        self.extra_movement &#061; 0<br \/>\n        # spill \u8bb0\u5f55<br \/>\n        self.spill_log &#061; []<br \/>\n        # \u5df2\u5b8c\u6210\u7684\u4efb\u52a1<br \/>\n        self.finished &#061; set()<\/p>\n<p>    def _current_usage(self):<br \/>\n        return sum(self.l1_used.values())<\/p>\n<p>    def allocate_buffer(self, buf_id, size, is_copyin&#061;False):<br \/>\n        &#034;&#034;&#034;<br \/>\n        \u4e3a buf_id \u5206\u914d L1 \u7f13\u5b58&#xff0c;\u5982\u679c\u7a7a\u95f4\u4e0d\u8db3\u5219 spill\u3002<br \/>\n        &#034;&#034;&#034;<br \/>\n        if buf_id in self.l1_used:<br \/>\n            return True  # \u5df2\u7ecf\u5206\u914d\u8fc7<\/p>\n<p>        # \u5982\u679c\u76f4\u63a5\u80fd\u653e\u4e0b<br \/>\n        if self._current_usage() &#043; size &lt;&#061; self.l1_capacity:<br \/>\n            self.l1_used[buf_id] &#061; size<br \/>\n            return True<\/p>\n<p>        # \u5c1d\u8bd5 spill<br \/>\n        if self._try_spill(size):<br \/>\n            self.l1_used[buf_id] &#061; size<br \/>\n            return True<\/p>\n<p>        return False  # spill \u540e\u4ecd\u7136\u653e\u4e0d\u4e0b<\/p>\n<p>    def _try_spill(self, required_size):<br \/>\n        &#034;&#034;&#034;<br \/>\n        \u5c1d\u8bd5\u6362\u51fa\u4e00\u4e9b\u7f13\u51b2\u533a&#xff0c;\u817e\u51fa\u7a7a\u95f4\u3002<br \/>\n        \u7b56\u7565&#xff1a;\u4f18\u5148\u6362\u51fa\u6700\u5927\u7684\u3002<br \/>\n        &#034;&#034;&#034;<br \/>\n        freed &#061; 0<br \/>\n        while self._current_usage() &#043; required_size &gt; self.l1_capacity and self.l1_used:<br \/>\n            # \u627e\u5230\u4e00\u4e2a\u6700\u5927\u7684 buf \u6362\u51fa<br \/>\n            victim &#061; max(self.l1_used.items(), key&#061;lambda x: x[1])<br \/>\n            buf_id, sz &#061; victim<br \/>\n            self.spill_log.append((buf_id, sz))<br \/>\n            self.extra_movement &#043;&#061; 2 * sz  # spill &#043; reload<br \/>\n            del self.l1_used[buf_id]<br \/>\n            freed &#043;&#061; sz<\/p>\n<p>        return self._current_usage() &#043; required_size &lt;&#061; self.l1_capacity<\/p>\n<p>    def release_buffer(self, buf_id):<br \/>\n        &#034;&#034;&#034;\u91ca\u653e\u5df2\u5b8c\u6210\u4efb\u52a1\u5360\u7528\u7684\u7f13\u5b58&#034;&#034;&#034;<br \/>\n        if buf_id in self.l1_used:<br \/>\n            del self.l1_used[buf_id]<\/p>\n<p>    def _postpone_allocation(self, task, ready_queue):<br \/>\n        &#034;&#034;&#034;<br \/>\n        \u987a\u5e8f\u8c03\u6574&#xff1a;\u628a\u5f53\u524d task \u63a8\u5230\u961f\u5c3e&#xff0c;\u5ef6\u8fdf\u6267\u884c<br \/>\n        &#034;&#034;&#034;<br \/>\n        ready_queue.append(task)<\/p>\n<p>    def summary(self):<br \/>\n        return {<br \/>\n            &#034;extra_movement&#034;: self.extra_movement,<br \/>\n            &#034;spill_log&#034;: self.spill_log<br \/>\n        }<\/p>\n<p>def load_case(json_path):<br \/>\n    &#034;&#034;&#034;\u8bfb\u53d6\u8ba1\u7b97\u56fe json&#034;&#034;&#034;<br \/>\n    with open(json_path, &#034;r&#034;, encoding&#061;&#034;utf-8&#034;) as f:<br \/>\n        return json.load(f)<\/p>\n<p>def schedule_case(case_name, case_json, l1_capacity&#061;65536):<br \/>\n    &#034;&#034;&#034;<br \/>\n    \u8c03\u5ea6\u4e00\u4e2a case&#xff0c;\u8fd4\u56de\u7ed3\u679c<br \/>\n    &#034;&#034;&#034;<br \/>\n    nodes &#061; case_json[&#034;Nodes&#034;]<br \/>\n    edges &#061; case_json[&#034;Edges&#034;]<\/p>\n<p>    # \u6784\u5efa\u4f9d\u8d56\u5173\u7cfb<br \/>\n    indeg &#061; {}<br \/>\n    children &#061; {}<br \/>\n    for n in nodes:<br \/>\n        indeg[n[&#034;Id&#034;]] &#061; 0<br \/>\n        children[n[&#034;Id&#034;]] &#061; []<\/p>\n<p>    for u, v in edges:<br \/>\n        indeg[v] &#043;&#061; 1<br \/>\n        children[u].append(v)<\/p>\n<p>    # \u5c31\u7eea\u961f\u5217<br \/>\n    ready &#061; deque([n for n in nodes if indeg[n[&#034;Id&#034;]] &#061;&#061; 0])<br \/>\n    solution &#061; SchedulingSolution(l1_capacity)<\/p>\n<p>    while ready:<br \/>\n        task &#061; ready.popleft()<br \/>\n        tid &#061; task[&#034;Id&#034;]<br \/>\n        buf_id &#061; task.get(&#034;BufId&#034;, tid)<br \/>\n        size &#061; task.get(&#034;Size&#034;, 0)<br \/>\n        is_copyin &#061; task[&#034;Op&#034;].upper().startswith(&#034;COPY_IN&#034;)<\/p>\n<p>        ok &#061; solution.allocate_buffer(buf_id, size, is_copyin&#061;is_copyin)<br \/>\n        if not ok:<br \/>\n            # \u987a\u5e8f\u8c03\u6574&#xff1a;\u63a8\u8fdf\u6267\u884c<br \/>\n            solution._postpone_allocation(task, ready)<br \/>\n            continue<\/p>\n<p>        # \u6807\u8bb0\u5b8c\u6210<br \/>\n        solution.finished.add(tid)<br \/>\n        solution.release_buffer(buf_id)<\/p>\n<p>        # \u66f4\u65b0\u540e\u7ee7\u4efb\u52a1<br \/>\n        for v in children[tid]:<br \/>\n            indeg[v] -&#061; 1<br \/>\n            if indeg[v] &#061;&#061; 0:<br \/>\n                # \u627e\u5230\u5bf9\u5e94\u8282\u70b9<br \/>\n                next_node &#061; next(n for n in nodes if n[&#034;Id&#034;] &#061;&#061; v)<br \/>\n                ready.append(next_node)<\/p>\n<p>    return solution.summary()<\/p>\n<p>def main():<br \/>\n    json_dir &#061; &#034;.\/shuju&#034;<br \/>\n    cases &#061; [f for f in os.listdir(json_dir) if f.endswith(&#034;.json&#034;)]<\/p>\n<p>    for case_file in cases:<br \/>\n        case_name &#061; os.path.splitext(case_file)[0]<br \/>\n        case_json &#061; load_case(os.path.join(json_dir, case_file))<\/p>\n<p>        result &#061; schedule_case(case_name, case_json, l1_capacity&#061;65536)<br \/>\n        print(f&#034;\\\\nCase {case_name}:&#034;)<br \/>\n        print(&#034;  \u603b\u989d\u5916\u6570\u636e\u642c\u8fd0\u91cf:&#034;, result[&#034;extra_movement&#034;])<br \/>\n        print(&#034;  Spill \u8bb0\u5f55:&#034;, result[&#034;spill_log&#034;])<\/p>\n<p>if __name__ &#061;&#061; &#034;__main__&#034;:<br \/>\n    main()<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001\u7a0b\u5e8f\u6982\u8ff0\u4e0e\u529f\u80fd\u5206\u67901.1 \u7a0b\u5e8f\u80cc\u666f\u4e0e\u5b9a\u4f4d\u8be5\u7a0b\u5e8f\u662f\u4e00\u4e2a\u7f13\u5b58\u8c03\u5ea6\u4f18\u5316\u7cfb\u7edf&#xff0c;\u4e13\u95e8\u7528\u4e8e\u89e3\u51b3\u8ba1\u7b97\u56fe\u4e2d\u4efb\u52a1\u6267\u884c\u7684\u7f13\u5b58\u5206\u914d\u95ee\u9898\u3002\u5728\u8ba1\u7b97\u5bc6\u96c6\u578b\u5e94\u7528\u4e2d&#xff0c;\u5f53\u4efb\u52a1\u4e4b\u95f4\u5b58\u5728\u4f9d\u8d56\u5173\u7cfb\u4e14\u9700\u8981\u5171\u4eab\u6709\u9650\u7684\u7f13\u5b58\u8d44\u6e90\u65f6&#xff0c;\u5982\u4f55\u9ad8\u6548\u7ba1\u7406\u7f13\u5b58\u5206\u914d\u6210\u4e3a\u5173\u952e\u6027\u80fd\u74f6\u9888\u3002\u672c\u7a0b\u5e8f\u901a\u8fc7\u667a\u80fd\u7684\u7f13\u5b58\u8c03\u5ea6\u7b97\u6cd5&#xff0c;\u5728\u4fdd\u8bc1\u4efb\u52a1\u6b63\u786e\u6267\u884c\u7684\u524d\u63d0\u4e0b&#xff0c;\u6700\u5c0f\u5316\u56e0\u7f13\u5b58\u4e0d\u8db3\u5bfc\u81f4\u7684\u989d\u5916\u6570\u636e\u642c\u8fd0\u6210\u672c\u30021.2 \u6838\u5fc3\u529f\u80fd\u6a21\u5757\u7a0b\u5e8f\u4e3b\u8981\u5305\u542b\u4e09\u5927\u529f\u80fd\u6a21\u5757&#xff1a;1. \u7f13\u5b58\u7ba1\u7406\u6a21\u5757\u52a8\u6001\u5206\u914d<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[6580,6581,6579,6582,81,190,1813],"topic":[],"class_list":["post-62073","post","type-post","status-publish","format-standard","hentry","category-server","tag-6580","tag-6581","tag-6579","tag-6582","tag-python","tag-190","tag-1813"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u7f13\u5b58\u8c03\u5ea6\u4f18\u5316\u7cfb\u7edf\u529f\u80fd\u3001\u6570\u636e\u7ed3\u6784\u4e0e\u7b97\u6cd5\u8be6\u89e3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/62073.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u7f13\u5b58\u8c03\u5ea6\u4f18\u5316\u7cfb\u7edf\u529f\u80fd\u3001\u6570\u636e\u7ed3\u6784\u4e0e\u7b97\u6cd5\u8be6\u89e3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u4e00\u3001\u7a0b\u5e8f\u6982\u8ff0\u4e0e\u529f\u80fd\u5206\u67901.1 \u7a0b\u5e8f\u80cc\u666f\u4e0e\u5b9a\u4f4d\u8be5\u7a0b\u5e8f\u662f\u4e00\u4e2a\u7f13\u5b58\u8c03\u5ea6\u4f18\u5316\u7cfb\u7edf&#xff0c;\u4e13\u95e8\u7528\u4e8e\u89e3\u51b3\u8ba1\u7b97\u56fe\u4e2d\u4efb\u52a1\u6267\u884c\u7684\u7f13\u5b58\u5206\u914d\u95ee\u9898\u3002\u5728\u8ba1\u7b97\u5bc6\u96c6\u578b\u5e94\u7528\u4e2d&#xff0c;\u5f53\u4efb\u52a1\u4e4b\u95f4\u5b58\u5728\u4f9d\u8d56\u5173\u7cfb\u4e14\u9700\u8981\u5171\u4eab\u6709\u9650\u7684\u7f13\u5b58\u8d44\u6e90\u65f6&#xff0c;\u5982\u4f55\u9ad8\u6548\u7ba1\u7406\u7f13\u5b58\u5206\u914d\u6210\u4e3a\u5173\u952e\u6027\u80fd\u74f6\u9888\u3002\u672c\u7a0b\u5e8f\u901a\u8fc7\u667a\u80fd\u7684\u7f13\u5b58\u8c03\u5ea6\u7b97\u6cd5&#xff0c;\u5728\u4fdd\u8bc1\u4efb\u52a1\u6b63\u786e\u6267\u884c\u7684\u524d\u63d0\u4e0b&#xff0c;\u6700\u5c0f\u5316\u56e0\u7f13\u5b58\u4e0d\u8db3\u5bfc\u81f4\u7684\u989d\u5916\u6570\u636e\u642c\u8fd0\u6210\u672c\u30021.2 \u6838\u5fc3\u529f\u80fd\u6a21\u5757\u7a0b\u5e8f\u4e3b\u8981\u5305\u542b\u4e09\u5927\u529f\u80fd\u6a21\u5757&#xff1a;1. \u7f13\u5b58\u7ba1\u7406\u6a21\u5757\u52a8\u6001\u5206\u914d\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/62073.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-01-19T01:34:03+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/62073.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/62073.html\",\"name\":\"\u7f13\u5b58\u8c03\u5ea6\u4f18\u5316\u7cfb\u7edf\u529f\u80fd\u3001\u6570\u636e\u7ed3\u6784\u4e0e\u7b97\u6cd5\u8be6\u89e3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-01-19T01:34:03+00:00\",\"dateModified\":\"2026-01-19T01:34:03+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/62073.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/62073.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/62073.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u7f13\u5b58\u8c03\u5ea6\u4f18\u5316\u7cfb\u7edf\u529f\u80fd\u3001\u6570\u636e\u7ed3\u6784\u4e0e\u7b97\u6cd5\u8be6\u89e3\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u7f13\u5b58\u8c03\u5ea6\u4f18\u5316\u7cfb\u7edf\u529f\u80fd\u3001\u6570\u636e\u7ed3\u6784\u4e0e\u7b97\u6cd5\u8be6\u89e3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/62073.html","og_locale":"zh_CN","og_type":"article","og_title":"\u7f13\u5b58\u8c03\u5ea6\u4f18\u5316\u7cfb\u7edf\u529f\u80fd\u3001\u6570\u636e\u7ed3\u6784\u4e0e\u7b97\u6cd5\u8be6\u89e3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u4e00\u3001\u7a0b\u5e8f\u6982\u8ff0\u4e0e\u529f\u80fd\u5206\u67901.1 \u7a0b\u5e8f\u80cc\u666f\u4e0e\u5b9a\u4f4d\u8be5\u7a0b\u5e8f\u662f\u4e00\u4e2a\u7f13\u5b58\u8c03\u5ea6\u4f18\u5316\u7cfb\u7edf&#xff0c;\u4e13\u95e8\u7528\u4e8e\u89e3\u51b3\u8ba1\u7b97\u56fe\u4e2d\u4efb\u52a1\u6267\u884c\u7684\u7f13\u5b58\u5206\u914d\u95ee\u9898\u3002\u5728\u8ba1\u7b97\u5bc6\u96c6\u578b\u5e94\u7528\u4e2d&#xff0c;\u5f53\u4efb\u52a1\u4e4b\u95f4\u5b58\u5728\u4f9d\u8d56\u5173\u7cfb\u4e14\u9700\u8981\u5171\u4eab\u6709\u9650\u7684\u7f13\u5b58\u8d44\u6e90\u65f6&#xff0c;\u5982\u4f55\u9ad8\u6548\u7ba1\u7406\u7f13\u5b58\u5206\u914d\u6210\u4e3a\u5173\u952e\u6027\u80fd\u74f6\u9888\u3002\u672c\u7a0b\u5e8f\u901a\u8fc7\u667a\u80fd\u7684\u7f13\u5b58\u8c03\u5ea6\u7b97\u6cd5&#xff0c;\u5728\u4fdd\u8bc1\u4efb\u52a1\u6b63\u786e\u6267\u884c\u7684\u524d\u63d0\u4e0b&#xff0c;\u6700\u5c0f\u5316\u56e0\u7f13\u5b58\u4e0d\u8db3\u5bfc\u81f4\u7684\u989d\u5916\u6570\u636e\u642c\u8fd0\u6210\u672c\u30021.2 \u6838\u5fc3\u529f\u80fd\u6a21\u5757\u7a0b\u5e8f\u4e3b\u8981\u5305\u542b\u4e09\u5927\u529f\u80fd\u6a21\u5757&#xff1a;1. \u7f13\u5b58\u7ba1\u7406\u6a21\u5757\u52a8\u6001\u5206\u914d","og_url":"https:\/\/www.wsisp.com\/helps\/62073.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-01-19T01:34:03+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"5 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/62073.html","url":"https:\/\/www.wsisp.com\/helps\/62073.html","name":"\u7f13\u5b58\u8c03\u5ea6\u4f18\u5316\u7cfb\u7edf\u529f\u80fd\u3001\u6570\u636e\u7ed3\u6784\u4e0e\u7b97\u6cd5\u8be6\u89e3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-01-19T01:34:03+00:00","dateModified":"2026-01-19T01:34:03+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/62073.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/62073.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/62073.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u7f13\u5b58\u8c03\u5ea6\u4f18\u5316\u7cfb\u7edf\u529f\u80fd\u3001\u6570\u636e\u7ed3\u6784\u4e0e\u7b97\u6cd5\u8be6\u89e3"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/62073","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=62073"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/62073\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=62073"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=62073"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=62073"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=62073"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}