Logo Perf Optimise

Perf Optimise

Cộng đồng
korchard333
perf-optimise

Tối ưu hiệu suất Power Platform. Dùng khi cần: hiệu suất, chậm, tối ưu hóa, ủy quyền, lưu vào bộ nhớ đệm, lập chỉ mục, hiệu suất truy vấn, giới hạn API, giới hạn tốc độ, cuộn ảo, tải theo nhu cầu, xử lý đồng thời, thao tác hàng loạt, tải biểu mẫu.

Add to TypingMind

Tổng quan

Nhà phát hànhkorchard333
Kho mãclaude-power-platform-community
Tên kỹ năngperf-optimise
Sao
50
Bản fork
6
Tệp đi kèm
Chỉ có hướng dẫn
Giấy phépMIT
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI dùng hướng dẫn viết bằng Markdown thay vì mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • Hướng dẫn có đủ mọi thứ cần thiết

    Mọi thứ mô hình cần đều nằm trong hướng dẫn — không có tệp bổ sung cần đồng bộ.

  • Mã nguồn mở

    Được korchard333 công bố trên GitHub. Hãy đọc các tệp nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Perf Optimise trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL của thư mục kỹ năng được hiển thị bên dưới rồi xác nhận.
    https://github.com/korchard333/claude-power-platform-community/tree/main/.claude/skills/perf-optimise
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/korchard333/claude-power-platform-community.git /tmp/claude-power-platform-community
mkdir -p .claude/skills
cp -r /tmp/claude-power-platform-community/.claude/skills/perf-optimise .claude/skills/perf-optimise
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Perf Optimise trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự nạp Perf Optimise ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên bạn có thể dùng Perf Optimise với cả những mô hình khác ngoài mô hình ban đầu. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên khi kỹ năng chưa được dùng, bạn không tốn token cho phần hướng dẫn.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

Skill: Performance Optimization

When to Use

Trigger when diagnosing or optimizing performance for Canvas Apps, Model-Driven Apps, Code Apps, Power Automate flows, Dataverse queries, or plugins. Also trigger when addressing API throttling (429 errors) or capacity limits.


Canvas App Performance

Delegation

Delegation pushes query logic to the data source. Non-delegable operations process only the first 500-2000 records locally.

Delegable to DataverseNOT Delegable
Filter with =, <>, <, >, <=, >=Distinct
Filter with in (choice columns)CountRows (use CountIf for delegable)
Sort (single column)GroupBy
Search (Dataverse only)AddColumns in a Filter
StartsWithNested Filter
LookUpFirst applied to non-delegable

Key Canvas Optimizations

powerfx
// BAD: Non-delegable — loads all records, filters locally
Filter(Contacts, Text(Phone, "[$-en-US]#") = "555-0100")

// GOOD: Delegable — server-side filter
Filter(Contacts, Phone = "555-0100")

// BAD: Loading all records then counting
CountRows(Filter(LargeTable, Status = "Active"))

// GOOD: CountIf is delegable to Dataverse
CountIf(LargeTable, Status = "Active")

Concurrent() for Parallel Data Loading

powerfx
// BAD: Sequential loading
ClearCollect(colAccounts, Accounts);
ClearCollect(colContacts, Contacts);
ClearCollect(colOrders, Orders);
// Total time = T1 + T2 + T3

// GOOD: Parallel loading
Concurrent(
    ClearCollect(colAccounts, Accounts),
    ClearCollect(colContacts, Contacts),
    ClearCollect(colOrders, Orders)
);
// Total time = max(T1, T2, T3)

Named Formulas (Pre-Computation)

powerfx
// App.Formulas — computed once, cached
ActiveAccounts = Filter(Accounts, statuscode = 1);
UserDepartment = Office365Users.MyProfile().Department;
TodayDate = Today();

// These are evaluated once and cached — no re-computation on screen navigation

Collection Pre-Loading

