gitoria

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitfd10c3d5fd10c3d5log: CB livemrefd10c3d5/tools/lambda-audit.py

1.8 KB

  1. # tools/lambda-audit.py <app dir> (mission 070, hybriel#48): every lambda that CHANGES a parameter without & (field/list
  2. # writes, or a local alias `x = p` / `let x = p` — mission 028: a plain declaration copies like `let`) — since 8efba065 it changes a COPY; check that each caller uses the returned value.
  3. import re,sys,glob,os
  4. os.chdir(sys.argv[1])
  5. files=[f for f in glob.glob('*.hl')+glob.glob('lib/*.hl')+glob.glob('components/*.hl')+glob.glob('tools/*.hl')+glob.glob('tests/*.hl')+glob.glob('shared/*.hl')]
  6. lam=re.compile(r'(?:^|[\s,(=])(?:static\s+)?([A-Za-z_]\w*)?\s*=?\s*\(([^()]*)\)\s*=>\s*\{')
  7. tot=0
  8. for f in sorted(files):
  9. src=open(f,encoding='utf-8').read()
  10. for m in re.finditer(r'\(([^()]*)\)\s*=>\s*\{',src):
  11. params=[p.strip() for p in m.group(1).split(',') if p.strip()]
  12. i=m.end(); depth=1
  13. while depth and i<len(src):
  14. c=src[i]
  15. if c=='{':depth+=1
  16. elif c=='}':depth-=1
  17. i+=1
  18. body=src[m.end():i-1]
  19. line=src.count('\n',0,m.start())+1
  20. tot+=1
  21. for p in params:
  22. if p.startswith('&'): continue
  23. p=p.split('=')[0].strip()
  24. if not re.match(r'^\w+$',p): continue
  25. hits=[]
  26. for pat,kind in [(r'\b%s(?:\.\w+|\[[^\]]*\])+\s*=(?!=)'%p,'field-assign'),(r'\b%s(?:\.\w+|\[[^\]]*\])*\.(push|pop|shift|unshift|splice|sort|reverse)\('%p,'list-mutate'),(r'^\s*(?:let\s+)?(\w+)\s*=\s*%s\s*$'%p,'alias')]:
  27. for h in re.finditer(pat,body,re.M):
  28. hits.append(kind+': '+body[max(0,h.start()-0):h.end()+20].split('\n')[0].strip())
  29. if hits:
  30. name=src[max(0,m.start()-60):m.start()].split('\n')[-1].strip()
  31. print(f'{f}:{line} [{name} ({",".join(params)})] param {p}:', ' | '.join(hits[:4]))
  32. print('lambdas scanned:',tot, file=sys.stderr)

Branches

Latest commits

  • fd10c3d5log: CB livemre
  • 7557c025log: CB deploy try 2mre
  • 06a7534aMerge branch 'cb'mre
  • 2f8030d6log: CB gates greenmre
  • 498bf644log: CB gates startmre
  • f59c2847gc1: bound the five request caches (shows.hl cacheLimit)mre
  • 6ea2c6d6log: morning re-measure 11-04mre
  • 446290f0log: GC1 livemre
  • 8e6aa91dlog: GC1 deploy retrymre
  • 87ad2dc1log: GC1 deployingmre
  • 53f10fb8Merge branch 'gc1-deploy'mre
  • 7fcbf1d2log: GC1 deploy GOmre
  • 1fb6664bcompose: TRACKER_QSTATS=1 (GC1 measurement)mre
  • 6576c1cdgc1: release the people-view scan lists once the view is builtmre
  • 94f8a373gc1: back out the kept episode-id set (no measurable gain on /my/unwatched: 4.69 -> 4.61 GB per 150 loads)mre
  • a1a88bd4gc1: search skips the stale-key string while no entry is stale; /my/unwatched asks a kept id set instead of building a key string per episode rowmre
  • cd830744gc1: dbSearch: no split / map / list copy per candidate (scores from the stored text, top list touched only when the hit can enter)mre
  • 451db7cdgc1: show page and check clicks read the kept watched set instead of building one from a by-value copy of every watchmre
  • ddb4127egc1: TRACKER_QSTATS=1 logs queue and cache sizes every 10 s (measurement only)mre
  • da60547fstatus: GC1 done, backup bugmre