Skip to main content

RenderPlanner

Struct RenderPlanner 

Source
pub struct RenderPlanner { /* private fields */ }

Implementations§

Source§

impl RenderPlanner

Source

pub fn decide( &self, family: &str, heuristic: bool, render_secs: f64, remaining_secs: f64, browser_price: f64, ) -> (bool, RenderWhy)

是否渲染。heuristic 是 0.81 规则的结论;render_secs 是预计渲染耗时(秒); remaining_secs 是这个请求剩下的期限;browser_price 是浏览器的影子价格(每标签秒)。

学过的族:渲染 ⇔ p > E[渲染秒]·(λ_browser + 1/剩余期限),p 是“渲染有增益“的后验抽样, 一次增益记为 1。0.90 在左边再乘 1 − Q_http,但质量分的训练标签是“召回不在所在评测集最差 δ“ (正例率 0.951),只能用来比较两个结果,不是“结果不完整“的绝对概率;乘上它让学过的族几乎不再渲染。 调用方只在 0.81 规则说要渲染时调用(候选闸门),所以渲染不会比 0.81 多。

Source

pub fn record(&self, family: &str, gain: bool)

记一次渲染的结果:渲染(或合并)后的质量分是否高于 HTTP 的。

Source

pub fn observe_with(&self, o: Arc<dyn Fn(u64, bool) + Send + Sync>) -> bool

装上观测的去处(只能装一次)。

Source

pub fn import(&self, key: u64, counts: BetaCounts)

导入别处学到的计数(网关下发的先验)。本地已经有这个族的观测时不导入:本地的观测已经报给过网关, 再加上网关的合并结果会重复计数。

Source

pub fn mean(&self, family: &str) -> Option<f64>

族里“渲染有增益“的后验均值(Beta(1,1) 先验);族里还没有数据时为 None。

Source

pub fn encode(&self) -> Vec<u8> ⓘ

整张表编码成字节(引擎把它写进存储)。

Source

pub fn decode_merge(&self, buf: &[u8])

读回 Self::encode 的字节;版本不同或损坏时保持空表(冷启动)。读回的计数与已有计数合并。

Trait Implementations§

Source§

impl Default for RenderPlanner

Source§

fn default() -> RenderPlanner

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more