powerfx
// App.OnStart — load reference data once
Concurrent(
    ClearCollect(colStatusOptions, Choices('Accounts'.Status)),
    ClearCollect(colCategoryOptions, Choices('Accounts'.Category)),
    ClearCollect(colCountries, Filter(Countries, IsActive = true))
);

// Galleries and dropdowns use local collections (fast) instead of Dataverse calls

Dataverse Query Performance

$select — Only Request Needed Columns

bash
# BAD: Returns ALL columns (slow, wastes bandwidth)
GET /api/data/v9.2/contacts

# GOOD: Only requested columns returned
GET /api/data/v9.2/contacts?$select=firstname,lastname,emailaddress1

$filter — Server-Side Filtering

bash
# BAD: Get all, filter client-side
GET /api/data/v9.2/contacts  # Then filter in JS

# GOOD: Server-side filter
GET /api/data/v9.2/contacts?$filter=statecode eq 0 and contains(lastname,'Smith')&$top=50

$top — Limit Result Set

bash
# Always use $top for paged results
GET /api/data/v9.2/contacts?$top=50&$select=fullname,emailaddress1

# For next page, use @odata.nextLink from response

Indexing

Dataverse automatically indexes primary key and common columns. For custom columns used in filters:

Power Platform Admin Center → Environments → [env] → Settings
  → Administration → System Settings → Administration tab
  → Performance: Entity-specific index recommendations

Or request custom indexes via support for high-volume tables

FetchXML Aggregate vs OData

For aggregations, FetchXML is significantly faster than OData:

xml
<!-- FetchXML aggregate — processed server-side -->
<fetch aggregate="true">
  <entity name="contact">
    <attribute name="contactid" alias="count" aggregate="count" />
    <attribute name="annual_revenue" alias="total_revenue" aggregate="sum" />
    <filter>
      <condition attribute="statecode" operator="eq" value="0" />
    </filter>
  </entity>
</fetch>
bash
# Equivalent OData (less efficient for aggregation)
GET /api/data/v9.2/contacts?$apply=filter(statecode eq 0)/aggregate(contactid with countdistinct as count, annual_revenue with sum as total_revenue)

Alternate Keys for Upsert

bash
# Instead of: GET to check existence, then POST or PATCH
# Use: PATCH with alternate key (single call, upsert)
PATCH /api/data/v9.2/contacts(emailaddress1='john@contoso.com')
  -H "If-Match: *"
  -d '{"firstname": "John", "lastname": "Doe"}'

Plugin Performance

Sandbox Constraints

ConstraintLimit
Execution timeout2 minutes
Memory256 MB
CPUShared (no guarantee)
External HTTP callsAllowed in async, risky in sync

Optimization Patterns

csharp
// BAD: Query inside a loop
foreach (var contactId in contactIds)
{
    var contact = service.Retrieve("contact", contactId, new ColumnSet("fullname"));
    // N+1 query problem
}

// GOOD: Single query with IN filter
var query = new QueryExpression("contact")
{
    ColumnSet = new ColumnSet("fullname"),
    Criteria = new FilterExpression
    {
        Conditions = {
            new ConditionExpression("contactid", ConditionOperator.In, contactIds.ToArray())
        }
    }
};
var results = service.RetrieveMultiple(query);
csharp
// BAD: Synchronous HTTP call in sync plugin (blocks user, risks timeout)
var client = new HttpClient();
var response = await client.GetAsync("https://external-api.com/validate");

// GOOD: Use Service Bus or async plugin for external calls
// Or use pre-validated data from Dataverse
csharp
// BAD: Processing all records in bulk operation trigger
// Plugin fires once per record in a CreateMultiple — 1000 records = 1000 plugin executions

// GOOD: Batch-aware plugin using IPluginExecutionContext4
var context4 = (IPluginExecutionContext4)context;
// Check if running in bulk context and optimize accordingly

Code App Performance

Tree-Shaking and Bundle Size

typescript
// BAD: Import entire library
import _ from "lodash";

// GOOD: Import only what you need
import debounce from "lodash/debounce";

Lazy Routes (Code Splitting)

typescript
// React Router with lazy loading
import { lazy, Suspense } from "react";

