-
Notifications
You must be signed in to change notification settings - Fork 238
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: We need to push logic of tracking of allocations per function down to arena to be able to measure retained memory, not allocated memory. The idea is: `Arena` should have a map from pointer to call stack. Reviewed By: ndmitchell Differential Revision: D37606255 fbshipit-source-id: 01bae7d9f5b43d707e9d55741afc8298f5d82f7e
- Loading branch information
1 parent
e71af1a
commit 76f5f73
Showing
4 changed files
with
120 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
starlark-rust/starlark/src/values/layout/heap/call_enter_exit.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* Copyright 2019 The Starlark in Rust Authors. | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
//! Marker objects to track allocations. | ||
use std::fmt::Debug; | ||
use std::time::Instant; | ||
|
||
use gazebo::any::ProvidesStaticType; | ||
|
||
use crate as starlark; | ||
use crate::values::StarlarkValue; | ||
use crate::values::Trace; | ||
use crate::values::Value; | ||
|
||
/// A type which is either drop or non-drop. | ||
pub(crate) trait MaybeDrop: Debug + Sync + Send + 'static {} | ||
|
||
/// Type which has `Drop`. | ||
#[derive(ProvidesStaticType, Debug, Trace)] | ||
pub(crate) struct NeedsDrop; | ||
impl Drop for NeedsDrop { | ||
fn drop(&mut self) { | ||
// Just make this type `Drop`. | ||
// Note `mem::needs_drop()` would return `true` for this type, | ||
// even if `drop` is optimized away: https://rust.godbolt.org/z/1cxKoMzdM | ||
} | ||
} | ||
|
||
/// Type which doesn't have `Drop`. | ||
#[derive(ProvidesStaticType, Debug, Trace)] | ||
pub(crate) struct NoDrop; | ||
|
||
impl MaybeDrop for NeedsDrop {} | ||
impl MaybeDrop for NoDrop {} | ||
|
||
#[derive(Trace, Debug, derive_more::Display, ProvidesStaticType, NoSerialize)] | ||
#[display(fmt = "CallEnter")] | ||
pub(crate) struct CallEnter<'v, D: MaybeDrop + 'static> { | ||
pub(crate) function: Value<'v>, | ||
pub(crate) time: Instant, | ||
pub(crate) maybe_drop: D, | ||
} | ||
|
||
impl<'v, D: MaybeDrop + Trace<'v> + 'v> StarlarkValue<'v> for CallEnter<'v, D> { | ||
starlark_type!("call_enter"); | ||
} | ||
|
||
#[derive(Debug, derive_more::Display, ProvidesStaticType, NoSerialize)] | ||
#[display(fmt = "CallExit")] | ||
pub(crate) struct CallExit<D: MaybeDrop + 'static> { | ||
pub(crate) time: Instant, | ||
pub(crate) maybe_drop: D, | ||
} | ||
|
||
impl<'v, D: MaybeDrop> StarlarkValue<'v> for CallExit<D> { | ||
starlark_type!("call_exit"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters