matcher_data.go ×4

Frontier kind: Code frontier

unlabeled · c_16ae08403114

321 tests · 3000 LOC · 145 files · introduces 0 tests · 23 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
5 ranges23 lines · 2 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
447 ranges3000 lines · 145 files · Browse complete extent
All tests (intent)
321 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

2 files ranked by introduced lines: 23 introduced LOC across 5 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/service/matching/matcher_data.go 18 introduced LOC · 4 ranges

Open complete file

68
69 // implements heap.Interface
70 > func (p *pollerPQ) Len() int { matcher_data.go
71 > return len(p.heap)
72 > }
73
74 // implements heap.Interface, do not call directly
414 // call with lock held
415 // nolint:revive // will improve later
416 > func (d *matcherData) findMatch(allowForwarding bool, now int64) (matchedTask *internalTask, matchedPoller *waitingPoller, minDelay time.Duration) { matcher_data.go
417 > // TODO(pri): optimize so it's not O(d*n) worst case
418 > // Scan keeps its callback on the stack, so this walk does not allocate; the equivalent
419 > // tree.Iter() cursor escapes to the heap.
420 >
421 > // Without a per-key limit the whole-queue ready time is the same for every task, so one
422 > // check suffices and we avoid locking readyTimeForTask per task in the scan below. Only
423 > // short-circuit when a match is actually possible (tasks and pollers both present) so we
424 > // don't arm the rate-limit timer in cases where the full scan would have found nothing.
425 > // TODO: reaching into the rate limiter's state like this breaks its encapsulation;
426 > // refactor the rate limit logic so findMatch doesn't need to know about it.
427 > wholeQueueReady, perKeyLimited := d.rateLimitManager.rateLimitState()
428 > if !perKeyLimited && d.tasks.Len() > 0 && d.pollers.Len() > 0 {
429 if delay := wholeQueueReady.delay(now); delay > 0 {
430 return nil, nil, delay
432 }
433
434 > d.tasks.tree.Scan(func(task *internalTask) bool { matcher_data.go
435 // disallow normal poll forwarding when allowForwarding is false, but allow the
436 // "priority backlog poll forwarders".
go.temporal.io/server/service/matching/ratelimit_manager.go 5 introduced LOC · 1 range

Open complete file

328
329 // rateLimitState returns the whole-queue ready time and whether a per-key limit is in effect.
330 > func (r *rateLimitManager) rateLimitState() (wholeQueueReady simpleLimiter, perKeyLimited bool) { ratelimit_manager.go
331 > r.mu.Lock()
332 > defer r.mu.Unlock()
333 > return r.wholeQueueReady, r.perKeyLimit.limited()
334 > }
335
336 func (r *rateLimitManager) readyTimeForTask(task *internalTask) simpleLimiter {