Closed
Bug 827523
Opened 12 years ago
Closed 12 years ago
DMD: add some options that are useful when adding new memory reporters
Categories
(Core :: DMD, defect)
Tracking
()
RESOLVED
FIXED
mozilla21
People
(Reporter: n.nethercote, Assigned: n.nethercote)
Details
Attachments
(3 files, 1 obsolete file)
13.25 KB,
patch
|
justin.lebar+bug
:
review+
|
Details | Diff | Splinter Review |
1.07 KB,
patch
|
justin.lebar+bug
:
review+
|
Details | Diff | Splinter Review |
22.13 KB,
patch
|
justin.lebar+bug
:
review+
|
Details | Diff | Splinter Review |
When adding new memory reporters, it's useful to see all the records, not just the top 1000, so you can see exactly which blocks are being reported. But to prevent the output being overly long, it's also useful to reduce the size of the stack traces.
This bug is about adding options for both of these things.
![]() |
Assignee | |
Comment 1•12 years ago
|
||
This removes valloc() from the test, because Windows doesn't support it.
Attachment #698982 -
Flags: review?(justin.lebar+bug)
![]() |
Assignee | |
Comment 2•12 years ago
|
||
This swaps the diff order in test mode so the expected output is first, which
is more intuitive.
Attachment #698983 -
Flags: review?(justin.lebar+bug)
![]() |
Assignee | |
Comment 3•12 years ago
|
||
This patch:
- Adds new --max-frames and --max-records options.
- Bundles all the options in a new |Options| class, which makes things neater.
- Fixes the indentation on the usage message.
Attachment #698987 -
Flags: review?(justin.lebar+bug)
![]() |
Assignee | |
Updated•12 years ago
|
Component: General → DMD
Updated•12 years ago
|
Attachment #698982 -
Flags: review?(justin.lebar+bug) → review+
Updated•12 years ago
|
Attachment #698983 -
Flags: review?(justin.lebar+bug) → review+
Comment 4•12 years ago
|
||
> //---------------------------------------------------------------------------
>+// Options
>+//---------------------------------------------------------------------------
>+
>+struct Options
>+{
>+ template <typename T>
>+ struct NumOption
>+ {
>+ const T mDefault;
>+ const T mMax;
>+ T mActual;
>+ NumOption(T aDefault, T aMax)
>+ : mDefault(aDefault), mMax(aMax), mActual(aDefault)
>+ {}
>+ };
>+
>+ enum Mode {
>+ Normal, // run normally
>+ Test, // do some basic correctness tests
>+ Stress // do some performance stress tests
>+ };
>+
>+ NumOption<size_t> mSampleBelowSize;
>+ NumOption<uint32_t> mMaxFrames;
>+ NumOption<uint32_t> mMaxRecords;
>+ Mode mMode;
>+
>+ Options();
>+};
I like the idea of having an Options object, but this API makes it
significantly more verbose to access an option.
How about if we had something like
struct Options
{
enum Mode {
[...]
};
size_t sampleBelowSize;
uint32_t maxFrames;
uint32_t maxRecords;
Mode mode;
Options(); // sets everything to defaults
void ParseOptions(int argc, const char** argv)
{
[...]
}
};
Options gOptions; // note, not a pointer
I agree this isn't as nice wrt having the options' [max, default, actual] all
in one object. But the consumer's API is nicer, and having ParseOptions be
part of Options is better OOP.
Making gOptions not be a pointer is a premature optimization for speed; the
compiler can statically address the members of a gOptions stored in the data
section. It also saves you one character ("." versus "->"). :)
What do you think?
![]() |
Assignee | |
Comment 5•12 years ago
|
||
> I agree this isn't as nice wrt having the options' [max, default, actual] all
> in one object. But the consumer's API is nicer, and having ParseOptions be
> part of Options is better OOP.
The mMax and mDefault fields are only used for parsing and the usage message. I'll try to encapsulate those operations inside the class to avoid exposing them.
> Making gOptions not be a pointer is a premature optimization for speed; the
> compiler can statically address the members of a gOptions stored in the data
> section. It also saves you one character ("." versus "->"). :)
That's not safe. The comment at the top of Init() says:
// WARNING: this function runs *very* early -- before all static initializers
// have run. For this reason, non-scalar globals such as gStateLock and
// gStackTraceTable are allocated dynamically (so we can guarantee their
// construction in this function) rather than statically.
![]() |
Assignee | |
Comment 6•12 years ago
|
||
New OOPier version.
Attachment #698987 -
Attachment is obsolete: true
Attachment #698987 -
Flags: review?(justin.lebar+bug)
Attachment #699470 -
Flags: review?(justin.lebar+bug)
Comment 7•12 years ago
|
||
> That's not safe.
Okay, but we don't have to rely on any static initializers -- we can make the constructor be a nop and rely on the .DATA section being 0.
Comment 8•12 years ago
|
||
Comment on attachment 699470 [details] [diff] [review]
(part 3) - DMD: Add --max-frames and --max-records options.
>@@ -272,20 +265,73 @@ static const size_t kBufLen = 64;
> //---------------------------------------------------------------------------
>+// Options (I)
>+//---------------------------------------------------------------------------
Nit: Could you say "Part I" or something?
>-static bool
>-OptionLong(const char* aArg, const char* aOptionName, long aMin, long aMax,
>- long* aN)
>+bool
>+Options::Long(const char* aArg, const char* aOptionName, long aMin, long aMax,
>+ long* aN)
Nit: ExtractLong or something?
Attachment #699470 -
Flags: review?(justin.lebar+bug) → review+
![]() |
Assignee | |
Comment 9•12 years ago
|
||
Comment 10•12 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/9035cb5c0812
https://hg.mozilla.org/mozilla-central/rev/b954323bf860
https://hg.mozilla.org/mozilla-central/rev/22d57a4edea5
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla21
You need to log in
before you can comment on or make changes to this bug.
Description
•