whet 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,6 @@
1
+ import {IMap} from "../Constraints"
2
+ import {EsMap} from "../../genes/util/EsMap"
3
+
4
+ export declare class IntMap<T> extends EsMap<number, T> implements IMap<number, T> {
5
+ constructor()
6
+ }
@@ -0,0 +1,25 @@
1
+ import {IMap} from "../Constraints.js"
2
+ import {EsMap} from "../../genes/util/EsMap.js"
3
+ import {Register} from "../../genes/Register.js"
4
+
5
+ const $global = Register.$global
6
+
7
+ export const IntMap = Register.global("$hxClasses")["haxe.ds.IntMap"] =
8
+ class IntMap extends Register.inherits(EsMap) {
9
+ [Register.new]() {
10
+ super[Register.new]();
11
+ }
12
+ static get __name__() {
13
+ return "haxe.ds.IntMap"
14
+ }
15
+ static get __interfaces__() {
16
+ return [IMap]
17
+ }
18
+ static get __super__() {
19
+ return EsMap
20
+ }
21
+ get __class__() {
22
+ return IntMap
23
+ }
24
+ }
25
+
@@ -0,0 +1,2 @@
1
+
2
+ export type VectorData<T> = T[]
@@ -32,6 +32,34 @@ export type MinimatchOptions = {
32
32
  */
33
33
  matchBase?: null | boolean,
34
34
  /**
35
+ Max depth to traverse for nested extglobs like `*(a|b|c)`
36
+
37
+ Default is 2, which is quite low, but any higher value
38
+ swiftly results in punishing performance impacts. Note
39
+ that this is *not* relevant when the globstar types can
40
+ be safely coalesced into a single set.
41
+
42
+ For example, `*(a|@(b|c)|d)` would be flattened into
43
+ `*(a|b|c|d)`. Thus, many common extglobs will retain good
44
+ performance and never hit this limit, even if they are
45
+ excessively deep and complicated.
46
+
47
+ If the limit is hit, then the extglob characters are simply
48
+ not parsed, and the pattern effectively switches into
49
+ `noextglob: true` mode for the contents of that nested
50
+ sub-pattern. This will typically _not_ result in a match,
51
+ but is considered a valid trade-off for security and
52
+ performance.
53
+ */
54
+ maxExtglobRecursion?: null | number,
55
+ /**
56
+ Max number of non-adjacent `**` patterns to recursively walk down.
57
+
58
+ The default of 200 is almost certainly high enough for most purposes,
59
+ and can handle absurdly excessive patterns.
60
+ */
61
+ maxGlobstarRecursion?: null | number,
62
+ /**
35
63
  do not expand `{x,y}` style braces
36
64
  */
37
65
  nobrace?: null | boolean,
@@ -1,3 +1,4 @@
1
+ import {Profiler, ProfilerConfig} from "./profiler/Profiler"
1
2
  import {CacheManager} from "./cache/CacheManager"
2
3
  import {CacheStrategy} from "./cache/Cache"
3
4
  import {AnyStone, OutputFilter} from "./Stone"
@@ -13,6 +14,7 @@ export declare class Project {
13
14
  rootDir: string
14
15
  cache: CacheManager
15
16
  configStore: ConfigStore
17
+ profiler: null | Profiler
16
18
  stones: AnyStone[]
17
19
  onInit: (config: any) => Promise<any>
18
20
 
@@ -25,9 +27,12 @@ export declare class Project {
25
27
  describeStones(): StoneDescription[]
26
28
  listStoneOutputs(id: string): Promise<null | string[]>
27
29
  getStoneSource(id: string, sourceId?: null | string): Promise<null | Source>
30
+ refreshStoneSource(id: string): Promise<null | Source>
28
31
  getStoneConfig(id: string): Promise<null | StoneConfigView>
29
32
  setStoneConfig(id: string, patch: any, mode: string): Promise<boolean>
30
33
  clearStoneConfigPreview(id: string): Promise<boolean>
34
+ enableProfiling(config?: null | ProfilerConfig): void
35
+ disableProfiling(): void
31
36
  addCommand(name: string, stone?: null | AnyStone): Command
32
37
  protected isCommandNameTaken(name: string): boolean
33
38
  toString(): string
@@ -48,6 +53,10 @@ export type ProjectConfig = {
48
53
  */
49
54
  onInit?: null | ((config: any) => Promise<any>),
50
55
  options?: null | Option[],
56
+ /**
57
+ Enable profiling with optional config.
58
+ */
59
+ profiler?: null | ProfilerConfig,
51
60
  rootDir?: null | string
52
61
  }
53
62
 
@@ -60,6 +69,7 @@ export type StoneDescription = {
60
69
 
61
70
  export type StoneConfigView = {
62
71
  editable: any,
72
+ fixed: any,
63
73
  id: string,
64
74
  meta: StoneConfigMeta
65
75
  }
@@ -1,7 +1,10 @@
1
+ import {Router} from "./route/Router.js"
2
+ import {Profiler} from "./profiler/Profiler.js"
1
3
  import {StoneId_Fields_} from "./magic/StoneId.js"
2
4
  import {MaybeArray_Fields_} from "./magic/MaybeArray.js"
3
5
  import {CacheManager} from "./cache/CacheManager.js"
4
6
  import {Whet_Fields_} from "./Whet.js"
7
+ import {Stone} from "./Stone.js"
5
8
  import {Log} from "./Log.js"
6
9
  import {ConfigStore} from "./ConfigStore.js"
7
10
  import * as Path from "path"
@@ -16,6 +19,7 @@ export const Project = Register.global("$hxClasses")["whet.Project"] =
16
19
  class Project extends Register.inherits() {
17
20
  [Register.new](config) {
18
21
  this.stones = [];
22
+ this.profiler = null;
19
23
  this.configStore = null;
20
24
  this.cache = null;
21
25
  Log.log(20, ...["Instantiating new Project."]);
@@ -53,6 +57,9 @@ class Project extends Register.inherits() {
53
57
  };
54
58
  this.configStore = config.configStore;
55
59
  this.cache = (config.cache == null) ? new CacheManager(this) : config.cache;
60
+ if (config.profiler != null) {
61
+ this.profiler = new Profiler(config.profiler);
62
+ };
56
63
  Project.projects.push(this);
57
64
  Log.log(30, ...["New project created.", {"project": this, "projectCount": Project.projects.length}]);
58
65
  }
@@ -97,6 +104,14 @@ class Project extends Register.inherits() {
97
104
  return stone.getSource();
98
105
  };
99
106
  }
107
+ refreshStoneSource(id) {
108
+ let stone = this.getStone(id);
109
+ if (stone == null) {
110
+ return Promise.resolve(null);
111
+ } else {
112
+ return this.cache.refreshSource(stone);
113
+ };
114
+ }
100
115
  getStoneConfig(id) {
101
116
  let stone = this.getStone(id);
102
117
  if (stone == null) {
@@ -129,7 +144,34 @@ class Project extends Register.inherits() {
129
144
  while (_g1 < deps.length) _g.push(deps[_g1++].id);
130
145
  depIds = _g;
131
146
  };
132
- return {"id": stone.id, "editable": editable, "meta": {"className": StoneId_Fields_.getTypeName(stone), "cacheStrategy": stone.cacheStrategy, "dependencyIds": depIds, "hasStoneConfigStore": stone.config.configStore != null, "hasProjectConfigStore": _gthis.configStore != null}};
147
+ let fixed = {};
148
+ let _g_keys1 = Reflect__1.fields(configObj);
149
+ let _g_index1 = 0;
150
+ while (_g_index1 < _g_keys1.length) {
151
+ let key = _g_keys1[_g_index1++];
152
+ let _g_value = configObj[key];
153
+ if (ConfigStore.BASE_CONFIG_KEYS.includes(key)) {
154
+ continue;
155
+ };
156
+ if (ConfigStore.isJsonSerializable(_g_value)) {
157
+ continue;
158
+ };
159
+ if (((_g_value) instanceof Stone)) {
160
+ fixed[key] = {"type": "stone", "stoneId": _g_value.id};
161
+ } else if (((_g_value) instanceof Router)) {
162
+ fixed[key] = {"type": "stones", "stoneIds": _g_value.collectStoneIds()};
163
+ } else if (((_g_value) instanceof Array)) {
164
+ let arr = _g_value;
165
+ if (arr.length > 0 && ((arr[0]) instanceof Stone)) {
166
+ let _g = [];
167
+ let _g1 = 0;
168
+ let _g2 = arr;
169
+ while (_g1 < _g2.length) _g.push(_g2[_g1++].id);
170
+ fixed[key] = {"type": "stones", "stoneIds": _g};
171
+ };
172
+ };
173
+ };
174
+ return {"id": stone.id, "editable": editable, "fixed": fixed, "meta": {"className": StoneId_Fields_.getTypeName(stone), "cacheStrategy": stone.cacheStrategy, "dependencyIds": depIds, "hasStoneConfigStore": stone.config.configStore != null, "hasProjectConfigStore": _gthis.configStore != null}};
133
175
  });
134
176
  }
135
177
  setStoneConfig(id, patch, mode) {
@@ -164,6 +206,14 @@ class Project extends Register.inherits() {
164
206
  store.clearEntry(stone.id);
165
207
  return Promise.resolve(true);
166
208
  }
209
+ enableProfiling(config) {
210
+ if (this.profiler == null) {
211
+ this.profiler = new Profiler(config);
212
+ };
213
+ }
214
+ disableProfiling() {
215
+ this.profiler = null;
216
+ }
167
217
  addCommand(name, stone) {
168
218
  let cmdName = name;
169
219
  let cmdAlias = null;
@@ -215,6 +265,7 @@ Project.prototype.description = null;
215
265
  Project.prototype.rootDir = null;
216
266
  Project.prototype.cache = null;
217
267
  Project.prototype.configStore = null;
268
+ Project.prototype.profiler = null;
218
269
  Project.prototype.stones = null;
219
270
  Project.prototype.onInit = null;
220
271
  Project.prototype.config = null;
@@ -1,3 +1,4 @@
1
+ import {AnySpan} from "./profiler/Span"
1
2
  import {StoneIdType} from "./magic/StoneId"
2
3
  import {MaybeArray} from "./magic/MaybeArray"
3
4
  import {CacheManager} from "./cache/CacheManager"
@@ -184,6 +185,26 @@ export declare class Stone<T extends StoneConfig> {
184
185
  * Useful for pure JS stones.
185
186
  */
186
187
  cwdPath(path: string): string
188
+
189
+ /**
190
+ Wraps an async operation in a profiler span. No-op when profiler is null.
191
+ */
192
+ protected profilerWithSpan<T, R>(op: string, fn: (() => Promise<R>), meta?: null | T): Promise<R>
193
+
194
+ /**
195
+ Starts a manual profiler span. Returns null when profiler is null.
196
+ */
197
+ protected profilerStartSpan<T>(op: string, meta?: null | T): null | AnySpan
198
+
199
+ /**
200
+ Ends a manual profiler span. No-op when span is null.
201
+ */
202
+ protected profilerEndSpan(span: null | AnySpan): void
203
+
204
+ /**
205
+ Returns the current span from ALS context, or null when profiler is disabled.
206
+ */
207
+ protected profilerGetCurrentSpan(): null | AnySpan
187
208
  protected get_cache(): CacheManager
188
209
  toString(): string
189
210
  }
package/bin/whet/Stone.js CHANGED
@@ -75,13 +75,23 @@ class Stone extends Register.inherits() {
75
75
  let _gthis = this;
76
76
  if (this.locked) {
77
77
  Log.log(20, ...["Stone is locked, waiting.", {"stone": this}]);
78
+ let waitSpan = (this.project.profiler != null) ? this.project.profiler.startSpan(this, "LockWait", {"queuePosition": this.lockQueue.length, "queueLength": this.lockQueue.length + 1}) : null;
78
79
  let deferredRes;
79
80
  let deferredRej;
80
81
  let deferred = new Promise(function (res, rej) {
81
82
  deferredRes = res;
82
83
  deferredRej = rej;
83
84
  });
84
- this.lockQueue.push({"run": run, "res": deferredRes, "rej": deferredRej});
85
+ this.lockQueue.push({"run": function () {
86
+ if (waitSpan != null) {
87
+ _gthis.project.profiler.endSpan(waitSpan);
88
+ };
89
+ if (_gthis.project.profiler != null) {
90
+ return _gthis.project.profiler.withSpan(_gthis, "LockHeld", run, null);
91
+ } else {
92
+ return run();
93
+ };
94
+ }, "res": deferredRes, "rej": deferredRej});
85
95
  return deferred;
86
96
  } else {
87
97
  this.locked = true;
@@ -96,7 +106,7 @@ class Stone extends Register.inherits() {
96
106
  Log.log(10, ...["No function in lock queue. Stone is now unlocked.", {"stone": _gthis}]);
97
107
  };
98
108
  };
99
- return run()["finally"](runNext);
109
+ return ((this.project.profiler != null) ? this.project.profiler.withSpan(this, "LockHeld", run, null) : run())["finally"](runNext);
100
110
  };
101
111
  }
102
112
 
@@ -158,13 +168,25 @@ class Stone extends Register.inherits() {
158
168
  throw new Error("Acquire a lock before generating.");
159
169
  };
160
170
  Log.log(20, ...["Generating source.", {"stone": this, "hash": hash}]);
171
+ let deps = (this.config.dependencies != null) ? MaybeArray_Fields_.makeArray(this.config.dependencies) : null;
161
172
  let init;
162
- if (this.config.dependencies != null) {
173
+ if (deps != null) {
163
174
  let _g = [];
164
175
  let _g1 = 0;
165
- let _g2 = MaybeArray_Fields_.makeArray(this.config.dependencies);
166
- while (_g1 < _g2.length) _g.push(_g2[_g1++].getSource());
167
- init = Promise.all(_g);
176
+ while (_g1 < deps.length) _g.push(deps[_g1++].id);
177
+ if (this.project.profiler != null) {
178
+ init = this.project.profiler.withSpan(this, "DependencyResolve", function () {
179
+ let _g = [];
180
+ let _g1 = 0;
181
+ while (_g1 < deps.length) _g.push(deps[_g1++].getSource());
182
+ return Promise.all(_g);
183
+ }, {"dependencyIds": _g});
184
+ } else {
185
+ let _g = [];
186
+ let _g1 = 0;
187
+ while (_g1 < deps.length) _g.push(deps[_g1++].getSource());
188
+ init = Promise.all(_g);
189
+ };
168
190
  } else {
169
191
  init = Promise.resolve(null);
170
192
  };
@@ -471,6 +493,48 @@ class Stone extends Register.inherits() {
471
493
  cwdPath(path) {
472
494
  return Path.posix.join(".", RootDir.fromProject(this.project), ".", path);
473
495
  }
496
+
497
+ /**
498
+ Wraps an async operation in a profiler span. No-op when profiler is null.
499
+ */
500
+ profilerWithSpan(op, fn, meta) {
501
+ if (this.project.profiler != null) {
502
+ return this.project.profiler.withSpan(this, op, fn, meta);
503
+ } else {
504
+ return fn();
505
+ };
506
+ }
507
+
508
+ /**
509
+ Starts a manual profiler span. Returns null when profiler is null.
510
+ */
511
+ profilerStartSpan(op, meta) {
512
+ if (this.project.profiler != null) {
513
+ return this.project.profiler.startSpan(this, op, meta);
514
+ } else {
515
+ return null;
516
+ };
517
+ }
518
+
519
+ /**
520
+ Ends a manual profiler span. No-op when span is null.
521
+ */
522
+ profilerEndSpan(span) {
523
+ if (span != null) {
524
+ this.project.profiler.endSpan(span);
525
+ };
526
+ }
527
+
528
+ /**
529
+ Returns the current span from ALS context, or null when profiler is disabled.
530
+ */
531
+ profilerGetCurrentSpan() {
532
+ if (this.project.profiler != null) {
533
+ return this.project.profiler.getCurrentSpan();
534
+ } else {
535
+ return null;
536
+ };
537
+ }
474
538
  get_cache() {
475
539
  return this.project.cache;
476
540
  }
package/bin/whet/Whet.js CHANGED
@@ -26,7 +26,7 @@ class Whet_Fields_ {
26
26
  if (entryUrl != thisUrl) {
27
27
  return;
28
28
  };
29
- Whet_Fields_.program.enablePositionalOptions().passThroughOptions().description("Project tooling.").usage("[options] [command] [+ [command]...]").version("0.1.0", "-v, --version").allowUnknownOption(true).allowExcessArguments(true).showSuggestionAfterError(true).option("-p, --project <file>", "project to run", "Project.mjs").option("-l, --log-level <level>", "log level, a string/number", "info").option("--no-pretty", "disable pretty logging").exitOverride();
29
+ Whet_Fields_.program.enablePositionalOptions().passThroughOptions().description("Project tooling.").usage("[options] [command] [+ [command]...]").version("0.2.0", "-v, --version").allowUnknownOption(true).allowExcessArguments(true).showSuggestionAfterError(true).option("-p, --project <file>", "project to run", "Project.mjs").option("-l, --log-level <level>", "log level, a string/number", "info").option("--no-pretty", "disable pretty logging").option("--profile <format>", "enable profiling, export to whet-profile.json on exit (format: json or trace, default: json)").exitOverride();
30
30
  try {
31
31
  Whet_Fields_.program.parse();
32
32
  }catch (_g) {
@@ -92,6 +92,25 @@ class Whet_Fields_ {
92
92
  if (commands.length > 0) {
93
93
  let res = Whet_Fields_.program.parseOptions(commands[0]);
94
94
  commands[0] = res.operands.concat(res.unknown);
95
+ let profileFormat = Whet_Fields_.program.opts().profile;
96
+ if (profileFormat != null) {
97
+ let format = (profileFormat == true) ? "json" : profileFormat;
98
+ let _g = 0;
99
+ let _g1 = Project.projects;
100
+ while (_g < _g1.length) _g1[_g++].enableProfiling();
101
+ let onExit = function () {
102
+ let _g = 0;
103
+ let _g1 = Project.projects;
104
+ while (_g < _g1.length) {
105
+ let p = _g1[_g];
106
+ ++_g;
107
+ if (p.profiler != null) {
108
+ Fs.writeFileSync("whet-profile.json", JSON.stringify(p.profiler["export"](format), null, " "));
109
+ };
110
+ };
111
+ };
112
+ process.on("exit", onExit);
113
+ };
95
114
  let promises = [];
96
115
  let _g = 0;
97
116
  let _g1 = Project.projects;
@@ -1,3 +1,4 @@
1
+ import {AnySpan} from "../profiler/Span"
1
2
  import {Cache, CacheDurability, DurabilityCheck} from "./Cache"
2
3
  import {AnyStone} from "../Stone"
3
4
  import {SourceHash} from "../SourceHash"
@@ -47,4 +48,5 @@ export declare class BaseCache<Key, Value extends {
47
48
  */
48
49
  protected replaceEntry(stone: AnyStone, existing: Value, replacement: Source): Promise<Value>
49
50
  toString(): string
51
+ protected static setGenerateMeta(span: null | AnySpan, src: Source): void
50
52
  }
@@ -23,12 +23,37 @@ class BaseCache extends Register.inherits() {
23
23
  get(stone, durability, check) {
24
24
  let _gthis = this;
25
25
  return stone.acquire(function () {
26
- return stone.finalMaybeHash().then(function (hash) {
26
+ let lockHeldSpan = (stone.project.profiler != null) ? stone.project.profiler.getCurrentSpan() : null;
27
+ return ((stone.project.profiler != null) ? stone.project.profiler.withSpan(stone, "Hash", function () {
28
+ return stone.finalMaybeHash().then(function (hash) {
29
+ let span = (stone.project.profiler != null) ? stone.project.profiler.getCurrentSpan() : null;
30
+ let meta = (hash != null) ? SourceHash.toHex(hash) : null;
31
+ if (span != null) {
32
+ span.metadata = {"hashHex": meta};
33
+ };
34
+ return hash;
35
+ });
36
+ }, null) : stone.finalMaybeHash().then(function (hash) {
37
+ let span = (stone.project.profiler != null) ? stone.project.profiler.getCurrentSpan() : null;
38
+ let meta = (hash != null) ? SourceHash.toHex(hash) : null;
39
+ if (span != null) {
40
+ span.metadata = {"hashHex": meta};
41
+ };
42
+ return hash;
43
+ })).then(function (hash) {
27
44
  if (hash == null) {
28
45
  Log.log(20, ...["Generating source, because it does not supply a hash.", {"stone": stone, "cache": _gthis}]);
29
46
  };
30
47
  if (hash == null) {
31
- return stone.generateSource(null).then(function (generatedSource) {
48
+ return ((stone.project.profiler != null) ? stone.project.profiler.withSpan(stone, "Generate", function () {
49
+ return stone.generateSource(null).then(function (src) {
50
+ BaseCache.setGenerateMeta((stone.project.profiler != null) ? stone.project.profiler.getCurrentSpan() : null, src);
51
+ return src;
52
+ });
53
+ }, null) : stone.generateSource(null).then(function (src) {
54
+ BaseCache.setGenerateMeta((stone.project.profiler != null) ? stone.project.profiler.getCurrentSpan() : null, src);
55
+ return src;
56
+ })).then(function (generatedSource) {
32
57
  return {"generatedSource": generatedSource, "hash": generatedSource.hash};
33
58
  });
34
59
  } else {
@@ -66,6 +91,9 @@ class BaseCache extends Register.inherits() {
66
91
  let srcPromise = ((value != null) ? _gthis.source(stone, value) : Promise.resolve(null)).then(function (src) {
67
92
  if (src == null) {
68
93
  Log.log(10, ...["Not cached.", {"stone": stone, "cache": _gthis}]);
94
+ if (lockHeldSpan != null) {
95
+ lockHeldSpan.metadata = {"cacheResult": "miss"};
96
+ };
69
97
  return ((value != null) ? _gthis.remove(stone, value) : Promise.resolve(null)).then(function (_) {
70
98
  if (check._hx_index == 1) {
71
99
  _gthis.checkDurability(stone, values, durability, function (v) {
@@ -74,19 +102,39 @@ class BaseCache extends Register.inherits() {
74
102
  return ageCount(v) + 1;
75
103
  });
76
104
  };
77
- return ((generatedSource != null) ? Promise.resolve(generatedSource) : stone.generateSource(hash)).then(function (src) {
78
- return _gthis.set(src);
105
+ return ((generatedSource != null) ? Promise.resolve(generatedSource) : (stone.project.profiler != null) ? stone.project.profiler.withSpan(stone, "Generate", function () {
106
+ return stone.generateSource(hash).then(function (src) {
107
+ BaseCache.setGenerateMeta((stone.project.profiler != null) ? stone.project.profiler.getCurrentSpan() : null, src);
108
+ return src;
109
+ });
110
+ }, null) : stone.generateSource(hash).then(function (src) {
111
+ BaseCache.setGenerateMeta((stone.project.profiler != null) ? stone.project.profiler.getCurrentSpan() : null, src);
112
+ return src;
113
+ })).then(function (src) {
114
+ if (stone.project.profiler != null) {
115
+ return stone.project.profiler.withSpan(stone, "CacheWrite", function () {
116
+ return _gthis.set(src);
117
+ }, null);
118
+ } else {
119
+ return _gthis.set(src);
120
+ };
79
121
  }).then(function (val) {
80
122
  return _gthis.source(stone, val);
81
123
  });
82
124
  });
83
125
  } else if (!src.complete) {
84
126
  Log.log(10, ...["Found partial entry in cache, completing.", {"stone": stone, "cache": _gthis}]);
127
+ if (lockHeldSpan != null) {
128
+ lockHeldSpan.metadata = {"cacheResult": "partial"};
129
+ };
85
130
  return _gthis.completePartialEntry(stone, value, hash).then(function (val) {
86
131
  return _gthis.source(stone, val);
87
132
  });
88
133
  } else {
89
134
  Log.log(10, ...["Found in cache", {"stone": stone, "cache": _gthis}]);
135
+ if (lockHeldSpan != null) {
136
+ lockHeldSpan.metadata = {"cacheResult": "hit"};
137
+ };
90
138
  return Promise.resolve(src);
91
139
  };
92
140
  });
@@ -104,7 +152,23 @@ class BaseCache extends Register.inherits() {
104
152
  getPartial(stone, sourceId, durability, check) {
105
153
  let _gthis = this;
106
154
  return stone.acquire(function () {
107
- return stone.finalMaybeHash().then(function (hash) {
155
+ return ((stone.project.profiler != null) ? stone.project.profiler.withSpan(stone, "Hash", function () {
156
+ return stone.finalMaybeHash().then(function (hash) {
157
+ let span = (stone.project.profiler != null) ? stone.project.profiler.getCurrentSpan() : null;
158
+ let meta = (hash != null) ? SourceHash.toHex(hash) : null;
159
+ if (span != null) {
160
+ span.metadata = {"hashHex": meta};
161
+ };
162
+ return hash;
163
+ });
164
+ }, null) : stone.finalMaybeHash().then(function (hash) {
165
+ let span = (stone.project.profiler != null) ? stone.project.profiler.getCurrentSpan() : null;
166
+ let meta = (hash != null) ? SourceHash.toHex(hash) : null;
167
+ if (span != null) {
168
+ span.metadata = {"hashHex": meta};
169
+ };
170
+ return hash;
171
+ })).then(function (hash) {
108
172
  let values = _gthis.cache.get(_gthis.key(stone));
109
173
  let value = null;
110
174
  if (values != null && values.length > 0) {
@@ -126,7 +190,9 @@ class BaseCache extends Register.inherits() {
126
190
  } else if (value != null && value.complete) {
127
191
  return Promise.resolve(null);
128
192
  } else {
129
- return stone.generatePartialSource(sourceId, hash).then(function (result) {
193
+ return ((stone.project.profiler != null) ? stone.project.profiler.withSpan(stone, "GeneratePartial", function () {
194
+ return stone.generatePartialSource(sourceId, hash);
195
+ }, {"sourceId": sourceId}) : stone.generatePartialSource(sourceId, hash)).then(function (result) {
130
196
  if (result.complete) {
131
197
  return ((value != null) ? _gthis.replaceEntry(stone, value, result.source) : _gthis.set(result.source)).then(function (_) {
132
198
  return result.source.filterTo(sourceId);
@@ -193,7 +259,21 @@ class BaseCache extends Register.inherits() {
193
259
  */
194
260
  completePartialEntry(stone, existing, hash) {
195
261
  let _gthis = this;
196
- return stone.list().then(function (allIds) {
262
+ return ((stone.project.profiler != null) ? stone.project.profiler.withSpan(stone, "List", function () {
263
+ return stone.list().then(function (ids) {
264
+ let span = (stone.project.profiler != null) ? stone.project.profiler.getCurrentSpan() : null;
265
+ if (span != null) {
266
+ span.metadata = {"resultCount": (ids != null) ? ids.length : null};
267
+ };
268
+ return ids;
269
+ });
270
+ }, null) : stone.list().then(function (ids) {
271
+ let span = (stone.project.profiler != null) ? stone.project.profiler.getCurrentSpan() : null;
272
+ if (span != null) {
273
+ span.metadata = {"resultCount": (ids != null) ? ids.length : null};
274
+ };
275
+ return ids;
276
+ })).then(function (allIds) {
197
277
  if (allIds != null) {
198
278
  let _g = [];
199
279
  let _g1 = 0;
@@ -285,6 +365,15 @@ class BaseCache extends Register.inherits() {
285
365
  let c = Boot.getClass(this);
286
366
  return c.__name__;
287
367
  }
368
+ static setGenerateMeta(span, src) {
369
+ if (span != null) {
370
+ let totalBytes = 0;
371
+ let _g = 0;
372
+ let _g1 = src.data;
373
+ while (_g < _g1.length) totalBytes += _g1[_g++].data.length;
374
+ span.metadata = {"outputCount": src.data.length, "totalBytes": totalBytes};
375
+ };
376
+ }
288
377
  static get __name__() {
289
378
  return "whet.cache.BaseCache"
290
379
  }