const Dashboard = lazy(() => import("./pages/Dashboard"));
const Settings = lazy(() => import("./pages/Settings"));

function App() {
  return (
    <Suspense fallback={<Loading />}>
      <Routes>
        <Route path="/" element={<Dashboard />} />
        <Route path="/settings" element={<Settings />} />
      </Routes>
    </Suspense>
  );
}

TanStack Query (Stale/Cache)

typescript
import { useQuery } from "@tanstack/react-query";

function useAccounts() {
  return useQuery({
    queryKey: ["accounts"],
    queryFn: fetchAccounts,
    staleTime: 5 * 60 * 1000,     // 5 min — don't refetch if fresh
    gcTime: 30 * 60 * 1000,        // 30 min — keep in cache
    refetchOnWindowFocus: false,    // Don't refetch on tab switch
  });
}

Virtual Scrolling for Large Lists

typescript
import { useVirtualizer } from "@tanstack/react-virtual";

function VirtualList({ items }: { items: Item[] }) {
  const parentRef = useRef<HTMLDivElement>(null);
  const virtualizer = useVirtualizer({
    count: items.length,
    getScrollElement: () => parentRef.current,
    estimateSize: () => 40,
  });

  return (
    <div ref={parentRef} style={{ height: "400px", overflow: "auto" }}>
      <div style={{ height: virtualizer.getTotalSize() }}>
        {virtualizer.getVirtualItems().map((virtual) => (
          <div key={virtual.key} style={{ transform: `translateY(${virtual.start}px)` }}>
            {items[virtual.index].name}
          </div>
        ))}
      </div>
    </div>
  );
}

Power Automate Performance

Apply to Each Concurrency

Apply to each → Settings → Concurrency Control
  → Turn on: Yes
  → Degree of parallelism: 50 (maximum)
SettingBehavior
Off (default)Sequential — 1 at a time
On, parallelism = 2020 concurrent iterations
On, parallelism = 50Maximum concurrency

Warning: High concurrency can cause API throttling (429). Monitor and adjust.

Pagination

Action: List rows (Dataverse)
  → Settings → Pagination → On
  → Threshold: 100,000 (max records to retrieve)

Default without pagination: 5,000 rows max

Child Flows

Break large flows into child flows for:

  • Reusability across multiple parent flows
  • Cleaner flow design
  • Independent error handling
  • Parallel execution of independent branches

Avoid Deep Nesting

BAD: Apply to each → Condition → Apply to each → Condition → Apply to each
  (> 8 levels of nesting = flow failure)

GOOD: Use child flows, Select/Filter expressions, or batch operations

Model-Driven App Performance

Form Load Optimization

OptimizationImpact
Fewer tabs and sectionsLess HTML to render
Lazy subgridsLoad on tab expand, not on form load
Fewer columns on formLess data fetched
Minimize OnLoad JavaScriptDefer non-critical logic
Quick View forms instead of subgridsLighter weight for related data

JavaScript Best Practices

javascript
// BAD: Heavy processing in OnLoad
function onLoad() {
    // Fetches data, updates 20 fields, calls external API
    var result = Xrm.WebApi.retrieveMultipleRecords("contact", "?$top=1000");
    // ...
}

// GOOD: Minimal OnLoad, defer heavy work
function onLoad(context) {
    // Only essential logic
    setFieldVisibility(context);

    // Defer non-critical work
    setTimeout(function() {
        loadSecondaryData(context);
    }, 100);
}

API Request Limits

Protection Limits (Hard Throttle)

LimitValueScope
Per user6,000 requests / 5-minute windowPer user
Per web server60,000 / 5 minPer web server (shared)
Concurrent requests52 per userSimultaneous connections

When Throttled (HTTP 429)

bash
# Response includes Retry-After header
HTTP/1.1 429 Too Many Requests
Retry-After: 30

# Always honor Retry-After
sleep $(curl -sI ... | grep Retry-After | awk '{print $2}')

Strategies to Avoid Throttling

