From 68a9f851085a496271a59a9c93c551e22df1b20f Mon Sep 17 00:00:00 2001 From: breandan Date: Thu, 24 Oct 2024 01:59:03 -0400 Subject: [PATCH] profiling aids --- latex/lafi2024/presentation/presentation.tex | 38 ++++++------ latex/popl2024/popl.tex | 36 +++++------ latex/splash2023/splash.tex | 36 +++++------ latex/tidyparse/presentation.tex | 62 ++++++------------- .../hypergraph/kaliningraph/repair/Cache.kt | 9 ++- 5 files changed, 80 insertions(+), 101 deletions(-) diff --git a/latex/lafi2024/presentation/presentation.tex b/latex/lafi2024/presentation/presentation.tex index 09f358b2..16753387 100644 --- a/latex/lafi2024/presentation/presentation.tex +++ b/latex/lafi2024/presentation/presentation.tex @@ -54,26 +54,26 @@ \HL} \makeatother -\newcommand\ddd{\Ddots} -\newcommand\vdd{\Vdots} -\newcommand\cdd{\Cdots} -\newcommand\lds{\ldots} -\newcommand\vno{\varnothing} +\newcommand{\ddd}{\Ddots} +\newcommand{\vdd}{\Vdots} +\newcommand{\cdd}{\Cdots} +\newcommand{\lds}{\ldots} +\newcommand{\vno}{\varnothing} \newcommand{\ts}[1]{\textsuperscript{#1}} -\newcommand\non{1\ts{st}} -\newcommand\ntw{2\ts{nd}} -\newcommand\nth{3\ts{rd}} -\newcommand\nfo{4\ts{th}} -\newcommand\nfi{5\ts{th}} -\newcommand\nsi{6\ts{th}} -\newcommand\nse{7\ts{th}} +\newcommand{\non}{1\ts{st}} +\newcommand{\ntw}{2\ts{nd}} +\newcommand{\nth}{3\ts{rd}} +\newcommand{\nfo}{4\ts{th}} +\newcommand{\nfi}{5\ts{th}} +\newcommand{\nsi}{6\ts{th}} +\newcommand{\nse}{7\ts{th}} \newcommand{\vs}[1]{\sigma_{#1}^{\shur}} -\newcommand\rcr{\rowcolor{black!15}} -\newcommand\rcw{\rowcolor{white}} -\newcommand\pcd{\cdot} -\newcommand\pcp{\phantom\cdot} -\newcommand\ppp{\phantom{\nse}} -\newcommand\hole{\underline{\hspace{0.25cm}}} +\newcommand{\rcr}{\rowcolor{black!15}} +\newcommand{\rcw}{\rowcolor{white}} +\newcommand{\pcd}{\cdot} +\newcommand{\pcp}{\phantom\cdot} +\newcommand{\ppp}{\phantom{\nse}} +\newcommand{\hole}{\underline{\hspace{0.25cm}}} \title[A Tree Sampler for Bounded CFLs]{A Tree Sampler for Bounded Context-Free Languages} \titlegraphic{\includegraphics[width=0.2\textwidth]{../../figures/tidyparse_logo.png}} @@ -146,7 +146,7 @@ \end{frame} \begin{frame}[fragile]{Satisfiability + holes (our contribution)} - Let us consider an example with two holes, $\sigma = 1$ \hole\phantom{.}\hole, and the grammar being $G\coloneqq\{S\rightarrow N O N, O \rightarrow + \mid \times, N \rightarrow 0 \mid 1\}$. This can be rewritten into CNF as $G'\coloneqq \{S \rightarrow N L, N \rightarrow 0 \mid 1, O \rightarrow × \mid +, L \rightarrow O N\}$. Using the algebra where $\oplus=\cup$, $X \otimes Z = \big\{\;w \mid \langle x, z\rangle \in X \times Z, (w\rightarrow xz) \in P\;\big\}$, the fixpoint $M' = M + M^2$ can be computed as follows:\\\vspace{10pt} + Let us consider an example with two holes, $\sigma = 1$ \hole\phantom{.}\hole, and the grammar being $G\coloneqq\{S\rightarrow N O N, O \rightarrow + \mid \times, N \rightarrow 0 \mid 1\}$. This can be rewritten into CNF as $G'\coloneqq \{S \rightarrow N L, N \rightarrow 0 \mid 1, O \rightarrow \times \mid +, L \rightarrow O N\}$. Using the algebra where $\oplus=\cup$, $X \otimes Z = \big\{\;w \mid \langle x, z\rangle \in X \times Z, (w\rightarrow xz) \in P\;\big\}$, the fixpoint $M' = M + M^2$ can be computed as follows:\\\vspace{10pt} \resizebox{\textwidth}{!}{ {\renewcommand{\arraystretch}{1.2} diff --git a/latex/popl2024/popl.tex b/latex/popl2024/popl.tex index e23afd4b..46218a8a 100644 --- a/latex/popl2024/popl.tex +++ b/latex/popl2024/popl.tex @@ -399,29 +399,29 @@ \subsection{Tensor sparsification}\label{sec:sparsity} \subsection{Isolation and reduction} -\newcommand\ddd{\Ddots} -\newcommand\vdd{\Vdots} -\newcommand\cdd{\Cdots} -\newcommand\lds{\ldots} -\newcommand\vno{\varnothing} +\newcommand{\ddd}{\Ddots} +\newcommand{\vdd}{\Vdots} +\newcommand{\cdd}{\Cdots} +\newcommand{\lds}{\ldots} +\newcommand{\vno}{\varnothing} \newcommand{\ts}[1]{\textsuperscript{#1}} -\newcommand\non{1\ts{st}} -\newcommand\ntw{2\ts{nd}} -\newcommand\nth{3\ts{rd}} -\newcommand\nfo{4\ts{th}} -\newcommand\nfi{5\ts{th}} -\newcommand\nsi{6\ts{th}} -\newcommand\nse{7\ts{th}} +\newcommand{\non}{1\ts{st}} +\newcommand{\ntw}{2\ts{nd}} +\newcommand{\nth}{3\ts{rd}} +\newcommand{\nfo}{4\ts{th}} +\newcommand{\nfi}{5\ts{th}} +\newcommand{\nsi}{6\ts{th}} +\newcommand{\nse}{7\ts{th}} \newcommand{\vs}[1]{\sigma_{#1}^{\shur}} \newcommand{\gs}[1]{\gamma_{#1}^{\shur}} \newcommand{\bs}[1]{\beta_{#1}^{\shur}} \newcommand{\qs}[1]{\alpha_{#1}^{\shur}} -\newcommand\rcr{\rowcolor{black!15}} -\newcommand\rcw{\rowcolor{white}} -\newcommand\pcd{\cdot} -\newcommand\pcp{\phantom\cdot} -\newcommand\ppp{\phantom{\nse}} -\newcommand\hhg[1]{\tikz[overlay]\node[rectangle,fill=black!15,draw=none,text opacity =1] {$#1$};} +\newcommand{\rcr}{\rowcolor{black!15}} +\newcommand{\rcw}{\rowcolor{white}} +\newcommand{\pcd}{\cdot} +\newcommand{\pcp}{\phantom\cdot} +\newcommand{\ppp}{\phantom{\nse}} +\newcommand{\hhg}[1]{\tikz[overlay]\node[rectangle,fill=black!15,draw=none,text opacity =1] {$#1$};} \begin{wrapfigure}{r}{0.4\textwidth} \vspace{-20pt} diff --git a/latex/splash2023/splash.tex b/latex/splash2023/splash.tex index 472fccd5..da93fbb4 100644 --- a/latex/splash2023/splash.tex +++ b/latex/splash2023/splash.tex @@ -302,29 +302,29 @@ \section{Parser incrementalization}\label{sec:incrementalization} % \includegraphics[width=2cm]{../figures/parse4.png} %\end{figure} -\newcommand\ddd{\Ddots} -\newcommand\vdd{\Vdots} -\newcommand\cdd{\Cdots} -\newcommand\lds{\ldots} -\newcommand\vno{\varnothing} +\newcommand{\ddd}{\Ddots} +\newcommand{\vdd}{\Vdots} +\newcommand{\cdd}{\Cdots} +\newcommand{\lds}{\ldots} +\newcommand{\vno}{\varnothing} \newcommand{\ts}[1]{\textsuperscript{#1}} -\newcommand\non{1\ts{st}} -\newcommand\ntw{2\ts{nd}} -\newcommand\nth{3\ts{rd}} -\newcommand\nfo{4\ts{th}} -\newcommand\nfi{5\ts{th}} -\newcommand\nsi{6\ts{th}} -\newcommand\nse{7\ts{th}} +\newcommand{\non}{1\ts{st}} +\newcommand{\ntw}{2\ts{nd}} +\newcommand{\nth}{3\ts{rd}} +\newcommand{\nfo}{4\ts{th}} +\newcommand{\nfi}{5\ts{th}} +\newcommand{\nsi}{6\ts{th}} +\newcommand{\nse}{7\ts{th}} \newcommand{\vs}[1]{\sigma_{#1}^{\shur}} \newcommand{\gs}[1]{\gamma_{#1}^{\shur}} \newcommand{\bs}[1]{\beta_{#1}^{\shur}} \newcommand{\qs}[1]{\alpha_{#1}^{\shur}} -\newcommand\rcr{\rowcolor{black!15}} -\newcommand\rcw{\rowcolor{white}} -\newcommand\pcd{\cdot} -\newcommand\pcp{\phantom\cdot} -\newcommand\ppp{\phantom{\nse}} -\newcommand\hhg[1]{\tikz[overlay]\node[rectangle,fill=black!15,draw=none,text opacity =1] {$#1$};} +\newcommand{\rcr}{\rowcolor{black!15}} +\newcommand{\rcw}{\rowcolor{white}} +\newcommand{\pcd}{\cdot} +\newcommand{\pcp}{\phantom\cdot} +\newcommand{\ppp}{\phantom{\nse}} +\newcommand{\hhg}[1]{\tikz[overlay]\node[rectangle,fill=black!15,draw=none,text opacity =1] {$#1$};} Our algorithm produces set of concrete syntax trees (CSTs) for a given valid string. Otherwise, if the string is invalid, the algorithm generates a set of admissible corrections, alongside their CSTs. diff --git a/latex/tidyparse/presentation.tex b/latex/tidyparse/presentation.tex index d926f53c..261fc07c 100644 --- a/latex/tidyparse/presentation.tex +++ b/latex/tidyparse/presentation.tex @@ -26,52 +26,26 @@ \newcommand{\cmark}{\ding{51}}% \newcommand{\xmark}{\ding{55}}% -\setbeamertemplate{footline} -{ - \leavevmode% - \hbox{% - \begin{beamercolorbox}[wd=.25\paperwidth,ht=2.25ex,dp=1ex,center]{author in head/foot}% - \usebeamerfont{author in head/foot}\insertshortauthor{}{~~(\insertshortinstitute)} - \end{beamercolorbox}% - \begin{beamercolorbox}[wd=.5\paperwidth,ht=2.25ex,dp=1ex,center]{title in head/foot}% - \usebeamerfont{title in head/foot}\insertshorttitle - \end{beamercolorbox}% - \begin{beamercolorbox}[wd=.3\paperwidth,ht=2.25ex,dp=1ex,right]{date in head/foot}% - \usebeamerfont{date in head/foot}\insertshortdate{}\hspace*{2em} - \insertframenumber{} / \inserttotalframenumber\hspace*{2ex} - \end{beamercolorbox}}% - \vskip0pt% -} -\makeatother - -\makeatletter -\let\HL\hl -\renewcommand\hl{% - \let\set@color\beamerorig@set@color - \let\reset@color\beamerorig@reset@color - \HL} -\makeatother - -\newcommand\ddd{\Ddots} -\newcommand\vdd{\Vdots} -\newcommand\cdd{\Cdots} -\newcommand\lds{\ldots} -\newcommand\vno{\varnothing} +\newcommand{\ddd}{\Ddots} +\newcommand{\vdd}{\Vdots} +\newcommand{\cdd}{\Cdots} +\newcommand{\lds}{\ldots} +\newcommand{\vno}{\varnothing} \newcommand{\ts}[1]{\textsuperscript{#1}} -\newcommand\non{1\ts{st}} -\newcommand\ntw{2\ts{nd}} -\newcommand\nth{3\ts{rd}} -\newcommand\nfo{4\ts{th}} -\newcommand\nfi{5\ts{th}} -\newcommand\nsi{6\ts{th}} -\newcommand\nse{7\ts{th}} +\newcommand{\non}{1\ts{st}} +\newcommand{\ntw}{2\ts{nd}} +\newcommand{\nth}{3\ts{rd}} +\newcommand{\nfo}{4\ts{th}} +\newcommand{\nfi}{5\ts{th}} +\newcommand{\nsi}{6\ts{th}} +\newcommand{\nse}{7\ts{th}} \newcommand{\vs}[1]{\sigma_{#1}^{\shur}} -\newcommand\rcr{\rowcolor{black!15}} -\newcommand\rcw{\rowcolor{white}} -\newcommand\pcd{\cdot} -\newcommand\pcp{\phantom\cdot} -\newcommand\ppp{\phantom{\nse}} -\newcommand\hole{\underline{\hspace{0.25cm}}} +\newcommand{\rcr}{\rowcolor{black!15}} +\newcommand{\rcw}{\rowcolor{white}} +\newcommand{\pcd}{\cdot} +\newcommand{\pcp}{\phantom\cdot} +\newcommand{\ppp}{\phantom{\nse}} +\newcommand{\hole}{\underline{\hspace{0.25cm}}} \title[Syntax Repair as Language Intersection]{Syntax Repair as Language Intersection} \titlegraphic{\includegraphics[width=0.2\textwidth]{../figures/tidyparse_logo.png}} diff --git a/src/jvmMain/kotlin/ai/hypergraph/kaliningraph/repair/Cache.kt b/src/jvmMain/kotlin/ai/hypergraph/kaliningraph/repair/Cache.kt index a4fe7e2e..c519c4a0 100644 --- a/src/jvmMain/kotlin/ai/hypergraph/kaliningraph/repair/Cache.kt +++ b/src/jvmMain/kotlin/ai/hypergraph/kaliningraph/repair/Cache.kt @@ -2,7 +2,9 @@ package ai.hypergraph.kaliningraph.repair import ai.hypergraph.kaliningraph.parsing.langCache import java.io.ByteArrayInputStream +import java.io.File import java.io.InputStreamReader +import java.net.URL import java.nio.charset.StandardCharsets import java.util.zip.ZipInputStream @@ -25,13 +27,16 @@ object LangCache { // Loads the Python Parikh map into memory fun prepopPythonLangCache() { if (1566012639 in langCache) return + val startTime = System.currentTimeMillis() val filename = "1566012639.cache.zip" - val zippedText = object {}.javaClass.classLoader.getResource(filename)!!.readBytes() + val zippedText = object {}.javaClass.classLoader.getResource(filename)?.readBytes() + ?: File(".").walk().first { it.name == filename }.readBytes() // Now decompress and load into memory val str = decompressZipToString(zippedText) val upperBound = str.lines().last().substringBefore(" ") - println("Prepopulated Parikh Map ($upperBound) for vanillaS2PCFG from $filename") + println("Prepopulated Parikh Map ($upperBound) for vanillaS2PCFG from $filename in " + + "${System.currentTimeMillis() - startTime}ms") langCache[1566012639] = str }