StrategyImplementation
Batch operationsUse CreateMultiple/UpdateMultiple instead of individual calls
$selectReduce payload size, faster responses
Exponential backoffOn 429, wait 1s → 2s → 4s → 8s
Connection poolingReuse HTTP connections
Off-peak schedulingRun bulk operations during low-usage hours
Service protection limit monitoringTrack via Admin Center analytics

Performance Checklist

markdown
## Performance Review Checklist

### Canvas App
- [ ] All gallery queries are delegable
- [ ] Using Concurrent() for parallel data loading
- [ ] Named Formulas for pre-computation
- [ ] Collections for reference data (not repeated server calls)
- [ ] No non-delegable functions on tables > 500 rows

### Dataverse Queries
- [ ] $select on every query (no select-all)
- [ ] $filter for server-side filtering
- [ ] $top for pagination
- [ ] FetchXML for aggregations
- [ ] Alternate keys for upsert operations

### Code App
- [ ] Tree-shaking (no unused library imports)
- [ ] Lazy routes for code splitting
- [ ] TanStack Query with staleTime configured
- [ ] Virtual scrolling for lists > 100 items
- [ ] Dynamic imports for heavy components

### Power Automate
- [ ] Apply to Each concurrency enabled (where safe)
- [ ] Pagination enabled for large queries
- [ ] Child flows for reusable/nested logic
- [ ] No nesting deeper than 4-5 levels
- [ ] Batch operations instead of loop + individual API calls

### Plugins
- [ ] No N+1 query patterns
- [ ] No sync HTTP calls in sync plugins
- [ ] Using early-bound types (faster than late-bound)
- [ ] ColumnSet specified (never ColumnSet(true))

### API Limits
- [ ] Retry-After handling for 429 responses
- [ ] Batch operations for bulk processing
- [ ] Off-peak scheduling for heavy operations
- [ ] Monitoring API usage in Admin Center

Anti-Patterns

  • Querying all columns ($select omitted) — wastes bandwidth, slower response
  • Non-delegable functions on large datasets — silent data truncation
  • Synchronous HTTP calls in sync plugins — blocks user, risks timeout
  • Apply to Each without concurrency — sequential processing of 1000 items
  • No caching in Code Apps — refetching data on every render
  • Full page loads instead of virtual scrolling — DOM bloat, slow rendering
  • Plugin executing inside loops — N+1 query pattern
  • Ignoring 429 errors — retrying immediately without backoff makes it worse
  • Loading all reference data on app start — slow startup, use lazy loading
  • No $top on OData queries — potentially returning millions of rows

Related Skills

  • dataverse-web-api — Query optimization, batch operations
  • canvas-apps — Delegation patterns, performance techniques
  • code-apps — React performance, bundling
  • plugins — Sandbox constraints, execution optimization
  • power-automate — Flow concurrency, pagination
  • observability — Performance monitoring and alerting

Câu hỏi thường gặp

Kỹ năng AI Perf Optimise làm được gì?

Tối ưu hiệu suất Power Platform. Dùng khi cần: hiệu suất, chậm, tối ưu hóa, ủy quyền, lưu vào bộ nhớ đệm, lập chỉ mục, hiệu suất truy vấn, giới hạn API, giới hạn tốc độ, cuộn ảo, tải theo nhu cầu, xử lý đồng thời, thao tác hàng loạt, tải biểu mẫu.

Vì sao nên dùng Perf Optimise trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Perf Optimise là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Perf Optimise trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/korchard333/claude-power-platform-community/tree/main/.claude/skills/perf-optimise. TypingMind đọc tệp SKILL.md rồi cài đặt kỹ năng để bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Perf Optimise?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Có thể dùng Perf Optimise với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Perf Optimise với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Perf Optimise có miễn phí không?

Có. Kỹ năng này được korchard333 phát hành trên GitHub theo giấy phép MIT. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp các công cụ mới mà mô hình có thể gọi. Khi mô hình gọi một công cụ, mã của công cụ đó chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và những tiêu chí mà kết quả cần đáp ứng. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